void Setup() { _setupReturnCode = ReturnCode.None; _controller = null; _azimuthRotor = null; _elevationRotor = null; _camera = null; _extraRotors.Clear(); _tools.Clear(); _gridToToolDict.Clear(); _restAngles.Clear(); _group.GetBlocks(null, CollectBlocks); if (_controller == null) { _setupReturnCode |= ReturnCode.MissingController; } if (_azimuthRotor == null) { _setupReturnCode |= ReturnCode.MissingAzimuth; } if (_elevationRotor == null) { _setupReturnCode |= ReturnCode.MissingElevation; } if (_extraRotors.Count == 0) { _setupReturnCode |= ReturnCode.NoExtraRotors; } if (_camera == null) { _setupReturnCode |= ReturnCode.MissingCamera; } if (_tools.Count == 0) { _setupReturnCode |= ReturnCode.MissingTools; } }
bool CollectBlocks(IMyTerminalBlock b) { if (!b.IsSameConstructAs(_p.Me)) { return(false); } var rotor = b as IMyMotorStator; if (rotor != null) { ParseRotorIni(rotor); if (StringExtensions.Contains(b.CustomName, _p.AzimuthName)) { if (_azimuthRotor != null) { _extraRotors.Add(rotor); } else { _azimuthRotor = rotor; } } else if (StringExtensions.Contains(b.CustomName, _p.ElevationName)) { if (_elevationRotor != null) { _extraRotors.Add(rotor); } else { _elevationRotor = rotor; } } else { _extraRotors.Add(rotor); } } var cam = b as IMyCameraBlock; if (cam != null) { if (_camera != null) { _tools.Add(cam); } else { _camera = cam; } _gridToToolDict[cam.CubeGrid] = cam; } var tcb = b as IMyTurretControlBlock; if (tcb != null) { if (_controller != null) { _setupReturnCode |= ReturnCode.MultipleTurretControllers; } else { _controller = tcb; } } var func = b as IMyFunctionalBlock; if (func != null) { if (!(func is IMyLargeTurretBase) && (func is IMyUserControllableGun || func is IMyLightingBlock || func is IMyShipToolBase || func is IMyShipConnector)) { _tools.Add(func); _gridToToolDict[func.CubeGrid] = func; } } return(false); }