59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
using Sandbox.ModAPI.Ingame;
|
|
using System.Collections.Generic;
|
|
|
|
namespace IngameScript
|
|
{
|
|
public class Door
|
|
{
|
|
public Door(MyGridProgram p)
|
|
{
|
|
_p = p;
|
|
_hinges = new List<DoorHinge>();
|
|
}
|
|
|
|
// 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<DoorHinge> _hinges;
|
|
}
|
|
} |