diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 08:39:16 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 08:39:16 +0300 |
| commit | af281721b24a4c80d4c640c3d79a293dba2bee61 (patch) | |
| tree | db70c0501e871171eef66516fc958ee42a256af0 /apps/fparkan-game/src/damage_visibility.rs | |
| parent | 590c8f39b935f34fc6a4f9c033520c2c0359253d (diff) | |
| download | fparkan-af281721b24a4c80d4c640c3d79a293dba2bee61.tar.xz fparkan-af281721b24a4c80d4c640c3d79a293dba2bee61.zip | |
fix(render): show building damage stages after projectile hits
Update the contacted provider with the native stage rule. Upload the authored variants with their original material and pose, and draw the active stage only. The Two Fortresses plant switches in a validated before/after capture.
Diffstat (limited to 'apps/fparkan-game/src/damage_visibility.rs')
| -rw-r--r-- | apps/fparkan-game/src/damage_visibility.rs | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/apps/fparkan-game/src/damage_visibility.rs b/apps/fparkan-game/src/damage_visibility.rs index e9ffdf53..fe462da1 100644 --- a/apps/fparkan-game/src/damage_visibility.rs +++ b/apps/fparkan-game/src/damage_visibility.rs @@ -4,7 +4,59 @@ use super::DynamicComponentGeometry; use fparkan_animation::NodePoseBuffer; use fparkan_msh::{draw_batches, selected_slot, Group, Lod, NodeId}; use fparkan_render_vulkan::{VulkanSmokeRenderer, VulkanStaticMesh}; -use fparkan_runtime::{depleted_warbot_nodes, Engine}; +use fparkan_runtime::{ + depleted_warbot_nodes, loaded_mission_control_device_tables, Engine, + MissionControlNodeProviderTableStatus, +}; +use std::collections::HashSet; + +pub(super) fn inactive_building_ranges( + engine: &Engine, + geometry: &[Vec<Option<DynamicComponentGeometry>>], +) -> HashSet<usize> { + let mut hidden = HashSet::new(); + let tables = loaded_mission_control_device_tables(engine).unwrap_or_default(); + for (object_index, components) in geometry.iter().enumerate() { + if !components + .iter() + .flatten() + .any(|component| !component.damage_stages.is_empty()) + { + continue; + } + let rows = tables + .iter() + .find(|table| { + table + .original_id + .is_some_and(|id| id.0 as usize == object_index) + }) + .and_then(|table| match &table.node_provider_status { + MissionControlNodeProviderTableStatus::Available(rows) => Some(rows.as_slice()), + MissionControlNodeProviderTableStatus::Unavailable(_) => None, + }) + .unwrap_or_default(); + for (component_index, component) in components.iter().enumerate() { + let Some(component) = component else { + continue; + }; + for variant in &component.damage_stages { + let active = rows + .iter() + .find(|row| { + row.unit_component_index == component_index + && row.source_row_index == variant.node + }) + .and_then(|row| row.mesh_state) + .map_or(0, |state| state.visible_stage); + if u32::from(variant.stage) != active { + hidden.extend(variant.ranges.clone()); + } + } + } + } + hidden +} pub(super) fn apply( engine: &Engine, |
