diff options
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> { |
