Reorganize systems
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
83
src/snake.rs
83
src/snake.rs
@@ -26,57 +26,46 @@ impl Plugin for SnakePlugin {
|
|||||||
.add_event::<AddTailEvent>()
|
.add_event::<AddTailEvent>()
|
||||||
.insert_resource(bulge::PropagationTimer::default())
|
.insert_resource(bulge::PropagationTimer::default())
|
||||||
.add_startup_system(setup_snake_system)
|
.add_startup_system(setup_snake_system)
|
||||||
.add_system(
|
.add_systems(
|
||||||
segments_movement_system
|
(
|
||||||
.in_schedule(CoreSchedule::FixedUpdate)
|
segments_movement_system
|
||||||
.in_set(SystemSet::Movement)
|
.in_set(SystemSet::Movement)
|
||||||
.run_if(in_state(GameState::InGame))
|
.run_if(in_state(GameState::InGame))
|
||||||
.after(SystemSet::DirectionFlush),
|
.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(
|
.add_systems((
|
||||||
direction::apply_direction_system
|
grid_transform_system.run_if(in_state(GameState::InGame)),
|
||||||
.in_schedule(CoreSchedule::FixedUpdate)
|
direction::start_game_system.run_if(in_state(GameState::Begin)),
|
||||||
.run_if(in_state(GameState::InGame))
|
direction::change_direction_system,
|
||||||
.before(SystemSet::DirectionFlush),
|
bulge::add_bulge_system,
|
||||||
)
|
bulge::propagate_bulge_system,
|
||||||
.add_system(
|
bulge::animate_bulge_system,
|
||||||
apply_system_buffers
|
add_tail_system,
|
||||||
.in_schedule(CoreSchedule::FixedUpdate)
|
eaten_event_system,
|
||||||
.in_set(SystemSet::DirectionFlush)
|
))
|
||||||
.run_if(in_state(GameState::InGame)),
|
.add_systems((
|
||||||
)
|
|
||||||
.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(
|
|
||||||
collision_sound_system
|
collision_sound_system
|
||||||
.run_if(in_state(GameState::InGame))
|
.run_if(in_state(GameState::InGame))
|
||||||
.run_if(about_to_collide),
|
.run_if(about_to_collide),
|
||||||
)
|
blip_sound_system.run_if(fruit::eaten_event_sent),
|
||||||
.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);
|
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
app.add_system(debug::add_tail);
|
app.add_system(debug::add_tail);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ pub(super) fn change_direction_system(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commands.entity(snake).insert(NewDirection(new_direction));
|
commands.entity(snake).insert(NewDirection(new_direction));
|
||||||
audio.play(audio_assets.tick.clone());
|
audio.play(audio_assets.tick.clone());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user