// Token: 0x06000738 RID: 1848 RVA: 0x000468DC File Offset: 0x00044CDC public void ForceUpdate() { if (this.handlers.Count == 0) { throw new Exception("Cannot update graphs. No TileHandler. Do not call this method in Awake."); } if (this.updateIndex >= this.handlers.Count - 1) { this.updateIndex = -1; } this.updateIndex++; this.lastUpdateTime = Time.realtimeSinceStartup; TileHandler tileHandler = this.handlers[this.updateIndex]; List <NavmeshCut> allInRange = NavmeshCut.GetAllInRange(tileHandler.graph.forcedBounds); if (this.forcedReloadBounds.Count == 0) { int num = 0; for (int i = 0; i < allInRange.Count; i++) { if (allInRange[i].RequiresUpdate()) { num++; break; } } if (num == 0) { ListPool <NavmeshCut> .Release(allInRange); return; } } bool flag = tileHandler.StartBatchLoad(); for (int j = 0; j < this.forcedReloadBounds.Count; j++) { tileHandler.ReloadInBounds(this.forcedReloadBounds[j]); } for (int k = 0; k < allInRange.Count; k++) { if (allInRange[k].enabled) { if (allInRange[k].RequiresUpdate()) { tileHandler.ReloadInBounds(allInRange[k].LastBounds); tileHandler.ReloadInBounds(allInRange[k].GetBounds()); } } else if (allInRange[k].RequiresUpdate()) { tileHandler.ReloadInBounds(allInRange[k].LastBounds); } } for (int l = 0; l < allInRange.Count; l++) { if (allInRange[l].RequiresUpdate()) { allInRange[l].NotifyUpdated(); } } ListPool <NavmeshCut> .Release(allInRange); if (flag) { tileHandler.EndBatchLoad(); } this.forcedReloadBounds.Clear(); }
/** Checks all NavmeshCut instances and updates graphs if needed */ public void ForceUpdate() { if (handler == null) { throw new System.Exception("Cannot update graphs. No TileHandler. Do not call this method in Awake."); } lastUpdateTime = Time.realtimeSinceStartup; List <NavmeshCut> cuts = NavmeshCut.GetAll(); if (forcedReloadBounds.Count == 0) { int any = 0; for (int i = 0; i < cuts.Count; i++) { if (cuts[i].RequiresUpdate()) { any++; break; } } // Nothing needs to be done for now if (any == 0) { return; } } bool end = handler.StartBatchLoad(); //Debug.Log ("Updating..."); for (int i = 0; i < forcedReloadBounds.Count; i++) { handler.ReloadInBounds(forcedReloadBounds[i]); } forcedReloadBounds.Clear(); for (int i = 0; i < cuts.Count; i++) { if (cuts[i].enabled) { if (cuts[i].RequiresUpdate()) { handler.ReloadInBounds(cuts[i].LastBounds); handler.ReloadInBounds(cuts[i].GetBounds()); } } else if (cuts[i].RequiresUpdate()) { handler.ReloadInBounds(cuts[i].LastBounds); } } for (int i = 0; i < cuts.Count; i++) { if (cuts[i].RequiresUpdate()) { cuts[i].NotifyUpdated(); } } if (end) { handler.EndBatchLoad(); } }
/** Checks all NavmeshCut instances and updates graphs if needed. * \note This schedules updates for all necessary tiles to happen as soon as possible. * The pathfinding threads will continue to calculate the paths that they were calculating when this function * was called and then they will be paused and the graph updates will be carried out (this may be several frames into the * future and the graph updates themselves may take several frames to complete). * If you want to force all navmesh cutting to be completed in a single frame call this method * and immediately after call AstarPath.FlushWorkItems. */ public void ForceUpdate() { if (handler == null) { throw new System.Exception("Cannot update graphs. No TileHandler. Do not call the ForceUpdate method in Awake."); } lastUpdateTime = Time.realtimeSinceStartup; if (!handler.isValid) { // Check if the graph has been destroyed if (!handler.graph.exists) { UseSpecifiedHandler(null); return; } Debug.Log("TileHandler no longer matched the underlaying graph (possibly because of a graph scan). Recreating TileHandler..."); UseSpecifiedHandler(new TileHandler(handler.graph)); handler.CreateTileTypesFromGraph(); // Reload in huge bounds. This will cause all tiles to be updated. forcedReloadRects.Add(new IntRect(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue)); } // Get all navmesh cuts in the scene var allCuts = handler.cuts.AllItems; if (forcedReloadRects.Count == 0) { int any = 0; // Check if any navmesh cuts need updating for (var cut = allCuts; cut != null; cut = cut.next) { if (cut.obj.RequiresUpdate()) { any++; break; } } // Nothing needs to be done for now if (any == 0) { return; } } // Start batching tile updates which is good for performance // if we are updating a lot of them bool end = handler.StartBatchLoad(); for (int i = 0; i < forcedReloadRects.Count; i++) { handler.ReloadInBounds(forcedReloadRects[i]); } forcedReloadRects.Clear(); // Reload all bounds touching the previous bounds and current bounds // of navmesh cuts that have moved or changed in some other way for (var cut = allCuts; cut != null; cut = cut.next) { if (cut.obj.RequiresUpdate()) { // Make sure the tile where it was is updated handler.ReloadInBounds(cut.previousBounds); var newGraphSpaceBounds = cut.obj.GetBounds(handler.graph.transform); var newTouchingTiles = handler.graph.GetTouchingTilesInGraphSpace(newGraphSpaceBounds); handler.cuts.Move(cut.obj, newTouchingTiles); handler.ReloadInBounds(newTouchingTiles); } } // Notify navmesh cuts that they have been updated // This will cause RequiresUpdate to return false // until it is changed again for (var cut = allCuts; cut != null; cut = cut.next) { if (cut.obj.RequiresUpdate()) { cut.obj.NotifyUpdated(); } } if (end) { handler.EndBatchLoad(); } }
/** Checks all NavmeshCut instances and updates graphs if needed. * \note This schedules updates for all necessary tiles to happen as soon as possible. * The pathfinding threads will continue to calculate the paths that they were calculating when this function * was called and then they will be paused and the graph updates will be carried out (this may be several frames into the * future and the graph updates themselves may take several frames to complete). * If you want to force all navmesh cutting to be completed in a single frame call this method * and immediately after call AstarPath.FlushWorkItems. */ public void ForceUpdate() { if (handler == null) { throw new System.Exception("Cannot update graphs. No TileHandler. Do not call this method in Awake."); } lastUpdateTime = Time.realtimeSinceStartup; // Get all navmesh cuts in the scene List <NavmeshCut> cuts = NavmeshCut.GetAll(); if (!handler.isValid) { Debug.Log("TileHandler no longer matched the underlaying RecastGraph (possibly because of a graph scan). Recreating TileHandler..."); handler = new TileHandler(handler.graph); handler.CreateTileTypesFromGraph(); // Reload in huge bounds. Cannot use infinity because that will not convert well to integers // This will cause all tiles to be updated forcedReloadBounds.Add(new Bounds(Vector3.zero, new Vector3(10000000, 10000000, 10000000))); } if (forcedReloadBounds.Count == 0) { int any = 0; // Check if any navmesh cuts need updating for (int i = 0; i < cuts.Count; i++) { if (cuts[i].RequiresUpdate()) { any++; break; } } // Nothing needs to be done for now if (any == 0) { return; } } // Start batching tile updates which is good for performance // if we are updating a lot of them bool end = handler.StartBatchLoad(); // Reload all tiles which touch the bounds in the forcedReloadBounds list for (int i = 0; i < forcedReloadBounds.Count; i++) { handler.ReloadInBounds(forcedReloadBounds[i]); } forcedReloadBounds.Clear(); // Reload all bounds touching the previous bounds and current bounds // of navmesh cuts that have moved or changed in some other way for (int i = 0; i < cuts.Count; i++) { if (cuts[i].enabled) { if (cuts[i].RequiresUpdate()) { handler.ReloadInBounds(cuts[i].LastBounds); handler.ReloadInBounds(cuts[i].GetBounds()); } } else if (cuts[i].RequiresUpdate()) { // The navmesh cut has been disabled // Make sure the tile where it was is updated handler.ReloadInBounds(cuts[i].LastBounds); } } // Notify navmesh cuts that they have been updated // This will cause RequiresUpdate to return false // until it is changed again for (int i = 0; i < cuts.Count; i++) { if (cuts[i].RequiresUpdate()) { cuts[i].NotifyUpdated(); } } if (end) { handler.EndBatchLoad(); } }