diff options
Diffstat (limited to 'crates/fparkan-runtime/src/production.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/production.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/crates/fparkan-runtime/src/production.rs b/crates/fparkan-runtime/src/production.rs index 9f6846f8..ef1c0f38 100644 --- a/crates/fparkan-runtime/src/production.rs +++ b/crates/fparkan-runtime/src/production.rs @@ -392,16 +392,21 @@ pub fn factory_project_components( engine: &Engine, scheme: usize, ) -> Option<&[UnitComponentRecord]> { - let (mission, production) = loaded_production(engine).ok()?; - if scheme >= production.player_scheme_count { - return None; - } - mission + engine + .loaded + .as_ref()? .object_drafts - .get(production.reserve_start + scheme * RESERVE_SLOTS) + .get(factory_project_root(engine, scheme)?) .map(|draft| draft.unit_components.as_slice()) } +/// Index of the first prepared world root for a player factory project. +pub fn factory_project_root(engine: &Engine, scheme: usize) -> Option<usize> { + let (_, production) = loaded_production(engine).ok()?; + (scheme < production.player_scheme_count) + .then(|| production.reserve_start + scheme * RESERVE_SLOTS) +} + fn schemes_for_plant<'a>( mission: &'a LoadedMissionState, production: &'a Production, |
