diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 19:08:24 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 19:08:24 +0300 |
| commit | 87c082f87844f47dd6b057fc2458cee80002dc55 (patch) | |
| tree | 8d8785580c9d804dadadf1053b49f40bfae4a91e /crates/fparkan-runtime/src/mobile_budget.rs | |
| parent | 3b10d83864d84715b875d596fcd5b4147fcd8ed3 (diff) | |
| download | fparkan-87c082f87844f47dd6b057fc2458cee80002dc55.tar.xz fparkan-87c082f87844f47dd6b057fc2458cee80002dc55.zip | |
feat(control): replenish ammunition on repair pads
Diffstat (limited to 'crates/fparkan-runtime/src/mobile_budget.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/mobile_budget.rs | 37 |
1 files changed, 21 insertions, 16 deletions
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 + ), + ); + } } } |
