diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 15:20:23 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 15:20:23 +0300 |
| commit | cc6bbdfa4aebf844ec7be2e8eb01b7fd1c69d24b (patch) | |
| tree | 4b69fecd2c3172724ad62cd2e75d1bb456ca0c65 /crates/fparkan-runtime/src/warbot_stats.rs | |
| parent | 04e58559f76c89a284dfab820efed25a97db2461 (diff) | |
| download | fparkan-cc6bbdfa4aebf844ec7be2e8eb01b7fd1c69d24b.tar.xz fparkan-cc6bbdfa4aebf844ec7be2e8eb01b7fd1c69d24b.zip | |
feat(ui): show strategic factories and order a warbot
Diffstat (limited to 'crates/fparkan-runtime/src/warbot_stats.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/warbot_stats.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/fparkan-runtime/src/warbot_stats.rs b/crates/fparkan-runtime/src/warbot_stats.rs index c7eab4b7..b37f5201 100644 --- a/crates/fparkan-runtime/src/warbot_stats.rs +++ b/crates/fparkan-runtime/src/warbot_stats.rs @@ -31,6 +31,10 @@ pub fn warbot_stats(engine: &Engine, handle: ObjectHandle) -> Option<WarbotStats .control_device_tables .iter() .find(|table| table.handle == handle)?; + Some(stats_from_table(table)) +} + +pub(super) fn stats_from_table(table: &MissionControlDeviceTableState) -> WarbotStats { let profile = table.owner_profile.as_ref(); let weight = profile.and_then(|profile| { let load = profile.load_projection.as_ref().ok()?; @@ -42,11 +46,11 @@ pub fn warbot_stats(engine: &Engine, handle: ObjectHandle) -> Option<WarbotStats }); let speed = profile.and_then(|profile| finite(profile.current_words[7])); let MissionControlDeviceTableStatus::Available(devices) = &table.status else { - return Some(WarbotStats { + return WarbotStats { weight, speed, ..WarbotStats::default() - }); + }; }; let weapons = devices .iter() @@ -60,13 +64,13 @@ pub fn warbot_stats(engine: &Engine, handle: ObjectHandle) -> Option<WarbotStats }); let radar = crate::radar::radar_device(table) .map_or(Some(0.0), |device| finite(device.coefficient_bits?[3])); - Some(WarbotStats { + WarbotStats { weight, speed, defence: defence(table, devices), offence: offence(weapons), radar, - }) + } } pub(super) fn durability_percent(table: &MissionControlDeviceTableState) -> Option<i32> { |
