internal static ModCraftTreeRoot CreateCustomCraftTreeAndType(string name, out CraftTree.Type craftTreeType) { EnumTypeCache cache = cacheManager.RequestCacheForTypeName(name); if (cache == null) { cache = new EnumTypeCache() { Name = name, Index = cacheManager.GetNextAvailableIndex() }; } if (cacheManager.IsIndexAvailable(cache.Index)) { cache.Index = cacheManager.GetNextAvailableIndex(); } craftTreeType = (CraftTree.Type)cache.Index; cacheManager.Add(craftTreeType, cache.Index, cache.Name); EnumPatcher.ClearCache(typeof(CraftTree.Type)); Logger.Log($"Successfully added CraftTree Type: '{name}' to Index: '{cache.Index}'", LogLevel.Debug); var customTreeRoot = new ModCraftTreeRoot(craftTreeType, name); CraftTreePatcher.CustomTrees[craftTreeType] = customTreeRoot; return(customTreeRoot); }
internal static PingType AddPingType(string name, Sprite sprite) { var cache = cacheManager.RequestCacheForTypeName(name) ?? new EnumTypeCache() { Name = name, Index = cacheManager.GetNextAvailableIndex() }; if (cacheManager.IsIndexAvailable(cache.Index)) { cache.Index = cacheManager.GetNextAvailableIndex(); } var pingType = (PingType)cache.Index; cacheManager.Add(pingType, cache.Index, cache.Name); SpritePatcher.AddSprite(SpriteManager.Group.Pings, pingType.ToString(), sprite); if (PingManager.sCachedPingTypeStrings.valueToString.ContainsKey(pingType) == false) { PingManager.sCachedPingTypeStrings.valueToString.Add(pingType, name); } if (PingManager.sCachedPingTypeTranslationStrings.valueToString.ContainsKey(pingType) == false) { PingManager.sCachedPingTypeTranslationStrings.valueToString.Add(pingType, name); } Logger.Log($"Successfully added PingType: '{name}' to Index: '{cache.Index}'", LogLevel.Debug); return(pingType); }
internal static Button EnsureButton(string name, string key, Device device) { if (!cacheManager.TryParse(name, out Button button)) { EnumTypeCache cache = cacheManager.RequestCacheForTypeName(name); if (cache == null) { cache = new EnumTypeCache() { Name = name, Index = cacheManager.GetNextAvailableIndex() }; } if (cacheManager.IsIndexAvailable(cache.Index)) { cache.Index = cacheManager.GetNextAvailableIndex(); } button = (Button)cache.Index; cacheManager.Add(button, cache.Index, cache.Name); RegisterNewButton(name, key, button, device); Logger.Log($"Successfully added Button: '{name}' to Index: '{cache.Index}'", LogLevel.Debug); return(button); } else { return(button); } }
internal static TechType AddTechType(string name) { EnumTypeCache cache = cacheManager.RequestCacheForTypeName(name) ?? new EnumTypeCache() { Name = name, Index = cacheManager.GetNextAvailableIndex() }; var techType = (TechType)cache.Index; cacheManager.Add(techType, cache.Index, cache.Name); // Direct access to private fields made possible by https://github.com/CabbageCrow/AssemblyPublicizer/ // See README.md for details. TechTypeExtensions.stringsNormal[techType] = name; TechTypeExtensions.stringsLowercase[techType] = name.ToLowerInvariant(); TechTypeExtensions.techTypesNormal[name] = techType; TechTypeExtensions.techTypesIgnoreCase[name] = techType; string intKey = cache.Index.ToString(); TechTypeExtensions.techTypeKeys[techType] = intKey; TechTypeExtensions.keyTechTypes[intKey] = techType; Logger.Log($"Successfully added Tech Type: '{name}' to Index: '{cache.Index}'", LogLevel.Debug); return(techType); }
internal static TechGroup AddTechGroup(string name) { EnumTypeCache cache = cacheManager.RequestCacheForTypeName(name) ?? new EnumTypeCache() { Name = name, Index = cacheManager.GetNextAvailableIndex() }; TechGroup techGroup = (TechGroup)cache.Index; cacheManager.Add(techGroup, cache.Index, cache.Name); if (!uGUI_BlueprintsTab.groups.Contains(techGroup)) { uGUI_BlueprintsTab.groups.Add(techGroup); } if (!CraftData.groups.ContainsKey(techGroup)) { CraftData.groups[techGroup] = new Dictionary <TechCategory, List <TechType> >(); } Logger.Log($"Successfully added TechGroup: '{name}' to Index: '{cache.Index}'", LogLevel.Debug); return(techGroup); }
internal static EquipmentType AddEquipmentType(string name) { var cache = cacheManager.RequestCacheForTypeName(name) ?? new EnumTypeCache() { Name = name, Index = cacheManager.GetNextAvailableIndex() }; var equipmentType = (EquipmentType)cache.Index; cacheManager.Add(equipmentType, cache.Index, cache.Name); Logger.Log($"Successfully added EquipmentType: '{name}' to Index: '{cache.Index}'", LogLevel.Debug); return(equipmentType); }
internal static CraftData.BackgroundType AddBackgroundType(string name) { EnumTypeCache cache = cacheManager.RequestCacheForTypeName(name) ?? new EnumTypeCache() { Name = name, Index = cacheManager.GetNextAvailableIndex() }; CraftData.BackgroundType backgroundType = (CraftData.BackgroundType)cache.Index; cacheManager.Add(backgroundType, cache.Index, cache.Name); Logger.Log($"Successfully added Backgroundtype: '{name}' to Index: '{cache.Index}'", LogLevel.Debug); return(backgroundType); }
internal static TechCategory AddTechCategory(string name) { EnumTypeCache cache = cacheManager.RequestCacheForTypeName(name) ?? new EnumTypeCache() { Name = name, Index = cacheManager.GetNextAvailableIndex() }; TechCategory TechCategory = (TechCategory)cache.Index; cacheManager.Add(TechCategory, cache.Index, cache.Name); Logger.Log($"Successfully added TechCategory: '{name}' to Index: '{cache.Index}'", LogLevel.Debug); return(TechCategory); }