Add informational/warning light support.
This commit is contained in:
parent
97eb659378
commit
6a51e203e0
|
@ -1,7 +1,7 @@
|
||||||
using Sandbox.ModAPI.Ingame;
|
using Sandbox.ModAPI.Ingame;
|
||||||
using SpaceEngineers.Game.ModAPI.Ingame;
|
using SpaceEngineers.Game.ModAPI.Ingame;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using VRage.Game.ModAPI.Ingame.Utilities;
|
using VRageMath;
|
||||||
|
|
||||||
namespace IngameScript
|
namespace IngameScript
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,7 @@ namespace IngameScript
|
||||||
private List<IMyTextSurface> _displays;
|
private List<IMyTextSurface> _displays;
|
||||||
private PrefixedConsole _console;
|
private PrefixedConsole _console;
|
||||||
private Sequencer _sequencer;
|
private Sequencer _sequencer;
|
||||||
|
private List<IMyLightingBlock> _lights;
|
||||||
|
|
||||||
private const float TriggerLevel = 0.75F;
|
private const float TriggerLevel = 0.75F;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ namespace IngameScript
|
||||||
Vents = new List<IMyAirVent>();
|
Vents = new List<IMyAirVent>();
|
||||||
_doors = new List<IMyDoor>();
|
_doors = new List<IMyDoor>();
|
||||||
_displays = new List<IMyTextSurface>();
|
_displays = new List<IMyTextSurface>();
|
||||||
|
_lights = new List<IMyLightingBlock>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddBlock(IMyTerminalBlock block)
|
public void AddBlock(IMyTerminalBlock block)
|
||||||
|
@ -51,6 +53,10 @@ namespace IngameScript
|
||||||
wrapped.LockClosed = true;
|
wrapped.LockClosed = true;
|
||||||
_sequencer.AddBlock(wrapped);
|
_sequencer.AddBlock(wrapped);
|
||||||
}
|
}
|
||||||
|
else if (block is IMyLightingBlock)
|
||||||
|
{
|
||||||
|
_lights.Add(block as IMyLightingBlock);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_console.Print("Tried to add incompatible block '{block.CustomName}'");
|
_console.Print("Tried to add incompatible block '{block.CustomName}'");
|
||||||
|
@ -78,10 +84,16 @@ namespace IngameScript
|
||||||
if (Triggered == true)
|
if (Triggered == true)
|
||||||
{
|
{
|
||||||
_console.Print($"Low pressure alarm triggered.");
|
_console.Print($"Low pressure alarm triggered.");
|
||||||
|
foreach (IMyLightingBlock light in _lights)
|
||||||
|
{
|
||||||
|
light.Enabled = true;
|
||||||
|
light.Color = Color.Red;
|
||||||
|
}
|
||||||
|
|
||||||
// close the doors
|
// close the doors
|
||||||
IEnumerator<bool> job = _sequencer.RunSequence(true);
|
IEnumerator<bool> 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"
|
// 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.
|
// We'll just monitor every tick instead.
|
||||||
_program.Runtime.UpdateFrequency |= UpdateFrequency.Once;
|
_program.Runtime.UpdateFrequency |= UpdateFrequency.Once;
|
||||||
|
@ -92,6 +104,12 @@ namespace IngameScript
|
||||||
|
|
||||||
// unlock the doors, but we'll leave them closed.
|
// unlock the doors, but we'll leave them closed.
|
||||||
foreach (IMyDoor door in _doors) { door.Enabled = true; }
|
foreach (IMyDoor door in _doors) { door.Enabled = true; }
|
||||||
|
|
||||||
|
foreach (IMyLightingBlock light in _lights)
|
||||||
|
{
|
||||||
|
light.Enabled = true;
|
||||||
|
light.Color = Color.White;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return true;
|
yield return true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user