Pathfinding.Path.Release C# (CSharp) Method

Release() public method

public Release ( System o ) : void
o System
return void
		public void Release (System.Object o) {
			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
					releasedNotSilent = true;
					if (claimed.Count == 0) {
						Recycle ();
					}
					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?");
			}
			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?");
		}

Usage Example

Beispiel #1
0
    public void OnDisable()
    {
        // Abort calculation of path
        if (seeker != null && !seeker.IsDone())
        {
            seeker.GetCurrentPath().Error();
        }

        // Release current path
        if (path != null)
        {
            path.Release(this);
        }
        path = null;

        //Make sure we receive callbacks when paths complete
        seeker.pathCallback -= OnPathComplete;
    }
All Usage Examples Of Pathfinding.Path::Release