aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/production.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-25 14:41:21 +0300
committerValentin Popov <valentin@popov.link>2026-11-25 14:41:21 +0300
commit7a7001c96afdbe0e5d574337bec476f230692477 (patch)
tree74d887cfb724d06aee67c61dfa5421b9e64c1408 /crates/fparkan-runtime/src/production.rs
parent27d6ea19b0206b71ef6c309142e0875275882bf0 (diff)
downloadfparkan-7a7001c96afdbe0e5d574337bec476f230692477.tar.xz
fparkan-7a7001c96afdbe0e5d574337bec476f230692477.zip
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.
Diffstat (limited to 'crates/fparkan-runtime/src/production.rs')
-rw-r--r--crates/fparkan-runtime/src/production.rs40
1 files changed, 24 insertions, 16 deletions
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(