예제 #1
0
 public ShipControllerBlock(IMyCubeBlock block, Action <Message> messageHandler)
 {
     CubeBlock   = block;
     Pseudo      = new PseudoBlock(block);
     NetworkNode = new RelayNode(block)
     {
         MessageHandler = messageHandler
     };
     AutopilotTerminal = new AutopilotTerminal(block);
 }
예제 #2
0
        private static string GetNameForDisplay(AutopilotTerminal autopilot, long entityId)
        {
            IMyEntity entity;

            if (!MyAPIGateway.Entities.TryGetEntityById(entityId, out entity))
            {
                Logger.DebugLog("Failed to get entity for " + entityId, Logger.severity.WARNING);
                return("Unknown Entity");
            }
            return(entity.GetNameForDisplay(autopilot.m_block.OwnerId));
        }
예제 #3
0
        private void UpdateCustomInfo()
        {
            AutopilotTerminal ApTerm = m_block.AutopilotTerminal;

            AllNavigationSettings.SettingsLevel Settings_Current = m_navSet.Settings_Current;

            ApTerm.m_autopilotStatus = m_state;
            if (m_state == State.Halted)
            {
                return;
            }

            AutopilotTerminal.AutopilotFlags flags = AutopilotTerminal.AutopilotFlags.None;
            if (m_controlledGrid != null)
            {
                flags |= AutopilotTerminal.AutopilotFlags.HasControl;
            }

            if (m_pathfinder.ReportedObstruction != null)
            {
                ApTerm.m_blockedBy = m_pathfinder.ReportedObstruction.EntityId;
                if (m_pathfinder.RotateCheck.ObstructingEntity != null)
                {
                    flags |= AutopilotTerminal.AutopilotFlags.RotationBlocked;
                }
            }
            else if (m_pathfinder.RotateCheck.ObstructingEntity != null)
            {
                flags |= AutopilotTerminal.AutopilotFlags.RotationBlocked;
                ApTerm.m_blockedBy = m_pathfinder.RotateCheck.ObstructingEntity.EntityId;
            }

            EnemyFinder ef = Settings_Current.EnemyFinder;

            if (ef != null && ef.Grid == null)
            {
                flags |= AutopilotTerminal.AutopilotFlags.EnemyFinderIssue;
                ApTerm.m_reasonCannotTarget = ef.m_reason;
                if (ef.m_bestGrid != null)
                {
                    ApTerm.m_enemyFinderBestTarget = ef.m_bestGrid.Entity.EntityId;
                }
            }
            INavigatorMover navM = Settings_Current.NavigatorMover;

            if (navM != null)
            {
                flags |= AutopilotTerminal.AutopilotFlags.HasNavigatorMover;
                ApTerm.m_prevNavMover = navM.GetType().Name;
                AutopilotTerminal.Static.prevNavMoverInfo.Update((IMyTerminalBlock)m_block.CubeBlock, navM.AppendCustomInfo);
            }
            INavigatorRotator navR = Settings_Current.NavigatorRotator;

            if (navR != null && navR != navM)
            {
                flags |= AutopilotTerminal.AutopilotFlags.HasNavigatorRotator;
                ApTerm.m_prevNavRotator = navR.GetType().Name;
                AutopilotTerminal.Static.prevNavRotatorInfo.Update((IMyTerminalBlock)m_block.CubeBlock, navR.AppendCustomInfo);
            }
            ApTerm.m_autopilotFlags  = flags;
            ApTerm.m_pathfinderState = m_pathfinder.CurrentState;
            ApTerm.SetWaitUntil(Settings_Current.WaitUntil);
            ApTerm.SetDistance(Settings_Current.Distance, Settings_Current.DistanceAngle);
            ApTerm.m_welderUnfinishedBlocks = m_navSet.WelderUnfinishedBlocks;
            ApTerm.m_complaint     = Settings_Current.Complaint;
            ApTerm.m_jumpComplaint = m_pathfinder.JumpComplaint;
        }
예제 #4
0
 public ShipControllerBlock(IMyCubeBlock block)
 {
     m_logger = new Logger(GetType().Name, block);
     CubeBlock = block;
     Pseudo = new PseudoBlock(block);
     NetworkNode = new RelayNode(block);
     AutopilotTerminal = new AutopilotTerminal(block);
 }