/// <summary> /// Destroys the cached list after a drag completes. /// </summary> private void DoneDrag() { if (cachedTypes != null) { cachedTypes.Recycle(); cachedTypes = null; } }
/// <summary> /// Destroys the items in the set and recycles the list. /// </summary> /// <param name="destroy">The objects to destroy.</param> private static void DestroyAndRecycle(HashSetPool <GameObject, FilteredDestroyTool> . PooledHashSet destroy) { foreach (var gameObject in destroy) { Util.KDestroyGameObject(gameObject); } destroy.Recycle(); }
protected override void OnPaintCell(int cell, int distFromOrigin) { base.OnPaintCell(cell, distFromOrigin); recentlyAffectedCells.Add(cell); Game.CallbackInfo item = new Game.CallbackInfo(delegate { recentlyAffectedCells.Remove(cell); }, false); int index = Game.Instance.callbackManager.Add(item).index; int gameCell = cell; SimHashes new_element = SimHashes.Vacuum; CellElementEvent sandBoxTool = CellEventLogger.Instance.SandBoxTool; float mass = 0f; float temperature = 0f; int callbackIdx = index; SimMessages.ReplaceElement(gameCell, new_element, sandBoxTool, mass, temperature, Db.Get().Diseases.GetIndex(settings.Disease.IdHash), 0, callbackIdx); HashSetPool <GameObject, SandboxDestroyerTool> .PooledHashSet pooledHashSet = HashSetPool <GameObject, SandboxDestroyerTool> .Allocate(); foreach (Pickupable item2 in Components.Pickupables.Items) { if (Grid.PosToCell(item2) == cell) { pooledHashSet.Add(item2.gameObject); } } foreach (BuildingComplete item3 in Components.BuildingCompletes.Items) { if (Grid.PosToCell(item3) == cell) { pooledHashSet.Add(item3.gameObject); } } if ((Object)Grid.Objects[cell, 1] != (Object)null) { pooledHashSet.Add(Grid.Objects[cell, 1]); } foreach (Crop item4 in Components.Crops.Items) { if (Grid.PosToCell(item4) == cell) { pooledHashSet.Add(item4.gameObject); } } foreach (Health item5 in Components.Health.Items) { if (Grid.PosToCell(item5) == cell) { pooledHashSet.Add(item5.gameObject); } } foreach (GameObject item6 in pooledHashSet) { Util.KDestroyGameObject(item6); } pooledHashSet.Recycle(); }
private static string MakeModList(List <Event> events) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(); HashSetPool <string, Manager> .PooledHashSet pooledHashSet = HashSetPool <string, Manager> .Allocate(); foreach (Event @event in events) { Event current = @event; if (pooledHashSet.Add(current.mod.title)) { stringBuilder.AppendLine(current.mod.title); } } pooledHashSet.Recycle(); return(stringBuilder.ToString()); }
public void GetTopLevelItems(List <FileSystemItem> file_system_items) { HashSetPool <string, ZipFile> .PooledHashSet pooledHashSet = HashSetPool <string, ZipFile> .Allocate(); foreach (ZipEntry item in zipfile) { string[] array = FileSystem.Normalize(item.FileName).Split('/'); string text = array[0]; if (pooledHashSet.Add(text)) { file_system_items.Add(new FileSystemItem { name = text, type = ((1 >= array.Length) ? FileSystemItem.ItemType.File : FileSystemItem.ItemType.Directory) }); } } pooledHashSet.Recycle(); }
public void Sim33ms(float dt) { EntombedItemVisualizer component = Game.Instance.GetComponent <EntombedItemVisualizer>(); HashSetPool <Pickupable, EntombedItemManager> .PooledHashSet pooledHashSet = HashSetPool <Pickupable, EntombedItemManager> .Allocate(); foreach (Pickupable pickupable in pickupables) { if (CanEntomb(pickupable)) { pooledHashSet.Add(pickupable); } } pickupables.Clear(); foreach (Pickupable item in pooledHashSet) { int num = Grid.PosToCell(item); PrimaryElement component2 = item.GetComponent <PrimaryElement>(); SimHashes elementID = component2.ElementID; float mass = component2.Mass; float temperature = component2.Temperature; byte diseaseIdx = component2.DiseaseIdx; int diseaseCount = component2.DiseaseCount; Element element = Grid.Element[num]; if (elementID == element.id && mass > 0.0100000007f && Grid.Mass[num] + mass < element.maxMass) { SimMessages.AddRemoveSubstance(num, ElementLoader.FindElementByHash(elementID).idx, CellEventLogger.Instance.ElementConsumerSimUpdate, mass, temperature, diseaseIdx, diseaseCount, true, -1); } else { component.AddItem(num); cells.Add(num); elementIds.Add((int)elementID); masses.Add(mass); temperatures.Add(temperature); diseaseIndices.Add(diseaseIdx); diseaseCounts.Add(diseaseCount); } Util.KDestroyGameObject(item.gameObject); } pooledHashSet.Recycle(); }
private void Explode(Vector3 pos, int cell, int prev_cell, Element element) { PlayImpactSound(pos); Vector3 pos2 = pos; pos2.z = Grid.GetLayerZ(Grid.SceneLayer.FXFront2); Game.Instance.SpawnFX(explosionEffectHash, pos2, 0f); Substance substance = element.substance; int num = Random.Range(explosionOreCount.x, explosionOreCount.y + 1); Vector2 a = -velocity.normalized; Vector2 a2 = new Vector2(a.y, 0f - a.x); ListPool <ScenePartitionerEntry, Comet> .PooledList pooledList = ListPool <ScenePartitionerEntry, Comet> .Allocate(); GameScenePartitioner.Instance.GatherEntries((int)pos.x - 3, (int)pos.y - 3, 6, 6, GameScenePartitioner.Instance.pickupablesLayer, pooledList); foreach (ScenePartitionerEntry item in pooledList) { GameObject gameObject = (item.obj as Pickupable).gameObject; if (!((Object)gameObject.GetComponent <MinionIdentity>() != (Object)null) && gameObject.GetDef <CreatureFallMonitor.Def>() == null) { Vector2 vector = gameObject.transform.GetPosition() - pos; vector = vector.normalized; vector += new Vector2(0f, 0.55f); vector *= 0.5f * Random.Range(explosionSpeedRange.x, explosionSpeedRange.y); if (GameComps.Fallers.Has(gameObject)) { GameComps.Fallers.Remove(gameObject); } if (GameComps.Gravities.Has(gameObject)) { GameComps.Gravities.Remove(gameObject); } GameComps.Fallers.Add(gameObject, vector); } } pooledList.Recycle(); int num2 = splashRadius + 1; for (int i = -num2; i <= num2; i++) { for (int j = -num2; j <= num2; j++) { int num3 = Grid.OffsetCell(cell, j, i); if (Grid.IsValidCell(num3) && !destroyedCells.Contains(num3)) { float num4 = (1f - (float)Mathf.Abs(j) / (float)num2) * (1f - (float)Mathf.Abs(i) / (float)num2); if (num4 > 0f) { DamageTiles(num3, prev_cell, num4 * totalTileDamage * 0.5f); } } } } float mass = (num <= 0) ? 1f : (explosionMass / (float)num); float temperature = Random.Range(explosionTemperatureRange.x, explosionTemperatureRange.y); for (int k = 0; k < num; k++) { Vector2 normalized = (a + a2 * Random.Range(-1f, 1f)).normalized; Vector3 v = normalized * Random.Range(explosionSpeedRange.x, explosionSpeedRange.y); Vector3 a3 = normalized.normalized * 0.75f; a3 += new Vector3(0f, 0.55f, 0f); a3 += pos; GameObject go = substance.SpawnResource(a3, mass, temperature, byte.MaxValue, 0, false, false, false); if (GameComps.Fallers.Has(go)) { GameComps.Fallers.Remove(go); } GameComps.Fallers.Add(go, v); } if (addTiles > 0) { int depthOfElement = GetDepthOfElement(cell, element); float num5 = 1f - (float)(depthOfElement - addTilesMinHeight) / (float)(addTilesMaxHeight - addTilesMinHeight); int num6 = Mathf.Min(addTiles, Mathf.Clamp(Mathf.RoundToInt((float)addTiles * num5), 1, addTiles)); HashSetPool <int, Comet> .PooledHashSet pooledHashSet = HashSetPool <int, Comet> .Allocate(); HashSetPool <int, Comet> .PooledHashSet pooledHashSet2 = HashSetPool <int, Comet> .Allocate(); QueuePool <GameUtil.FloodFillInfo, Comet> .PooledQueue pooledQueue = QueuePool <GameUtil.FloodFillInfo, Comet> .Allocate(); pooledQueue.Enqueue(new GameUtil.FloodFillInfo { cell = cell, depth = 0 }); pooledQueue.Enqueue(new GameUtil.FloodFillInfo { cell = prev_cell, depth = 0 }); pooledQueue.Enqueue(new GameUtil.FloodFillInfo { cell = Grid.OffsetCell(cell, new CellOffset(-1, 0)), depth = 0 }); pooledQueue.Enqueue(new GameUtil.FloodFillInfo { cell = Grid.OffsetCell(cell, new CellOffset(1, 0)), depth = 0 }); GameUtil.FloodFillConditional(pooledQueue, SpawnTilesCellTest, pooledHashSet2, pooledHashSet, 10); float mass2 = (num6 <= 0) ? 1f : (addTileMass / (float)addTiles); UnstableGroundManager component = World.Instance.GetComponent <UnstableGroundManager>(); foreach (int item2 in pooledHashSet) { if (num6 <= 0) { break; } component.Spawn(item2, element, mass2, temperature, byte.MaxValue, 0); num6--; } pooledHashSet.Recycle(); pooledHashSet2.Recycle(); pooledQueue.Recycle(); } }