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 bool LoadTranslations() { string path = FileSystem.Normalize(label.install_path); if (!System.IO.Directory.Exists(path)) { return(false); } DirectoryInfo directoryInfo = new DirectoryInfo(path); HashSetPool <Localization.Locale, Mod> .PooledHashSet pooledHashSet = HashSetPool <Localization.Locale, Mod> .Allocate(); FileInfo[] files = directoryInfo.GetFiles(); foreach (FileInfo fileInfo in files) { if (!(fileInfo.Extension.ToLower() != ".po")) { string[] lines = File.ReadAllLines(fileInfo.FullName, Encoding.UTF8); pooledHashSet.Add(Localization.GetLocale(lines)); Dictionary <string, string> translated_strings = Localization.ExtractTranslatedStrings(lines, false); Localization.OverloadStrings(translated_strings); } } if (pooledHashSet.Count == 0) { return(false); } Localization.Locale new_locale = pooledHashSet.First(); if (!pooledHashSet.All((Localization.Locale locale) => locale == new_locale)) { return(false); } Localization.SetLocale(new_locale); Localization.SwapToLocalizedFont(new_locale.FontName); KPlayerPrefs.SetString(Localization.SELECTED_LANGUAGE_TYPE_KEY, 2.ToString()); KPlayerPrefs.SetString(Localization.SELECTED_LANGUAGE_CODE_KEY, new_locale.Code); return(true); }