From 5dc10e361bc6dc38f46a28cdf0016428cdcba321 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sat, 23 Aug 2025 21:44:45 +0200 Subject: [PATCH] Check if missiles doors are open before launching missiles --- MissileLauncher/Program.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/MissileLauncher/Program.cs b/MissileLauncher/Program.cs index 0bcea26..1116d01 100644 --- a/MissileLauncher/Program.cs +++ b/MissileLauncher/Program.cs @@ -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 launchers = new List(); + readonly IEnumerable 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(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();