Esempio n. 1
0
        /// <summary>
        /// Waits for the grid to stop.
        /// </summary>
        public override void Move()
        {
            if (LinearSlowdown() || AngularSlowdown())
            {
                Log.DebugLog("linear: " + m_mover.Block.Physics.LinearVelocity + ", angular: " + m_mover.Block.Physics.AngularVelocity);
                return;
            }

            INavigatorRotator rotator = m_navSet.Settings_Current.NavigatorRotator;

            if (rotator != null && !m_navSet.DirectionMatched())
            {
                Log.DebugLog("waiting for rotator to match");
                return;
            }

            m_mover.MoveAndRotateStop();
            Log.DebugLog("stopped");
            m_navSet.OnTaskComplete_NavRot();
            if (m_exitAfter)
            {
                Log.DebugLog("setting disable", Logger.severity.DEBUG);
                m_mover.SetControl(false);
            }
        }
Esempio n. 2
0
        private bool MoveAndRotate()
        {
            INavigatorMover navM = m_navSet.Settings_Current.NavigatorMover;

            if (navM != null)
            {
                Profiler.Profile(navM.Move);

                INavigatorRotator navR = m_navSet.Settings_Current.NavigatorRotator;                 // fetched here because mover might remove it
                if (navR != null)
                {
                    Profiler.Profile(navR.Rotate);
                }
                else
                {
                    navR = m_navSet.Settings_Current.NavigatorMover as INavigatorRotator;                     // fetch again in case it was removed
                    if (navR != null)
                    {
                        Profiler.Profile(navR.Rotate);
                    }
                }

                Profiler.Profile(m_mover.MoveAndRotate);
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// run the rotator by itself until direction is matched
        /// </summary>
        private bool RotateOnly()
        {
            INavigatorRotator navR = m_navSet.Settings_Current.NavigatorRotator;

            if (navR != null)
            {
                // direction might have been matched by another rotator, so run it first

                Profiler.Profile(navR.Rotate);
                Profiler.Profile(m_mover.MoveAndRotate);

                if (m_navSet.DirectionMatched())
                {
                    m_mover.StopRotate();
                    m_mover.MoveAndRotate();
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 4
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;
        }