Lightyear setup (#55)

This commit is contained in:
extrawurst
2025-07-10 23:21:11 +02:00
committed by GitHub
parent 691b9eed33
commit 78b09b33d6
26 changed files with 2515 additions and 242 deletions

View File

@@ -114,11 +114,11 @@ fn update_player_aim(
}
}
if let Some(e) = &aim_target.0 {
if commands.get_entity(*e).is_err() {
aim_target.0 = None;
return;
}
if let Some(e) = &aim_target.0
&& commands.get_entity(*e).is_err()
{
aim_target.0 = None;
return;
}
if new_target != aim_target.0 {
@@ -166,11 +166,11 @@ fn update_npc_aim(
}
}
if let Some(e) = &aim_target.0 {
if commands.get_entity(*e).is_err() {
aim_target.0 = None;
return;
}
if let Some(e) = &aim_target.0
&& commands.get_entity(*e).is_err()
{
aim_target.0 = None;
return;
}
if new_target != aim_target.0 {

View File

@@ -140,16 +140,16 @@ fn sync(
target_data: Query<(&Hitpoints, &ActiveHeads), With<Npc>>,
) {
let mut new_state = None;
if let Some(e) = player_target.iter().next().and_then(|target| target.0) {
if let Ok((hp, heads)) = target_data.get(e) {
let head = heads.current().expect("target must have a head on");
new_state = Some(UiHeadState {
head: head.head,
health: hp.health(),
ammo: 1.,
reloading: None,
});
}
if let Some(e) = player_target.iter().next().and_then(|target| target.0)
&& let Ok((hp, heads)) = target_data.get(e)
{
let head = heads.current().expect("target must have a head on");
new_state = Some(UiHeadState {
head: head.head,
health: hp.health(),
ammo: 1.,
reloading: None,
});
}
if new_state != target.head {