Run snap system after direction is updated.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nolan Darilek 2022-07-11 12:48:04 -05:00
parent 1ff98c9132
commit 3994fef9d0

View File

@ -379,25 +379,36 @@ where
.get_resource::<NavigationConfig<S, A>>() .get_resource::<NavigationConfig<S, A>>()
.unwrap() .unwrap()
.clone(); .clone();
const SNAP: &str = "SNAP";
app.init_resource::<Snapping>() app.init_resource::<Snapping>()
.register_type::<MaxSpeed>() .register_type::<MaxSpeed>()
.register_type::<RotationSpeed>() .register_type::<RotationSpeed>()
.register_type::<Sprinting>() .register_type::<Sprinting>()
.add_system(update_direction) .add_system(update_direction.before(SNAP))
.add_system(speak_direction.chain(error_handler)) .add_system(speak_direction.chain(error_handler))
.add_system(add_speed) .add_system(add_speed)
.add_system_to_stage(CoreStage::PostUpdate, remove_speed); .add_system_to_stage(CoreStage::PostUpdate, remove_speed);
const MOVEMENT_CONTROLS: &str = "MOVEMENT_CONTROLS"; const MOVEMENT_CONTROLS: &str = "MOVEMENT_CONTROLS";
if config.movement_control_states.is_empty() { if config.movement_control_states.is_empty() {
app.add_system(movement_controls::<S, A>.label(MOVEMENT_CONTROLS)) app.add_system(movement_controls::<S, A>.label(MOVEMENT_CONTROLS))
.add_system(snap::<S, A>.chain(error_handler).before(MOVEMENT_CONTROLS)); .add_system(
snap::<S, A>
.chain(error_handler)
.label(SNAP)
.before(MOVEMENT_CONTROLS),
);
} else { } else {
let states = config.movement_control_states; let states = config.movement_control_states;
for state in states { for state in states {
app.add_system_set( app.add_system_set(
SystemSet::on_update(state) SystemSet::on_update(state)
.with_system(movement_controls::<S, A>.label(MOVEMENT_CONTROLS)) .with_system(movement_controls::<S, A>.label(MOVEMENT_CONTROLS))
.with_system(snap::<S, A>.chain(error_handler).before(MOVEMENT_CONTROLS)), .with_system(
snap::<S, A>
.chain(error_handler)
.label(SNAP)
.before(MOVEMENT_CONTROLS),
),
); );
} }
} }