From 87c082f87844f47dd6b057fc2458cee80002dc55 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 20:08:24 +0400 Subject: feat(control): replenish ammunition on repair pads --- crates/fparkan-runtime/src/mobile_budget.rs | 37 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'crates/fparkan-runtime/src/mobile_budget.rs') diff --git a/crates/fparkan-runtime/src/mobile_budget.rs b/crates/fparkan-runtime/src/mobile_budget.rs index 32e81eae..fb8dad48 100644 --- a/crates/fparkan-runtime/src/mobile_budget.rs +++ b/crates/fparkan-runtime/src/mobile_budget.rs @@ -309,6 +309,9 @@ pub(super) fn read( for weapon in weapons { let device = devices .and_then(|devices| devices.iter().find(|device| matches_weapon(device, weapon))); + if let Some(device) = device { + weapon.rounds_remaining = device.weapon_rounds; + } weapon.destroyed = device .and_then(|device| crate::control_node_provider_row(table?, device.key).ok()) .is_some_and(|row| row.current_flags.is_some_and(|flags| flags & 0x10 != 0)); @@ -378,29 +381,31 @@ pub(super) fn publish( if weapon.destroyed { continue; } - let Some(charge) = &weapon.charge else { - if available { - mission.control_resources.mobile.stub( - object, - format!( - "weapon_link_{}_{}", - weapon.component_index, weapon.control_record_index - ), - ); - } - continue; - }; - if let MissionControlDeviceTableStatus::Available(devices) = &mut table.status { - if let Some(device) = devices + let device = match &mut table.status { + MissionControlDeviceTableStatus::Available(devices) => devices .iter_mut() - .find(|device| matches_weapon(device, weapon)) - { + .find(|device| matches_weapon(device, weapon)), + _ => None, + }; + if let Some(device) = device { + device.weapon_rounds = weapon.rounds_remaining; + if let Some(charge) = &weapon.charge { device.weapon_charge_bits = Some(charge.amount.to_bits()); if charge.capacity > 0.0 { device.multiplier_bits = Some((charge.amount / charge.capacity).to_bits()); } + continue; } } + if available { + mission.control_resources.mobile.stub( + object, + format!( + "weapon_link_{}_{}", + weapon.component_index, weapon.control_record_index + ), + ); + } } } -- cgit v1.2.3