Add an info display option for loading docks.

This commit is contained in:
Anna Rose 2025-02-23 13:43:16 -05:00
parent 3727cf8f20
commit 64a1a414a1
3 changed files with 31 additions and 2 deletions

View File

@ -1,6 +1,6 @@
using Sandbox.ModAPI.Ingame; using Sandbox.ModAPI.Ingame;
using SpaceEngineers.Game.ModAPI.Ingame;
using System.Collections.Generic; using System.Collections.Generic;
using VRage.Game.GUI.TextPanel;
using VRage.Game.ModAPI.Ingame.Utilities; using VRage.Game.ModAPI.Ingame.Utilities;
namespace IngameScript namespace IngameScript
@ -30,6 +30,7 @@ namespace IngameScript
} }
} }
private IMyTextSurface _display;
private IMyConveyorSorter _inputSorter; private IMyConveyorSorter _inputSorter;
private IMyConveyorSorter _outputSorter; private IMyConveyorSorter _outputSorter;
private List<IMyShipConnector> _ports = new List<IMyShipConnector>(); private List<IMyShipConnector> _ports = new List<IMyShipConnector>();
@ -62,9 +63,26 @@ namespace IngameScript
_wasDocked = isDocked; _wasDocked = isDocked;
} }
public void UpdateDisplay()
{
if (_display == null) return;
switch (Mode)
{
case DockMode.Loading:
_display.WriteText("Ready to load cargo");
break;
case DockMode.Unloading:
_display.WriteText("Unloading Cargo");
break;
case DockMode.Off:
_display.WriteText("Standby Mode");
break;
}
}
public void StartLoading() public void StartLoading()
{ {
_console.Print("Loading mode.");
Mode = DockMode.Loading; Mode = DockMode.Loading;
_outputSorter.Enabled = false; _outputSorter.Enabled = false;
_inputSorter.Enabled = true; _inputSorter.Enabled = true;
@ -72,6 +90,7 @@ namespace IngameScript
public void StartUnloading() public void StartUnloading()
{ {
_console.Print("Unloading mode.");
Mode = DockMode.Unloading; Mode = DockMode.Unloading;
_inputSorter.Enabled = false; _inputSorter.Enabled = false;
_outputSorter.Enabled = true; _outputSorter.Enabled = true;
@ -79,6 +98,7 @@ namespace IngameScript
public void Reset() public void Reset()
{ {
_console.Print("Disabling conveyors.");
Mode = DockMode.Off; Mode = DockMode.Off;
_inputSorter.Enabled = false; _inputSorter.Enabled = false;
_outputSorter.Enabled = false; _outputSorter.Enabled = false;
@ -108,6 +128,13 @@ namespace IngameScript
{ {
_ports.Add(block as IMyShipConnector); _ports.Add(block as IMyShipConnector);
} }
else if (block is IMyTextSurfaceProvider)
{
// for now we'll just assume the first display, since that meets our most popular use case
_display = ((IMyTextSurfaceProvider)block).GetSurface(0);
_display.ContentType = ContentType.TEXT_AND_IMAGE;
_display.WriteText("Standby Mode");
}
else else
{ {
_console.Print($"Can't add block '{block.CustomName}'"); _console.Print($"Can't add block '{block.CustomName}'");

View File

@ -32,6 +32,7 @@ namespace IngameScript
_timeoutTicks--; _timeoutTicks--;
if (_timeoutTicks == 0 || loadingCount == 0) if (_timeoutTicks == 0 || loadingCount == 0)
{ {
_console.Print("Disabling loading mode and restoring default behavior.");
_timeoutTicks = 0; _timeoutTicks = 0;
_outputSorter.Enabled = false; _outputSorter.Enabled = false;
_inputSorter.Enabled = true; _inputSorter.Enabled = true;
@ -42,6 +43,7 @@ namespace IngameScript
// A dock has requested loading // A dock has requested loading
public void StartLoading() public void StartLoading()
{ {
_console.Print("A dock has requested loading mode.");
_inputSorter.Enabled = false; _inputSorter.Enabled = false;
_outputSorter.Enabled = true; _outputSorter.Enabled = true;
_timeoutTicks = 75; // This is approximately 2 minutes. _timeoutTicks = 75; // This is approximately 2 minutes.

View File

@ -29,7 +29,7 @@ namespace IngameScript
{ {
switch (key.Name) switch (key.Name)
{ {
case "ingotReport": case "resourceReport":
if (_oreReport != null) break; if (_oreReport != null) break;
int index = Ini.Get(key).ToInt32(); int index = Ini.Get(key).ToInt32();
// extract text surface // extract text surface