diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 09:02:23 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 09:02:23 +0300 |
| commit | d4c2ee22771b20208ee07ec38d868c3b0ce963bf (patch) | |
| tree | 2ccf2da527dd9e664d3f2ab541e852ded8474e2d /crates/fparkan-runtime/src/autodemo_combat.rs | |
| parent | 176b377c8d4406161ff206a8cb5ac8c8359877cf (diff) | |
| download | fparkan-d4c2ee22771b20208ee07ec38d868c3b0ce963bf.tar.xz fparkan-d4c2ee22771b20208ee07ec38d868c3b0ce963bf.zip | |
feat(runtime): replenish AutoDemo clans after combat losses
Diffstat (limited to 'crates/fparkan-runtime/src/autodemo_combat.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/autodemo_combat.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/crates/fparkan-runtime/src/autodemo_combat.rs b/crates/fparkan-runtime/src/autodemo_combat.rs index 65631ae0..5769b647 100644 --- a/crates/fparkan-runtime/src/autodemo_combat.rs +++ b/crates/fparkan-runtime/src/autodemo_combat.rs @@ -50,6 +50,7 @@ pub enum AutoDemoCombatEvent { pub(super) struct AutoDemoCombat { units: Vec<Unit>, + reserve: Vec<Unit>, hostile: Vec<Vec<bool>>, projectiles: Vec<AutoDemoProjectileType>, flights: Vec<Flight>, @@ -63,6 +64,7 @@ pub(super) struct CombatTarget { pub(super) in_range: bool, } +#[derive(Clone)] struct Unit { handle: ObjectHandle, index: usize, @@ -83,6 +85,7 @@ impl AutoDemoCombat { drafts: &[MissionObjectDraft], handles: &[ObjectHandle], assets: &MissionAssets, + reserve_start: usize, ) -> Self { let hostile = mission .clans @@ -102,6 +105,7 @@ impl AutoDemoCombat { .collect(); let mut battle = Self { units: Vec::new(), + reserve: Vec::new(), hostile, projectiles: Vec::new(), flights: Vec::new(), @@ -156,7 +160,12 @@ impl AutoDemoCombat { }) .collect(); battle.unavailable += usize::from(weapons.weapons().is_empty()); - battle.units.push(Unit { + let units = if index < reserve_start { + &mut battle.units + } else { + &mut battle.reserve + }; + units.push(Unit { handle, index, weapons, @@ -166,6 +175,22 @@ impl AutoDemoCombat { battle } + pub(super) fn activate( + &mut self, + world: &fparkan_world::World, + index: usize, + handle: ObjectHandle, + ) { + self.units + .retain(|unit| transform_state(world, unit.handle).is_ok()); + if let Some(template) = self.reserve.iter().find(|unit| unit.index == index) { + self.units.push(Unit { + handle, + ..template.clone() + }); + } + } + pub(super) fn types(&self) -> &[AutoDemoProjectileType] { &self.projectiles } |
