use bevy hierarchy system
This commit is contained in:
parent
35413b563c
commit
cfe2631578
15 changed files with 246 additions and 643 deletions
|
|
@ -3,12 +3,11 @@ use std::collections::HashMap;
|
|||
use bevy_ecs::prelude::*;
|
||||
use proxisim_models::{
|
||||
bundle::{
|
||||
Id, Name,
|
||||
player::{Attacker, Player},
|
||||
weapon::Weapon,
|
||||
Id, Name,
|
||||
},
|
||||
dto::metrics::EntityInfo,
|
||||
hierarchy::Parent,
|
||||
};
|
||||
|
||||
use crate::Stages;
|
||||
|
|
@ -18,7 +17,7 @@ pub struct EntityRegistry(pub HashMap<Entity, EntityInfo>);
|
|||
|
||||
fn read_entities(
|
||||
player_q: Query<(Entity, &Name, &Id, Has<Attacker>), With<Player>>,
|
||||
weapon_q: Query<(Entity, &Parent, &Name, &Id), With<Weapon>>,
|
||||
weapon_q: Query<(Entity, &ChildOf, &Name, &Id), With<Weapon>>,
|
||||
mut registry: ResMut<EntityRegistry>,
|
||||
) {
|
||||
for (player, name, id, is_attacker) in player_q.iter() {
|
||||
|
|
@ -33,7 +32,7 @@ fn read_entities(
|
|||
}
|
||||
|
||||
for (weapon, player, name, id) in weapon_q.iter() {
|
||||
let (_, _, player_id, _) = player_q.get(player.get()).unwrap();
|
||||
let (_, _, player_id, _) = player_q.get(player.parent()).unwrap();
|
||||
registry.0.insert(
|
||||
weapon,
|
||||
EntityInfo::Weapon {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue