From 6a51e203e05ab87d96fb59d4a5b46f755aaf76b3 Mon Sep 17 00:00:00 2001 From: annabunches Date: Tue, 11 Feb 2025 12:50:09 -0500 Subject: [PATCH] Add informational/warning light support. --- AirMonitor/AirZone.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/AirMonitor/AirZone.cs b/AirMonitor/AirZone.cs index 06605e3..198b07c 100644 --- a/AirMonitor/AirZone.cs +++ b/AirMonitor/AirZone.cs @@ -1,7 +1,7 @@ using Sandbox.ModAPI.Ingame; using SpaceEngineers.Game.ModAPI.Ingame; using System.Collections.Generic; -using VRage.Game.ModAPI.Ingame.Utilities; +using VRageMath; namespace IngameScript { @@ -18,6 +18,7 @@ namespace IngameScript private List _displays; private PrefixedConsole _console; private Sequencer _sequencer; + private List _lights; private const float TriggerLevel = 0.75F; @@ -30,6 +31,7 @@ namespace IngameScript Vents = new List(); _doors = new List(); _displays = new List(); + _lights = new List(); } public void AddBlock(IMyTerminalBlock block) @@ -51,6 +53,10 @@ namespace IngameScript wrapped.LockClosed = true; _sequencer.AddBlock(wrapped); } + else if (block is IMyLightingBlock) + { + _lights.Add(block as IMyLightingBlock); + } else { _console.Print("Tried to add incompatible block '{block.CustomName}'"); @@ -78,10 +84,16 @@ namespace IngameScript if (Triggered == true) { _console.Print($"Low pressure alarm triggered."); + foreach (IMyLightingBlock light in _lights) + { + light.Enabled = true; + light.Color = Color.Red; + } // close the doors IEnumerator job = _sequencer.RunSequence(true); - while (job.MoveNext()) { + while (job.MoveNext()) + { // It would be nice if the API had UpdateFrequency.Once10, e.g. "re-run in 10 ticks and then clear the flag" // We'll just monitor every tick instead. _program.Runtime.UpdateFrequency |= UpdateFrequency.Once; @@ -92,6 +104,12 @@ namespace IngameScript // unlock the doors, but we'll leave them closed. foreach (IMyDoor door in _doors) { door.Enabled = true; } + + foreach (IMyLightingBlock light in _lights) + { + light.Enabled = true; + light.Color = Color.White; + } } yield return true;