Reorganize systems

This commit is contained in:
2023-03-18 18:14:08 +01:00
parent 18f55a9cce
commit e11ba22c93
5 changed files with 37 additions and 48 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -26,57 +26,46 @@ impl Plugin for SnakePlugin {
.add_event::<AddTailEvent>()
.insert_resource(bulge::PropagationTimer::default())
.add_startup_system(setup_snake_system)
.add_system(
segments_movement_system
.in_schedule(CoreSchedule::FixedUpdate)
.in_set(SystemSet::Movement)
.run_if(in_state(GameState::InGame))
.after(SystemSet::DirectionFlush),
.add_systems(
(
segments_movement_system
.in_set(SystemSet::Movement)
.run_if(in_state(GameState::InGame))
.after(SystemSet::DirectionFlush),
direction::apply_direction_system
.run_if(in_state(GameState::InGame))
.before(SystemSet::DirectionFlush),
apply_system_buffers
.in_set(SystemSet::DirectionFlush)
.run_if(in_state(GameState::InGame)),
collision_system
.in_set(SystemSet::CollisionDetection)
.run_if(in_state(GameState::InGame))
.after(SystemSet::DirectionFlush),
game_over_system
.in_set(SystemSet::CollisionDetection)
.run_if(in_state(GameState::InGame))
.after(collision_system)
.run_if(about_to_collide),
)
.in_schedule(CoreSchedule::FixedUpdate),
)
.add_system(
direction::apply_direction_system
.in_schedule(CoreSchedule::FixedUpdate)
.run_if(in_state(GameState::InGame))
.before(SystemSet::DirectionFlush),
)
.add_system(
apply_system_buffers
.in_schedule(CoreSchedule::FixedUpdate)
.in_set(SystemSet::DirectionFlush)
.run_if(in_state(GameState::InGame)),
)
.add_system(
collision_system
.in_schedule(CoreSchedule::FixedUpdate)
.in_set(SystemSet::CollisionDetection)
.run_if(in_state(GameState::InGame))
.after(SystemSet::DirectionFlush),
)
.add_system(
game_over_system
.in_schedule(CoreSchedule::FixedUpdate)
.in_set(SystemSet::CollisionDetection)
.run_if(in_state(GameState::InGame))
.after(collision_system)
.run_if(about_to_collide),
)
.add_system(
.add_systems((
grid_transform_system.run_if(in_state(GameState::InGame)),
direction::start_game_system.run_if(in_state(GameState::Begin)),
direction::change_direction_system,
bulge::add_bulge_system,
bulge::propagate_bulge_system,
bulge::animate_bulge_system,
add_tail_system,
eaten_event_system,
))
.add_systems((
collision_sound_system
.run_if(in_state(GameState::InGame))
.run_if(about_to_collide),
)
.add_system(
blip_sound_system
.run_if(fruit::eaten_event_sent),
)
.add_system(direction::start_game_system.run_if(in_state(GameState::Begin)))
.add_system(direction::change_direction_system)
.add_system(grid_transform_system.run_if(in_state(GameState::InGame)))
.add_system(add_tail_system)
.add_system(bulge::add_bulge_system)
.add_system(bulge::propagate_bulge_system)
.add_system(bulge::animate_bulge_system)
.add_system(eaten_event_system);
blip_sound_system.run_if(fruit::eaten_event_sent),
));
#[cfg(debug_assertions)]
app.add_system(debug::add_tail);

View File

@@ -61,7 +61,7 @@ pub(super) fn change_direction_system(
return;
}
}
commands.entity(snake).insert(NewDirection(new_direction));
audio.play(audio_assets.tick.clone());
}