Exemplo n.º 1
0
        public static FleePath Construct(Vector3 start, Vector3 avoid, int searchLength, [Optional, DefaultParameterValue(null)] OnPathDelegate callback)
        {
            FleePath path = PathPool.GetPath <FleePath>();

            path.Setup(start, avoid, searchLength, callback);
            return(path);
        }
Exemplo n.º 2
0
        public static RandomPath Construct(Vector3 start, int length, [Optional, DefaultParameterValue(null)] OnPathDelegate callback)
        {
            RandomPath path = PathPool.GetPath <RandomPath>();

            path.Setup(start, length, callback);
            return(path);
        }
Exemplo n.º 3
0
        //Good Game
        //public static RandomPath Construct (Vector3 start, int length, OnPathDelegate callback = null) {
        public static RandomPath Construct(VInt3 start, int length, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <RandomPath>();

            p.Setup(start, length, callback);
            return(p);
        }
Exemplo n.º 4
0
        public static FloodPathTracer Construct(Vector3 start, FloodPath flood, [Optional, DefaultParameterValue(null)] OnPathDelegate callback)
        {
            FloodPathTracer path = PathPool.GetPath <FloodPathTracer>();

            path.Setup(start, flood, callback);
            return(path);
        }
Exemplo n.º 5
0
        // Token: 0x06002741 RID: 10049 RVA: 0x001B035C File Offset: 0x001AE55C
        public static FloodPathTracer Construct(Vector3 start, FloodPath flood, OnPathDelegate callback = null)
        {
            FloodPathTracer path = PathPool.GetPath <FloodPathTracer>();

            path.Setup(start, flood, callback);
            return(path);
        }
Exemplo n.º 6
0
        public static MultiTargetPath Construct(Vector3 start, Vector3[] targets, OnPathDelegate[] callbackDelegates, OnPathDelegate callback = null)
        {
            MultiTargetPath path = PathPool.GetPath <MultiTargetPath>();

            path.Setup(start, targets, callbackDelegates, callback);
            return(path);
        }
Exemplo n.º 7
0
        // Token: 0x06000761 RID: 1889 RVA: 0x00048158 File Offset: 0x00046558
        public static FloodPath Construct(Vector3 start, OnPathDelegate callback = null)
        {
            FloodPath path = PathPool <FloodPath> .GetPath();

            path.Setup(start, callback);
            return(path);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public static ABPath Construct(ref VInt3 start, ref VInt3 end, OnPathDelegate callback = null)
        {
            ABPath path = PathPool <ABPath> .GetPath();

            path.Setup(ref start, ref end, callback);
            return(path);
        }
Exemplo n.º 10
0
 public void Release(object o, bool silent = false)
 {
     if (o == null)
     {
         throw new ArgumentNullException("o");
     }
     for (int i = 0; i < this.claimed.Count; i++)
     {
         if (object.ReferenceEquals(this.claimed[i], o))
         {
             this.claimed.RemoveAt(i);
             if (!silent)
             {
                 this.releasedNotSilent = true;
             }
             if (this.claimed.Count == 0 && this.releasedNotSilent)
             {
                 PathPool.Pool(this);
             }
             return;
         }
     }
     if (this.claimed.Count == 0)
     {
         throw new 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 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?\nCheck out the documentation on path pooling for help.");
 }
Exemplo n.º 11
0
        public static MultiTargetPath Construct(Vector3 start, Vector3[] targets, OnPathDelegate[] callbackDelegates, [Optional, DefaultParameterValue(null)] OnPathDelegate callback)
        {
            MultiTargetPath path = PathPool.GetPath <MultiTargetPath>();

            path.Setup(start, targets, callbackDelegates, callback);
            return(path);
        }
Exemplo n.º 12
0
        public static ABPath Construct(Vector3 start, Vector3 end, [Optional, DefaultParameterValue(null)] OnPathDelegate callback)
        {
            ABPath path = PathPool.GetPath <ABPath>();

            path.Setup(start, end, callback);
            return(path);
        }
Exemplo n.º 13
0
        /** 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 (!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.");
        }
Exemplo n.º 14
0
        /// <summary>
        /// Constructs a ConstantPath starting from the specified point.
        ///
        /// Searching will be stopped when a node has a G score (cost to reach it) greater or equal to maxGScore
        /// in order words it will search all nodes with a cost to get there less than maxGScore.
        /// </summary>
        /// <param name="start">From where the path will be started from (the closest node to that point will be used)</param>
        /// <param name="maxGScore">Searching will be stopped when a node has a G score greater than this</param>
        /// <param name="callback">Will be called when the path has completed, leave this to null if you use a Seeker to handle calls</param>
        public static ConstantPath Construct(Vector3 start, int maxGScore, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <ConstantPath>();

            p.Setup(start, maxGScore, callback);
            return(p);
        }
Exemplo n.º 15
0
        public static ABPath Construct(Vector3 start, Vector3 end, OnPathDelegate callback = null)
        {
            ABPath path = PathPool <ABPath> .GetPath();

            path.Setup(start, end, callback);
            return(path);
        }
Exemplo n.º 16
0
        public static ConstantPath Construct(Vector3 start, int maxGScore, OnPathDelegate callback = null)
        {
            ConstantPath path = PathPool <ConstantPath> .GetPath();

            path.Setup(start, maxGScore, callback);
            return(path);
        }
Exemplo n.º 17
0
        public static FloodPath Construct(Vector3 start, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <FloodPath>();

            p.Setup(start, callback);
            return(p);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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 ABTilePath Construct(Tile start, Tile end, OnPathDelegate callback = null)
        {
            ABTilePath p = PathPool <ABTilePath> .GetPath();

            p.Setup(start, end, callback);
            return(p);
        }
Exemplo n.º 20
0
        public static FleePath Construct(Vector3 start, Vector3 avoid, int searchLength, OnPathDelegate callback = null)
        {
            FleePath path = PathPool <FleePath> .GetPath();

            path.Setup(start, avoid, searchLength, callback);
            return(path);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Creates a fake path.
        /// Creates a path that looks almost exactly like it would if the pathfinding system had calculated it.
        ///
        /// This is useful if you want your agents to follow some known path that cannot be calculated using the pathfinding system for some reason.
        ///
        /// <code>
        /// var path = ABPath.FakePath(new List<Vector3> { new Vector3(1, 2, 3), new Vector3(4, 5, 6) });
        ///
        /// ai.SetPath(path);
        /// </code>
        ///
        /// You can use it to combine existing paths like this:
        ///
        /// <code>
        /// var a = Vector3.zero;
        /// var b = new Vector3(1, 2, 3);
        /// var c = new Vector3(2, 3, 4);
        /// var path1 = ABPath.Construct(a, b);
        /// var path2 = ABPath.Construct(b, c);
        ///
        /// AstarPath.StartPath(path1);
        /// AstarPath.StartPath(path2);
        /// path1.BlockUntilCalculated();
        /// path2.BlockUntilCalculated();
        ///
        /// // Combine the paths
        /// // Note: Skip the first element in the second path as that will likely be the last element in the first path
        /// var newVectorPath = path1.vectorPath.Concat(path2.vectorPath.Skip(1)).ToList();
        /// var newNodePath = path1.path.Concat(path2.path.Skip(1)).ToList();
        /// var combinedPath = ABPath.FakePath(newVectorPath, newNodePath);
        /// </code>
        /// </summary>
        public static ABPath FakePath(List <Vector3> vectorPath, List <GraphNode> nodePath = null)
        {
            var path = PathPool.GetPath <ABPath>();

            for (int i = 0; i < vectorPath.Count; i++)
            {
                path.vectorPath.Add(vectorPath[i]);
            }

            path.completeState = PathCompleteState.Complete;
            ((IPathInternals)path).AdvanceState(PathState.Returned);

            if (vectorPath.Count > 0)
            {
                path.UpdateStartEnd(vectorPath[0], vectorPath[vectorPath.Count - 1]);
            }

            if (nodePath != null)
            {
                for (int i = 0; i < nodePath.Count; i++)
                {
                    path.path.Add(nodePath[i]);
                }
                if (nodePath.Count > 0)
                {
                    path.startNode = nodePath[0];
                    path.endNode   = nodePath[nodePath.Count - 1];
                }
            }

            return(path);
        }
Exemplo n.º 22
0
        public static ConstantPath Construct(Vector3 start, int maxGScore, [Optional, DefaultParameterValue(null)] OnPathDelegate callback)
        {
            ConstantPath path = PathPool.GetPath <ConstantPath>();

            path.Setup(start, maxGScore, callback);
            return(path);
        }
Exemplo n.º 23
0
        // Token: 0x06002761 RID: 10081 RVA: 0x001B14A5 File Offset: 0x001AF6A5
        public static RandomPath Construct(Vector3 start, int length, OnPathDelegate callback = null)
        {
            RandomPath path = PathPool.GetPath <RandomPath>();

            path.Setup(start, length, callback);
            return(path);
        }
Exemplo n.º 24
0
        //Good Game
        //public static MultiTargetPath Construct (Vector3 start, Vector3[] targets, OnPathDelegate[] callbackDelegates, OnPathDelegate callback = null) {
        public static MultiTargetPath Construct(VInt3 start, VInt3[] targets, OnPathDelegate[] callbackDelegates, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <MultiTargetPath>();

            p.Setup(start, targets, callbackDelegates, callback);
            return(p);
        }
Exemplo n.º 25
0
        //Good Game
        //public static FloodPathTracer Construct (Vector3 start, FloodPath flood, OnPathDelegate callback = null) {
        public static FloodPathTracer Construct(VInt3 start, FloodPath flood, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <FloodPathTracer>();

            p.Setup(start, flood, callback);
            return(p);
        }
Exemplo n.º 26
0
        public new static XPath Construct(Vector3 start, Vector3 end, OnPathDelegate callback = null)
        {
            XPath path = PathPool <XPath> .GetPath();

            path.Setup(start, end, callback);
            path.endingCondition = new ABPathEndingCondition(path);
            return(path);
        }
Exemplo n.º 27
0
        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);
        }
Exemplo n.º 28
0
        public static XPath Construct(Vector3 start, Vector3 end, [Optional, DefaultParameterValue(null)] OnPathDelegate callback)
        {
            XPath p = PathPool.GetPath <XPath>();

            p.Setup(start, end, callback);
            p.endingCondition = new ABPathEndingCondition(p);
            return(p);
        }
Exemplo n.º 29
0
        public static FloodPath Construct(GraphNode start, OnPathDelegate callback = null)
        {
            if (start == null)
            {
                throw new ArgumentNullException("start");
            }
            FloodPath path = PathPool <FloodPath> .GetPath();

            path.Setup(start, callback);
            return(path);
        }
Exemplo n.º 30
0
        public static FloodPath Construct(GraphNode start, [Optional, DefaultParameterValue(null)] OnPathDelegate callback)
        {
            if (start == null)
            {
                throw new ArgumentNullException("start");
            }
            FloodPath path = PathPool.GetPath <FloodPath>();

            path.Setup(start, callback);
            return(path);
        }