示例#1
0
        /** Construct a path with a start and end point.
         * The delegate will be called when the path has been calculated.
         * Do not confuse it with the Seeker callback as they are sent at different times.
         * If you are using a Seeker to start the path you can set \a callback to null.
         *
         * \returns The constructed path object
         */
        public static ABPath Construct(Vector3 start, Vector3 end, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <ABPath>();

            p.Setup(start, end, callback);
            return(p);
        }
示例#2
0
        public static FloodPath Construct(Vector3 start, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <FloodPath>();

            p.Setup(start, callback);
            return(p);
        }
示例#3
0
        public static RandomPath Construct(Vector3 start, int length, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <RandomPath>();

            p.Setup(start, length, callback);
            return(p);
        }
        public static MultiTargetPath Construct(Vector3 start, Vector3[] targets, OnPathDelegate[] callbackDelegates, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <MultiTargetPath>();

            p.Setup(start, targets, callbackDelegates, callback);
            return(p);
        }
示例#5
0
        /** Constructs a ConstantPath starting from the specified point.
         * \param start             From where the path will be started from (the closest node to that point will be used)
         * \param maxGScore			Searching will be stopped when a node has a G score greater than this
         * \param callback			Will be called when the path has completed, leave this to null if you use a Seeker to handle calls
         *
         * Searching will be stopped when a node has a G score (cost to reach it) greater or equal to \a maxGScore
         * in order words it will search all nodes with a cost to get there less than \a maxGScore.
         */
        public static ConstantPath Construct(Vector3 start, int maxGScore, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <ConstantPath>();

            p.Setup(start, maxGScore, callback);
            return(p);
        }
示例#6
0
        /** Constructs a new FleePath.
         * The FleePath will be taken from a pool.
         */
        public static FleePath Construct(Vector3 start, Vector3 avoid, int searchLength, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <FleePath>();

            p.Setup(start, avoid, searchLength, callback);
            return(p);
        }
示例#7
0
文件: XPath.cs 项目: yangtzehina/ET
        public new static XPath Construct(Vector3 start, Vector3 end, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <XPath>();

            p.Setup(start, end, callback);
            p.endingCondition = new ABPathEndingCondition(p);
            return(p);
        }
示例#8
0
        public static FloodPath Construct(GraphNode start, OnPathDelegate callback = null)
        {
            if (start == null)
            {
                throw new ArgumentNullException("start");
            }

            var p = PathPool.GetPath <FloodPath>();

            p.Setup(start, callback);
            return(p);
        }
示例#9
0
文件: Path.cs 项目: isoundy000/ETGame
        /** Releases a path claim (pooling).
         * Removes the claim of the path by the specified object.
         * When the claim count reaches zero, the path will be pooled, all variables will be cleared and the path will be put in a pool to be used again.
         * This is great for performance since fewer allocations are made.
         *
         * If the silent parameter is true, this method will remove the claim by the specified object
         * but the path will not be pooled if the claim count reches zero unless a Release call (not silent) has been made earlier.
         * This is used by the internal pathfinding components such as Seeker and AstarPath so that they will not cause paths to be pooled.
         * This enables users to skip the claim/release calls if they want without the path being pooled by the Seeker or AstarPath and
         * thus causing strange bugs.
         *
         * \see Claim
         * \see PathPool
         */
        public void Release(System.Object o, bool silent = false)
        {
            if (o == null)
            {
                throw new System.ArgumentNullException("o");
            }

            for (int i = 0; i < claimed.Count; i++)
            {
                // Need to use ReferenceEquals because it might be called from another thread
                if (System.Object.ReferenceEquals(claimed[i], o))
                {
                    claimed.RemoveAt(i);
#if ASTAR_POOL_DEBUG
                    claimInfo.RemoveAt(i);
#endif
                    if (!silent)
                    {
                        releasedNotSilent = true;
                    }

                    if (claimed.Count == 0 && releasedNotSilent)
                    {
                        PathPool.Pool(this);
                    }
                    return;
                }
            }
            if (claimed.Count == 0)
            {
                throw new System.ArgumentException("You are releasing a path which is not claimed at all (most likely it has been pooled already). " +
                                                   "Are you releasing the path with the same object (" + o + ") twice?" +
                                                   "\nCheck out the documentation on path pooling for help.");
            }
            throw new System.ArgumentException("You are releasing a path which has not been claimed with this object (" + o + "). " +
                                               "Are you releasing the path with the same object twice?\n" +
                                               "Check out the documentation on path pooling for help.");
        }