void HandleMessageInit() { if (!_initialized) { while (_turtleListenerInit.HasPendingMessage) { var vectorString = _turtleListenerInit.AcceptMessage(); string[] split = vectorString.Data.ToString().Split(';'); var name = split[0]; var data = split[1]; switch (name) { case "A": Vector3D.TryParse(data, out _basis[0]); _basis[1] = -_basis[0]; break; case "B": Vector3D.TryParse(data, out _basis[2]); _basis[3] = -_basis[2]; break; case "Up": Vector3D.TryParse(data, out _basis[4]); _basis[5] = -_basis[4]; break; case "Origin": Vector3D.TryParse(data, out _origin); break; default: _messageBuilder.AppendLine("_turtleListenerInit: Unknown"); break; } } if (VectorsValid()) { _initialized = true; _messageBuilder.AppendLine("Successfully oriented.\nInitialized."); _turtleListenerInit.DisableMessageCallback(); } else { _initialized = false; _messageBuilder.AppendLine("Could not orient.\nFailed to initialize."); } } }
private void UpdateSettings() { var parser = new MyIni(); if (!parser.TryParse(Me.CustomData)) { throw new InvalidOperationException("Couldn't parse CustomData as INI!"); } this.tag = parser.Get(SETTINGS_SECTION, "tag").ToString(MissileCommons.DEFAULT_TAG); this.statusTag = parser.Get(SETTINGS_SECTION, "statusTag").ToString(MissileCommons.STATUS_TAG); this.directing = parser.Get(SETTINGS_SECTION, "directing").ToBoolean(true); if (this.directing) { this.directorTurret = GridTerminalSystem.GetBlockOfType <IMyLargeTurretBase>(t => MyIni.HasSection(t.CustomData, DIRECTOR_TURRET_SECTION)); if (this.directorTurret != null) { LogLine($"Director mode on, found director turret {directorTurret.CustomName}"); } else { LogLine($"No director turret was found. If you have one, add the [{DIRECTOR_TURRET_SECTION}] line to its Custom Data. Disabling director mode."); this.directing = false; } } if (missileMsgListener != null) { missileMsgListener.DisableMessageCallback(); } missileMsgListener = IGC.RegisterBroadcastListener(this.tag); missileMsgListener.SetMessageCallback(); if (missileStatusListener != null) { missileStatusListener.DisableMessageCallback(); } missileStatusListener = IGC.RegisterBroadcastListener(MissileCommons.STATUS_TAG); missileStatusListener.SetMessageCallback(); }