From d4c2ee22771b20208ee07ec38d868c3b0ce963bf Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 10:02:23 +0400 Subject: feat(runtime): replenish AutoDemo clans after combat losses --- crates/fparkan-runtime/src/autodemo_combat.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'crates/fparkan-runtime/src/autodemo_combat.rs') 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, + reserve: Vec, hostile: Vec>, projectiles: Vec, flights: Vec, @@ -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 } -- cgit v1.2.3