diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-26 06:21:39 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-26 06:21:39 +0300 |
| commit | f0a92313d0628eda8e163ab0608ce8fcbedaad95 (patch) | |
| tree | 203c15e66a577e621b88c28428e01a55d9fac37c /crates/fparkan-runtime/src/destruction.rs | |
| parent | 8f1ba615bf1e393698eae7624073c1ad9f54c02b (diff) | |
| download | fparkan-f0a92313d0628eda8e163ab0608ce8fcbedaad95.tar.xz fparkan-f0a92313d0628eda8e163ab0608ce8fcbedaad95.zip | |
feat(combat): show detached assemblies after chassis destruction
Diffstat (limited to 'crates/fparkan-runtime/src/destruction.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/destruction.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/fparkan-runtime/src/destruction.rs b/crates/fparkan-runtime/src/destruction.rs index 38a4e38f..89688de5 100644 --- a/crates/fparkan-runtime/src/destruction.rs +++ b/crates/fparkan-runtime/src/destruction.rs @@ -1,10 +1,12 @@ //! Presentation events for projectile damage that destroys a unit. use crate::{autodemo::MOBILE_UNIT, Engine, MissionControlDeviceTableState, ObjectHandle}; -use fparkan_world::transform_state; +use fparkan_world::{identity_metadata, transform_state}; /// Position and attached EXPL resource of a chassis at lethal contact. pub struct UnitDestructionEffect { + /// Prepared draft index for the destroyed actor when it has an authored layout. + pub object_index: Option<usize>, /// World-space origin of the destroyed chassis. pub position: [f32; 3], /// Archive containing the explosion description. @@ -60,11 +62,21 @@ pub(super) fn pending_effect( .iter() .find(|table| table.handle == handle)?; let (archive, name) = root_effect(table)?; + let object_index = identity_metadata(&engine.world, handle) + .ok() + .and_then(|identity| identity.original_id) + .and_then(|id| { + mission + .object_drafts + .iter() + .position(|draft| draft.original_id == Some(id)) + }); let position = transform_state(&engine.world, handle) .ok()? .position .map(f32::from_bits); Some(UnitDestructionEffect { + object_index, position, archive, name, |
