aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/projectile.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 07:12:30 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 07:12:30 +0300
commit352026c1ce039443efc779876b27654d992bfff1 (patch)
tree81b8106d529e1b808af462d20de73351fe8456dc /crates/fparkan-runtime/src/projectile.rs
parent31dd73cbf59f5c8fe58b77b373a75033dc5a037a (diff)
downloadfparkan-352026c1ce039443efc779876b27654d992bfff1.tar.xz
fparkan-352026c1ce039443efc779876b27654d992bfff1.zip
fix(combat): propagate the loss of a warbot chassis section
Reuse the Control provider traversal after a lethal chassis hit so attached links disappear with the failed section. The GOG Control oracle and a controlled AutoDemo hit confirm the subtree behavior. All 29 missions reached 900 simulated seconds.
Diffstat (limited to 'crates/fparkan-runtime/src/projectile.rs')
-rw-r--r--crates/fparkan-runtime/src/projectile.rs29
1 files changed, 25 insertions, 4 deletions
diff --git a/crates/fparkan-runtime/src/projectile.rs b/crates/fparkan-runtime/src/projectile.rs
index 4666dfd9..5359fc42 100644
--- a/crates/fparkan-runtime/src/projectile.rs
+++ b/crates/fparkan-runtime/src/projectile.rs
@@ -377,12 +377,33 @@ fn apply_contact_damage(
.then(|| super::destruction::part_effect(engine, row, contact))
.flatten();
let updated = apply_loaded_mission_control_node_delta(engine, contact.handle, key, -volume)?;
- if updated.is_some() {
- if let (Some(effect), Some(events)) = (effect, engine.destruction_effects.as_mut()) {
- events.push(effect);
+ if updated.is_none() {
+ return Ok(None);
+ }
+ if volume >= remaining && matches!(contact.node, Some(ProjectileNode::Chassis(_))) {
+ let table = engine
+ .loaded
+ .as_mut()
+ .and_then(|mission| {
+ mission
+ .control_device_tables
+ .iter_mut()
+ .find(|table| table.handle == contact.handle)
+ })
+ .expect("successful damage updated the target table");
+ match super::node_stage::propagate_chassis_damage(table, key) {
+ Ok(true) => {
+ super::destruction::destroy(engine, contact.handle)?;
+ return Ok(Some((0.0, true)));
+ }
+ Ok(false) => {}
+ Err(reason) => eprintln!("sim_coverage chassis_depletion_cascade_stub=1 object={} node={key} reason={reason:?}", contact.handle.slot),
}
}
- Ok(updated.map(|_| ((remaining - volume).max(0.0), false)))
+ if let (Some(effect), Some(events)) = (effect, engine.destruction_effects.as_mut()) {
+ events.push(effect);
+ }
+ Ok(Some(((remaining - volume).max(0.0), false)))
}
pub(super) fn segment_sphere_fraction(