diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 05:09:14 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 05:09:14 +0300 |
| commit | 0ad190894afd8e9592ef182e36e16ee7a61483f6 (patch) | |
| tree | e9aacd5995bcad2024bee939d629f186c2667ef9 /crates/fparkan-runtime | |
| parent | 8e11cede8106e36aa1b91400318cff353c157986 (diff) | |
| download | fparkan-0ad190894afd8e9592ef182e36e16ee7a61483f6.tar.xz fparkan-0ad190894afd8e9592ef182e36e16ee7a61483f6.zip | |
feat(ui): render assembled warbots in the designer
Diffstat (limited to 'crates/fparkan-runtime')
| -rw-r--r-- | crates/fparkan-runtime/src/lib.rs | 4 | ||||
| -rw-r--r-- | crates/fparkan-runtime/src/production.rs | 17 |
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, |
