aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/cockpit_instruments.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 21:14:34 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 21:14:34 +0300
commit31d770f66c89ce23ca0a9510aa1259e8505179dd (patch)
treea856d0a66cb507ad1c3e51d4ad6554a1fad918c1 /crates/fparkan-runtime/src/cockpit_instruments.rs
parentbd3fbb71cdef1cda0e4db5efa14c632ae72859d6 (diff)
downloadfparkan-31d770f66c89ce23ca0a9510aa1259e8505179dd.tar.xz
fparkan-31d770f66c89ce23ca0a9510aa1259e8505179dd.zip
fix(ui): show live damage stages in cockpit miniatures
Diffstat (limited to 'crates/fparkan-runtime/src/cockpit_instruments.rs')
-rw-r--r--crates/fparkan-runtime/src/cockpit_instruments.rs39
1 files changed, 38 insertions, 1 deletions
diff --git a/crates/fparkan-runtime/src/cockpit_instruments.rs b/crates/fparkan-runtime/src/cockpit_instruments.rs
index 88ea8df5..9911d52e 100644
--- a/crates/fparkan-runtime/src/cockpit_instruments.rs
+++ b/crates/fparkan-runtime/src/cockpit_instruments.rs
@@ -3,11 +3,13 @@
use crate::{
control_device_provider_value, control_device_selector_zero,
projectile::unit_sphere,
+ projectile_parts::warbot_node_is_depleted,
projectile_shield::{enclosing_sphere, world_sphere},
query_control_device_table_selector,
strategic_map_readout::{contact_readout, ContactReadout},
weapon_pose::WeaponPoses,
- Engine, MissionControlDeviceTableStatus, StartingCockpit, HERO_UNIT_CLASS,
+ Engine, MissionControlDeviceTableStatus, MissionControlNodeProviderTableStatus,
+ StartingCockpit, HERO_UNIT_CLASS,
};
use fparkan_world::{identity_metadata, transform_state, ObjectHandle};
@@ -97,6 +99,41 @@ pub fn instrument_bounds(engine: &Engine, object_index: usize) -> Option<([f32;
enclosing_sphere(&poses.instrument_node_spheres(&mission.mission_assets, object_index))
}
+/// Current MSH state by component and local node. A detached warbot part has
+/// no visible state. A node with no Control provider uses its initial slot.
+pub fn instrument_node_states(
+ engine: &Engine,
+ subject: ObjectHandle,
+) -> impl Iterator<Item = ((usize, usize), Option<u32>)> + '_ {
+ engine
+ .loaded
+ .iter()
+ .filter_map(move |mission| {
+ let table = mission
+ .control_device_tables
+ .iter()
+ .find(|table| table.handle == subject)?;
+ let MissionControlNodeProviderTableStatus::Available(rows) =
+ &table.node_provider_status
+ else {
+ return None;
+ };
+ let draft = mission.object_drafts.get(table.original_id?.0 as usize)?;
+ let warbot = draft.unit_dat_header_flags == Some(crate::boarding::WARBOT_CLASS);
+ Some((rows.as_slice(), warbot))
+ })
+ .flat_map(|(rows, warbot)| {
+ rows.iter().enumerate().map(move |(index, row)| {
+ let state = if warbot && index != 0 && warbot_node_is_depleted(row) {
+ None
+ } else {
+ Some(row.mesh_state.map_or(0, |state| state.visible_stage))
+ };
+ ((row.unit_component_index, row.source_row_index), state)
+ })
+ })
+}
+
/// Places the sphere in the object's current world pose.
pub fn instrument_sphere(
engine: &Engine,