Created
January 4, 2015 23:57
-
-
Save awstanley/33a4982e07110fbf866c to your computer and use it in GitHub Desktop.
This is some old/test docking code which never got tested. There are potential limitations here, but the aim behind the system was to set flight mode on/off, so that the system could then trigger a "dock" command prior to connecting. The undock sequence would happen AFTER it had been released (connector goes off). Newer code is here: https://gis…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OnOff code seems to be global... | |
ITerminalAction GetOnOffAction(IMyTerminalBlock block, bool enable) | |
{ | |
ITerminalAction Action; | |
if (enable) | |
{ | |
Action = block.GetActionWithName("Toggle block On"); | |
} | |
else | |
{ | |
Action = block.GetActionWithName("Toggle block Off"); | |
} | |
return Action; | |
} | |
// Set all by type | |
void SetBlockStateByType<T>(bool enable) | |
{ | |
var blocks = new List<IMyTerminalBlock>(); | |
GridTerminalSystem.GetBlocksOfType<T>(blocks); | |
if(blocks.Count > 0) | |
{ | |
ITerminalAction Action = GetOnOffAction(blocks[0], enable); | |
foreach(IMyTerminalBlock target in blocks) | |
{ | |
Action.Apply(target); | |
} | |
} | |
} | |
void SetFlightMode(bool enable) | |
{ | |
SetBlockStateByType<IMyThrust>(enable); | |
SetBlockStateByType<IMyGyro>(enable); | |
// anything else you need on/off ... | |
} | |
// To dock: | |
// SetFlightMode(false); | |
// Our undock: | |
// SetFlightMode(true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment