From 7a7001c96afdbe0e5d574337bec476f230692477 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 25 Nov 2026 15:41:21 +0400 Subject: feat(ai): construct clan factories, storage and laboratories Allow ORDER_ROBOT_BUILD to use the first BuildDat scheme for factories, storage and laboratories, with the existing technology and onboard-ore gates. Register completed factories for production and reset their free-build quota when a prepared slot is reused. Exclude reserved models from initial BAS cuts using the mission object count, preserving placed neutral buildings. Validation: fmt, workspace check and tests; ignored licensed stock-start test builds a factory in mission 29 and queues a transport there. Original Behavior.dll price calls confirm 670/770/560 ore for storage/factory/laboratory. Stock simulation also builds a laboratory; a validation-enabled window reaches the first factory. The new buildings were outside the player's window view; visual construction parity is not established. G7 still needs mine query 40, research transition 8, builder resupply and live BAS updates. --- crates/fparkan-runtime/src/production.rs | 40 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'crates/fparkan-runtime/src/production.rs') diff --git a/crates/fparkan-runtime/src/production.rs b/crates/fparkan-runtime/src/production.rs index c144eb43..2375cf9d 100644 --- a/crates/fparkan-runtime/src/production.rs +++ b/crates/fparkan-runtime/src/production.rs @@ -170,29 +170,37 @@ impl Production { "build scheme must be a mobile Unit DAT".into(), )); } - let plants = drafts[..reserve_start] - .iter() - .enumerate() - .filter(|(_, draft)| draft.unit_dat_header_flags == Some(PLANT_CLASS)) - .map(|(index, draft)| { - let count = draft - .properties - .iter() - .find(|property| property.name_raw == b"FreeBotNum") - .map_or(1, |property| property.raw_value[1] as i32); - (index, count.max(0) as u32) - }) - .collect(); - Ok(Self { + let mut production = Self { reserve_start, schemes, player_scheme_count, transport_schemes, controls, - plants, + plants: Vec::new(), pending: VecDeque::new(), rng: 1, - }) + }; + production.register_factories(0, &drafts[..reserve_start]); + Ok(production) + } + + pub(super) fn register_factories(&mut self, first_slot: usize, drafts: &[MissionObjectDraft]) { + self.plants + .retain(|&(index, _)| !(first_slot..first_slot + drafts.len()).contains(&index)); + self.plants.extend( + drafts + .iter() + .enumerate() + .filter(|(_, draft)| draft.unit_dat_header_flags == Some(PLANT_CLASS)) + .map(|(index, draft)| { + let count = draft + .properties + .iter() + .find(|property| property.name_raw == b"FreeBotNum") + .map_or(1, |property| property.raw_value[1] as i32); + (first_slot + index, count.max(0) as u32) + }), + ); } pub(super) fn tick( -- cgit v1.2.3