Compare commits

...

2 Commits

3 changed files with 11 additions and 43 deletions

View File

@@ -8,7 +8,7 @@ use crate::events::GameEvent;
use crate::map::builder::Map;
use crate::map::direction::Direction;
use crate::systems::blinking::Blinking;
use crate::systems::{self, ghost_collision_system, present_system, MovementModifiers};
use crate::systems::{self, ghost_collision_system, present_system, Hidden, MovementModifiers};
use crate::systems::movement::{BufferedDirection, Position, Velocity};
use crate::systems::profiling::SystemId;
@@ -24,7 +24,8 @@ use crate::texture::animated::AnimatedTexture;
use crate::texture::sprite::AtlasTile;
use bevy_ecs::event::EventRegistry;
use bevy_ecs::observer::Trigger;
use bevy_ecs::schedule::{IntoScheduleConfigs, Schedule, SystemSet};
use bevy_ecs::schedule::common_conditions::resource_changed;
use bevy_ecs::schedule::{Condition, IntoScheduleConfigs, Schedule, SystemSet};
use bevy_ecs::system::ResMut;
use bevy_ecs::world::World;
use sdl2::image::LoadTexture;
@@ -255,7 +256,12 @@ impl Game {
let debug_render_system = profile(SystemId::DebugRender, debug_render_system);
let present_system = profile(SystemId::Present, present_system);
let forced_dirty_system = |mut dirty: ResMut<RenderDirty>| {
dirty.0 = true;
};
schedule.add_systems((
forced_dirty_system.run_if(resource_changed::<ScoreResource>.or(resource_changed::<StartupSequence>)),
(
input_system,
player_control_system,
@@ -281,8 +287,7 @@ impl Game {
));
// Spawn player and attach initial state bundle
let player_entity = world.spawn(player).id();
world.entity_mut(player_entity).insert(Frozen);
world.spawn(player).insert((Frozen, Hidden));
// Spawn ghosts
Self::spawn_ghosts(&mut world)?;
@@ -430,7 +435,7 @@ impl Game {
}
};
world.spawn(ghost).insert(Frozen);
world.spawn(ghost).insert((Frozen, Hidden));
}
Ok(())

View File

@@ -24,44 +24,6 @@ impl CommonPlatform for Platform {
}
fn init_console(&self) -> Result<(), PlatformError> {
#[cfg(windows)]
{
unsafe {
use winapi::{
shared::ntdef::NULL,
um::{
fileapi::{CreateFileA, OPEN_EXISTING},
handleapi::INVALID_HANDLE_VALUE,
processenv::SetStdHandle,
winbase::{STD_ERROR_HANDLE, STD_OUTPUT_HANDLE},
wincon::{AttachConsole, GetConsoleWindow},
winnt::{FILE_SHARE_READ, FILE_SHARE_WRITE, GENERIC_READ, GENERIC_WRITE},
},
};
if !std::ptr::eq(GetConsoleWindow(), std::ptr::null_mut()) {
return Ok(());
}
if AttachConsole(winapi::um::wincon::ATTACH_PARENT_PROCESS) != 0 {
let handle = CreateFileA(
c"CONOUT$".as_ptr(),
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
std::ptr::null_mut(),
OPEN_EXISTING,
0,
NULL,
);
if handle != INVALID_HANDLE_VALUE {
SetStdHandle(STD_OUTPUT_HANDLE, handle);
SetStdHandle(STD_ERROR_HANDLE, handle);
}
}
}
}
Ok(())
}

View File

@@ -26,6 +26,7 @@ impl Blinking {
///
/// This system manages entities that have both `Blinking` and `Renderable` components,
/// accumulating time and toggling visibility when the specified interval is reached.
#[allow(clippy::type_complexity)]
pub fn blinking_system(
mut commands: Commands,
time: Res<DeltaTime>,