Only look for relevant blocks on the same real grid.

This commit is contained in:
Anna Rose 2025-02-19 22:02:43 -05:00
parent a6ff06ac08
commit 79f467e60c
4 changed files with 22 additions and 35 deletions

View File

@ -20,7 +20,7 @@ namespace IngameScript
// initialize all the sequencers
List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocksOfType(blocks, block => MyIni.HasSection(block.CustomData, "sequencer"));
GridTerminalSystem.GetBlocksOfType(blocks, blockFilter);
foreach (IMyTerminalBlock block in blocks)
{
@ -173,5 +173,10 @@ namespace IngameScript
Console.Print($"Can't add unsupported block '{block.CustomName}'");
return null;
}
public bool blockFilter(IMyTerminalBlock block)
{
return block.IsSameConstructAs(this.Me) && MyIni.HasSection(block.CustomData, "sequencer");
}
}
}

View File

@ -32,7 +32,7 @@ namespace IngameScript
// Find all tagged objects and build out zones
List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocksOfType(blocks, block => MyIni.HasSection(block.CustomData, "airMonitor"));
GridTerminalSystem.GetBlocksOfType(blocks, blockFilter);
foreach (IMyTerminalBlock block in blocks)
{
Ini.TryParse(block.CustomData);
@ -149,36 +149,9 @@ namespace IngameScript
}
}
// write diagnostics to any configured display screens
// private void updateDisplays()
// {
// if (_displays.Count == 0) return;
// _displayBuffer.Clear();
// _displayBuffer.Append("AIR PRESSURE REPORT\n\n");
// foreach (AirZone zone in _zones.Values)
// {
// _displayBuffer.Append(zone.Name);
// _displayBuffer.Append(": ");
// _displayBuffer.Append(zone.Triggered ? "ALARM TRIPPED " : "nominal ");
// foreach (IMyAirVent vent in zone.Vents)
// {
// _displayBuffer.Append((int)(vent.GetOxygenLevel() * 100F));
// _displayBuffer.Append("% ");
// }
// _displayBuffer.Append("\n");
// }
// _displayBuffer.Append("\n");
// _displayBuffer.Append("OXYGEN TANK LEVELS\n");
// foreach (IMyGasTank tank in _oxygenTanks)
// {
// _displayBuffer.Append((int)(tank.FilledRatio * 100));
// _displayBuffer.Append("% ");
// }
// foreach (IMyTextSurface display in _displays) display.WriteText(_displayBuffer.ToString());
// }
private bool blockFilter(IMyTerminalBlock block)
{
return block.IsSameConstructAs(this.Me) && MyIni.HasSection(block.CustomData, "airMonitor");
}
}
}

View File

@ -19,7 +19,7 @@ namespace IngameScript
Console = new MainConsole(this, "Airlock Controller");
List<IMyTerminalBlock> airlockBlocks = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocksOfType(airlockBlocks, block => MyIni.HasSection(block.CustomData, "airlock"));
GridTerminalSystem.GetBlocksOfType(airlockBlocks, blockFilter);
IMyAirVent referenceVent = null;
foreach (IMyTerminalBlock block in airlockBlocks)
{
@ -87,5 +87,10 @@ namespace IngameScript
if (_jobs.Count == 0) Runtime.UpdateFrequency = UpdateFrequency.None;
}
private bool blockFilter(IMyTerminalBlock block)
{
return block.IsSameConstructAs(this.Me) && MyIni.HasSection(block.CustomData, "airlock");
}
}
}

View File

@ -22,7 +22,6 @@ namespace IngameScript
// We store a list of the dockingPorts because we will only dock if one is ready to lock.
GridTerminalSystem.GetBlocksOfType(_dockingPorts, blockFilter);
foreach (IMyShipConnector dockingPort in _dockingPorts)
{
_actionGroup.AddActionBlock("dock", 0, new BlockActionConnector(dockingPort, ConnectorAction.Connect));
@ -45,6 +44,10 @@ namespace IngameScript
_actionGroup.AddActionBlock("undock", 0, new BlockActionGasTank(gasTank, GasTankAction.Dispense));
}
Console.Print($"Found {_dockingPorts.Count} docking ports.");
Console.Print($"Found {thrusters.Count} thrusters.");
Console.Print($"Found {gasTanks.Count} gas tanks.");
Console.UpdateTickCount();
}
@ -89,6 +92,7 @@ namespace IngameScript
private bool blockFilter(IMyTerminalBlock block)
{
if (!block.IsSameConstructAs(this.Me)) return false;
if (MyIni.HasSection(block.CustomData, "docking"))
{
Ini.TryParse(block.CustomData);