aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/player_weapon.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 19:08:24 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 19:08:24 +0300
commit87c082f87844f47dd6b057fc2458cee80002dc55 (patch)
tree8d8785580c9d804dadadf1053b49f40bfae4a91e /crates/fparkan-runtime/src/player_weapon.rs
parent3b10d83864d84715b875d596fcd5b4147fcd8ed3 (diff)
downloadfparkan-87c082f87844f47dd6b057fc2458cee80002dc55.tar.xz
fparkan-87c082f87844f47dd6b057fc2458cee80002dc55.zip
feat(control): replenish ammunition on repair pads
Diffstat (limited to 'crates/fparkan-runtime/src/player_weapon.rs')
-rw-r--r--crates/fparkan-runtime/src/player_weapon.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/fparkan-runtime/src/player_weapon.rs b/crates/fparkan-runtime/src/player_weapon.rs
index e9d748e6..347e0450 100644
--- a/crates/fparkan-runtime/src/player_weapon.rs
+++ b/crates/fparkan-runtime/src/player_weapon.rs
@@ -56,7 +56,7 @@ pub struct PlayerWeapon {
deployment: Option<WeaponDeployment>,
barrels: Vec<Barrel>,
barrel_index: usize,
- rounds_remaining: Option<u32>,
+ pub(super) rounds_remaining: Option<u32>,
shot_hold_ms: f64,
reload_ms: f64,
phase: FirePhase,
@@ -83,14 +83,14 @@ enum FirePhase {
}
impl PlayerWeapons {
- /// Reads the authoritative Control charge before sampling this weapon bank.
+ /// Reads the authoritative Control charge and ammunition before firing.
pub fn read_control_energy(&mut self, engine: &Engine, handle: crate::ObjectHandle) {
if let Some(mission) = &engine.loaded {
crate::mobile_budget::read(mission, handle, &mut self.weapons);
}
}
- /// Publishes completed shots to Control before its next resource budget.
+ /// Publishes charge and ammunition consumed by completed shots to Control.
pub fn publish_control_energy(&mut self, engine: &mut Engine, handle: crate::ObjectHandle) {
if let Some(mission) = &mut engine.loaded {
crate::mobile_budget::publish(mission, handle, &mut self.weapons);
@@ -545,10 +545,8 @@ fn prepare_weapons(
let rounds = f32::from_bits(record.fixed_words[11]).round_ties_even();
let rounds_remaining = if rounds == -1.0 {
None
- } else if (0.0..2_147_483_648.0).contains(&rounds) {
- Some(rounds as u32)
} else {
- return None;
+ Some(crate::weapon_resupply::capacity(record.fixed_words[11])?)
};
let effect_row = firing_effect_row(control, row);
let effect_node = effect_row.and_then(|effect| {