From d7150a58d53786580fed00a3d4a0e9d2406fe9bb Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2026 20:15:26 +0400 Subject: feat(prototype): retain unit component provenance --- crates/fparkan-runtime/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crates/fparkan-runtime') diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index 740ad34..696bb33 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -31,6 +31,7 @@ use fparkan_assets::{ use fparkan_path::{normalize_relative, NormalizedPath, PathError, PathPolicy}; use fparkan_prototype::{ build_prototype_graph_report, PrototypeGraph, PrototypeGraphFailure, PrototypeGraphReport, + UnitComponentRecord, }; use fparkan_resource::{resource_name, CachedResourceRepository, ResourceRepository}; use fparkan_terrain::SurfaceQuery; @@ -229,6 +230,11 @@ pub struct MissionObjectDraft { pub visual_ids: Vec>, /// Ordered mission properties. pub properties: Vec, + /// Ordered raw Unit DAT components that selected this mission root. + /// + /// The records preserve source provenance for future controller loading; + /// their fields intentionally have no inferred Control/physics semantics. + pub unit_components: Vec, } #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] @@ -912,6 +918,11 @@ fn load_mission_with_options_and_progress( name_raw: property.name_raw.clone(), }) .collect(), + unit_components: prototype_graph + .root_unit_components + .get(index) + .cloned() + .unwrap_or_default(), }) .collect(); let mut new_runtime_world = new_world(WorldConfig); @@ -1608,6 +1619,7 @@ mod tests { .expect("load mission"); let drafts = loaded_mission_object_drafts(&engine).expect("object drafts"); let assets = loaded_mission_assets(&engine).expect("mission assets"); + let graph = loaded_prototype_graph(&engine).expect("prototype graph"); assert_eq!(drafts.len(), loaded.object_count); assert!(drafts.iter().any(|draft| !draft.visual_ids.is_empty())); @@ -1617,6 +1629,7 @@ mod tests { u32::try_from(index).ok().map(OriginalObjectId) ); assert_eq!(draft.visual_ids, assets.visuals_for_object(index)); + assert_eq!(draft.unit_components, graph.root_unit_components[index]); assert!(draft.position.iter().all(|component| component.is_finite())); assert!(draft .orientation_raw -- cgit v1.2.3