diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 07:36:47 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 07:36:47 +0300 |
| commit | 20491de7c29f56fda9be16d3b56a9633cb71d386 (patch) | |
| tree | 9505e9e89e542e7e8fdebfb5d3e334cef205cf3a /crates/fparkan-runtime/src/robot_designer.rs | |
| parent | 2f5791c59692beda3c948d3f9efd6557a32f4913 (diff) | |
| download | fparkan-20491de7c29f56fda9be16d3b56a9633cb71d386.tar.xz fparkan-20491de7c29f56fda9be16d3b56a9633cb71d386.zip | |
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.
Diffstat (limited to 'crates/fparkan-runtime/src/robot_designer.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/robot_designer.rs | 11 |
1 files changed, 10 insertions, 1 deletions
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<Arc<[u8]>, 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::<Vec<_>>(); 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() |
