Check if missiles doors are open before launching missiles
This commit is contained in:
parent
7656b66348
commit
5dc10e361b
1 changed files with 19 additions and 0 deletions
|
|
@ -185,12 +185,14 @@ namespace IngameScript
|
|||
public const double HYDRO_TANK_FILLED_PERCENT = 20;
|
||||
|
||||
const string LAUNCHER_SMALL_CONNECTOR_NAME = "Connector Launcher"; // Following by a number: "01", "02", etc.
|
||||
const string DOORS_MISSILES_GROUP = "Doors Missiles";
|
||||
|
||||
const float EPSILON = 0.05f;
|
||||
|
||||
readonly Output output;
|
||||
|
||||
readonly List<Launcher> launchers = new List<Launcher>();
|
||||
readonly IEnumerable<IMyDoor> missilesDoors;
|
||||
|
||||
int nbLaunched = 0;
|
||||
int nextToLaunch = 0;
|
||||
|
|
@ -203,6 +205,13 @@ namespace IngameScript
|
|||
this.output = new Output(output);
|
||||
this.output.Print("Missile launcher system starting...");
|
||||
|
||||
this.missilesDoors = Utils.GetBlocksFromGroup<IMyDoor>(this.GridTerminalSystem, String.Format("{0} {1}", GRID_PREFIX, DOORS_MISSILES_GROUP));
|
||||
if (missilesDoors.Count() == 0)
|
||||
{
|
||||
this.output.Print("No missile doors found: Aborted");
|
||||
return;
|
||||
}
|
||||
|
||||
var connectorNamePrefix = String.Format("{0} {1} ", GRID_PREFIX, LAUNCHER_SMALL_CONNECTOR_NAME);
|
||||
|
||||
// Find all launcher sub-grid and create the associated launcher.
|
||||
|
|
@ -225,6 +234,16 @@ namespace IngameScript
|
|||
|
||||
void LaunchNext()
|
||||
{
|
||||
// Check if the hangar door is open.
|
||||
foreach (var missileDoor in this.missilesDoors)
|
||||
{
|
||||
if (missileDoor.Status != DoorStatus.Open)
|
||||
{
|
||||
this.output.Print("Can't launch when missile doors are closed: Aborted");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.launchers.Count > 0)
|
||||
{
|
||||
this.launchers[this.nextToLaunch].Launch();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue