aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/robot_designer.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 06:04:16 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 06:04:16 +0300
commit7b3a106ff7a376b95b3bb9e52d3186ebe1a9bcaa (patch)
treec08796dc7a745059701845d735156600202c1b24 /crates/fparkan-runtime/src/robot_designer.rs
parent0d8031eccad92190ea01c2c7f9a2cee28adecb62 (diff)
downloadfparkan-7b3a106ff7a376b95b3bb9e52d3186ebe1a9bcaa.tar.xz
fparkan-7b3a106ff7a376b95b3bb9e52d3186ebe1a9bcaa.zip
feat(ui): open saved warbot projects with distinct geometry
Prepare saved Unit DAT geometry alongside factory reserves at mission entry and expose compatible, researched files through the designer. Verified a single-gun assembly in the Field Camp window and after factory release with the ore and power supply established in the test.
Diffstat (limited to 'crates/fparkan-runtime/src/robot_designer.rs')
-rw-r--r--crates/fparkan-runtime/src/robot_designer.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/crates/fparkan-runtime/src/robot_designer.rs b/crates/fparkan-runtime/src/robot_designer.rs
index 289881f0..f196f9c1 100644
--- a/crates/fparkan-runtime/src/robot_designer.rs
+++ b/crates/fparkan-runtime/src/robot_designer.rs
@@ -110,7 +110,7 @@ pub fn restore_factory_design(
})
}
-fn restore_mounts(
+pub(super) fn restore_mounts(
base: &[UnitComponentRecord],
project: &[UnitComponentRecord],
) -> Option<Vec<FactoryPartChange>> {
@@ -429,15 +429,7 @@ pub(super) fn starting_designs(
vfs: Arc<dyn Vfs>,
mission: &MissionDocument,
) -> (Arc<dyn Vfs>, Vec<NormalizedPath>) {
- let mut players = mission
- .clans
- .iter()
- .enumerate()
- .filter(|(_, clan)| clan.mode == 1);
- let Some(owner) = players.next().filter(|_| players.next().is_none()) else {
- return (vfs, Vec::new());
- };
- let Ok(owner) = u16::try_from(owner.0).map(OwnerId) else {
+ let Some(owner) = mission_player(mission) else {
return (vfs, Vec::new());
};
let Ok(research) = crate::research::load_technology_table(vfs.as_ref(), mission, owner) else {
@@ -495,6 +487,16 @@ pub(super) fn starting_designs(
)
}
+pub(super) fn mission_player(mission: &MissionDocument) -> Option<OwnerId> {
+ let mut players = mission
+ .clans
+ .iter()
+ .enumerate()
+ .filter(|(_, clan)| clan.mode == 1);
+ let (index, _) = players.next().filter(|_| players.next().is_none())?;
+ u16::try_from(index).ok().map(OwnerId)
+}
+
fn adapt_template(
mut bytes: Vec<u8>,
research: &ResearchTrfDocument,