// Token: 0x06000730 RID: 1840 RVA: 0x000465B0 File Offset: 0x000449B0 public void ForceUpdate() { if (this.handler == null) { throw new Exception("Cannot update graphs. No TileHandler. Do not call this method in Awake."); } this.lastUpdateTime = Time.realtimeSinceStartup; List <NavmeshCut> all = NavmeshCut.GetAll(); if (this.forcedReloadBounds.Count == 0) { int num = 0; for (int i = 0; i < all.Count; i++) { if (all[i].RequiresUpdate()) { num++; break; } } if (num == 0) { return; } } bool flag = this.handler.StartBatchLoad(); for (int j = 0; j < this.forcedReloadBounds.Count; j++) { this.handler.ReloadInBounds(this.forcedReloadBounds[j]); } this.forcedReloadBounds.Clear(); for (int k = 0; k < all.Count; k++) { if (all[k].enabled) { if (all[k].RequiresUpdate()) { this.handler.ReloadInBounds(all[k].LastBounds); this.handler.ReloadInBounds(all[k].GetBounds()); } } else if (all[k].RequiresUpdate()) { this.handler.ReloadInBounds(all[k].LastBounds); } } for (int l = 0; l < all.Count; l++) { if (all[l].RequiresUpdate()) { all[l].NotifyUpdated(); } } if (flag) { this.handler.EndBatchLoad(); } }
public void DiscardPending() { List<NavmeshCut> all = NavmeshCut.GetAll(); for (int i = 0; i < all.Count; i++) { if (all[i].RequiresUpdate()) { all[i].NotifyUpdated(); } } }
public void DiscardPending() { List <NavmeshCut> cuts = NavmeshCut.GetAll(); for (int i = 0; i < cuts.Count; i++) { if (cuts[i].RequiresUpdate()) { cuts[i].NotifyUpdated(); } } }
private bool ShouldRebuild() { List <NavmeshCut> all = NavmeshCut.GetAll(); if (this.forcedReloadBounds.Count != 0) { return(true); } for (int i = 0; i < all.Count; i++) { if (all[i].RequiresUpdate()) { return(true); } } return(false); }
public void Rebuild() { List <NavmeshCut> all = NavmeshCut.GetAll(); List <NavmeshCut> listView = new List <NavmeshCut>(); this.CreateHandlers(all); if (this.handler == null) { return; } AstarPath active = AstarPath.active; int num = active.astarData.graphs.Length + 1; for (int i = 0; i < all.Count; i++) { all[i].Check(); } listView.Clear(); for (int k = 0; k < all.Count; k++) { NavmeshCut navmeshCut = all[k]; listView.Add(navmeshCut); } this.handler.ReloadTiles(listView); AstarPath.active.astarData.InitRasterizer(); for (int l = 0; l < all.Count; l++) { if (all[l].RequiresUpdate()) { all[l].NotifyUpdated(); } } this.forcedReloadBounds.Clear(); }
public void ForceUpdate() { if (this.handler == null) { throw new Exception("Cannot update graphs. No TileHandler. Do not call this method in Awake."); } this.lastUpdateTime = Time.realtimeSinceStartup; List <NavmeshCut> all = NavmeshCut.GetAll(); if (!this.handler.isValid) { Debug.Log("TileHandler no longer matched the underlaying RecastGraph (possibly because of a graph scan). Recreating TileHandler..."); this.handler = new TileHandler(this.handler.graph); this.handler.CreateTileTypesFromGraph(); this.forcedReloadBounds.Add(new Bounds(Vector3.zero, new Vector3(1E+07f, 1E+07f, 1E+07f))); } if (this.forcedReloadBounds.Count == 0) { int num = 0; for (int m = 0; m < all.Count; m++) { if (all[m].RequiresUpdate()) { num++; break; } } if (num == 0) { return; } } bool flag = this.handler.StartBatchLoad(); for (int i = 0; i < this.forcedReloadBounds.Count; i++) { this.handler.ReloadInBounds(this.forcedReloadBounds[i]); } this.forcedReloadBounds.Clear(); for (int j = 0; j < all.Count; j++) { if (all[j].enabled) { if (all[j].RequiresUpdate()) { this.handler.ReloadInBounds(all[j].LastBounds); this.handler.ReloadInBounds(all[j].GetBounds()); } } else if (all[j].RequiresUpdate()) { this.handler.ReloadInBounds(all[j].LastBounds); } } for (int k = 0; k < all.Count; k++) { if (all[k].RequiresUpdate()) { all[k].NotifyUpdated(); } } if (flag) { this.handler.EndBatchLoad(); } }
/** 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 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(); } }