Release() public method

public Release ( System o ) : void
o System
return void
示例#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;
    }
示例#2
0
	// Metodo que se llama cuando una ruta ha sido calculada
	public void OnPathComplete (Path p) {
		p.Claim (this);
		if (!p.error) {
			if (path != null) path.Release (this);
			path = p;
			currentWaypoint = 1;
		} else {
			p.Release (this);
			Debug.Log ("No se puede llegar a este punto de destino: "+p.errorLog);
		}
	}
示例#3
0
 public void OnPathComplete(Path p)
 {
     p.Claim (this);
     if (!p.error) {
         if (path != null) path.Release (this);
         path = p;
         //Reset the waypoint counter
         currentWaypoint = 0;
         currentPathCount = path.vectorPath.Count;
     } else {
         p.Release (this);
         Debug.Log ("The target was not reachable: "+p.errorLog);
     }
 }
示例#4
0
    public void OnPathComplete(Path p)
    {
        p.Claim (this);
        if (!p.error) {
            if (path != null) path.Release (this);
            path = p;
            //Reset the waypoint counter
            currentAIWaypoint = 0;
        } else {
            p.Release (this);
            //Debug.Log ("Oh noes, the target was not reachable: "+p.errorLog);
        }

        //seeker.StartPath (transform.position,targetPosition, OnPathComplete);
    }
 static int Release(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Pathfinding.Path obj  = (Pathfinding.Path)ToLua.CheckObject <Pathfinding.Path>(L, 1);
         object           arg0 = ToLua.ToVarObject(L, 2);
         obj.Release(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 /** Stop calculating the current path request.
  * If this Seeker is currently calculating a path it will be canceled.
  * The callback (usually to a method named OnPathComplete) will soon be called
  * with a path that has the 'error' field set to true.
  *
  * This does not stop the character from moving, it just aborts
  * the path calculation.
  *
  * \param pool If true then the path will be pooled when the pathfinding system is done with it.
  */
 public void CancelCurrentPathRequest(bool pool = true)
 {
     if (!IsDone())
     {
         path.FailWithError("Canceled by script (Seeker.CancelCurrentPathRequest)");
         if (pool)
         {
             // Make sure the path has had its reference count incremented and decremented once.
             // If this is not done the system will think no pooling is used at all and will not pool the path.
             // The particular object that is used as the parameter (in this case 'path') doesn't matter at all
             // it just has to be *some* object.
             path.Claim(path);
             path.Release(path);
         }
     }
 }
示例#7
0
        public override void UpdatePath()
        {
            this.canSearchPath      = true;
            this.waitingForPathCalc = false;
            Path currentPath = this.seeker.GetCurrentPath();

            if (currentPath != null && !this.seeker.IsDone())
            {
                currentPath.Error();
                currentPath.Claim(this);
                currentPath.Release(this, false);
            }
            this.waitingForPathCalc = true;
            this.lastRepath         = Time.time;
            Matrix4x4 matrix = this.graph.GetMatrix();

            this.seeker.StartPath(matrix.MultiplyPoint3x4(this.tr.position), matrix.MultiplyPoint3x4(this.target.position));
        }
        public override void UpdatePath()
        {
            base.canSearchPath      = true;
            base.waitingForPathCalc = false;
            Path currentPath = base.seeker.GetCurrentPath();

            if ((currentPath != null) && !base.seeker.IsDone())
            {
                currentPath.Error();
                currentPath.Claim(this);
                currentPath.Release(this, false);
            }
            base.waitingForPathCalc = true;
            base.lastRepath         = Time.time;
            Matrix4x4 matrix = this.graph.GetMatrix();
            Vector3   start  = matrix.MultiplyPoint3x4(base.tr.position);

            base.seeker.StartPath(start, matrix.MultiplyPoint3x4(base.target.position));
        }
示例#9
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;
            seeker.StartPath(tr.position, target.position);
        }
示例#10
0
        public virtual void UpdatePath()
        {
            this.canSearchPath      = true;
            this.waitingForPathCalc = false;
            Path currentPath = this.seeker.GetCurrentPath();

            if (currentPath != null && !this.seeker.IsDone())
            {
                currentPath.Error();
                currentPath.Claim(this);
                currentPath.Release(this);
            }
            if (this.target == null)
            {
                return;
            }
            this.waitingForPathCalc = true;
            this.lastRepath         = Time.time;
            this.seeker.StartPath(this.tr.position, this.target.position);
        }
示例#11
0
        public void ReturnPaths(bool timeSlice)
        {
            Path next = this.pathReturnStack.PopAll();

            if (this.pathReturnPop == null)
            {
                this.pathReturnPop = next;
            }
            else
            {
                Path next2 = this.pathReturnPop;
                while (next2.next != null)
                {
                    next2 = next2.next;
                }
                next2.next = next;
            }
            long num  = timeSlice ? (DateTime.UtcNow.Ticks + 10000L) : 0L;
            int  num2 = 0;

            while (this.pathReturnPop != null)
            {
                Path path = this.pathReturnPop;
                this.pathReturnPop = this.pathReturnPop.next;
                path.next          = null;
                ((IPathInternals)path).ReturnPath();
                ((IPathInternals)path).AdvanceState(PathState.Returned);
                path.Release(this.pathsClaimedSilentlyBy, true);
                num2++;
                if (num2 > 5 && timeSlice)
                {
                    num2 = 0;
                    if (DateTime.UtcNow.Ticks >= num)
                    {
                        return;
                    }
                }
            }
        }
示例#12
0
        public void ReturnPaths(bool timeSlice)
        {
            Path path = this.pathReturnStack.PopAll();

            if (this.pathReturnPop == null)
            {
                this.pathReturnPop = path;
            }
            else
            {
                Path pathReturnPop = this.pathReturnPop;
                while (pathReturnPop.next != null)
                {
                    pathReturnPop = pathReturnPop.next;
                }
                pathReturnPop.next = path;
            }
            long num  = !timeSlice ? 0L : (DateTime.UtcNow.Ticks + 0x2710L);
            int  num2 = 0;

            while (this.pathReturnPop != null)
            {
                Path path3 = this.pathReturnPop;
                this.pathReturnPop = this.pathReturnPop.next;
                path3.next         = null;
                path3.ReturnPath();
                path3.AdvanceState(PathState.Returned);
                path3.Release(this.pathsClaimedSilentlyBy, true);
                num2++;
                if ((num2 > 5) && timeSlice)
                {
                    num2 = 0;
                    if (DateTime.UtcNow.Ticks >= num)
                    {
                        return;
                    }
                }
            }
        }
示例#13
0
    private void OnPathComplete(Path p)
    {
        p.Claim(this);
        if (!p.error) {
            StopMoving();
            isMoving = true;

            path = p;
            currentWaypoint = 0;
        }
        else {
            p.Release(this);
            isMoving = false;
        }
    }
示例#14
0
    public void OnPathComplete(Path p)
    {
        if(target == null)
        {
            p.Claim (this);
          //  Debug.Log ("Yey, we got a path back. Did it have an error? "+p.error);
            if (!p.error) {
                if (path != null) path.Release (this);
                path = p;
                //Reset the waypoint counter
                currentWaypoint = 0;
            }
            else {
                p.Release (this);
                bChangeWaypoint = true;
                Debug.Log ("Oh noes, the target was not reachable: "+p.errorLog);
            }
        }
        else
        {
            /*if (Time.time-lastPathSearch >= repathRate) {
            Repath ();
            } else {*/
                StartCoroutine (WaitToRepath ());
            //}
            p.Claim (this);
            //If the path didn't succeed, don't proceed
            if (p.error) {
                p.Release (this);
                return;
            }
            else
            {
                //if(path != null) path.Release (this);
                //Get the calculated path as a Vector3 array
                path2 = p.vectorPath.ToArray();

                //Find the segment in the path which is closest to the AI
                //If a closer segment hasn't been found in '6' iterations, break because it is unlikely to find any closer ones then
                float minDist = Mathf.Infinity;
                int notCloserHits = 0;

                for (int i=0;i<path2.Length-1;i++) {
                    float dist = Mathfx.DistancePointSegmentStrict (path2[i],path2[i+1],tr.position);
                    if (dist < minDist) {
                        notCloserHits = 0;
                        minDist = dist;
                        pathIndex = i+1;
                    } else if (notCloserHits > 6) {
                        break;
                    }
                }
            }
        }
    }
示例#15
0
        private void PathPlotCompletedEventHandler(Path path) {
            if (path.error) {
                D.Warn("{0} generated an error plotting a course to {1}.", DebugName, ApTarget.DebugName);
                HandleApCoursePlotFailure();
                return;
            }
            ConstructApCourse(path.vectorPath);
            path.Release(this);

            if (_isPathReplotting) {
                ResetPathReplotValues();
                EngagePilot_Internal();
            }
            else {
                HandleApCoursePlotSuccess();
            }
        }
示例#16
0
        /**
         * Returns all paths in the return stack.
         * Paths which have been processed are put in the return stack.
         * This function will pop all items from the stack and return them to e.g the Seeker requesting them.
         *
         * \param timeSlice Do not return all paths at once if it takes a long time, instead return some and wait until the next call.
         */
        public void ReturnPaths(bool timeSlice)
        {
            Profiler.BeginSample("Calling Path Callbacks");
            // Pop all items from the stack
            Path p = pathReturnStack.PopAll();

            if (pathReturnPop == null)
            {
                pathReturnPop = p;
            }
            else
            {
                Path tail = pathReturnPop;
                while (tail.next != null)
                {
                    tail = tail.next;
                }
                tail.next = p;
            }

            // Hard coded limit on 1.0 ms
            long targetTick = timeSlice ? System.DateTime.UtcNow.Ticks + 1 * 10000 : 0;

            int counter = 0;

            // Loop through the linked list and return all paths
            while (pathReturnPop != null)
            {
                //Move to the next path
                Path prev = pathReturnPop;
                pathReturnPop = pathReturnPop.next;

                // Remove the reference to prevent possible memory leaks
                // If for example the first path computed was stored somewhere,
                // it would through the linked list contain references to all comming paths to be computed,
                // and thus the nodes those paths searched.
                // That adds up to a lot of memory not being released
                prev.next = null;

                //Return the path
                ((IPathInternals)prev).ReturnPath();

                // Will increment to Returned
                // However since multithreading is annoying, it might be set to ReturnQueue for a small time until the pathfinding calculation
                // thread advanced the state as well
                ((IPathInternals)prev).AdvanceState(PathState.Returned);

                prev.Release(pathsClaimedSilentlyBy, true);

                counter++;
                // At least 5 paths will be returned, even if timeSlice is enabled
                if (counter > 5 && timeSlice)
                {
                    counter = 0;
                    if (System.DateTime.UtcNow.Ticks >= targetTick)
                    {
                        return;
                    }
                }
            }
            Profiler.EndSample();
        }
示例#17
0
		void OnPathComplete (Path p) {
			waitingForPathCalc = false;
			p.Claim(this);
			
			if (p.error) {
				p.Release(this);
				return;
			}
			
			if (traversingSpecialPath) {
				delayUpdatePath = true;
			} else {
				if (rp == null) rp = new RichPath();
				rp.Initialize (seeker, p,true, funnelSimplification);
			}
			p.Release(this);
		}