Add an air monitor script and necessary additions to the Sequencer.

This commit is contained in:
2025-02-11 00:20:39 -05:00
parent 85ce54ad1d
commit 1f33b7fbb4
10 changed files with 323 additions and 0 deletions

View File

@ -0,0 +1,66 @@
using Sandbox.ModAPI.Ingame;
using System.Collections.Generic;
using VRage.Game.ModAPI.Ingame.Utilities;
namespace IngameScript
{
partial class Program
{
public class SequenceableDoor : ISequenceable
{
public bool Running { get; }
public int Step { get; set; }
private IMyDoor _door;
public bool DeployOpen { get; set; }
public bool LockOpen { get; set; }
public bool LockClosed { get; set; }
public SequenceableDoor(
IMyDoor door,
MyIni ini,
string sectionName)
{
_door = door;
ini.TryParse(door.CustomData);
DeployOpen = ini.Get(sectionName, "deployOpen").ToBoolean(true);
LockOpen = ini.Get(sectionName, "lockOpen").ToBoolean(true);
LockClosed = ini.Get(sectionName, "lockClosed").ToBoolean(true);
Step = ini.Get(sectionName, "step").ToInt32(0);
}
public IEnumerator<bool> Run(bool deploy)
{
if (deploy && DeployOpen || !deploy && !DeployOpen)
{
foreach (bool tick in _openDoor()) yield return true;
}
else
{
foreach (bool tick in _closeDoor()) yield return true;
}
}
public IEnumerable<bool> _openDoor()
{
_door.Enabled = true;
_door.OpenDoor();
while (_door.Status != DoorStatus.Open) yield return true;
if (LockOpen) {
_door.Enabled = false;
}
}
public IEnumerable<bool> _closeDoor()
{
_door.Enabled = true;
_door.CloseDoor();
while (_door.Status != DoorStatus.Closed) yield return true;
if (LockClosed) {
_door.Enabled = false;
}
}
}
}
}

View File

@ -27,6 +27,10 @@ namespace IngameScript
{
// return new SequenceableMergeBlock(block as IMyShipMergeBlock, step);
}
if (block is IMyDoor)
{
return new SequenceableDoor(block as IMyDoor, ini, sectionName);
}
return null;
}
}