diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 06:24:01 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 06:24:01 +0300 |
| commit | b0c3a064c29c2bf97981f45806696c2dd0d4dd90 (patch) | |
| tree | a677357a8519520a49cd4ccad3daa9cfde68d28e /crates/fparkan-runtime/src/production.rs | |
| parent | 7b3a106ff7a376b95b3bb9e52d3186ebe1a9bcaa (diff) | |
| download | fparkan-b0c3a064c29c2bf97981f45806696c2dd0d4dd90.tar.xz fparkan-b0c3a064c29c2bf97981f45806696c2dd0d4dd90.zip | |
feat(ui): preview new warbot geometry during a mission
On stock Field Camp, open a compatible Unit DAT created after start, resize the preview, switch to a resident project, reopen the new project, and return to the mission with Vulkan validation clean. The factory reserve for new geometry is still prepared at mission load.
Diffstat (limited to 'crates/fparkan-runtime/src/production.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/production.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/crates/fparkan-runtime/src/production.rs b/crates/fparkan-runtime/src/production.rs index 3502c45d..0817cfb8 100644 --- a/crates/fparkan-runtime/src/production.rs +++ b/crates/fparkan-runtime/src/production.rs @@ -467,7 +467,19 @@ pub fn factory_saved_schemes( plant: Option<ObjectHandle>, ) -> Result<Vec<usize>, EngineError> { let (mission, production) = loaded_production(engine)?; - let index = match plant { + let index = player_factory_index(engine, cockpit, plant)?; + Ok(schemes_for_plant(mission, production, index) + .filter_map(|(scheme, _)| production.saved_schemes.contains(&scheme).then_some(scheme)) + .collect()) +} + +pub(super) fn player_factory_index( + engine: &Engine, + cockpit: StartingCockpit, + plant: Option<ObjectHandle>, +) -> Result<usize, EngineError> { + let (mission, production) = loaded_production(engine)?; + Ok(match plant { Some(plant) => { let owner = player_owner(&engine.world, cockpit)?; owned_factories(&engine.world, mission, production, owner) @@ -478,10 +490,7 @@ pub fn factory_saved_schemes( })? } None => factory_at_communicator(&engine.world, mission, production, cockpit)?.0, - }; - Ok(schemes_for_plant(mission, production, index) - .filter_map(|(scheme, _)| production.saved_schemes.contains(&scheme).then_some(scheme)) - .collect()) + }) } fn recent_schemes_for_plant<'a>( @@ -929,7 +938,7 @@ fn set_factory_power( Ok(()) } -fn free_duration_ms(plant: &[u8; 32], robot: &[u8; 32]) -> Option<u32> { +pub(super) fn free_duration_ms(plant: &[u8; 32], robot: &[u8; 32]) -> Option<u32> { // shortcut: stock chassis and factory keys supply sizes until the // calculated capacity and assembled-scheme descriptors are wired. let plant = plant.split(|&byte| byte == 0).next()?; |
