use bevy hierarchy system
This commit is contained in:
parent
35413b563c
commit
cfe2631578
15 changed files with 246 additions and 643 deletions
|
|
@ -1,23 +1,18 @@
|
|||
use bevy_ecs::prelude::*;
|
||||
use proxisim_models::{
|
||||
bundle::{
|
||||
armour::{ArmourBodyPart, ArmourBodyParts},
|
||||
passive::{FactionUpgrades, Merits},
|
||||
player::{
|
||||
Attacker, BodyPart, ChooseWeapon, CombatTurns, Current, CurrentTarget, Defeated,
|
||||
Defender, FightEndType, Level, MaxHealth, PartDamageBonus, Player, PlayerStrategy,
|
||||
Weapons,
|
||||
},
|
||||
stat::{
|
||||
AmmoControl, Clips, CritRate, DamageBonus, Defence, Dexterity, EffectiveStat, Health,
|
||||
SimpleStatBundle, SimpleStatEffective, Speed, Strength, WeaponAccuracy,
|
||||
},
|
||||
weapon::{
|
||||
Ammo, DamageStat, NeedsReload, NonTargeted, RateOfFire, Usable, Uses, Weapon,
|
||||
WeaponSlot,
|
||||
},
|
||||
use proxisim_models::bundle::{
|
||||
armour::{ArmourBodyPart, ArmourBodyParts},
|
||||
passive::{FactionUpgrades, Merits},
|
||||
player::{
|
||||
Attacker, BodyPart, ChooseWeapon, CombatTurns, Current, CurrentTarget, Defeated, Defender,
|
||||
FightEndType, Level, MaxHealth, PartDamageBonus, Player, PlayerStrategy, Weapons,
|
||||
},
|
||||
stat::{
|
||||
AmmoControl, Clips, CritRate, DamageBonus, Defence, Dexterity, EffectiveStat, Health,
|
||||
SimpleStatBundle, SimpleStatEffective, Speed, Strength, WeaponAccuracy,
|
||||
},
|
||||
weapon::{
|
||||
Ammo, DamageStat, NeedsReload, NonTargeted, RateOfFire, Usable, Uses, Weapon, WeaponSlot,
|
||||
},
|
||||
hierarchy::Children,
|
||||
};
|
||||
use rand::Rng as _;
|
||||
|
||||
|
|
@ -33,12 +28,12 @@ use crate::{
|
|||
pub mod stats;
|
||||
pub mod status_effect;
|
||||
|
||||
fn select_weapon(
|
||||
fn select_weapon<'a>(
|
||||
weapons: &Weapons,
|
||||
slot: WeaponSlot,
|
||||
reload: bool,
|
||||
usable_q: &Query<(Has<NeedsReload>, Option<&Children>), With<Usable>>,
|
||||
) -> Option<(Entity, Option<Children>)> {
|
||||
usable_q: &'a Query<(Has<NeedsReload>, Option<&Children>), With<Usable>>,
|
||||
) -> Option<(Entity, Option<&'a Children>)> {
|
||||
let id = match slot {
|
||||
WeaponSlot::Primary => weapons.primary?,
|
||||
WeaponSlot::Secondary => weapons.secondary?,
|
||||
|
|
@ -53,7 +48,7 @@ fn select_weapon(
|
|||
if !reload && needs_reload {
|
||||
None
|
||||
} else {
|
||||
Some((id, children.cloned()))
|
||||
Some((id, children))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +150,7 @@ pub fn pick_action(
|
|||
let target = target_q.single().unwrap();
|
||||
|
||||
if let Some(children) = children {
|
||||
for effect in weapon_trigger_q.iter_many(children.get()) {
|
||||
for effect in weapon_trigger_q.iter_many(children) {
|
||||
effect.trigger(&mut effects, current, target);
|
||||
}
|
||||
}
|
||||
|
|
@ -357,7 +352,7 @@ pub fn use_damaging_weapon(
|
|||
|
||||
let mut dmg_bonus = dmg_bonus + p_dmg_bonus;
|
||||
|
||||
for part_bonus in part_bonus_q.iter_many(children.get()) {
|
||||
for part_bonus in part_bonus_q.iter_many(children) {
|
||||
if let Some(bonus) = part_bonus.dmg_bonus(body_part) {
|
||||
dmg_bonus.value += bonus;
|
||||
}
|
||||
|
|
@ -378,7 +373,7 @@ pub fn use_damaging_weapon(
|
|||
metrics.record_histogram(Some(weapon), "dmg", dmg);
|
||||
|
||||
if dmg > 0 {
|
||||
for effect in damage_proc_q.iter_many(children.get()) {
|
||||
for effect in damage_proc_q.iter_many(children) {
|
||||
match *effect {
|
||||
DamageProcEffect::MultiTurn { value, bonus } => {
|
||||
if multi_attack_proc.is_some() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue