Beispiel #1
0
        ///<summary>Test if a path can be flown. From current position to AlternatePoint</summary>
        /// <returns>true iff the path is flyable</returns>
        private bool TestAltPath(Vector3 AlternatePoint, bool usefulTest = true)
        {
            myLogger.debugLog("testing alternate path: " + AlternatePoint, "TestAltPath()");
            Vector3?  alt_pointOfObstruction;
            IMyEntity Alt_ObstructingEntity = myPathChecker.TestPath(AlternatePoint, NavigationBlock, IgnoreAsteroids, out alt_pointOfObstruction, DestGrid);

            if (Alt_ObstructingEntity == null)             // found a new path
            {
                CheckInterrupt();

                if (usefulTest)
                {
                    // Is this a useful path; can we get closer to the destination by flying it?
                    float pathwiseDistanceToDest = myPathChecker.distanceCanTravel(new Line(AlternatePoint, Destination, false));
                    CheckInterrupt();

                    if (pathwiseDistanceToDest >= DistanceToDest + CNS.destinationRadius)
                    {
                        myLogger.debugLog("path is unobstructed but not useful enough. distance to dest = " + DistanceToDest + ", pathwise = " + pathwiseDistanceToDest, "TestAltPath()", Logger.severity.TRACE);
                        CheckInterrupt();
                        return(false);
                    }
                    myLogger.debugLog("path is useful. distance to dest = " + DistanceToDest + ", pathwise = " + pathwiseDistanceToDest, "TestAltPath()", Logger.severity.TRACE);
                }

                SetOutput(new PathfinderOutput(myPathChecker, PathfinderOutput.Result.Alternate_Path, null, AlternatePoint));
                myLogger.debugLog("Found a new path: " + AlternatePoint, "CheckPath()", Logger.severity.DEBUG);
                return(true);
            }
            myLogger.debugLog("Alternate path is obstructed by " + Alt_ObstructingEntity.getBestName() + " at " + alt_pointOfObstruction, "TestAltPath()", Logger.severity.TRACE);
            CheckInterrupt();
            return(false);
        }
Beispiel #2
0
        private void PathClear(ref Vector3D destination, byte runId, bool isAlternate, bool slowDown)
        {
            if (runId == m_runId)
            {
                if (isAlternate)
                {
                    LineSegment line = new LineSegment()
                    {
                        From = destination, To = m_destination
                    };
                    float distToWaypoint = (float)Vector3D.Distance(m_navBlock.WorldPosition, destination);
                    float pathValue      = m_pathChecker.distanceCanTravel(line) + distToWaypoint * WaypointDistanceBias;
                    m_logger.debugLog("for point: " + line.From + ", waypoint distance: " + (float)Vector3D.Distance(m_navBlock.WorldPosition, destination) + ", path value: " + pathValue + ", required: " + m_altPath_PathValue, Logger.severity.TRACE);

                    if (!AddAlternatePath(pathValue, ref destination))
                    {
                        m_logger.debugLog("throwing out: " + line.From + ", path value: " + pathValue + ", required: " + m_altPath_PathValue, Logger.severity.TRACE);
                    }

                    return;
                }
                if (slowDown)
                {
                    //m_logger.debugLog("Removing speed limit", "PathClear()");
                    m_navSet.Settings_Task_NavWay.SpeedMaxRelative = float.MaxValue;
                    m_navSet.Settings_Task_NavWay.SpeedTarget      = float.MaxValue;
                    return;
                }
                m_logger.debugLog("path clear, throwing out search", Logger.severity.DEBUG, condition: m_pathLow.Count != 0);
                MoveObstruction = null;
                m_pathState     = PathState.No_Obstruction;
                m_pathLow.Clear();
            }
            else
            {
                m_logger.debugLog("destination changed, abort", Logger.severity.DEBUG);
            }
            return;
        }