|
|
|
@ -79,7 +79,6 @@ fn main() {
|
|
|
|
sync_resource_to_ui::<Deaths>.run_if(resource_changed::<Deaths>),
|
|
|
|
sync_resource_to_ui::<Deaths>.run_if(resource_changed::<Deaths>),
|
|
|
|
sync_resource_to_ui::<RewindFrames>.run_if(resource_changed::<RewindFrames>),
|
|
|
|
sync_resource_to_ui::<RewindFrames>.run_if(resource_changed::<RewindFrames>),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
scoring.run_if(on_event::<CollisionEnded>),
|
|
|
|
|
|
|
|
update_batch_position.run_if(any_component_changed::<Batch>),
|
|
|
|
update_batch_position.run_if(any_component_changed::<Batch>),
|
|
|
|
update_tooltip.run_if(in_state(DebuggingState::On)),
|
|
|
|
update_tooltip.run_if(in_state(DebuggingState::On)),
|
|
|
|
(
|
|
|
|
(
|
|
|
|
@ -96,6 +95,7 @@ fn main() {
|
|
|
|
.add_observer(populate_ground)
|
|
|
|
.add_observer(populate_ground)
|
|
|
|
.add_observer(populate_hitbox)
|
|
|
|
.add_observer(populate_hitbox)
|
|
|
|
.add_observer(manage_batches)
|
|
|
|
.add_observer(manage_batches)
|
|
|
|
|
|
|
|
.add_observer(manage_score)
|
|
|
|
.run();
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -687,21 +687,24 @@ impl Display for Deaths {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Scoring is bugged, need to make it correct.
|
|
|
|
// TODO: Scoring is bugged, need to make it correct.
|
|
|
|
fn scoring(
|
|
|
|
fn manage_score(
|
|
|
|
mut events: EventReader<CollisionEnded>,
|
|
|
|
trigger: Trigger<OnCollisionEnd>,
|
|
|
|
state: Res<State<PlayerState>>,
|
|
|
|
state: Res<State<PlayerState>>,
|
|
|
|
bird: Query<Entity, With<Bird>>,
|
|
|
|
bird: Query<Entity, With<Bird>>,
|
|
|
|
hitboxes: Query<&Batch, With<Hitbox>>,
|
|
|
|
hitboxes: Query<&Batch, With<Hitbox>>,
|
|
|
|
mut score: ResMut<Score>,
|
|
|
|
mut score: ResMut<Score>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
events
|
|
|
|
let a = trigger.target();
|
|
|
|
.read()
|
|
|
|
let b = trigger.collider;
|
|
|
|
.filter(|CollisionEnded(a, b)| bird.contains(*a) && hitboxes.contains(*b))
|
|
|
|
if bird.contains(a) && hitboxes.contains(b) {
|
|
|
|
.for_each(|CollisionEnded(_a, b)| {
|
|
|
|
|
|
|
|
debug!("Hit event while {:?}", state.get());
|
|
|
|
debug!("Hit event while {:?}", state.get());
|
|
|
|
let Batch(id) = hitboxes.get(*b).unwrap();
|
|
|
|
let Batch(id) = hitboxes.get(b).unwrap();
|
|
|
|
score.0 = *id;
|
|
|
|
score.0 = match state.get() {
|
|
|
|
})
|
|
|
|
PlayerState::Alive => *id,
|
|
|
|
|
|
|
|
PlayerState::Rewind => *id - 1,
|
|
|
|
|
|
|
|
_ => *id, // HOW???
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -746,8 +749,8 @@ fn manage_batches(
|
|
|
|
);
|
|
|
|
);
|
|
|
|
let a = trigger.target();
|
|
|
|
let a = trigger.target();
|
|
|
|
let b = trigger.collider;
|
|
|
|
let b = trigger.collider;
|
|
|
|
if bird.contains(*a)
|
|
|
|
if bird.contains(a)
|
|
|
|
&& let Ok((e, Batch(idx))) = batches.get(*b)
|
|
|
|
&& let Ok((_e, Batch(idx))) = batches.get(b)
|
|
|
|
&& *idx > 2
|
|
|
|
&& *idx > 2
|
|
|
|
{
|
|
|
|
{
|
|
|
|
info!("Managing batches in player state {:?}", state.get());
|
|
|
|
info!("Managing batches in player state {:?}", state.get());
|
|
|
|
|