diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-26 11:16:16 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-26 11:16:16 +0300 |
| commit | dfbdef7d4d1d295ee962dd8aab754ce6be902f8d (patch) | |
| tree | 9c9f2b6fd6f9519ee05868df3f0d950e00318c24 /crates/fparkan-runtime/src/building_door.rs | |
| parent | a519d5efefb4d846a9f65c6b9376fa245215a0f6 (diff) | |
| download | fparkan-dfbdef7d4d1d295ee962dd8aab754ce6be902f8d.tar.xz fparkan-dfbdef7d4d1d295ee962dd8aab754ce6be902f8d.zip | |
fix(ai): follow capture passages through building doors
A stock Two Fortresses run now takes the generator after the capturer descends its authored hallway. Symmetric Res17 door links drive the CTLD animation and unsupported routes retain explicit coverage. Checked the approach and descent in the game window with Vulkan validation and verified the owner transfer in a licensed test.
Diffstat (limited to 'crates/fparkan-runtime/src/building_door.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/building_door.rs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/crates/fparkan-runtime/src/building_door.rs b/crates/fparkan-runtime/src/building_door.rs index 0d9c88a1..9ac89206 100644 --- a/crates/fparkan-runtime/src/building_door.rs +++ b/crates/fparkan-runtime/src/building_door.rs @@ -2,6 +2,8 @@ use fparkan_assets::PreparedComponentControl; use fparkan_msh::{selected_slot, Group, Lod, ModelAsset, NodeId}; use fparkan_render::LegacyIron3dEulerTransform; +pub(super) const DOOR_BLEND_PER_SECOND: f32 = 2.0; + /// Whether this controller has a door record with a supported node binding. pub fn has_proximity_doors(control: &PreparedComponentControl) -> bool { door_bindings(control).next().is_some() @@ -25,6 +27,38 @@ fn door_bindings( }) } +pub(super) fn is_bound_door(control: &PreparedComponentControl, key: u32) -> bool { + door_bindings(control).any(|binding| binding.node_index == key as usize) +} + +/// Mixes the active hallway door request into the capture target's pose. +pub fn sample_capture_doors( + engine: &crate::Engine, + handle: crate::ObjectHandle, + control: &PreparedComponentControl, + blends: &mut Vec<f32>, + times: &mut [Option<f32>], +) { + let Some(patrol) = engine + .loaded + .as_ref() + .and_then(|mission| mission.unit_patrol.as_ref()) + else { + return; + }; + for (node, requested) in patrol.hallway_doors(handle) { + let Some(binding) = door_bindings(control).find(|binding| binding.node_index == node) + else { + continue; + }; + blends.resize(control.model_node_count, 0.0); + if let (Some(blend), Some(time)) = (blends.get_mut(node), times.get_mut(node)) { + *blend = blend.max(requested); + *time = Some(binding.frame_a + (binding.frame_b - binding.frame_a) * *blend); + } + } +} + /// Updates the authored door tracks next to the player. pub fn sample_proximity_doors( control: &PreparedComponentControl, @@ -72,7 +106,7 @@ pub fn sample_proximity_doors( } else { -1.0 }; - *blend = (*blend + direction * delta_seconds * 2.0).clamp(0.0, 1.0); + *blend = (*blend + direction * delta_seconds * DOOR_BLEND_PER_SECOND).clamp(0.0, 1.0); if let Some(time) = times.get_mut(index) { *time = Some(binding.frame_a + (binding.frame_b - binding.frame_a) * *blend); } |
