aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/mobile_budget.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 07:55:10 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 07:55:10 +0300
commit79635316902c69a363f1d1a9ebef110d94190356 (patch)
tree806e345cc9d5553cea330483b828cb080bd22061 /crates/fparkan-runtime/src/mobile_budget.rs
parent777f48345c7faf891ac105fc4a831114914aff5d (diff)
downloadfparkan-79635316902c69a363f1d1a9ebef110d94190356.tar.xz
fparkan-79635316902c69a363f1d1a9ebef110d94190356.zip
fix(combat): let projectiles destroy mounted warbot parts
Resolve mounted model triangles through the sampled socket chain and publish the damage to the assembled Control provider. Remove the damaged geometry, stop weapons whose provider was depleted, and preserve already separated ranges when the chassis later dies. Confirmed with a licensed AutoDemo ray query and two frames around a controlled hit in the Vulkan window.
Diffstat (limited to 'crates/fparkan-runtime/src/mobile_budget.rs')
-rw-r--r--crates/fparkan-runtime/src/mobile_budget.rs36
1 files changed, 21 insertions, 15 deletions
diff --git a/crates/fparkan-runtime/src/mobile_budget.rs b/crates/fparkan-runtime/src/mobile_budget.rs
index 06dc251e..1df2ab80 100644
--- a/crates/fparkan-runtime/src/mobile_budget.rs
+++ b/crates/fparkan-runtime/src/mobile_budget.rs
@@ -267,21 +267,24 @@ pub(super) fn read(
_ => None,
});
for weapon in weapons {
- weapon.charge = if mission.control_resources.energy_available(handle) {
- devices
- .and_then(|devices| devices.iter().find(|device| matches_weapon(device, weapon)))
- .and_then(|device| {
- let coefficients = device.coefficient_bits?;
- let charge = Charge {
- capacity: f32::from_bits(coefficients[1]),
- cost: f32::from_bits(coefficients[2]),
- amount: f32::from_bits(device.weapon_charge_bits?),
- };
- [charge.capacity, charge.cost, charge.amount]
- .into_iter()
- .all(|value| value.is_finite() && !value.is_subnormal())
- .then_some(charge)
- })
+ let device = devices
+ .and_then(|devices| devices.iter().find(|device| matches_weapon(device, weapon)));
+ 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));
+ weapon.charge = if !weapon.destroyed && mission.control_resources.energy_available(handle) {
+ device.and_then(|device| {
+ let coefficients = device.coefficient_bits?;
+ let charge = Charge {
+ capacity: f32::from_bits(coefficients[1]),
+ cost: f32::from_bits(coefficients[2]),
+ amount: f32::from_bits(device.weapon_charge_bits?),
+ };
+ [charge.capacity, charge.cost, charge.amount]
+ .into_iter()
+ .all(|value| value.is_finite() && !value.is_subnormal())
+ .then_some(charge)
+ })
} else {
None
};
@@ -332,6 +335,9 @@ pub(super) fn publish(
}
for weapon in weapons {
weapon.energy_waits = 0;
+ if weapon.destroyed {
+ continue;
+ }
let Some(charge) = &weapon.charge else {
if available {
mission.control_resources.mobile.stub(