コード例 #1
0
ファイル: ShipAutopilot.cs プロジェクト: Souper07/Autopilot
        /// <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);
        }
コード例 #2
0
ファイル: GridFinder.cs プロジェクト: zrisher/ARMS
        /// <summary>
        /// Creates a GridFinder to find an enemy grid based on distance.
        /// </summary>
        public GridFinder(AllNavigationSettings navSet, ShipControllerBlock controller, float maxRange = 0f)
        {
            Log.DebugLog("navSet == null", Logger.severity.FATAL, condition: navSet == null);
            Log.DebugLog("controller == null", Logger.severity.FATAL, condition: controller == null);
            Log.DebugLog("controller.CubeBlock == null", Logger.severity.FATAL, condition: controller.CubeBlock == null);

            this.m_controlBlock = controller;
            //this.m_enemies = new List<LastSeen>();

            this.MaximumRange    = maxRange;
            this.m_navSet        = navSet;
            this.m_mustBeRecent  = true;
            this.m_startPosition = m_controlBlock.CubeBlock.GetPosition();
        }
コード例 #3
0
ファイル: GridFinder.cs プロジェクト: Souper07/Autopilot
        /// <summary>
        /// Creates a GridFinder to find an enemy grid based on distance.
        /// </summary>
        public GridFinder(AllNavigationSettings navSet, ShipControllerBlock controller, float maxRange = 0f)
        {
            this.m_logger = new Logger(GetType().Name, controller.CubeBlock);

            m_logger.debugLog(navSet == null, "navSet == null", Logger.severity.FATAL);
            m_logger.debugLog(controller == null, "controller == null", Logger.severity.FATAL);
            m_logger.debugLog(controller.CubeBlock == null, "controller.CubeBlock == null", Logger.severity.FATAL);

            this.m_controlBlock = controller;
            //this.m_enemies = new List<LastSeen>();

            this.MaximumRange = maxRange;
            this.m_navSet = navSet;
            this.m_mustBeRecent = true;
        }
コード例 #4
0
ファイル: GridFinder.cs プロジェクト: helppass/Autopilot
		/// <summary>
		/// Creates a GridFinder to find an enemy grid based on distance.
		/// </summary>
		public GridFinder(AllNavigationSettings navSet, ShipControllerBlock controller, float maxRange = 0f)
		{
			this.m_logger = new Logger(GetType().Name + " enemy", controller.CubeBlock);

			m_logger.debugLog(navSet == null, "navSet == null", "GridFinder()", Logger.severity.FATAL);
			m_logger.debugLog(controller == null, "controller == null", "GridFinder()", Logger.severity.FATAL);
			m_logger.debugLog(controller.CubeBlock == null, "controller.CubeBlock == null", "GridFinder()", Logger.severity.FATAL);

			this.m_controlBlock = controller;
			this.m_enemies = new List<LastSeen>();

			if (!Registrar.TryGetValue(controller.CubeBlock.EntityId, out this.m_controller))
				throw new NullReferenceException("ShipControllerBlock is not a ShipController");

			this.MaximumRange = maxRange;
			this.m_navSet = navSet;
			this.m_mustBeRecent = true;
		}
コード例 #5
0
ファイル: GridFinder.cs プロジェクト: Souper07/Autopilot
        /// <summary>
        /// Creates a GridFinder to find a friendly grid based on its name.
        /// </summary>
        public GridFinder(AllNavigationSettings navSet, ShipControllerBlock controller, string targetGrid, string targetBlock = null,
			AttachedGrid.AttachmentKind allowedAttachment = AttachedGrid.AttachmentKind.Permanent, bool mustBeRecent = false)
        {
            this.m_logger = new Logger(GetType().Name, controller.CubeBlock);

            m_logger.debugLog(navSet == null, "navSet == null", Logger.severity.FATAL);
            m_logger.debugLog(controller == null, "controller == null", Logger.severity.FATAL);
            m_logger.debugLog(controller.CubeBlock == null, "controller.CubeBlock == null", Logger.severity.FATAL);
            m_logger.debugLog(targetGrid == null, "targetGrid == null", Logger.severity.FATAL);

            this.m_targetGridName = targetGrid.LowerRemoveWhitespace();
            if (targetBlock != null)
                this.m_targetBlockName = targetBlock.LowerRemoveWhitespace();
            this.m_controlBlock = controller;
            this.m_allowedAttachment = allowedAttachment;
            this.MaximumRange = float.MaxValue;
            this.m_navSet = navSet;
            this.m_mustBeRecent = mustBeRecent;
        }
コード例 #6
0
ファイル: GridFinder.cs プロジェクト: zrisher/ARMS
        /// <summary>
        /// Creates a GridFinder to find a friendly grid based on its name.
        /// </summary>
        public GridFinder(AllNavigationSettings navSet, ShipControllerBlock controller, string targetGrid, string targetBlock = null,
                          AttachedGrid.AttachmentKind allowedAttachment = AttachedGrid.AttachmentKind.Permanent, bool mustBeRecent = false)
        {
            Log.DebugLog("navSet == null", Logger.severity.FATAL, condition: navSet == null);
            Log.DebugLog("controller == null", Logger.severity.FATAL, condition: controller == null);
            Log.DebugLog("controller.CubeBlock == null", Logger.severity.FATAL, condition: controller.CubeBlock == null);
            Log.DebugLog("targetGrid == null", Logger.severity.FATAL, condition: targetGrid == null);

            this.m_targetGridName = targetGrid.LowerRemoveWhitespace();
            if (targetBlock != null)
            {
                this.m_targetBlockName = targetBlock.LowerRemoveWhitespace();
            }
            this.m_controlBlock      = controller;
            this.m_allowedAttachment = allowedAttachment;
            this.MaximumRange        = 0f;
            this.m_navSet            = navSet;
            this.m_mustBeRecent      = mustBeRecent;
            this.m_startPosition     = m_controlBlock.CubeBlock.GetPosition();
        }
コード例 #7
0
ファイル: GridFinder.cs プロジェクト: helppass/Autopilot
		/// <summary>
		/// Creates a GridFinder to find a friendly grid based on its name.
		/// </summary>
		public GridFinder(AllNavigationSettings navSet, ShipControllerBlock controller, string targetGrid, string targetBlock = null,
			AttachedGrid.AttachmentKind allowedAttachment = AttachedGrid.AttachmentKind.Permanent)
		{
			this.m_logger = new Logger(GetType().Name + " friendly", controller.CubeBlock);

			m_logger.debugLog(navSet == null, "navSet == null", "GridFinder()", Logger.severity.FATAL);
			m_logger.debugLog(controller == null, "controller == null", "GridFinder()", Logger.severity.FATAL);
			m_logger.debugLog(controller.CubeBlock == null, "controller.CubeBlock == null", "GridFinder()", Logger.severity.FATAL);
			m_logger.debugLog(targetGrid == null, "targetGrid == null", "GridFinder()", Logger.severity.FATAL);

			if (!Registrar.TryGetValue(controller.CubeBlock.EntityId, out this.m_controller))
				throw new NullReferenceException("ShipControllerBlock is not a ShipController");
			this.m_targetGridName = targetGrid.LowerRemoveWhitespace();
			if (targetBlock != null)
				this.m_targetBlockName = targetBlock.LowerRemoveWhitespace();
			this.m_controlBlock = controller;
			this.m_allowedAttachment = allowedAttachment;
			this.MaximumRange = float.MaxValue;
			this.m_navSet = navSet;
		}
コード例 #8
0
ファイル: ShipAutopilot.cs プロジェクト: zrisher/ARMS
        /// <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, HandleMessage);
            this.m_pathfinder = new Pathfinder(m_block);
            this.m_commands   = AutopilotCommands.GetOrCreate(m_block.Terminal);
            this.m_block.CubeBlock.OnClosing += CubeBlock_OnClosing;

            int start = block.DisplayNameText.IndexOf('[') + 1, end = block.DisplayNameText.IndexOf(']');

            if (start > 0 && end > start)
            {
                m_block.AutopilotTerminal.AutopilotCommandsText = 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.CustomName = (nameBefore + nameAfter).Trim();
            }

            Log.DebugLog("Created autopilot for: " + block.DisplayNameText);
            Registrar.Add(block, this);
        }
コード例 #9
0
		/// <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()");
		}