From: Greg Burri Date: Wed, 8 May 2024 19:20:58 +0000 (+0200) Subject: Add missile launcher and missile controller projects X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=6b3ee666d6489deb3b03742aaaf47d6f148fbd21;p=SEScripts.git Add missile launcher and missile controller projects --- diff --git a/AutoPilot/MDK/MDK.paths.props b/AutoPilot/MDK/MDK.paths.props index a0f8f66..6cd170a 100644 --- a/AutoPilot/MDK/MDK.paths.props +++ b/AutoPilot/MDK/MDK.paths.props @@ -5,76 +5,76 @@ You can safely exclude this file from code repositories and use different user settings per machine. --> - 1.5.17 + 1.4.14 no G:\SteamLibrary\SteamApps\common\SpaceEngineers\Bin64 - c:\users\lyssmetal\appdata\local\microsoft\visualstudio\17.0_6c02a30d\extensions\bnnd2422.thc + c:\users\lyssmetal\appdata\local\microsoft\visualstudio\17.0_6c02a30d\extensions\twejjmj5.r1e C:\Users\LyssMetal\AppData\Roaming\SpaceEngineers\IngameScripts\local - - $(MDKGameBinPath)\System.Collections.Immutable.dll - false - $(MDKGameBinPath)\Sandbox.Common.dll - False + false $(MDKGameBinPath)\Sandbox.Game.dll - False + false $(MDKGameBinPath)\Sandbox.Graphics.dll - False + false $(MDKGameBinPath)\SpaceEngineers.Game.dll - False + false $(MDKGameBinPath)\SpaceEngineers.ObjectBuilders.dll - False + false $(MDKGameBinPath)\VRage.dll - False + false $(MDKGameBinPath)\VRage.Audio.dll - False + false $(MDKGameBinPath)\VRage.Game.dll - False + false $(MDKGameBinPath)\VRage.Input.dll - False + false $(MDKGameBinPath)\VRage.Library.dll - False + false $(MDKGameBinPath)\VRage.Math.dll - False + false $(MDKGameBinPath)\VRage.Render.dll - False + false $(MDKGameBinPath)\VRage.Render11.dll - False + false $(MDKGameBinPath)\VRage.Scripting.dll - False + false $(MDKInstallPath)\MDKUtilities.dll - True + true + + + $(MDKGameBinPath)\System.Collections.Immutable.dll + false diff --git a/BaseMiner/MDK/MDK.paths.props b/BaseMiner/MDK/MDK.paths.props index a0f8f66..6cd170a 100644 --- a/BaseMiner/MDK/MDK.paths.props +++ b/BaseMiner/MDK/MDK.paths.props @@ -5,76 +5,76 @@ You can safely exclude this file from code repositories and use different user settings per machine. --> - 1.5.17 + 1.4.14 no G:\SteamLibrary\SteamApps\common\SpaceEngineers\Bin64 - c:\users\lyssmetal\appdata\local\microsoft\visualstudio\17.0_6c02a30d\extensions\bnnd2422.thc + c:\users\lyssmetal\appdata\local\microsoft\visualstudio\17.0_6c02a30d\extensions\twejjmj5.r1e C:\Users\LyssMetal\AppData\Roaming\SpaceEngineers\IngameScripts\local - - $(MDKGameBinPath)\System.Collections.Immutable.dll - false - $(MDKGameBinPath)\Sandbox.Common.dll - False + false $(MDKGameBinPath)\Sandbox.Game.dll - False + false $(MDKGameBinPath)\Sandbox.Graphics.dll - False + false $(MDKGameBinPath)\SpaceEngineers.Game.dll - False + false $(MDKGameBinPath)\SpaceEngineers.ObjectBuilders.dll - False + false $(MDKGameBinPath)\VRage.dll - False + false $(MDKGameBinPath)\VRage.Audio.dll - False + false $(MDKGameBinPath)\VRage.Game.dll - False + false $(MDKGameBinPath)\VRage.Input.dll - False + false $(MDKGameBinPath)\VRage.Library.dll - False + false $(MDKGameBinPath)\VRage.Math.dll - False + false $(MDKGameBinPath)\VRage.Render.dll - False + false $(MDKGameBinPath)\VRage.Render11.dll - False + false $(MDKGameBinPath)\VRage.Scripting.dll - False + false $(MDKInstallPath)\MDKUtilities.dll - True + true + + + $(MDKGameBinPath)\System.Collections.Immutable.dll + false diff --git a/BaseMiner/Program.cs b/BaseMiner/Program.cs index bb89dc5..0275435 100644 --- a/BaseMiner/Program.cs +++ b/BaseMiner/Program.cs @@ -58,10 +58,25 @@ namespace IngameScript var output = this.Me.GetSurface(0); this.output = new Output(output, CONSOLE_NB_LINES); - this.output.Print("Base mining system starting..."); + this.output.Print("Base system starting..."); + + this.InitMiningSystem(); + + this.minerConnector = this.GridTerminalSystem.GetBlockWithName("[Base] Connector Miner") as IMyShipConnector; + if (this.minerConnector == null) + this.output.Print($"Error: miner connector not found"); + + this.Runtime.UpdateFrequency = UpdateFrequency.Update100; + + this.output.Print("Base system has started"); + } + + void InitMiningSystem() + { + this.output.Print("Mining system initializing..."); this.GridTerminalSystem.GetBlocksOfType( - this.drills, + this.drills, (IMyShipDrill drill) => drill.CustomName.StartsWith(GRID_PREFIX) ); @@ -86,14 +101,8 @@ namespace IngameScript ); this.output.Print($"Nb of rotating lights: {this.rotatingLights.Count}"); - - this.minerConnector = this.GridTerminalSystem.GetBlockWithName("[Base] Connector Miner") as IMyShipConnector; - if (this.minerConnector == null) - this.output.Print($"Error: miner connector not found"); - - this.Runtime.UpdateFrequency = UpdateFrequency.Update100; - this.output.Print("base Mining system has started"); + this.output.Print("Mining system initialized"); } public void Save() diff --git a/MiningRover/MDK/MDK.paths.props b/MiningRover/MDK/MDK.paths.props index a0f8f66..6cd170a 100644 --- a/MiningRover/MDK/MDK.paths.props +++ b/MiningRover/MDK/MDK.paths.props @@ -5,76 +5,76 @@ You can safely exclude this file from code repositories and use different user settings per machine. --> - 1.5.17 + 1.4.14 no G:\SteamLibrary\SteamApps\common\SpaceEngineers\Bin64 - c:\users\lyssmetal\appdata\local\microsoft\visualstudio\17.0_6c02a30d\extensions\bnnd2422.thc + c:\users\lyssmetal\appdata\local\microsoft\visualstudio\17.0_6c02a30d\extensions\twejjmj5.r1e C:\Users\LyssMetal\AppData\Roaming\SpaceEngineers\IngameScripts\local - - $(MDKGameBinPath)\System.Collections.Immutable.dll - false - $(MDKGameBinPath)\Sandbox.Common.dll - False + false $(MDKGameBinPath)\Sandbox.Game.dll - False + false $(MDKGameBinPath)\Sandbox.Graphics.dll - False + false $(MDKGameBinPath)\SpaceEngineers.Game.dll - False + false $(MDKGameBinPath)\SpaceEngineers.ObjectBuilders.dll - False + false $(MDKGameBinPath)\VRage.dll - False + false $(MDKGameBinPath)\VRage.Audio.dll - False + false $(MDKGameBinPath)\VRage.Game.dll - False + false $(MDKGameBinPath)\VRage.Input.dll - False + false $(MDKGameBinPath)\VRage.Library.dll - False + false $(MDKGameBinPath)\VRage.Math.dll - False + false $(MDKGameBinPath)\VRage.Render.dll - False + false $(MDKGameBinPath)\VRage.Render11.dll - False + false $(MDKGameBinPath)\VRage.Scripting.dll - False + false $(MDKInstallPath)\MDKUtilities.dll - True + true + + + $(MDKGameBinPath)\System.Collections.Immutable.dll + false diff --git a/MissileController/MDK/Bootstrapper.cs b/MissileController/MDK/Bootstrapper.cs new file mode 100644 index 0000000..dd86886 --- /dev/null +++ b/MissileController/MDK/Bootstrapper.cs @@ -0,0 +1,27 @@ +using Malware.MDKUtilities; + +namespace IngameScript.MDK +{ + public class TestBootstrapper + { + // All the files in this folder, as well as all files containing the file ".debug.", will be excluded + // from the build process. You can use this to create utilites for testing your scripts directly in + // Visual Studio. + + static TestBootstrapper() + { + // Initialize the MDK utility framework + MDKUtilityFramework.Load(); + } + + public static void Main() + { + // In order for your program to actually run, you will need to provide a mockup of all the facilities + // your script uses from the game, since they're not available outside of the game. + + // Create and configure the desired program. + var program = MDKFactory.CreateProgram(); + MDKFactory.Run(program); + } + } +} \ No newline at end of file diff --git a/MissileController/MDK/MDK.options.props b/MissileController/MDK/MDK.options.props new file mode 100644 index 0000000..0a291ca --- /dev/null +++ b/MissileController/MDK/MDK.options.props @@ -0,0 +1,18 @@ + + + + + 1.5.17 + + no + + + None + + + mdk + + + \ No newline at end of file diff --git a/MissileController/MDK/MDK.paths.props b/MissileController/MDK/MDK.paths.props new file mode 100644 index 0000000..6cd170a --- /dev/null +++ b/MissileController/MDK/MDK.paths.props @@ -0,0 +1,81 @@ + + + + + 1.4.14 + no + G:\SteamLibrary\SteamApps\common\SpaceEngineers\Bin64 + c:\users\lyssmetal\appdata\local\microsoft\visualstudio\17.0_6c02a30d\extensions\twejjmj5.r1e + C:\Users\LyssMetal\AppData\Roaming\SpaceEngineers\IngameScripts\local + + + + $(MDKGameBinPath)\Sandbox.Common.dll + false + + + $(MDKGameBinPath)\Sandbox.Game.dll + false + + + $(MDKGameBinPath)\Sandbox.Graphics.dll + false + + + $(MDKGameBinPath)\SpaceEngineers.Game.dll + false + + + $(MDKGameBinPath)\SpaceEngineers.ObjectBuilders.dll + false + + + $(MDKGameBinPath)\VRage.dll + false + + + $(MDKGameBinPath)\VRage.Audio.dll + false + + + $(MDKGameBinPath)\VRage.Game.dll + false + + + $(MDKGameBinPath)\VRage.Input.dll + false + + + $(MDKGameBinPath)\VRage.Library.dll + false + + + $(MDKGameBinPath)\VRage.Math.dll + false + + + $(MDKGameBinPath)\VRage.Render.dll + false + + + $(MDKGameBinPath)\VRage.Render11.dll + false + + + $(MDKGameBinPath)\VRage.Scripting.dll + false + + + $(MDKInstallPath)\MDKUtilities.dll + true + + + $(MDKGameBinPath)\System.Collections.Immutable.dll + false + + + + \ No newline at end of file diff --git a/MissileController/MissileController.csproj b/MissileController/MissileController.csproj new file mode 100644 index 0000000..bfd62ec --- /dev/null +++ b/MissileController/MissileController.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {F902E413-8F1A-423D-98A5-F26B684E28BA} + Exe + IngameScript + MissileController + v4.8 + 512 + true + + + + true + bin\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + 6 + + + + + + + + + + + + + + + + + + Always + + + Always + + + + + + + + + + + + + \ No newline at end of file diff --git a/MissileController/Program.cs b/MissileController/Program.cs new file mode 100644 index 0000000..3fcc33c --- /dev/null +++ b/MissileController/Program.cs @@ -0,0 +1,206 @@ +using Sandbox.Game.Entities.Cube; +using Sandbox.Game.EntityComponents; +//using Sandbox.ModAPI; +using Sandbox.ModAPI.Ingame; +using Sandbox.ModAPI.Interfaces; + +using SpaceEngineers.Game.ModAPI.Ingame; + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; + +using VRage; +using VRage.Collections; +using VRage.Game; +using VRage.Game.Components; +using VRage.Game.GUI.TextPanel; +using VRage.Game.ModAPI.Ingame; +using VRage.Game.ModAPI.Ingame.Utilities; +using VRage.Game.ObjectBuilders.Definitions; + +using VRageMath; + +namespace IngameScript +{ + partial class Program : MyGridProgram + { + const string MISSILE_GRID_PREFIX = "[PM]"; + + const float EPSILON = 0.05f; + const double DELAY_BEFORE_TRAVELLING_MODE = 3000; // [ms]. + const double AUTO_DESTRUCTION_AFTER = 60000; // [ms] (1 min). + + + enum State + { + NORMAL, + LAUNCHING, + TRAVELLING, + } + + State currentState = State.NORMAL; + + readonly Output output; + + int tickFromStart; + IMyThrust forwardThruster; + IMyFlightMovementBlock aiMove; + IMyOffensiveCombatBlock aiCombat; + IMySensorBlock sensor; + List warheads = new List(); + IMyGasTank gasTank; + IMyLightingBlock light; + + public Program() + { + var output = this.Me.GetSurface(0); + this.output = new Output(output); + + this.output.Print("Missile controller system starting..."); + + this.Runtime.UpdateFrequency = UpdateFrequency.Update10; + + this.output.Print("Missile controller system started"); + } + + void UpdateState10() + { + if (this.forwardThruster == null) + this.forwardThruster = this.GridTerminalSystem.GetBlockWithName("[PM] Hydrogen Thruster 01") as IMyThrust; + if (this.forwardThruster == null) + { + this.output.Print("Error: Cannot find forward thruster"); + return; + } + + if (this.aiMove == null) + this.aiMove = this.GridTerminalSystem.GetBlockWithName("[PM] AI Flight (Move)") as IMyFlightMovementBlock; + if (this.aiMove == null) + { + this.output.Print("Error: Cannot find AI move"); + return; + } + + if (this.aiCombat == null) + this.aiCombat = this.GridTerminalSystem.GetBlockWithName("[PM] AI Offensive (Combat)") as IMyOffensiveCombatBlock; + if (this.aiCombat == null) + { + this.output.Print("Error: Cannot find AI combat"); + return; + } + + if (this.sensor == null) + this.sensor = this.GridTerminalSystem.GetBlockWithName("[PM] Sensor") as IMySensorBlock; + if (this.sensor == null) + { + this.output.Print("Error: Cannot find sensor"); + return; + } + + if (this.warheads.Count == 0) + this.GridTerminalSystem.GetBlockGroupWithName("[PM] Warheads").GetBlocksOfType(this.warheads); + if (this.warheads.Count == 0) + { + this.output.Print("Error: Cannot find any warhead"); + return; + } + + if (this.gasTank == null) + this.gasTank = this.GridTerminalSystem.GetBlockWithName("[PM] Hydrogen Tank") as IMyGasTank; + if (this.gasTank == null) + { + this.output.Print("Error: Cannot find gas tank"); + return; + } + + if (this.light == null) + this.light = this.GridTerminalSystem.GetBlockWithName("[PM] Light") as IMyLightingBlock; + if (this.light == null) + { + this.output.Print("Error: Cannot find light"); + return; + } + + switch (this.currentState) + { + case State.LAUNCHING: + // this.output.Print($"Tick: {this.tickFromStart}"); + //this.forwardThruster.ove + this.forwardThruster.ThrustOverridePercentage = 1; + if (this.MsSinceLaunch > DELAY_BEFORE_TRAVELLING_MODE) + { + this.forwardThruster.ThrustOverridePercentage = 0; + this.aiMove.Enabled = true; + this.aiCombat.Enabled = true; + + foreach (var warhead in this.warheads) + warhead.IsArmed = true; + + this.output.Print($"Travelling mode"); + this.currentState = State.TRAVELLING; + } + break; + + case State.TRAVELLING: + var detectedEntity = this.sensor.LastDetectedEntity; + + if (this.MsSinceLaunch > AUTO_DESTRUCTION_AFTER - 3000) + this.light.BlinkIntervalSeconds = 0.5f; + + if (this.gasTank.FilledRatio <= EPSILON || detectedEntity.Type != MyDetectedEntityType.None || this.MsSinceLaunch > AUTO_DESTRUCTION_AFTER) + { + Detonate(); + } + break; + + case State.NORMAL: + break; // Nothing; + } + } + + void Detonate() + { + foreach (var warhead in this.warheads) + warhead.Detonate(); + } + + public void Save() + { + } + + double MsSinceLaunch + { + get { return (double)this.tickFromStart / 60 * 1000; } + } + + public void Main(string argument, UpdateType updateSource) + { + if ((updateSource & UpdateType.Update10) != 0) + { + this.tickFromStart += 10; + this.UpdateState10(); + } + else if ((updateSource & (UpdateType.Script | UpdateType.Terminal | UpdateType.Trigger)) != 0) + { + switch (argument) + { + case "START": + this.output.Print("Launching mode"); + this.tickFromStart = 0; + this.currentState = State.LAUNCHING; + break; + + default: + this.output.Print($"Uknown command: {argument}"); + break; + } + } + } + } +} diff --git a/MissileController/thumb.png b/MissileController/thumb.png new file mode 100644 index 0000000..5f05800 Binary files /dev/null and b/MissileController/thumb.png differ diff --git a/MissileLauncher/MDK/Bootstrapper.cs b/MissileLauncher/MDK/Bootstrapper.cs new file mode 100644 index 0000000..dd86886 --- /dev/null +++ b/MissileLauncher/MDK/Bootstrapper.cs @@ -0,0 +1,27 @@ +using Malware.MDKUtilities; + +namespace IngameScript.MDK +{ + public class TestBootstrapper + { + // All the files in this folder, as well as all files containing the file ".debug.", will be excluded + // from the build process. You can use this to create utilites for testing your scripts directly in + // Visual Studio. + + static TestBootstrapper() + { + // Initialize the MDK utility framework + MDKUtilityFramework.Load(); + } + + public static void Main() + { + // In order for your program to actually run, you will need to provide a mockup of all the facilities + // your script uses from the game, since they're not available outside of the game. + + // Create and configure the desired program. + var program = MDKFactory.CreateProgram(); + MDKFactory.Run(program); + } + } +} \ No newline at end of file diff --git a/MissileLauncher/MDK/MDK.options.props b/MissileLauncher/MDK/MDK.options.props new file mode 100644 index 0000000..0a291ca --- /dev/null +++ b/MissileLauncher/MDK/MDK.options.props @@ -0,0 +1,18 @@ + + + + + 1.5.17 + + no + + + None + + + mdk + + + \ No newline at end of file diff --git a/MissileLauncher/MDK/MDK.paths.props b/MissileLauncher/MDK/MDK.paths.props new file mode 100644 index 0000000..6cd170a --- /dev/null +++ b/MissileLauncher/MDK/MDK.paths.props @@ -0,0 +1,81 @@ + + + + + 1.4.14 + no + G:\SteamLibrary\SteamApps\common\SpaceEngineers\Bin64 + c:\users\lyssmetal\appdata\local\microsoft\visualstudio\17.0_6c02a30d\extensions\twejjmj5.r1e + C:\Users\LyssMetal\AppData\Roaming\SpaceEngineers\IngameScripts\local + + + + $(MDKGameBinPath)\Sandbox.Common.dll + false + + + $(MDKGameBinPath)\Sandbox.Game.dll + false + + + $(MDKGameBinPath)\Sandbox.Graphics.dll + false + + + $(MDKGameBinPath)\SpaceEngineers.Game.dll + false + + + $(MDKGameBinPath)\SpaceEngineers.ObjectBuilders.dll + false + + + $(MDKGameBinPath)\VRage.dll + false + + + $(MDKGameBinPath)\VRage.Audio.dll + false + + + $(MDKGameBinPath)\VRage.Game.dll + false + + + $(MDKGameBinPath)\VRage.Input.dll + false + + + $(MDKGameBinPath)\VRage.Library.dll + false + + + $(MDKGameBinPath)\VRage.Math.dll + false + + + $(MDKGameBinPath)\VRage.Render.dll + false + + + $(MDKGameBinPath)\VRage.Render11.dll + false + + + $(MDKGameBinPath)\VRage.Scripting.dll + false + + + $(MDKInstallPath)\MDKUtilities.dll + true + + + $(MDKGameBinPath)\System.Collections.Immutable.dll + false + + + + \ No newline at end of file diff --git a/MissileLauncher/MissileLauncher.csproj b/MissileLauncher/MissileLauncher.csproj new file mode 100644 index 0000000..1e05b49 --- /dev/null +++ b/MissileLauncher/MissileLauncher.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {761F968E-CE71-404B-A20A-7C1458D6C014} + Exe + IngameScript + MissileLauncher + v4.8 + 512 + true + + + + true + bin\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + 6 + + + + + + + + + + + + + + + + + + Always + + + Always + + + + + + + + + + + + + \ No newline at end of file diff --git a/MissileLauncher/Program.cs b/MissileLauncher/Program.cs new file mode 100644 index 0000000..130d36d --- /dev/null +++ b/MissileLauncher/Program.cs @@ -0,0 +1,193 @@ +using Sandbox.Game.Entities.Cube; +using Sandbox.Game.EntityComponents; +using Sandbox.Game.GameSystems; +using Sandbox.ModAPI.Ingame; +using Sandbox.ModAPI.Interfaces; + +using SpaceEngineers.Game.ModAPI.Ingame; + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Text; + +using VRage; +using VRage.Collections; +using VRage.Game; +using VRage.Game.Components; +using VRage.Game.GUI.TextPanel; +using VRage.Game.ModAPI.Ingame; +using VRage.Game.ModAPI.Ingame.Utilities; +using VRage.Game.ObjectBuilders.Definitions; + +using VRageMath; + +using static VRageRender.Utils.MyWingedEdgeMesh; + +namespace IngameScript +{ + enum State + { + NORMAL, + STARTING_SEQUENCE, + FILLING_TANK, + LAUNCHING, + } + + class Missile + { + string prefix; + readonly string tankName = "Hydrogen Tank"; + readonly string connectorName = "Connector"; + readonly string mergeBlockName = "Merge Block"; + readonly string programmableBlockName = "Programmable Block"; + + State currentState = State.NORMAL; + + IMyGridTerminalSystem gridTerminalSystem; + + IMyGasTank tank = null; + IMyShipConnector connector = null; + IMyShipMergeBlock mergeBlock = null; + IMyProgrammableBlock programmableBlock = null; + + // bool loop = false; // Not used for the moment. + public Missile(string prefix, IMyGridTerminalSystem gridTerminalSystem) + { + this.prefix = prefix; + this.gridTerminalSystem = gridTerminalSystem; + } + } + + partial class Program : MyGridProgram + { + const string GRID_PREFIX = "[PML]"; + const string MISSILE_GRID_PREFIX = "[PM]"; + const double HYDRO_TANK_FILLED_PERCENT = 20; + + const float EPSILON = 0.05f; + + readonly Output output; + + public Program() + { + var output = this.Me.GetSurface(0); + this.output = new Output(output); + this.output.Print("Missile launcher system starting..."); + + this.Runtime.UpdateFrequency = UpdateFrequency.Update100; + + this.output.Print("Missile launcher system started"); + } + + void UpdateState() + { + switch (this.currentState) + { + case State.STARTING_SEQUENCE: + this.tank = this.GridTerminalSystem.GetBlockWithName("[PM] Hydrogen Tank") as IMyGasTank; + if (this.tank == null) + { + this.output.Print("Cannot find the missile hydrogen tank"); + break; + } + + this.connector = this.GridTerminalSystem.GetBlockWithName("[PM] Connector") as IMyShipConnector; + if (this.connector == null) + { + this.output.Print("Cannot find the missile connector"); + break; + } + + this.mergeBlock = this.GridTerminalSystem.GetBlockWithName("[PM] Merge Block") as IMyShipMergeBlock; + if (this.mergeBlock == null) + { + this.output.Print("Cannot find the missile merge block"); + break; + } + + this.programmableBlock = this.GridTerminalSystem.GetBlockWithName("[PM] Programmable Block") as IMyProgrammableBlock; + if (this.programmableBlock == null) + { + this.output.Print("Cannot find the missile programmable block"); + break; + } + + this.tank.Stockpile = true; + this.connector.Connect(); + + this.currentState = State.FILLING_TANK; + break; ; + + case State.FILLING_TANK: + this.output.Print("Waiting missile tank filled..."); + if (this.tank.FilledRatio >= HYDRO_TANK_FILLED_PERCENT / 100) + { + this.tank.Stockpile = false; + this.currentState = State.LAUNCHING; + } + break; + + case State.LAUNCHING: + this.output.Print("Launching missile..."); + + if (this.programmableBlock.TryRun("START")) + this.output.Print("Missile launched!"); + else + this.output.Print("ERROR: Can't send START command to missile"); + + this.mergeBlock.Enabled = false; + this.connector.Disconnect(); + + if (this.loop) + this.currentState = State.STARTING_SEQUENCE; + else + this.currentState = State.NORMAL; + + break; + + case State.NORMAL: + break; // Nothing; + } + + } + + public void Save() + { + } + + public void Main(string argument, UpdateType updateSource) + { + if ((updateSource & UpdateType.Update100) != 0) + { + this.UpdateState(); + } + else if ((updateSource & (UpdateType.Terminal | UpdateType.Trigger)) != 0) + { + switch (argument) + { + case "LAUNCH ONE": + this.loop = false; + this.currentState = State.STARTING_SEQUENCE; + break; + + case "LAUNCH SOME": + this.loop = true; + this.currentState = State.STARTING_SEQUENCE; + break; + + case "STOP": + this.loop = false; + this.currentState = State.NORMAL; + break; + + default: + this.output.Print($"Uknown command: {argument}"); + break; + } + } + } + } +} diff --git a/MissileLauncher/thumb.png b/MissileLauncher/thumb.png new file mode 100644 index 0000000..5f05800 Binary files /dev/null and b/MissileLauncher/thumb.png differ diff --git a/SEScripts.sln b/SEScripts.sln index a4defba..f75f310 100644 --- a/SEScripts.sln +++ b/SEScripts.sln @@ -11,6 +11,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoPilot", "AutoPilot\Auto EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiningRover", "MiningRover\MiningRover.csproj", "{DBCD62FE-F7AA-4A03-9241-0A4BE6952664}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A3A0A2EE-BB1F-426A-80EA-3B19273EDCCD}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + TODO.md = TODO.md + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MissileController", "MissileController\MissileController.csproj", "{F902E413-8F1A-423D-98A5-F26B684E28BA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MissileLauncher", "MissileLauncher\MissileLauncher.csproj", "{761F968E-CE71-404B-A20A-7C1458D6C014}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -22,6 +32,10 @@ Global {141E1804-F644-48F8-A3D8-BEFEEE66ECBA}.Debug|x64.Build.0 = Debug|x64 {DBCD62FE-F7AA-4A03-9241-0A4BE6952664}.Debug|x64.ActiveCfg = Debug|x64 {DBCD62FE-F7AA-4A03-9241-0A4BE6952664}.Debug|x64.Build.0 = Debug|x64 + {F902E413-8F1A-423D-98A5-F26B684E28BA}.Debug|x64.ActiveCfg = Debug|x64 + {F902E413-8F1A-423D-98A5-F26B684E28BA}.Debug|x64.Build.0 = Debug|x64 + {761F968E-CE71-404B-A20A-7C1458D6C014}.Debug|x64.ActiveCfg = Debug|x64 + {761F968E-CE71-404B-A20A-7C1458D6C014}.Debug|x64.Build.0 = Debug|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -32,6 +46,8 @@ Global GlobalSection(SharedMSBuildProjectFiles) = preSolution SECommon\SECommon.projitems*{141e1804-f644-48f8-a3d8-befeee66ecba}*SharedItemsImports = 4 SECommon\SECommon.projitems*{22a83955-fe9b-4eba-8980-d9de01353c4c}*SharedItemsImports = 4 + SECommon\SECommon.projitems*{761f968e-ce71-404b-a20a-7c1458d6c014}*SharedItemsImports = 4 SECommon\SECommon.projitems*{9e97399c-4fe6-495b-aa87-acc2213647cd}*SharedItemsImports = 13 + SECommon\SECommon.projitems*{f902e413-8f1a-423d-98a5-f26b684e28ba}*SharedItemsImports = 4 EndGlobalSection EndGlobal diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..9d74dee --- /dev/null +++ b/TODO.md @@ -0,0 +1,3 @@ +* Make procedure to deploy tank + button +* Make procedure to pack tank + button +* Security system for Loir: Can't \ No newline at end of file