- Add an extension method to get all inventories.
- Update README and TODO
This commit is contained in:
parent
16040e5f5a
commit
169719ba4b
5 changed files with 135 additions and 28 deletions
|
|
@ -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
|
||||
|
||||
*
|
||||
* [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°
|
||||
|
|
@ -26,8 +26,8 @@ namespace IngameScript
|
|||
{
|
||||
class Output
|
||||
{
|
||||
IList<IMyTextSurface> outputs;
|
||||
int maxNbLines;
|
||||
readonly IList<IMyTextSurface> outputs;
|
||||
readonly int maxNbLines;
|
||||
|
||||
public Output(IList<IMyTextSurface> surfaces, int maxNbLines = 10)
|
||||
{
|
||||
|
|
@ -58,47 +58,68 @@ namespace IngameScript
|
|||
: this(new List<IMyTextSurface> { 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);
|
||||
}
|
||||
}
|
||||
|
||||
public void PrintError(string text, int outputNumber = 0)
|
||||
{
|
||||
this.Print($"Error: {text}", outputNumber);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
|||
/// <param name="name"></param>
|
||||
/// <param name="grid"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> GetBlocks<T>(this IMyGridTerminalSystem gridTerminal, string name = null, IMyCubeGrid grid = null)
|
||||
public static IEnumerable<T> GetBlocks<T>(this IMyGridTerminalSystem gridTerminal, string name = null, IMyCubeGrid grid = null, Func<T, bool> filter = null)
|
||||
where T : class, IMyTerminalBlock
|
||||
{
|
||||
var l = new List<T>();
|
||||
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<T>();
|
||||
}
|
||||
|
||||
public static IEnumerable<IMyInventory> GetAllInventories(this IMyGridTerminalSystem gridTerminal, IMyCubeGrid grid = null)
|
||||
{
|
||||
var inventories = new List<IMyInventory>();
|
||||
|
||||
// Containers.
|
||||
foreach (var container in gridTerminal.GetBlocks<IMyCargoContainer>(grid: grid))
|
||||
inventories.Add(container.GetInventory());
|
||||
|
||||
// Assemblers.
|
||||
foreach (var assembler in gridTerminal.GetBlocks<IMyAssembler>(grid: grid))
|
||||
{
|
||||
inventories.Add(assembler.InputInventory);
|
||||
inventories.Add(assembler.OutputInventory);
|
||||
}
|
||||
|
||||
// Refineries
|
||||
foreach (var refinery in gridTerminal.GetBlocks<IMyRefinery>(grid: grid))
|
||||
{
|
||||
inventories.Add(refinery.InputInventory);
|
||||
inventories.Add(refinery.OutputInventory);
|
||||
}
|
||||
|
||||
// Connectors.
|
||||
foreach (var connector in gridTerminal.GetBlocks<IMyShipConnector>(grid: grid))
|
||||
inventories.Add(connector.GetInventory());
|
||||
|
||||
// Welders.
|
||||
foreach (var welder in gridTerminal.GetBlocks<IMyShipWelder>(grid: grid))
|
||||
inventories.Add(welder.GetInventory());
|
||||
|
||||
// Turrets.
|
||||
foreach (var turret in gridTerminal.GetBlocks<IMyLargeTurretBase>(grid: grid))
|
||||
inventories.Add(turret.GetInventory());
|
||||
|
||||
// Artillery and missile launcher.
|
||||
foreach (var missileLauncher in gridTerminal.GetBlocks<IMySmallMissileLauncher>(grid: grid))
|
||||
inventories.Add(missileLauncher.GetInventory());
|
||||
|
||||
return inventories;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
32
TODO.md
32
TODO.md
|
|
@ -1,15 +1,39 @@
|
|||
# Active
|
||||
|
||||
## SSPifou
|
||||
|
||||
* Missile autodestruction (after 1min or when tank empty)
|
||||
* Finish missile launchers
|
||||
* Remote control for the Bee
|
||||
* Add external lights + commands
|
||||
* Command to stop thrusters
|
||||
* 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
|
||||
|
||||
* 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?
|
||||
Loading…
Add table
Add a link
Reference in a new issue