From 20491de7c29f56fda9be16d3b56a9633cb71d386 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 08:36:47 +0400 Subject: feat(ui): build factory projects from a selected chassis Use researched chassis that fit the selected factory and populate a new Unit DAT from the chassis Control slots and stock default parts. The designer can remove the old chassis, preview the new model, edit its internal parts, and transfer it to the factory. Verified the stock start of Field Camp: remove S-12w, select S-31, install another battery, and queue the resulting project with Vulkan validation enabled. --- crates/fparkan-runtime/src/robot_designer.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'crates/fparkan-runtime/src/robot_designer.rs') diff --git a/crates/fparkan-runtime/src/robot_designer.rs b/crates/fparkan-runtime/src/robot_designer.rs index f196f9c1..10ee7a94 100644 --- a/crates/fparkan-runtime/src/robot_designer.rs +++ b/crates/fparkan-runtime/src/robot_designer.rs @@ -40,6 +40,15 @@ pub fn factory_design_parts( Ok(parts) } +/// Writes replacements into a project being edited outside the factory catalogue. +pub fn edit_factory_project( + project: &UnitDat, + changes: &[FactoryPartChange], +) -> Result, EngineError> { + let records = factory_design_parts(&project.records, changes)?; + Ok(crate::designer_chassis::encode_project(project, &records)) +} + /// Checks the edited project against the current clan's research before transfer. pub fn check_factory_design( engine: &Engine, @@ -666,7 +675,7 @@ mod tests { .filter_map(|(index, part)| (key(&part.resource_raw) == b"i_c06_b_df").then_some(index)) .collect::>(); assert_eq!(mounts.len(), 2); - let variants = factory_part_variants(&engine, cockpit, scheme, mounts[0]).unwrap(); + let variants = factory_part_variants(&engine, cockpit, &base, mounts[0]).unwrap(); assert_eq!(variants, ["i_c06_b_01", "i_c06_b_02", "i_c06_b_df"]); let armor = base .iter() -- cgit v1.2.3