123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using System.Collections.Generic;
- using Pathfinding.Util;
- namespace Pathfinding {
-
-
-
-
-
-
-
-
-
- public static class GraphUpdateUtilities {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static bool UpdateGraphsNoBlock (GraphUpdateObject guo, GraphNode node1, GraphNode node2, bool alwaysRevert = false) {
- List<GraphNode> buffer = ListPool<GraphNode>.Claim();
- buffer.Add(node1);
- buffer.Add(node2);
- bool worked = UpdateGraphsNoBlock(guo, buffer, alwaysRevert);
- ListPool<GraphNode>.Release(ref buffer);
- return worked;
- }
-
-
-
-
-
-
-
-
-
-
-
-
- public static bool UpdateGraphsNoBlock (GraphUpdateObject guo, List<GraphNode> nodes, bool alwaysRevert = false) {
- bool worked;
-
- var graphLock = AstarPath.active.PausePathfinding();
- try {
-
- AstarPath.active.FlushGraphUpdates();
-
- for (int i = 0; i < nodes.Count; i++) if (!nodes[i].Walkable) return false;
-
- guo.trackChangedNodes = true;
- AstarPath.active.UpdateGraphs(guo);
-
- AstarPath.active.FlushGraphUpdates();
-
- worked = PathUtilities.IsPathPossible(nodes);
-
- if (!worked || alwaysRevert) {
- guo.RevertFromBackup();
-
- AstarPath.active.hierarchicalGraph.RecalculateIfNecessary();
- }
- } finally {
- graphLock.Release();
- }
-
- guo.trackChangedNodes = false;
- return worked;
- }
- }
- }
|