using Sandbox.ModAPI.Ingame; using System.Collections.Generic; namespace IngameScript { public class Door { private PrefixedConsole _console; private List _hinges; public bool Locked { get { foreach (DoorHinge hinge in _hinges) { if (!hinge.Locked) return false; } return true; } } public Door(Console console, string name) { _console = new PrefixedConsole(console, name); _hinges = new List(); } // Add a hinge to the door public void AddHinge(IMyMotorStator hinge) { _hinges.Add(new DoorHinge(_console, hinge)); } public void OpenDoor() { foreach (DoorHinge hinge in _hinges) { hinge.OpenDoorHinge(); } } public void CloseDoor() { foreach (DoorHinge hinge in _hinges) { hinge.CloseDoorHinge(); } } // Process the door's movement. This will return true when the door is done moving. public bool Actuate() { bool done = true; foreach (DoorHinge hinge in _hinges) { if (!hinge.Actuate()) done = false; } return done; } } }