finishing up docking and undocking polling logic
This commit is contained in:
parent
4104681bf9
commit
3609e1526e
1 changed files with 29 additions and 2 deletions
31
Program.cs
31
Program.cs
|
@ -391,7 +391,8 @@ namespace IngameScript
|
||||||
Echo("Polling...");
|
Echo("Polling...");
|
||||||
List<IMyShipConnector> connectors = new List<IMyShipConnector>();
|
List<IMyShipConnector> connectors = new List<IMyShipConnector>();
|
||||||
|
|
||||||
// Get all connectors on the grid
|
// Get all connectors on the grid that are managed by the script
|
||||||
|
Echo($"Retrieving connectors, filtering by \"{_connectorPrefix}\"...");
|
||||||
GridTerminalSystem.GetBlocksOfType(
|
GridTerminalSystem.GetBlocksOfType(
|
||||||
connectors,
|
connectors,
|
||||||
connector =>
|
connector =>
|
||||||
|
@ -403,13 +404,39 @@ namespace IngameScript
|
||||||
{
|
{
|
||||||
foreach (IMyShipConnector connector in connectors)
|
foreach (IMyShipConnector connector in connectors)
|
||||||
{
|
{
|
||||||
if (connector.IsConnected == _isDocked)
|
if (connector.IsConnected == true)
|
||||||
{
|
{
|
||||||
|
Echo($"Connector '{connector.CustomName}' is connected. Exiting.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Echo(
|
||||||
|
$"Connector '{connector.CustomName}' is not connected. Continuing."
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Echo("No connectors are connected. Undocking...");
|
||||||
Undock();
|
Undock();
|
||||||
}
|
}
|
||||||
|
else if (_isDocked == false)
|
||||||
|
{
|
||||||
|
foreach (IMyShipConnector connector in connectors)
|
||||||
|
{
|
||||||
|
if (connector.IsConnected == true)
|
||||||
|
{
|
||||||
|
Echo($"Connector '{connector.CustomName}' is connected. Docking...");
|
||||||
|
Dock();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Echo(
|
||||||
|
$"Connector '{connector.CustomName}' is not connected. Continuing."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue