using Sandbox.ModAPI.Ingame; using System.Collections.Generic; namespace IngameScript { public class Door { public Door(MyGridProgram p) { _p = p; _hinges = new List(); } // Add a hinge to the door public void AddHinge(IMyMotorStator hinge) { _hinges.Add(new DoorHinge(_p, 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; } public bool Locked() { foreach (DoorHinge hinge in _hinges) { if (!hinge.Locked) return false; } return true; } private MyGridProgram _p; private List _hinges; } }