async Task DelayedPerform() { var cancelSource = AutoPool <CancellationTokenSource> .Create(); this._cancelationSource = cancelSource; var token = cancelSource.Token; try { await Task.Delay((int)(this._delay * 1000), token); if (!token.IsCancellationRequested) { this.Perform(); AutoPool <CancellationTokenSource> .Dispose(cancelSource); } else { cancelSource.Dispose(); } } catch (TaskCanceledException) { } catch (System.Exception ex) { Debug.LogException(ex); } if (this._cancelationSource == cancelSource) { this._cancelationSource = null; } }
public void ClearAll() { foreach (var tileData in this._tiles.Values) { tileData.Clear(true); AutoPool <TileData> .Dispose(tileData); } this._tiles.Clear(); }
//Clears internal data including path, pools reuasable bits public void Clear() { UnityEngine.Profiling.Profiler.BeginSample("AStar.Clear"); foreach (var tileData in this._tilesData.Values) { AutoPool <TileData> .Dispose(tileData); } this._tilesData.Clear(); this._openedSorted.Clear(); this._opened.Clear(); this._closed.Clear(); this._path.Clear(); UnityEngine.Profiling.Profiler.EndSample(); }
public bool Clear(Vector2Int tile, bool shallowCleanup = false) { TileData tileData; if (this._tiles.TryGetValue(tile, out tileData)) { this._tiles.Remove(tile); tileData.Clear(shallowCleanup); AutoPool <TileData> .Dispose(tileData); return(true); } return(false); }
public void UnsetTileData <V>(Vector2Int tile, IDataIdentifier dataIdentifier) { TileData tileData; if (this._tiles.TryGetValue(tile, out tileData)) { if (tileData.UnsetValue <V>(dataIdentifier)) { if (!tileData.HasValues()) { this._tiles.Remove(tile); tileData.Clear(true); AutoPool <TileData> .Dispose(tileData); } } } }