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 {get; set; } private List Hinges {get; set; } } }