當前位置: 首頁>>代碼示例>>C#>>正文


C# GraphUpdateObject.RevertFromBackup方法代碼示例

本文整理匯總了C#中Pathfinding.GraphUpdateObject.RevertFromBackup方法的典型用法代碼示例。如果您正苦於以下問題:C# GraphUpdateObject.RevertFromBackup方法的具體用法?C# GraphUpdateObject.RevertFromBackup怎麽用?C# GraphUpdateObject.RevertFromBackup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pathfinding.GraphUpdateObject的用法示例。


在下文中一共展示了GraphUpdateObject.RevertFromBackup方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateGraphsNoBlock

		/** Updates graphs and checks if all nodes are still reachable from each other.
		 * Graphs are updated, then a check is made to see if the nodes are still reachable from each other.
		 * If they are not, the graphs are reverted to before the update and \a false is returned.
		 * This is slower than a normal graph update.
		 * All queued graph updates and thread safe callbacks will be flushed during this function.
		 * 
		 * \note This might return true for small areas even if there is no possible path if AstarPath.minAreaSize is greater than zero (0).
		 * So when using this, it is recommended to set AstarPath.minAreaSize to 0. (A* Inspector -> Settings -> Pathfinding)
		 * 
		 * \param guo The GraphUpdateObject to update the graphs with
		 * \param nodes Nodes which should have valid paths between them. All nodes should be walkable or \a false will be returned.
		 * \param alwaysRevert If true, reverts the graphs to the old state even if no blocking ocurred
		 */
		public static bool UpdateGraphsNoBlock (GraphUpdateObject guo, List<GraphNode> nodes, bool alwaysRevert = false) {
			
			//Make sure all nodes are walkable
			for (int i=0;i<nodes.Count;i++) if (!nodes[i].Walkable) return false;
			
			//Track changed nodes to enable reversion of the guo
			guo.trackChangedNodes = true;
			bool worked = true;
			
			AstarPath.RegisterSafeUpdate (delegate () {
				
				AstarPath.active.UpdateGraphs (guo);
				
				//Make sure graph updates are registered for update and not delayed for performance
				AstarPath.active.QueueGraphUpdates ();
				
				//Call thread safe callbacks, includes graph updates
				AstarPath.active.FlushGraphUpdates();
				
				//Check if all nodes are in the same area and that they are walkable, i.e that there are paths between all of them
				worked = worked && PathUtilities.IsPathPossible (nodes);
				
				//If it did not work, revert the GUO
				if (!worked || alwaysRevert) {
					guo.RevertFromBackup ();
					
					//The revert operation does not revert ALL nodes' area values, so we must flood fill again
					AstarPath.active.FloodFill ();
				}
			},true);
			
			//Force the thread safe callback to be called
			AstarPath.active.FlushThreadSafeCallbacks();
			
			//Disable tracking nodes, not strictly necessary, but will slightly reduce the cance that some user causes errors
			guo.trackChangedNodes = false;
			
			return worked;
		}
開發者ID:henryj41043,項目名稱:TheUnseen,代碼行數:52,代碼來源:GraphUpdateUtilities.cs

示例2: WillBlockPathInternal

	private bool WillBlockPathInternal (GraphUpdateObject ob, Node n1, Node n2) {
		if (n1.area != n2.area) return true;
		
		ob.trackChangedNodes = true;
		foreach (IUpdatableGraph g in astarData.GetUpdateableGraphs ()) {
				g.UpdateArea (ob);
		}
		
		FloodFill ();
		
		bool returnVal = n1.area != n2.area;
		
		ob.RevertFromBackup ();
		FloodFill ();
		
		return returnVal;
	}
開發者ID:pravusjif,項目名稱:PravusUnityTests,代碼行數:17,代碼來源:AstarPath.cs


注:本文中的Pathfinding.GraphUpdateObject.RevertFromBackup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。