/// <summary> /// Creates an Autopilot for the given ship controller. /// </summary> /// <param name="block">The ship controller to use</param> public ShipAutopilot(IMyCubeBlock block) { this.m_block = new ShipControllerBlock(block); this.m_logger = new Logger(GetType().Name, block); this.m_interpreter = new Interpreter(m_block); this.m_block.CubeBlock.OnClosing += CubeBlock_OnClosing; ((MyCubeBlock)block).ResourceSink.SetRequiredInputFuncByType(new MyDefinitionId(typeof(MyObjectBuilder_GasProperties), "Electricity"), PowerRequired); if (Saver.Instance.LoadOldVersion(69)) { int start = block.DisplayNameText.IndexOf('[') + 1, end = block.DisplayNameText.IndexOf(']'); if (start > 0 && end > start) { m_block.AutopilotTerminal.AutopilotCommands = new StringBuilder(block.DisplayNameText.Substring(start, end - start).Trim()); int lengthBefore = start - 1; string nameBefore = lengthBefore > 0 ? m_block.Terminal.DisplayNameText.Substring(0, lengthBefore) : string.Empty; end++; int lengthAfter = m_block.Terminal.DisplayNameText.Length - end; string nameAfter = lengthAfter > 0 ? m_block.Terminal.DisplayNameText.Substring(end, lengthAfter) : string.Empty; m_block.Terminal.SetCustomName((nameBefore + nameAfter).Trim()); } } m_logger.debugLog("Created autopilot for: " + block.DisplayNameText); Registrar.Add(block, this); }
/// <summary> /// Creates an Autopilot for the given ship controller. /// </summary> /// <param name="block">The ship controller to use</param> public ShipController_Autopilot(IMyCubeBlock block) { this.m_block = new ShipControllerBlock(block); this.m_logger = new Logger("ShipController_Autopilot", block); this.m_interpreter = new Interpreter(m_block); this.m_block.CubeBlock.OnClosing += CubeBlock_OnClosing; // for my German friends... if (!m_block.Terminal.DisplayNameText.Contains("[") && !m_block.Terminal.DisplayNameText.Contains("]")) m_block.Terminal.SetCustomName(m_block.Terminal.DisplayNameText + " []"); m_logger.debugLog("Created autopilot for: " + block.DisplayNameText, "ShipController_Autopilot()"); }