diff --git a/README.md b/README.md index 87366ae..6e95f5b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ # Modules AutoPilot: Automatic control of piloting on planet. -SSPifou: The main control for the spaceship SSPifou. +SSPifou: The main control for the spaceship SSPifou. (TODO) MissileController: Run in the missile computer to pilot it to its target. MissileLauncher: Can launch multiple missiles. @@ -14,4 +14,9 @@ MissileLauncher: Can launch multiple missiles. ## Elements -* \ No newline at end of file +* [PML] Connector Launcher 01 +* [PML] Merge Block Missile 01 +* [PML] Projector 01 +* Offsets: (0, -8, 2), pitch: 0° +* [PML] Projector 02 +* Offsets: (0, -8, -2), pitch: 180° \ No newline at end of file diff --git a/SECommon/Output.cs b/SECommon/Output.cs index 5573c61..1e5ed7c 100644 --- a/SECommon/Output.cs +++ b/SECommon/Output.cs @@ -26,8 +26,8 @@ namespace IngameScript { class Output { - IList outputs; - int maxNbLines; + readonly IList outputs; + readonly int maxNbLines; public Output(IList surfaces, int maxNbLines = 10) { @@ -58,29 +58,41 @@ namespace IngameScript : this(new List { surface }, maxNbLines) { } - public void Print(string text, int outputNumber = 0) + public void Print(string text, int outputNumber = -1) { - if (this.outputs.Count() <= outputNumber) + if (outputNumber >= 0 && this.outputs.Count() <= outputNumber) { throw new Exception($"Output number {outputNumber} doesn't exist (number of output: {this.outputs.Count()}"); } else { - var output = this.outputs[outputNumber]; - var currentText = output.GetText(); - var lines = currentText.Split('\n'); - if (lines.Count() >= this.maxNbLines) + if (outputNumber == -1) { - output.WriteText(lines.Skip(lines.Count() - this.maxNbLines + 1).Append(text).Aggregate((a, b) => a + Environment.NewLine + b)); - } - else if (lines.Count() == 0) - { - output.WriteText(text); + foreach (var output in this.outputs) + this.Print(text, output); } else { - output.WriteText(Environment.NewLine + text, true); - } + this.Print(text, this.outputs[outputNumber]); + } + } + } + + void Print(string text, IMyTextSurface surface) + { + var currentText = surface.GetText(); + var lines = currentText.Split('\n'); + if (lines.Count() >= this.maxNbLines) + { + surface.WriteText(lines.Skip(lines.Count() - this.maxNbLines + 1).Append(text).Aggregate((a, b) => a + Environment.NewLine + b)); + } + else if (lines.Count() == 0) + { + surface.WriteText(text); + } + else + { + surface.WriteText(Environment.NewLine + text, true); } } @@ -90,15 +102,24 @@ namespace IngameScript } - public void Display(string text, int outputNumber = 0) + public void Display(string text, int outputNumber = -1) { - if (this.outputs.Count() <= outputNumber) + if (outputNumber >= 0 && this.outputs.Count() <= outputNumber) { throw new Exception($"Output number {outputNumber} doesn't exist (number of output: {this.outputs.Count()}"); } else { - this.outputs[outputNumber].WriteText(text); + if (outputNumber == -1) + { + foreach (var output in this.outputs) + output.WriteText(text); + } + else + { + this.outputs[outputNumber].WriteText(text); + } + } } } diff --git a/SECommon/Utils.cs b/SECommon/Utils.cs index c083571..96d8ef2 100644 --- a/SECommon/Utils.cs +++ b/SECommon/Utils.cs @@ -1,8 +1,10 @@ using Sandbox.ModAPI.Ingame; +using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Security.Cryptography; using VRage.Game.ModAPI.Ingame; @@ -33,12 +35,12 @@ namespace IngameScript /// /// /// - public static IEnumerable GetBlocks(this IMyGridTerminalSystem gridTerminal, string name = null, IMyCubeGrid grid = null) + public static IEnumerable GetBlocks(this IMyGridTerminalSystem gridTerminal, string name = null, IMyCubeGrid grid = null, Func filter = null) where T : class, IMyTerminalBlock { var l = new List(); gridTerminal.GetBlocksOfType(l, (T block) => - (name == null || block.CustomName == name) && (grid == null || block.CubeGrid == grid) + (name == null || block.CustomName == name) && (grid == null || block.CubeGrid == grid) && (filter == null || filter(block)) ); return l; } @@ -90,5 +92,46 @@ namespace IngameScript return new List(); } + + public static IEnumerable GetAllInventories(this IMyGridTerminalSystem gridTerminal, IMyCubeGrid grid = null) + { + var inventories = new List(); + + // Containers. + foreach (var container in gridTerminal.GetBlocks(grid: grid)) + inventories.Add(container.GetInventory()); + + // Assemblers. + foreach (var assembler in gridTerminal.GetBlocks(grid: grid)) + { + inventories.Add(assembler.InputInventory); + inventories.Add(assembler.OutputInventory); + } + + // Refineries + foreach (var refinery in gridTerminal.GetBlocks(grid: grid)) + { + inventories.Add(refinery.InputInventory); + inventories.Add(refinery.OutputInventory); + } + + // Connectors. + foreach (var connector in gridTerminal.GetBlocks(grid: grid)) + inventories.Add(connector.GetInventory()); + + // Welders. + foreach (var welder in gridTerminal.GetBlocks(grid: grid)) + inventories.Add(welder.GetInventory()); + + // Turrets. + foreach (var turret in gridTerminal.GetBlocks(grid: grid)) + inventories.Add(turret.GetInventory()); + + // Artillery and missile launcher. + foreach (var missileLauncher in gridTerminal.GetBlocks(grid: grid)) + inventories.Add(missileLauncher.GetInventory()); + + return inventories; + } } } \ No newline at end of file diff --git a/SEScripts.sln b/SEScripts.sln index 2951aed..be758fb 100644 --- a/SEScripts.sln +++ b/SEScripts.sln @@ -22,6 +22,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MissileLauncher", "MissileL EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BaseMiner", "BaseMiner\BaseMiner.csproj", "{1C2F7DB3-26AD-4C5E-B6C5-D6715B3CFB36}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PML", "PML\PML.csproj", "{F280FA02-7E9E-7390-1771-4B1F144AC88C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mimine", "Mimine\Mimine.csproj", "{1E123126-9FA8-67F1-5E48-3B8C400AAEDF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -48,6 +52,14 @@ Global {1C2F7DB3-26AD-4C5E-B6C5-D6715B3CFB36}.Debug|x64.Build.0 = Debug|x64 {1C2F7DB3-26AD-4C5E-B6C5-D6715B3CFB36}.Release|x64.ActiveCfg = Release|x64 {1C2F7DB3-26AD-4C5E-B6C5-D6715B3CFB36}.Release|x64.Build.0 = Release|x64 + {F280FA02-7E9E-7390-1771-4B1F144AC88C}.Debug|x64.ActiveCfg = Debug|x64 + {F280FA02-7E9E-7390-1771-4B1F144AC88C}.Debug|x64.Build.0 = Debug|x64 + {F280FA02-7E9E-7390-1771-4B1F144AC88C}.Release|x64.ActiveCfg = Release|x64 + {F280FA02-7E9E-7390-1771-4B1F144AC88C}.Release|x64.Build.0 = Release|x64 + {1E123126-9FA8-67F1-5E48-3B8C400AAEDF}.Debug|x64.ActiveCfg = Debug|x64 + {1E123126-9FA8-67F1-5E48-3B8C400AAEDF}.Debug|x64.Build.0 = Debug|x64 + {1E123126-9FA8-67F1-5E48-3B8C400AAEDF}.Release|x64.ActiveCfg = Release|x64 + {1E123126-9FA8-67F1-5E48-3B8C400AAEDF}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -58,9 +70,11 @@ Global GlobalSection(SharedMSBuildProjectFiles) = preSolution SECommon\SECommon.projitems*{141e1804-f644-48f8-a3d8-befeee66ecba}*SharedItemsImports = 5 SECommon\SECommon.projitems*{1c2f7db3-26ad-4c5e-b6c5-d6715b3cfb36}*SharedItemsImports = 5 + SECommon\SECommon.projitems*{1e123126-9fa8-67f1-5e48-3b8c400aaedf}*SharedItemsImports = 5 SECommon\SECommon.projitems*{761f968e-ce71-404b-a20a-7c1458d6c014}*SharedItemsImports = 5 SECommon\SECommon.projitems*{9e97399c-4fe6-495b-aa87-acc2213647cd}*SharedItemsImports = 13 SECommon\SECommon.projitems*{dbcd62fe-f7aa-4a03-9241-0a4be6952664}*SharedItemsImports = 5 + SECommon\SECommon.projitems*{f280fa02-7e9e-7390-1771-4b1f144ac88c}*SharedItemsImports = 5 SECommon\SECommon.projitems*{f902e413-8f1a-423d-98a5-f26b684e28ba}*SharedItemsImports = 5 EndGlobalSection EndGlobal diff --git a/TODO.md b/TODO.md index 2dd8bc9..272cb8f 100644 --- a/TODO.md +++ b/TODO.md @@ -1,15 +1,39 @@ # Active + ## SSPifou -* Missile autodestruction (after 1min or when tank empty) -* Finish missile launchers -* Add external lights + commands -* Command to stop thrusters +* Remote control for the Bee +* Add external lights + commands * Add weapons rack * Embedded computer: - * Auto landing + auto stabilization * Display of ore, ingot, ammo status * Autocraft of some element: ammo + components + * Auto landing + auto stabilization +## Missile -# Finished \ No newline at end of file +* Missile autodestruction (after 1min or when tank empty) + +### Components: + Steel plate: 252 + Construction Comp: 167 + Motor: 18 + Interior Plate: 40 + Computer: 47 + Powercell: 2 + Display: 1 + Small Steel Tube: 27 + Metal Grid: 48 + Large Steel Tube: 16 + Detector Comp: 8 + Girder: 11 + Explosives: 22 + + Volume: 3'084 L + +# Finished + +* Cockpit commands to open/close hangar doors (3 commands) +* Command to stop thrusters +* Finish missile launchers +* Why the missile stops after ~100 m? \ No newline at end of file