aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/fparkan-runtime/src')
-rw-r--r--crates/fparkan-runtime/src/lib.rs4
-rw-r--r--crates/fparkan-runtime/src/production.rs17
2 files changed, 13 insertions, 8 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs
index b5527a4a..35dfa5b0 100644
--- a/crates/fparkan-runtime/src/lib.rs
+++ b/crates/fparkan-runtime/src/lib.rs
@@ -197,8 +197,8 @@ pub use player_weapon::{
WeaponIndicator, WeaponLamp,
};
pub use production::{
- clan_factory_schemes, factory_project_components, factory_schemes, order_clan_factory_scheme,
- order_factory_robot, order_factory_scheme,
+ clan_factory_schemes, factory_project_components, factory_project_root, factory_schemes,
+ order_clan_factory_scheme, order_factory_robot, order_factory_scheme,
};
pub use projectile::{
apply_projectile_contact, apply_projectile_hit, apply_projectile_impact,
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,