/** 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); }
private void OnPathComplete(Path p) { this.waitingForPathCalc = false; p.Claim(this); if (p.error) { p.Release(this, false); } else { if (this.traversingSpecialPath) { this.delayUpdatePath = true; } else { if (this.rp == null) { this.rp = new RichPath(); } this.rp.Initialize(this.seeker, p, true, this.funnelSimplification); } p.Release(this, false); } }
private void OnPathComplete(Path p) { this.waitingForPathCalc = false; p.Claim(this); if (p.error) { p.Release(this, false); return; } if (this.traversingSpecialPath) { this.delayUpdatePath = true; } else { this.richPath.Initialize(this.seeker, p, true, this.funnelSimplification); RichFunnel richFunnel = this.richPath.GetCurrentPart() as RichFunnel; if (richFunnel != null) { Vector2 b = this.movementPlane.ToPlane(this.UpdateTarget(richFunnel)); if (this.lastCorner && this.nextCorners.Count == 1) { Vector2 a = this.waypoint = this.movementPlane.ToPlane(this.nextCorners[0]); this.distanceToWaypoint = (a - b).magnitude; if (this.distanceToWaypoint <= this.endReachedDistance) { this.NextPart(); } } } } p.Release(this, false); }
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); }
/// <summary> /// Called when a path has completed. /// Will post process it and return it by calling <see cref="tmpPathCallback"/> and <see cref="pathCallback"/> /// </summary> void OnPathComplete(Path p, bool runModifiers, bool sendCallbacks) { if (p != null && p != path && sendCallbacks) { return; } if (this == null || p == null || p != path) { return; } if (!path.error && runModifiers) { // This will send the path for post processing to modifiers attached to this Seeker RunModifiers(ModifierPass.PostProcess, path); } if (sendCallbacks) { p.Claim(this); lastCompletedNodePath = p.path; lastCompletedVectorPath = p.vectorPath; // This will send the path to the callback (if any) specified when calling StartPath if (tmpPathCallback != null) { tmpPathCallback(p); } // This will send the path to any script which has registered to the callback if (pathCallback != null) { pathCallback(p); } PathComplete?.Invoke(); PathComplete = null; // Note: it is important that #prevPath is kept alive (i.e. not pooled) // if we are drawing gizmos. // It is also important that #path is kept alive since it can be returned // from the GetCurrentPath method. // Since #path will be copied to #prevPath it is sufficient that #prevPath // is kept alive until it is replaced. // Recycle the previous path to reduce the load on the GC if (prevPath != null) { prevPath.Release(this, true); } prevPath = p; } }
// 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); } }
/// <summary> /// Called when a path has completed. /// Will post process it and return it by calling <see cref="tmpPathCallback"/> and <see cref="pathCallback"/> /// </summary> private void OnPathComplete(Path p, bool runModifiers, bool sendCallbacks) { if (p != null && p != path && sendCallbacks) { return; } if (this == null || p == null || p != path) { return; } if (!path.error && runModifiers ) // This will send the path for post processing to modifiers attached to this Seeker { RunModifiers(ModifierPass.PostProcess, path); } if (sendCallbacks) { p.Claim(this); lastCompletedNodePath = p.path; lastCompletedVectorPath = p.vectorPath; // This will send the path to the callback (if any) specified when calling StartPath if (tmpPathCallback != null) { tmpPathCallback(p); } // This will send the path to any script which has registered to the callback if (pathCallback != null) { pathCallback(p); } // Recycle the previous path to reduce the load on the GC if (prevPath != null) { prevPath.Release(this, true); } prevPath = p; // If not drawing gizmos, then storing prevPath is quite unecessary // So clear it and set prevPath to null if (!drawGizmos) { ReleaseClaimedPath(); } } }
/// <summary> /// 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. /// </summary> /// <param name="pool">If true then the path will be pooled when the pathfinding system is done with it.</param> 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); } } }
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); } }
static int Claim(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.Claim(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
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); }
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, false); } this.waitingForPathCalc = true; this.lastRepath = Time.time; this.seeker.StartPath(this.tr.position, this.target.position); }
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)); }
protected override void OnPathComplete(Path p) { waitingForPathCalculation = false; p.Claim(this); if (p.error) { p.Release(this); return; } if (traversingOffMeshLink) { delayUpdatePath = true; } else { richPath.Initialize(seeker, p, true, funnelSimplification); // Check if we have already reached the end of the path // We need to do this here to make sure that the #reachedEndOfPath // property is up to date. var part = richPath.GetCurrentPart() as RichFunnel; if (part != null) { if (updatePosition) { simulatedPosition = tr.position; } // Note: UpdateTarget has some side effects like setting the nextCorners list and the lastCorner field var localPosition = movementPlane.ToPlane(UpdateTarget(part)); // Target point steeringTarget = nextCorners[0]; Vector2 targetPoint = movementPlane.ToPlane(steeringTarget); distanceToSteeringTarget = (targetPoint - localPosition).magnitude; if (lastCorner && nextCorners.Count == 1 && distanceToSteeringTarget <= endReachedDistance) { NextPart(); } } } p.Release(this); }
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)); }
void OnPathComplete(Path p) { waitingForPathCalc = false; p.Claim(this); if (p.error) { p.Release(this); return; } if (traversingSpecialPath) { delayUpdatePath = true; } else { richPath.Initialize(seeker, p, true, funnelSimplification); // Check if we have already reached the end of the path // We need to do this here to make sure that the #TargetReached // property is up to date. var part = richPath.GetCurrentPart() as RichFunnel; if (part != null) { var position = movementPlane.ToPlane(UpdateTarget(part)); if (lastCorner && nextCorners.Count == 1) { // Target point Vector2 targetPoint = waypoint = movementPlane.ToPlane(nextCorners[0]); distanceToWaypoint = (targetPoint - position).magnitude; if (distanceToWaypoint <= endReachedDistance) { NextPart(); } } } } p.Release(this); }
// Token: 0x060021BE RID: 8638 RVA: 0x0019026C File Offset: 0x0018E46C private void OnPathComplete(Path p, bool runModifiers, bool sendCallbacks) { if (p != null && p != this.path && sendCallbacks) { return; } if (this == null || p == null || p != this.path) { return; } if (!this.path.error && runModifiers) { this.RunModifiers(Seeker.ModifierPass.PostProcess, this.path); } if (sendCallbacks) { p.Claim(this); this.lastCompletedNodePath = p.path; this.lastCompletedVectorPath = p.vectorPath; if (this.tmpPathCallback != null) { this.tmpPathCallback(p); } if (this.pathCallback != null) { this.pathCallback(p); } if (this.prevPath != null) { this.prevPath.Release(this, true); } this.prevPath = p; if (!this.drawGizmos) { this.ReleaseClaimedPath(); } } }
// Token: 0x06002177 RID: 8567 RVA: 0x0018E20C File Offset: 0x0018C40C protected override void OnPathComplete(Path p) { this.waitingForPathCalculation = false; p.Claim(this); if (p.error) { p.Release(this, false); return; } if (this.traversingOffMeshLink) { this.delayUpdatePath = true; } else { this.richPath.Initialize(this.seeker, p, true, this.funnelSimplification); RichFunnel richFunnel = this.richPath.GetCurrentPart() as RichFunnel; if (richFunnel != null) { if (this.updatePosition) { this.simulatedPosition = this.tr.position; } Vector2 b = this.movementPlane.ToPlane(this.UpdateTarget(richFunnel)); if (this.lastCorner && this.nextCorners.Count == 1) { this.steeringTarget = this.nextCorners[0]; Vector2 a = this.movementPlane.ToPlane(this.steeringTarget); this.distanceToSteeringTarget = (a - b).magnitude; if (this.distanceToSteeringTarget <= this.endReachedDistance) { this.NextPart(); } } } } p.Release(this, false); }
private void OnPathComplete(Path p) { p.Claim(this); if (!p.error) { StopMoving(); isMoving = true; path = p; currentWaypoint = 0; } else { p.Release(this); isMoving = false; } }
/** Called when a path has completed. * Will post process it and return it by calling #tmpPathCallback and #pathCallback */ public void OnPathComplete (Path p, bool runModifiers, bool sendCallbacks) { AstarProfiler.StartProfile ("Seeker OnPathComplete"); if (p != null && p != path && sendCallbacks) { return; } if (this == null || p == null || p != path) return; if (!path.error && runModifiers) { AstarProfiler.StartProfile ("Seeker Modifiers"); //This will send the path for post processing to modifiers attached to this Seeker RunModifiers (ModifierPass.PostProcessOriginal, path); //This will send the path for post processing to modifiers attached to this Seeker RunModifiers (ModifierPass.PostProcess, path); AstarProfiler.EndProfile (); } if (sendCallbacks) { p.Claim (this); AstarProfiler.StartProfile ("Seeker Callbacks"); lastCompletedNodePath = p.path; lastCompletedVectorPath = p.vectorPath; //This will send the path to the callback (if any) specified when calling StartPath if (tmpPathCallback != null) { tmpPathCallback (p); } //This will send the path to any script which has registered to the callback if (pathCallback != null) { pathCallback (p); } //Recycle the previous path if (prevPath != null) { prevPath.ReleaseSilent (this); } prevPath = p; //If not drawing gizmos, then storing prevPath is quite unecessary //So clear it and set prevPath to null if (!drawGizmos) ReleaseClaimedPath (); AstarProfiler.EndProfile(); } AstarProfiler.EndProfile (); }
/** Puts the Path in queue for calculation. * The callback specified when constructing the path will be called when the path has been calculated. * Usually you should use the Seeker component instead of calling this function directly. * * \param p The path that should be put in queue for calculation * \param pushToFront If true, the path will be pushed to the front of the queue, bypassing all waiting paths and making it the next path to be calculated. * This can be useful if you have a path which you want to prioritize over all others. Be careful to not overuse it though. * If too many paths are put in the front of the queue often, this can lead to normal paths having to wait a very long time before being calculated. */ public static void StartPath (Path p, bool pushToFront = false) { if (active == null) { Debug.LogError ("There is no AstarPath object in the scene"); return; } if (p.GetState() != PathState.Created) { throw new System.Exception ("The path has an invalid state. Expected " + PathState.Created + " found " + p.GetState() + "\n" + "Make sure you are not requesting the same path twice"); } if (active.pathQueue.IsTerminating) { p.Error (); p.LogError ("No new paths are accepted"); return; } if (active.graphs == null || active.graphs.Length == 0) { Debug.LogError ("There are no graphs in the scene"); p.Error (); p.LogError ("There are no graphs in the scene"); Debug.LogError (p.errorLog); return; } p.Claim (active); //Will increment to PathQueue p.AdvanceState (PathState.PathQueue); if (pushToFront) { active.pathQueue.PushFront (p); } else { active.pathQueue.Push (p); } }
private void OnPathComplete(Path p, bool runModifiers, bool sendCallbacks) { if (p != null && p != this.path && sendCallbacks) { return; } if (this == null || p == null || p != this.path) { return; } if (!this.path.error && runModifiers) { this.RunModifiers(Seeker.ModifierPass.PostProcess, this.path); } if (sendCallbacks) { p.Claim(this); this.lastCompletedNodePath = p.path; this.lastCompletedVectorPath = p.vectorPath; if (this.tmpPathCallback != null) { this.tmpPathCallback(p); } if (this.pathCallback != null) { this.pathCallback(p); } if (this.prevPath != null) { this.prevPath.ReleaseSilent(this); } this.prevPath = p; if (!this.drawGizmos) { this.ReleaseClaimedPath(); } } }
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; } } } } }
/** Puts the Path in queue for calculation. * The callback specified when constructing the path will be called when the path has been calculated. * Usually you should use the Seeker component instead of calling this function directly. */ public static void StartPath (Path p) { if (active == null) { Debug.LogError ("There is no AstarPath object in the scene"); return; } if (p.GetState() != PathState.Created) { throw new System.Exception ("The path has an invalid state. Expected " + PathState.Created + " found " + p.GetState() + "\n" + "Make sure you are not requesting the same path twice"); } if (!active.acceptNewPaths) { p.Error (); p.LogError ("No new paths are accepted"); //Debug.LogError (p.errorLog); //p.ReturnPath (); return; } if (active.graphs == null || active.graphs.Length == 0) { Debug.LogError ("There are no graphs in the scene"); p.Error (); p.LogError ("There are no graphs in the scene"); Debug.LogError (p.errorLog); //p.ReturnPath (); return; } /*MultithreadPath p2 = p as MultithreadPath; if (p2 == null) { Debug.LogError ("Path Not Set Up For Multithreading"); return; }*/ p.Claim (active); lock (pathQueue) { //Will increment to PathQueue p.AdvanceState (PathState.PathQueue); pathQueue.Enqueue (p); if (doSetQueueState) pathQueueFlag.Set (); } }
public void OnPathComplete(Path p) { //Debug.Log ("Error? -" + p.error); if(!p.error) //if no error { path = p; //set path to correct path currentNode = 0; //reset index path.Claim(this); } else{ ToggleAttack(isPissed); } }
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); }
private void OnPathingComplete(Path path) { if (path.error == false) { if (_path != null) { _path.Release(this); } _path = path; _path.Claim(this); _pathIndex = 0; //Update distanec to objective. this.DistanceToObjective = _path.GetTotalLength(); } }