Add an air monitor script and necessary additions to the Sequencer.
This commit is contained in:
66
Mixins/Sequencer/SequenceableDoor.cs
Normal file
66
Mixins/Sequencer/SequenceableDoor.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user