本文整理汇总了C#中Pathfinding.Path.AdvanceState方法的典型用法代码示例。如果您正苦于以下问题:C# Path.AdvanceState方法的具体用法?C# Path.AdvanceState怎么用?C# Path.AdvanceState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pathfinding.Path
的用法示例。
在下文中一共展示了Path.AdvanceState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartPath
/** 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);
}
}
示例2: StartPath
/** 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 ();
}
}