Pathfinding.Path.Claim C# (CSharp) Method

Claim() public method

public Claim ( System o ) : void
o System
return void
		public void Claim (System.Object o) {
			if (System.Object.ReferenceEquals (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) )
					throw new System.ArgumentException ("You have already claimed the path with that object ("+o+"). Are you claiming the path with the same object twice?");
			}

			claimed.Add (o);
#if ASTAR_POOL_DEBUG
			claimInfo.Add (o.ToString () + "\n\nClaimed from:\n" + System.Environment.StackTrace);
#endif
		}

Usage Example

Ejemplo n.º 1
0
        /** Force recalculation of the current path.
         * If there is an ongoing path calculation, it will be canceled (so make sure you leave time for the paths to get calculated before calling this function again).
         */
        public virtual void UpdatePath()
        {
            canSearchPath      = true;
            waitingForPathCalc = false;
            Path p = seeker.GetCurrentPath();

            //Cancel any eventual pending pathfinding request
            if (p != null && !seeker.IsDone())
            {
                p.Error();
                // Make sure it is recycled. We won't receive a callback for this one since we
                // replace the path directly after this
                p.Claim(this);
                p.Release(this);
            }

            waitingForPathCalc = true;
            lastRepath         = Time.time;

            if (target != null)
            {
                seeker.StartPath(tr.position, target.position);
            }

//          seeker.StartPath(tr.position, targetPosition);
        }
All Usage Examples Of Pathfinding.Path::Claim