aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime
diff options
context:
space:
mode:
Diffstat (limited to 'crates/fparkan-runtime')
-rw-r--r--crates/fparkan-runtime/src/control_profile.rs2
-rw-r--r--crates/fparkan-runtime/src/control_resources.rs6
-rw-r--r--crates/fparkan-runtime/src/lib.rs12
3 files changed, 19 insertions, 1 deletions
diff --git a/crates/fparkan-runtime/src/control_profile.rs b/crates/fparkan-runtime/src/control_profile.rs
index 236d523b..21c54607 100644
--- a/crates/fparkan-runtime/src/control_profile.rs
+++ b/crates/fparkan-runtime/src/control_profile.rs
@@ -63,7 +63,7 @@ pub(super) fn project_initial(
#[derive(Default)]
pub(super) struct DamageAlarm {
threshold: Option<f32>,
- active: bool,
+ pub(super) active: bool,
}
#[derive(Default)]
diff --git a/crates/fparkan-runtime/src/control_resources.rs b/crates/fparkan-runtime/src/control_resources.rs
index b9958229..e34a3dfc 100644
--- a/crates/fparkan-runtime/src/control_resources.rs
+++ b/crates/fparkan-runtime/src/control_resources.rs
@@ -34,6 +34,12 @@ impl Default for Resources {
}
impl Resources {
+ pub(super) fn alarm_active(&self, handle: ObjectHandle) -> bool {
+ self.clocks
+ .iter()
+ .any(|(owner, clock)| *owner == handle && clock.alarm.active)
+ }
+
pub(super) fn energy_available(&self, handle: ObjectHandle) -> bool {
!self.blocked_budgets.contains(&handle)
}
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs
index 3b097acd..e6fe77af 100644
--- a/crates/fparkan-runtime/src/lib.rs
+++ b/crates/fparkan-runtime/src/lib.rs
@@ -3875,6 +3875,16 @@ pub fn loaded_mission_control_device_tables(
.map(|state| state.control_device_tables.as_slice())
}
+/// Whether Control has switched this live object into its damage alarm.
+#[must_use]
+pub fn control_damage_alarm_active(engine: &Engine, handle: ObjectHandle) -> bool {
+ transform_state(&engine.world, handle).is_ok()
+ && engine
+ .loaded
+ .as_ref()
+ .is_some_and(|mission| mission.control_resources.alarm_active(handle))
+}
+
/// Returns the initial prepared Control grouping for full-load mission objects.
#[must_use]
pub fn loaded_mission_behavior_control_groupings(
@@ -8606,6 +8616,7 @@ mod tests {
node_data: None,
effect_section: PreparedControlEffectSection::Parsed(rows),
initial_effect_group,
+ alarm_effect_rows: Vec::new(),
node_effect_links: Vec::new(),
effect_modes: Vec::new(),
point_list: point_count.map(|count| PreparedControlPointList {
@@ -9112,6 +9123,7 @@ mod tests {
node_data: None,
effect_section,
initial_effect_group: None,
+ alarm_effect_rows: Vec::new(),
node_effect_links: Vec::new(),
effect_modes: Vec::new(),
point_list: None,