npc reloading (#28)
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
use super::AimTarget;
|
||||
use crate::{
|
||||
GameState, backpack::UiHeadState, heads::HeadsImages, hitpoints::Hitpoints,
|
||||
loading_assets::UIAssets, npc::Npc, player::Player,
|
||||
GameState,
|
||||
backpack::UiHeadState,
|
||||
heads::{ActiveHeads, HeadsImages},
|
||||
hitpoints::Hitpoints,
|
||||
loading_assets::UIAssets,
|
||||
npc::Npc,
|
||||
player::Player,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
|
||||
@@ -142,11 +147,12 @@ fn update(
|
||||
fn sync(
|
||||
mut target: ResMut<TargetUi>,
|
||||
player_target: Query<&AimTarget, With<Player>>,
|
||||
target_data: Query<(&Hitpoints, &Npc)>,
|
||||
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, head)) = target_data.get(e) {
|
||||
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(),
|
||||
|
||||
Reference in New Issue
Block a user