diff --git a/COTL_API/CustomFollowerCommand/CustomFollowerCommandPatches.cs b/COTL_API/CustomFollowerCommand/CustomFollowerCommandPatches.cs index 1085121b..7bb5b276 100644 --- a/COTL_API/CustomFollowerCommand/CustomFollowerCommandPatches.cs +++ b/COTL_API/CustomFollowerCommand/CustomFollowerCommandPatches.cs @@ -10,8 +10,8 @@ public partial class CustomFollowerCommandManager [HarmonyPrefix] private static bool CommandItem_GetTitle(CommandItem __instance, Follower follower, ref string __result) { - if (!CustomFollowerCommandList.ContainsKey(__instance.Command)) return true; - __result = CustomFollowerCommandList[__instance.Command].GetTitle(follower); + if (!CustomFollowerCommandList.TryGetValue(__instance.Command, out var value)) return true; + __result = value.GetTitle(follower); return false; } @@ -19,8 +19,8 @@ private static bool CommandItem_GetTitle(CommandItem __instance, Follower follow [HarmonyPrefix] private static bool CommandItem_IsAvailable(CommandItem __instance, Follower follower, ref bool __result) { - if (!CustomFollowerCommandList.ContainsKey(__instance.Command)) return true; - __result = CustomFollowerCommandList[__instance.Command].IsAvailable(follower); + if (!CustomFollowerCommandList.TryGetValue(__instance.Command, out var value)) return true; + __result = value.IsAvailable(follower); return false; } @@ -28,8 +28,8 @@ private static bool CommandItem_IsAvailable(CommandItem __instance, Follower fol [HarmonyPrefix] private static bool CommandItem_GetDescription(CommandItem __instance, Follower follower, ref string __result) { - if (!CustomFollowerCommandList.ContainsKey(__instance.Command)) return true; - __result = CustomFollowerCommandList[__instance.Command].GetDescription(follower); + if (!CustomFollowerCommandList.TryGetValue(__instance.Command, out var value)) return true; + __result = value.GetDescription(follower); return false; } @@ -37,8 +37,8 @@ private static bool CommandItem_GetDescription(CommandItem __instance, Follower [HarmonyPrefix] private static bool CommandItem_GetLockedDescription(CommandItem __instance, Follower follower, ref string __result) { - if (!CustomFollowerCommandList.ContainsKey(__instance.Command)) return true; - __result = CustomFollowerCommandList[__instance.Command].GetLockedDescription(follower); + if (!CustomFollowerCommandList.TryGetValue(__instance.Command, out var value)) return true; + __result = value.GetLockedDescription(follower); return false; } @@ -131,9 +131,9 @@ private static bool interaction_FollowerInteraction_OnFollowerCommandFinalized( private static bool FontImageNames_IconForCommand(FollowerCommands followerCommands, ref string __result) { - if (!CustomFollowerCommandList.ContainsKey(followerCommands)) return true; + if (!CustomFollowerCommandList.TryGetValue(followerCommands, out var value)) return true; - __result = CustomFollowerCommandList[followerCommands].CommandStringIcon(); + __result = value.CommandStringIcon(); return false; } diff --git a/COTL_API/CustomInventory/Patches/CustomInventoryPatches.cs b/COTL_API/CustomInventory/Patches/CustomInventoryPatches.cs index 1ba5c327..51a25950 100644 --- a/COTL_API/CustomInventory/Patches/CustomInventoryPatches.cs +++ b/COTL_API/CustomInventory/Patches/CustomInventoryPatches.cs @@ -15,9 +15,9 @@ public static partial class CustomItemManager [HarmonyPostfix] private static void ItemInfoCard_Configure(ItemInfoCard __instance, InventoryItem.ITEM_TYPE config) { - if (!CustomItemList.ContainsKey(config)) return; + if (!CustomItemList.TryGetValue(config, out var value)) return; - __instance._itemHeader.text = CustomItemList[config].Name(); + __instance._itemHeader.text = value.Name(); __instance._itemLore.text = CustomItemList[config].Lore(); __instance._itemDescription.text = CustomItemList[config].Description(); } @@ -62,8 +62,8 @@ where item.CanBeGivenToFollower private static bool FollowerCommandItems_GiftCommandItem_GetTitle(FollowerCommandItems.GiftCommandItem __instance, Follower follower, ref string __result) { - if (!CustomItemList.ContainsKey(__instance._itemType)) return true; - __result = CustomItemList[__instance._itemType].GiftTitle(follower); + if (!CustomItemList.TryGetValue(__instance._itemType, out var value)) return true; + __result = value.GiftTitle(follower); return false; } @@ -71,8 +71,8 @@ private static bool FollowerCommandItems_GiftCommandItem_GetTitle(FollowerComman [HarmonyPrefix] private static bool FontImageNames_GetIconByType(InventoryItem.ITEM_TYPE Type, ref string __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].InventoryStringIcon(); + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.InventoryStringIcon(); return false; } @@ -81,8 +81,8 @@ private static bool FontImageNames_GetIconByType(InventoryItem.ITEM_TYPE Type, r [HarmonyPrefix] private static bool InventoryIconMapping_GetImage(InventoryItem.ITEM_TYPE type, ref Sprite __result) { - if (!CustomItemList.ContainsKey(type)) return true; - __result = CustomItemList[type].InventoryIcon; + if (!CustomItemList.TryGetValue(type, out var value)) return true; + __result = value.InventoryIcon; return false; } @@ -90,8 +90,8 @@ private static bool InventoryIconMapping_GetImage(InventoryItem.ITEM_TYPE type, [HarmonyPrefix] private static bool InventoryItem_Name(InventoryItem.ITEM_TYPE Type, ref string __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].Name(); + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.Name(); return false; } @@ -99,8 +99,8 @@ private static bool InventoryItem_Name(InventoryItem.ITEM_TYPE Type, ref string [HarmonyPrefix] private static bool InventoryItem_LocalizedName(InventoryItem.ITEM_TYPE Type, ref string __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].LocalizedName(); + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.LocalizedName(); return false; } @@ -108,8 +108,8 @@ private static bool InventoryItem_LocalizedName(InventoryItem.ITEM_TYPE Type, re [HarmonyPrefix] private static bool InventoryItem_Description(InventoryItem.ITEM_TYPE Type, ref string __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].Description(); + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.Description(); return false; } @@ -117,8 +117,8 @@ private static bool InventoryItem_Description(InventoryItem.ITEM_TYPE Type, ref [HarmonyPrefix] private static bool InventoryItem_LocalizedDescription(InventoryItem.ITEM_TYPE Type, ref string __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].LocalizedDescription(); + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.LocalizedDescription(); return false; } @@ -126,8 +126,8 @@ private static bool InventoryItem_LocalizedDescription(InventoryItem.ITEM_TYPE T [HarmonyPrefix] private static bool InventoryItem_Lore(InventoryItem.ITEM_TYPE Type, ref string __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].Lore(); + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.Lore(); return false; } @@ -136,8 +136,8 @@ private static bool InventoryItem_Lore(InventoryItem.ITEM_TYPE Type, ref string private static bool InventoryItem_ItemCategory(InventoryItem.ITEM_TYPE type, ref InventoryItem.ITEM_CATEGORIES __result) { - if (!CustomItemList.ContainsKey(type)) return true; - __result = CustomItemList[type].ItemCategory; + if (!CustomItemList.TryGetValue(type, out var value)) return true; + __result = value.ItemCategory; return false; } @@ -145,8 +145,8 @@ private static bool InventoryItem_ItemCategory(InventoryItem.ITEM_TYPE type, [HarmonyPrefix] private static bool InventoryItem_GetSeedType(InventoryItem.ITEM_TYPE type, ref InventoryItem.ITEM_TYPE __result) { - if (!CustomItemList.ContainsKey(type)) return true; - __result = CustomItemList[type].SeedType; + if (!CustomItemList.TryGetValue(type, out var value)) return true; + __result = value.SeedType; return false; } @@ -154,8 +154,8 @@ private static bool InventoryItem_GetSeedType(InventoryItem.ITEM_TYPE type, ref [HarmonyPrefix] private static bool InventoryItem_FuelWeight(InventoryItem.ITEM_TYPE type, ref int __result) { - if (!CustomItemList.ContainsKey(type)) return true; - __result = CustomItemList[type].FuelWeight; + if (!CustomItemList.TryGetValue(type, out var value)) return true; + __result = value.FuelWeight; return false; } @@ -163,8 +163,8 @@ private static bool InventoryItem_FuelWeight(InventoryItem.ITEM_TYPE type, ref i [HarmonyPrefix] private static bool InventoryItem_FoodSatitation(InventoryItem.ITEM_TYPE Type, ref int __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].FoodSatitation; + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.FoodSatitation; return false; } @@ -172,8 +172,8 @@ private static bool InventoryItem_FoodSatitation(InventoryItem.ITEM_TYPE Type, r [HarmonyPrefix] private static bool InventoryItem_IsFish(InventoryItem.ITEM_TYPE Type, ref bool __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].IsFish; + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.IsFish; return false; } @@ -181,8 +181,8 @@ private static bool InventoryItem_IsFish(InventoryItem.ITEM_TYPE Type, ref bool [HarmonyPrefix] private static bool InventoryItem_IsFood(InventoryItem.ITEM_TYPE Type, ref bool __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].IsFood; + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.IsFood; return false; } @@ -190,8 +190,8 @@ private static bool InventoryItem_IsFood(InventoryItem.ITEM_TYPE Type, ref bool [HarmonyPrefix] private static bool InventoryItem_IsBigFish(InventoryItem.ITEM_TYPE Type, ref bool __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].IsBigFish; + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.IsBigFish; return false; } @@ -199,8 +199,8 @@ private static bool InventoryItem_IsBigFish(InventoryItem.ITEM_TYPE Type, ref bo [HarmonyPrefix] private static bool InventoryItem_CanBeGivenToFollower(InventoryItem.ITEM_TYPE Type, ref bool __result) { - if (!CustomItemList.ContainsKey(Type)) return true; - __result = CustomItemList[Type].CanBeGivenToFollower; + if (!CustomItemList.TryGetValue(Type, out var value)) return true; + __result = value.CanBeGivenToFollower; return false; } @@ -208,8 +208,8 @@ private static bool InventoryItem_CanBeGivenToFollower(InventoryItem.ITEM_TYPE T [HarmonyPrefix] private static bool InventoryItem_CapacityString(InventoryItem.ITEM_TYPE type, int minimum, ref string __result) { - if (!CustomItemList.ContainsKey(type)) return true; - __result = CustomItemList[type].CapacityString(minimum); + if (!CustomItemList.TryGetValue(type, out var value)) return true; + __result = value.CapacityString(minimum); return false; } @@ -228,9 +228,9 @@ private static bool InventoryItem_GiveToFollowerCallbacks(InventoryItem.ITEM_TYP if (!CustomItemList.ContainsKey(Type)) return true; __result = (follower, type, callback) => { - if (!CustomItemList.ContainsKey(type)) + if (!CustomItemList.TryGetValue(type, out var value)) InventoryItem.GiveToFollowerCallbacks(type)(follower, type, callback); - else CustomItemList[type].OnGiftTo(follower, callback); + else value.OnGiftTo(follower, callback); }; return false; } diff --git a/COTL_API/CustomInventory/Patches/CustomItemRefineryPatches.cs b/COTL_API/CustomInventory/Patches/CustomItemRefineryPatches.cs index 7ae9a3d7..587a4125 100644 --- a/COTL_API/CustomInventory/Patches/CustomItemRefineryPatches.cs +++ b/COTL_API/CustomInventory/Patches/CustomItemRefineryPatches.cs @@ -56,9 +56,9 @@ public static void UIRefineryMenuController_Show(ref UIMenuBase __instance) [HarmonyPatch(typeof(RefineryInfoCard), nameof(RefineryInfoCard.Configure), typeof(InventoryItem.ITEM_TYPE))] public static void RefineryInfoCard_Configure(ref RefineryInfoCard __instance, ref InventoryItem.ITEM_TYPE config) { - if (!CustomItemList.ContainsKey(config)) return; + if (!CustomItemList.TryGetValue(config, out var value)) return; - __instance._descriptionText.text = CustomItemList[config].LocalizedDescription(); + __instance._descriptionText.text = value.LocalizedDescription(); __instance._headerText.text = CustomItemList[config].LocalizedName(); } } \ No newline at end of file diff --git a/COTL_API/CustomLocalization/CustomLocalizationPatches.cs b/COTL_API/CustomLocalization/CustomLocalizationPatches.cs index 5b7ad8c0..104bae96 100644 --- a/COTL_API/CustomLocalization/CustomLocalizationPatches.cs +++ b/COTL_API/CustomLocalization/CustomLocalizationPatches.cs @@ -20,8 +20,8 @@ private static bool TermData_GetTranslation(ref string __result, TermData __inst } var lang = SettingsManager.Settings.Game.Language; - if (!LocalizationMap.ContainsKey(lang)) return true; - if (!LocalizationMap[lang].ContainsKey(__instance.Term)) return true; + if (!LocalizationMap.TryGetValue(lang, out var value)) return true; + if (!value.ContainsKey(__instance.Term)) return true; __result = LocalizationMap[lang][__instance.Term]; return false; @@ -32,8 +32,8 @@ private static bool TermData_GetTranslation(ref string __result, TermData __inst private static bool LanguageSourceData_TryGetTranslation(string term, ref string Translation, ref bool __result) { var lang = SettingsManager.Settings.Game.Language; - if (!LocalizationMap.ContainsKey(lang)) return true; - if (!LocalizationMap[lang].ContainsKey(term)) return true; + if (!LocalizationMap.TryGetValue(lang, out var value)) return true; + if (!value.ContainsKey(term)) return true; Translation = LocalizationMap[lang][term]; __result = true; diff --git a/COTL_API/CustomMission/CustomMissionPatches.cs b/COTL_API/CustomMission/CustomMissionPatches.cs index 05de5fde..add9121c 100644 --- a/COTL_API/CustomMission/CustomMissionPatches.cs +++ b/COTL_API/CustomMission/CustomMissionPatches.cs @@ -67,21 +67,21 @@ public static void MissionInfoCard_Configure(ref MissionInfoCard __instance, ref [HarmonyPatch(typeof(InventoryItem), nameof(InventoryItem.LocalizedName), typeof(InventoryItem.ITEM_TYPE))] public static void PrefixPatchesOne(ref InventoryItem.ITEM_TYPE Type) { - if (CustomMissionList.ContainsKey(Type)) Type = CustomMissionList[Type].RewardType; + if (CustomMissionList.TryGetValue(Type, out var value)) Type = value.RewardType; } [HarmonyPrefix] [HarmonyPatch(typeof(MissionaryManager), nameof(MissionaryManager.GetDurationDeterministic))] public static void MissionaryManager_GetDurationDeterministic(ref InventoryItem.ITEM_TYPE type) { - if (CustomMissionList.ContainsKey(type)) type = CustomMissionList[type].RewardType; + if (CustomMissionList.TryGetValue(type, out var value)) type = value.RewardType; } [HarmonyPrefix] [HarmonyPatch(typeof(Inventory), nameof(Inventory.GetItemQuantity), typeof(InventoryItem.ITEM_TYPE))] public static void Inventory_GetItemQuantity(ref InventoryItem.ITEM_TYPE itemType) { - if (CustomMissionList.ContainsKey(itemType)) itemType = CustomMissionList[itemType].RewardType; + if (CustomMissionList.TryGetValue(itemType, out var value)) itemType = value.RewardType; } [HarmonyPrefix] @@ -89,11 +89,11 @@ public static void Inventory_GetItemQuantity(ref InventoryItem.ITEM_TYPE itemTyp public static bool MissionaryManager_GetChance(ref float __result, InventoryItem.ITEM_TYPE type, FollowerInfo followerInfo, StructureBrain.TYPES missionaryType) { - if (!CustomMissionList.ContainsKey(type)) return true; + if (!CustomMissionList.TryGetValue(type, out var value)) return true; var baseChanceMultiplier = - MissionaryManager.GetBaseChanceMultiplier(CustomMissionList[type].RewardType, followerInfo); + MissionaryManager.GetBaseChanceMultiplier(value.RewardType, followerInfo); var random = new Random((int)(followerInfo.ID + CustomMissionList[type].RewardType)); __result = Mathf.Clamp( @@ -108,9 +108,9 @@ public static bool MissionaryManager_GetChance(ref float __result, InventoryItem [HarmonyPatch(typeof(MissionaryManager), nameof(MissionaryManager.GetRewardRange))] public static bool MissionaryManager_GetRewardRange(ref IntRange __result, InventoryItem.ITEM_TYPE type) { - if (!CustomMissionList.ContainsKey(type)) return true; + if (!CustomMissionList.TryGetValue(type, out var value)) return true; - __result = CustomMissionList[type].RewardRange; + __result = value.RewardRange; return false; } diff --git a/COTL_API/CustomObjectives/CustomObjectivePatches.cs b/COTL_API/CustomObjectives/CustomObjectivePatches.cs index e6503037..3a750eb0 100644 --- a/COTL_API/CustomObjectives/CustomObjectivePatches.cs +++ b/COTL_API/CustomObjectives/CustomObjectivePatches.cs @@ -1,4 +1,3 @@ -using System.Reflection.Emit; using HarmonyLib; using MMTools; diff --git a/COTL_API/CustomRelics/CustomRelicPatches.cs b/COTL_API/CustomRelics/CustomRelicPatches.cs index b26d01fc..d835f5df 100644 --- a/COTL_API/CustomRelics/CustomRelicPatches.cs +++ b/COTL_API/CustomRelics/CustomRelicPatches.cs @@ -39,9 +39,9 @@ private static bool LocalizationManager_GetTranslation(string Term, ref string _ [HarmonyPrefix] private static bool RelicData_GetChargeCategory(RelicType relicType, ref RelicChargeCategory __result) { - if (!CustomRelicDataList.ContainsKey(relicType)) return true; + if (!CustomRelicDataList.TryGetValue(relicType, out var value)) return true; - __result = CustomRelicDataList[relicType].GetChargeCategory(); + __result = value.GetChargeCategory(); return false; } @@ -50,9 +50,9 @@ private static bool RelicData_GetChargeCategory(RelicType relicType, ref RelicCh [HarmonyPrefix] private static bool RelicData_GetChargeCategory(RelicData relicData, ref RelicChargeCategory __result) { - if (!CustomRelicDataList.ContainsKey(relicData.RelicType)) return true; + if (!CustomRelicDataList.TryGetValue(relicData.RelicType, out var value)) return true; - __result = CustomRelicDataList[relicData.RelicType].GetChargeCategory(); + __result = value.GetChargeCategory(); return false; } diff --git a/COTL_API/CustomRituals/CustomRitualPatches.cs b/COTL_API/CustomRituals/CustomRitualPatches.cs index a4b03fe4..a3f5e09e 100644 --- a/COTL_API/CustomRituals/CustomRitualPatches.cs +++ b/COTL_API/CustomRituals/CustomRitualPatches.cs @@ -26,6 +26,7 @@ private static bool RitualItem_Configure(RitualItem __instance, UpgradeSystem.Ty if (!DataManager.Instance.UnlockedUpgrades.Contains(ritualType)) DataManager.Instance.UnlockedUpgrades.Add(ritualType); + return true; } @@ -33,9 +34,9 @@ private static bool RitualItem_Configure(RitualItem __instance, UpgradeSystem.Ty [HarmonyPrefix] private static bool DoctrineUpgradeSystem_GetIconForRitual(ref Sprite __result, UpgradeSystem.Type type) { - if (!CustomRitualList.ContainsKey(type)) return true; + if (!CustomRitualList.TryGetValue(type, out var value)) return true; - __result = CustomRitualList[type].Sprite; + __result = value.Sprite; return false; } @@ -43,9 +44,9 @@ private static bool DoctrineUpgradeSystem_GetIconForRitual(ref Sprite __result, [HarmonyPrefix] private static bool UpgradeSystem_GetCost(ref List __result, UpgradeSystem.Type Type) { - if (!CustomRitualList.ContainsKey(Type)) return true; + if (!CustomRitualList.TryGetValue(Type, out var value)) return true; - __result = CustomRitualList[Type].ItemCosts; + __result = value.ItemCosts; return false; } @@ -53,9 +54,9 @@ private static bool UpgradeSystem_GetCost(ref List __re [HarmonyPrefix] private static bool UpgradeSystem_GetLocalizedName(ref string __result, UpgradeSystem.Type Type) { - if (!CustomRitualList.ContainsKey(Type)) return true; + if (!CustomRitualList.TryGetValue(Type, out var value)) return true; - __result = CustomRitualList[Type].GetLocalizedName; + __result = value.GetLocalizedName; return false; } @@ -63,9 +64,9 @@ private static bool UpgradeSystem_GetLocalizedName(ref string __result, UpgradeS [HarmonyPrefix] private static bool UpgradeSystem_GetLocalizedDescription(ref string __result, UpgradeSystem.Type Type) { - if (!CustomRitualList.ContainsKey(Type)) return true; + if (!CustomRitualList.TryGetValue(Type, out var value)) return true; - __result = CustomRitualList[Type].GetLocalizedDescription; + __result = value.GetLocalizedDescription; return false; } @@ -73,9 +74,9 @@ private static bool UpgradeSystem_GetLocalizedDescription(ref string __result, U [HarmonyPrefix] private static bool UpgradeSystem_GetRitualFaithChange(ref float __result, UpgradeSystem.Type Type) { - if (!CustomRitualList.ContainsKey(Type)) return true; + if (!CustomRitualList.TryGetValue(Type, out var value)) return true; - __result = CustomRitualList[Type].FaithChange; + __result = value.FaithChange; return false; } @@ -83,9 +84,9 @@ private static bool UpgradeSystem_GetRitualFaithChange(ref float __result, Upgra [HarmonyPrefix] private static bool UpgradeSystem_GetRitualTrait(ref FollowerTrait.TraitType __result, UpgradeSystem.Type Type) { - if (!CustomRitualList.ContainsKey(Type)) return true; + if (!CustomRitualList.TryGetValue(Type, out var value)) return true; - __result = CustomRitualList[Type].RitualTrait; + __result = value.RitualTrait; return false; } @@ -94,10 +95,10 @@ private static bool UpgradeSystem_GetRitualTrait(ref FollowerTrait.TraitType __r private static void Interaction_TempleAltar_PerformRitual(Interaction_TempleAltar __instance, UpgradeSystem.Type RitualType) { - if (!CustomRitualList.ContainsKey(RitualType)) return; + if (!CustomRitualList.TryGetValue(RitualType, out var value)) return; var ritual = - (CustomRitual)__instance.gameObject.AddComponent(CustomRitualList[RitualType].GetType()); + (CustomRitual)__instance.gameObject.AddComponent(value.GetType()); ritual.UpgradeType = CustomRitualList[RitualType].UpgradeType; ritual.ModPrefix = CustomRitualList[RitualType].ModPrefix; __instance.CurrentRitual = ritual; @@ -108,10 +109,10 @@ private static void Interaction_TempleAltar_PerformRitual(Interaction_TempleAlta [HarmonyPostfix] private static void Interaction_TempleAltar_RitualOnEnd(Interaction_TempleAltar __instance, bool cancelled) { - if (!CustomRitualList.ContainsKey(__instance.RitualType)) return; + if (!CustomRitualList.TryGetValue(__instance.RitualType, out var value)) return; if (!cancelled) UpgradeSystem.AddCooldown(__instance.RitualType, - CustomRitualList[__instance.RitualType].Cooldown); + value.Cooldown); } } \ No newline at end of file diff --git a/COTL_API/CustomSkins/CustomFollowerSkin.cs b/COTL_API/CustomSkins/CustomFollowerSkin.cs index 1e541923..b1aaa7fc 100644 --- a/COTL_API/CustomSkins/CustomFollowerSkin.cs +++ b/COTL_API/CustomSkins/CustomFollowerSkin.cs @@ -27,4 +27,4 @@ public abstract class CustomFollowerSkin : CustomSkin } } }; -} +} \ No newline at end of file diff --git a/COTL_API/CustomSkins/CustomSkinManager.cs b/COTL_API/CustomSkins/CustomSkinManager.cs index cb32eb9c..493b900b 100644 --- a/COTL_API/CustomSkins/CustomSkinManager.cs +++ b/COTL_API/CustomSkins/CustomSkinManager.cs @@ -686,4 +686,4 @@ public static void ResetPlayerSkin() PlayerSkinOverride = null; SkinUtils.SkinToLoad = null; } -} +} \ No newline at end of file diff --git a/COTL_API/CustomSkins/CustomSkinPatches.cs b/COTL_API/CustomSkins/CustomSkinPatches.cs index 9ffddec0..31f62256 100644 --- a/COTL_API/CustomSkins/CustomSkinPatches.cs +++ b/COTL_API/CustomSkins/CustomSkinPatches.cs @@ -19,11 +19,9 @@ private static void SkeletonData_FindSkin(ref Skin? __result, SkeletonData __ins { if (__result != null) return; if (skinName.StartsWith("CustomTarotSkin_")) __result = CreateOrGetTarotSkinFromTemplate(__instance, skinName); - if (CustomFollowerSkins.ContainsKey(skinName)) - { - if (AlwaysUnlockedSkins[skinName]) DataManager.SetFollowerSkinUnlocked(skinName); - __result = CustomFollowerSkins[skinName]; - } + if (!CustomFollowerSkins.TryGetValue(skinName, out var skin)) return; + if (AlwaysUnlockedSkins[skinName]) DataManager.SetFollowerSkinUnlocked(skinName); + __result = skin; } [HarmonyPatch(typeof(Graphics), nameof(Graphics.CopyTexture), typeof(Texture), typeof(int), typeof(int), diff --git a/COTL_API/CustomStructures/CustomStructurePatches.cs b/COTL_API/CustomStructures/CustomStructurePatches.cs index 7f2e34f6..aa1b79e8 100644 --- a/COTL_API/CustomStructures/CustomStructurePatches.cs +++ b/COTL_API/CustomStructures/CustomStructurePatches.cs @@ -11,8 +11,8 @@ public partial class CustomStructureManager [HarmonyPrefix] private static bool StructureBrain_CreateBrain(ref StructureBrain __result, StructuresData data) { - if (!CustomStructureList.ContainsKey(data.Type)) return true; - var t = CustomStructureList[data.Type].GetType(); + if (!CustomStructureList.TryGetValue(data.Type, out var value)) return true; + var t = value.GetType(); var structureBrain = Activator.CreateInstance(t) as StructureBrain; StructureBrain.ApplyConfigToData(data); @@ -28,8 +28,8 @@ private static bool StructureBrain_CreateBrain(ref StructureBrain __result, Stru private static bool StructuresData_GetInfoByType(ref StructuresData __result, StructureBrain.TYPES Type, int variantIndex) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].StructuresData; + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.StructuresData; __result.PrefabPath ??= CustomStructureList[Type].PrefabPath; @@ -67,8 +67,8 @@ private static void StructuresData_GetUnlocked(StructureBrain.TYPES Types) private static bool TypeAndPlacementObjects_GetByType(ref TypeAndPlacementObject __result, StructureBrain.TYPES Type) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].GetTypeAndPlacementObject(); + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.GetTypeAndPlacementObject(); return false; } @@ -76,8 +76,8 @@ private static bool TypeAndPlacementObjects_GetByType(ref TypeAndPlacementObject [HarmonyPrefix] private static bool StructuresData_BuildDurationGameMinutes(ref int __result, StructureBrain.TYPES Type) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].BuildDurationMinutes; + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.BuildDurationMinutes; return false; } @@ -85,8 +85,8 @@ private static bool StructuresData_BuildDurationGameMinutes(ref int __result, St [HarmonyPrefix] private static bool StructuresData_GetCost(ref List __result, StructureBrain.TYPES Type) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].Cost; + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.Cost; return false; } @@ -94,8 +94,8 @@ private static bool StructuresData_GetCost(ref List __r [HarmonyPrefix] private static bool StructuresData_GetLocalizedNameStatic(StructureBrain.TYPES Type, ref string __result) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].GetLocalizedNameStatic(); + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.GetLocalizedNameStatic(); return false; } @@ -103,8 +103,8 @@ private static bool StructuresData_GetLocalizedNameStatic(StructureBrain.TYPES T [HarmonyPrefix] private static bool StructuresData_LocalizedName(StructureBrain.TYPES Type, ref string __result) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].LocalizedName(); + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.LocalizedName(); return false; } @@ -112,8 +112,8 @@ private static bool StructuresData_LocalizedName(StructureBrain.TYPES Type, ref [HarmonyPrefix] private static bool StructuresData_LocalizedDescription(StructureBrain.TYPES Type, ref string __result) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].LocalizedDescription(); + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.LocalizedDescription(); return false; } @@ -121,8 +121,8 @@ private static bool StructuresData_LocalizedDescription(StructureBrain.TYPES Typ [HarmonyPrefix] private static bool StructuresData_LocalizedPros(StructureBrain.TYPES Type, ref string __result) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].LocalizedPros(); + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.LocalizedPros(); return false; } @@ -130,8 +130,8 @@ private static bool StructuresData_LocalizedPros(StructureBrain.TYPES Type, ref [HarmonyPrefix] private static bool StructuresData_LocalizedCons(StructureBrain.TYPES Type, ref string __result) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].LocalizedCons(); + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.LocalizedCons(); return false; } @@ -139,8 +139,8 @@ private static bool StructuresData_LocalizedCons(StructureBrain.TYPES Type, ref [HarmonyPrefix] private static bool StructuresData_GetLocalizedName(StructuresData __instance, ref string __result) { - if (!CustomStructureList.ContainsKey(__instance.Type)) return true; - __result = CustomStructureList[__instance.Type].GetLocalizedName(); + if (!CustomStructureList.TryGetValue(__instance.Type, out var value)) return true; + __result = value.GetLocalizedName(); return false; } @@ -150,8 +150,8 @@ private static bool StructuresData_GetLocalizedName(StructuresData __instance, r private static bool StructuresData_GetLocalizedName(StructuresData __instance, bool plural, bool withArticle, bool definite, ref string __result) { - if (!CustomStructureList.ContainsKey(__instance.Type)) return true; - __result = CustomStructureList[__instance.Type].GetLocalizedName(plural, withArticle, definite); + if (!CustomStructureList.TryGetValue(__instance.Type, out var value)) return true; + __result = value.GetLocalizedName(plural, withArticle, definite); return false; } @@ -159,8 +159,8 @@ private static bool StructuresData_GetLocalizedName(StructuresData __instance, b [HarmonyPrefix] private static bool StructuresData_GetLocalizedDescription(StructuresData __instance, ref string __result) { - if (!CustomStructureList.ContainsKey(__instance.Type)) return true; - __result = CustomStructureList[__instance.Type].GetLocalizedDescription(); + if (!CustomStructureList.TryGetValue(__instance.Type, out var value)) return true; + __result = value.GetLocalizedDescription(); return false; } @@ -168,8 +168,8 @@ private static bool StructuresData_GetLocalizedDescription(StructuresData __inst [HarmonyPrefix] private static bool StructuresData_GetLocalizedLore(StructuresData __instance, ref string __result) { - if (!CustomStructureList.ContainsKey(__instance.Type)) return true; - __result = CustomStructureList[__instance.Type].GetLocalizedLore(); + if (!CustomStructureList.TryGetValue(__instance.Type, out var value)) return true; + __result = value.GetLocalizedLore(); return false; } @@ -177,8 +177,8 @@ private static bool StructuresData_GetLocalizedLore(StructuresData __instance, r [HarmonyPrefix] private static bool StructuresData_GetResearchCost(StructureBrain.TYPES Type, ref int __result) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].GetResearchCost(); + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.GetResearchCost(); return false; } @@ -186,8 +186,8 @@ private static bool StructuresData_GetResearchCost(StructureBrain.TYPES Type, re [HarmonyPrefix] private static bool StructuresData_RequiresTempleToBuild(StructureBrain.TYPES type, ref bool __result) { - if (!CustomStructureList.ContainsKey(type)) return true; - __result = CustomStructureList[type].RequiresTempleToBuild(); + if (!CustomStructureList.TryGetValue(type, out var value)) return true; + __result = value.RequiresTempleToBuild(); return false; } @@ -195,8 +195,8 @@ private static bool StructuresData_RequiresTempleToBuild(StructureBrain.TYPES ty [HarmonyPrefix] private static bool StructuresData_GetBuildOnlyOne(StructureBrain.TYPES Type, ref bool __result) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].GetBuildOnlyOne(); + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.GetBuildOnlyOne(); return false; } @@ -204,8 +204,8 @@ private static bool StructuresData_GetBuildOnlyOne(StructureBrain.TYPES Type, re [HarmonyPrefix] private static bool StructuresData_GetBuildSfx(StructureBrain.TYPES Type, ref string __result) { - if (!CustomStructureList.ContainsKey(Type)) return true; - __result = CustomStructureList[Type].GetBuildSfx(); + if (!CustomStructureList.TryGetValue(Type, out var value)) return true; + __result = value.GetBuildSfx(); return false; } @@ -213,8 +213,8 @@ private static bool StructuresData_GetBuildSfx(StructureBrain.TYPES Type, ref st [HarmonyPrefix] private static bool StructuresData_HiddenUntilUnlocked(StructureBrain.TYPES structure, ref bool __result) { - if (!CustomStructureList.ContainsKey(structure)) return true; - __result = CustomStructureList[structure].HiddenUntilUnlocked(); + if (!CustomStructureList.TryGetValue(structure, out var value)) return true; + __result = value.HiddenUntilUnlocked(); return false; } @@ -222,8 +222,8 @@ private static bool StructuresData_HiddenUntilUnlocked(StructureBrain.TYPES stru [HarmonyPrefix] private static bool StructuresData_CanBeFlipped(StructureBrain.TYPES type, ref bool __result) { - if (!CustomStructureList.ContainsKey(type)) return true; - __result = CustomStructureList[type].CanBeFlipped(); + if (!CustomStructureList.TryGetValue(type, out var value)) return true; + __result = value.CanBeFlipped(); return false; } @@ -231,8 +231,8 @@ private static bool StructuresData_CanBeFlipped(StructureBrain.TYPES type, ref b [HarmonyPostfix] private static void Structure_Start(Structure __instance) { - if (!CustomStructureList.ContainsKey(__instance.Type)) return; - if (CustomStructureList[__instance.Type].Interaction == null) return; + if (!CustomStructureList.TryGetValue(__instance.Type, out var value)) return; + if (value.Interaction == null) return; LogDebug("adding structure interaction " + CustomStructureList[__instance.Type].Interaction); diff --git a/COTL_API/CustomTarotCard/CustomTarotCardPatches.cs b/COTL_API/CustomTarotCard/CustomTarotCardPatches.cs index 9c460416..e4aba3f4 100644 --- a/COTL_API/CustomTarotCard/CustomTarotCardPatches.cs +++ b/COTL_API/CustomTarotCard/CustomTarotCardPatches.cs @@ -9,9 +9,9 @@ public partial class CustomTarotCardManager { private static void UpdateUIWeaponCard(UIWeaponCard UICard, TarotCards.TarotCard Card) { - if (!CustomTarotCardList.ContainsKey(Card.CardType)) return; + if (!CustomTarotCardList.TryGetValue(Card.CardType, out var value)) return; - UICard.NameText.text = CustomTarotCardList[Card.CardType].LocalisedName(); + UICard.NameText.text = value.LocalisedName(); UICard.SubtitleText.text = CustomTarotCardList[Card.CardType].LocalisedLore(); UICard.EffectText.text = CustomTarotCardList[Card.CardType].LocalisedDescription(); } @@ -46,9 +46,9 @@ private static void TarotInfoCard_Configure(TarotInfoCard __instance, TarotCards [HarmonyPrefix] private static bool TarotCards_GetCardCategory(TarotCards.Card Type, ref TarotCards.CardCategory __result) { - if (!CustomTarotCardList.ContainsKey(Type)) return true; + if (!CustomTarotCardList.TryGetValue(Type, out var value)) return true; - __result = CustomTarotCardList[Type].Category; + __result = value.Category; return false; } @@ -57,9 +57,9 @@ private static bool TarotCards_GetCardCategory(TarotCards.Card Type, ref TarotCa [HarmonyPrefix] private static bool TarotCards_LocalisedName(TarotCards.Card type, ref string __result) { - if (!CustomTarotCardList.ContainsKey(type)) return true; + if (!CustomTarotCardList.TryGetValue(type, out var value)) return true; - __result = CustomTarotCardList[type].LocalisedName(); + __result = value.LocalisedName(); return false; } @@ -68,9 +68,9 @@ private static bool TarotCards_LocalisedName(TarotCards.Card type, ref string __ [HarmonyPrefix] private static bool TarotCards_LocalisedName(TarotCards.Card Card, int upgradeIndex, ref string __result) { - if (!CustomTarotCardList.ContainsKey(Card)) return true; + if (!CustomTarotCardList.TryGetValue(Card, out var value)) return true; - __result = CustomTarotCardList[Card].LocalisedName(upgradeIndex); + __result = value.LocalisedName(upgradeIndex); return false; } @@ -79,9 +79,9 @@ private static bool TarotCards_LocalisedName(TarotCards.Card Card, int upgradeIn [HarmonyPrefix] private static bool TarotCards_LocalisedDescription(TarotCards.Card Type, ref string __result) { - if (!CustomTarotCardList.ContainsKey(Type)) return true; + if (!CustomTarotCardList.TryGetValue(Type, out var value)) return true; - __result = CustomTarotCardList[Type].LocalisedDescription(); + __result = value.LocalisedDescription(); return false; } @@ -90,9 +90,9 @@ private static bool TarotCards_LocalisedDescription(TarotCards.Card Type, ref st [HarmonyPrefix] private static bool TarotCards_LocalisedDescription(TarotCards.Card Type, int upgradeIndex, ref string __result) { - if (!CustomTarotCardList.ContainsKey(Type)) return true; + if (!CustomTarotCardList.TryGetValue(Type, out var value)) return true; - __result = CustomTarotCardList[Type].LocalisedDescription(upgradeIndex); + __result = value.LocalisedDescription(upgradeIndex); return false; } @@ -101,9 +101,9 @@ private static bool TarotCards_LocalisedDescription(TarotCards.Card Type, int up [HarmonyPrefix] private static bool TarotCards_LocalisedLore(TarotCards.Card Type, ref string __result) { - if (!CustomTarotCardList.ContainsKey(Type)) return true; + if (!CustomTarotCardList.TryGetValue(Type, out var value)) return true; - __result = CustomTarotCardList[Type].LocalisedLore(); + __result = value.LocalisedLore(); return false; } @@ -129,9 +129,9 @@ private static bool TarotCards_Skin(TarotCards.Card Type, ref string __result) [HarmonyPrefix] private static bool TarotCards_GetTarotCardWeight(TarotCards.Card cardType, ref int __result) { - if (!CustomTarotCardList.ContainsKey(cardType)) return true; + if (!CustomTarotCardList.TryGetValue(cardType, out var value)) return true; - __result = CustomTarotCardList[cardType].TarotCardWeight; + __result = value.TarotCardWeight; return false; } @@ -140,9 +140,9 @@ private static bool TarotCards_GetTarotCardWeight(TarotCards.Card cardType, ref [HarmonyPrefix] private static bool TarotCards_GetMaxTarotCardLevel(TarotCards.Card cardType, ref int __result) { - if (!CustomTarotCardList.ContainsKey(cardType)) return true; + if (!CustomTarotCardList.TryGetValue(cardType, out var value)) return true; - __result = CustomTarotCardList[cardType].MaxTarotCardLevel; + __result = value.MaxTarotCardLevel; return false; } @@ -151,9 +151,9 @@ private static bool TarotCards_GetMaxTarotCardLevel(TarotCards.Card cardType, re [HarmonyPrefix] private static bool TarotCards_AnimationSuffix(TarotCards.Card Type, ref string __result) { - if (!CustomTarotCardList.ContainsKey(Type)) return true; + if (!CustomTarotCardList.TryGetValue(Type, out var value)) return true; - __result = CustomTarotCardList[Type].AnimationSuffix; + __result = value.AnimationSuffix; return false; } @@ -162,9 +162,9 @@ private static bool TarotCards_AnimationSuffix(TarotCards.Card Type, ref string [HarmonyPrefix] private static bool TarotCards_IsCurseRelatedTarotCard(TarotCards.Card card, ref bool __result) { - if (!CustomTarotCardList.ContainsKey(card)) return true; + if (!CustomTarotCardList.TryGetValue(card, out var value)) return true; - __result = CustomTarotCardList[card].IsCursedRelated; + __result = value.IsCursedRelated; return false; } @@ -175,9 +175,9 @@ private static bool TarotCards_IsCurseRelatedTarotCard(TarotCards.Card card, ref [HarmonyPrefix] private static bool TarotCards_ApplyInstantEffects(TarotCards.TarotCard card) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - CustomTarotCardList[card.CardType].ApplyInstantEffects(card); + value.ApplyInstantEffects(card); return false; } @@ -186,9 +186,9 @@ private static bool TarotCards_ApplyInstantEffects(TarotCards.TarotCard card) [HarmonyPrefix] private static bool TarotCards_GetSpiritHeartCount(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetSpiritHeartCount(card); + __result = value.GetSpiritHeartCount(card); return false; } @@ -197,9 +197,9 @@ private static bool TarotCards_GetSpiritHeartCount(TarotCards.TarotCard card, re [HarmonyPrefix] private static bool TarotCards_GetSpiritAmmoCount(TarotCards.TarotCard card, ref int __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetSpiritAmmoCount(card); + __result = value.GetSpiritAmmoCount(card); return false; } @@ -208,9 +208,9 @@ private static bool TarotCards_GetSpiritAmmoCount(TarotCards.TarotCard card, ref [HarmonyPrefix] private static bool TarotCards_GetWeaponDamageMultiplerIncrease(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetWeaponDamageMultiplerIncrease(card); + __result = value.GetWeaponDamageMultiplerIncrease(card); return false; } @@ -219,9 +219,9 @@ private static bool TarotCards_GetWeaponDamageMultiplerIncrease(TarotCards.Tarot [HarmonyPrefix] private static bool TarotCards_GetCurseDamageMultiplerIncrease(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetCurseDamageMultiplerIncrease(card); + __result = value.GetCurseDamageMultiplerIncrease(card); return false; } @@ -230,9 +230,9 @@ private static bool TarotCards_GetCurseDamageMultiplerIncrease(TarotCards.TarotC [HarmonyPrefix] private static bool TarotCards_GetWeaponCritChanceIncrease(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetWeaponCritChanceIncrease(card); + __result = value.GetWeaponCritChanceIncrease(card); return false; } @@ -243,9 +243,9 @@ private static bool TarotCards_GetLootIncreaseModifier( TarotCards.TarotCard card, InventoryItem.ITEM_TYPE itemType, ref int __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetLootIncreaseModifier(card, itemType); + __result = value.GetLootIncreaseModifier(card, itemType); return false; } @@ -254,9 +254,9 @@ private static bool TarotCards_GetLootIncreaseModifier( [HarmonyPrefix] private static bool TarotCards_GetMovementSpeedMultiplier(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetMovementSpeedMultiplier(card); + __result = value.GetMovementSpeedMultiplier(card); return false; } @@ -265,9 +265,9 @@ private static bool TarotCards_GetMovementSpeedMultiplier(TarotCards.TarotCard c [HarmonyPrefix] private static bool TarotCards_GetAttackRateMultiplier(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetAttackRateMultiplier(card); + __result = value.GetAttackRateMultiplier(card); return false; } @@ -276,9 +276,9 @@ private static bool TarotCards_GetAttackRateMultiplier(TarotCards.TarotCard card [HarmonyPrefix] private static bool TarotCards_GetBlackSoulsMultiplier(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetBlackSoulsMultiplier(card); + __result = value.GetBlackSoulsMultiplier(card); return false; } @@ -287,9 +287,9 @@ private static bool TarotCards_GetBlackSoulsMultiplier(TarotCards.TarotCard card [HarmonyPrefix] private static bool TarotCards_GetHealChance(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetHealChance(card); + __result = value.GetHealChance(card); return false; } @@ -298,9 +298,9 @@ private static bool TarotCards_GetHealChance(TarotCards.TarotCard card, ref floa [HarmonyPrefix] private static bool TarotCards_GetNegateDamageChance(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetNegateDamageChance(card); + __result = value.GetNegateDamageChance(card); return false; } @@ -309,9 +309,9 @@ private static bool TarotCards_GetNegateDamageChance(TarotCards.TarotCard card, [HarmonyPrefix] private static bool TarotCards_GetDamageAllEnemiesAmount(TarotCards.TarotCard card, ref int __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetDamageAllEnemiesAmount(card); + __result = value.GetDamageAllEnemiesAmount(card); return false; } @@ -320,9 +320,9 @@ private static bool TarotCards_GetDamageAllEnemiesAmount(TarotCards.TarotCard ca [HarmonyPrefix] private static bool TarotCards_GetHealthAmountMultiplier(TarotCards.TarotCard card, ref int __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetHealthAmountMultiplier(card); + __result = value.GetHealthAmountMultiplier(card); return false; } @@ -331,9 +331,9 @@ private static bool TarotCards_GetHealthAmountMultiplier(TarotCards.TarotCard ca [HarmonyPrefix] private static bool TarotCards_GetAmmoEfficiency(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetAmmoEfficiency(card); + __result = value.GetAmmoEfficiency(card); return false; } @@ -342,9 +342,9 @@ private static bool TarotCards_GetAmmoEfficiency(TarotCards.TarotCard card, ref [HarmonyPrefix] private static bool TarotCards_GetBlackSoulsOnDamage(TarotCards.TarotCard card, ref int __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetBlackSoulsOnDamage(card); + __result = value.GetBlackSoulsOnDamage(card); return false; } @@ -353,10 +353,10 @@ private static bool TarotCards_GetBlackSoulsOnDamage(TarotCards.TarotCard card, [HarmonyPrefix] private static bool TarotCards_GetItemToDrop(TarotCards.TarotCard card, ref InventoryItem __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; #pragma warning disable CS8601 - __result = CustomTarotCardList[card.CardType].GetItemToDrop(card); + __result = value.GetItemToDrop(card); #pragma warning restore CS8601 return false; @@ -366,9 +366,9 @@ private static bool TarotCards_GetItemToDrop(TarotCards.TarotCard card, ref Inve [HarmonyPrefix] private static bool TarotCards_GetChanceOfGainingBlueHeart(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetChanceOfGainingBlueHeart(card); + __result = value.GetChanceOfGainingBlueHeart(card); return false; } @@ -377,9 +377,9 @@ private static bool TarotCards_GetChanceOfGainingBlueHeart(TarotCards.TarotCard [HarmonyPrefix] private static bool TarotCards_GetChanceForRelicsMultiplier(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetChanceForRelicsMultiplier(card); + __result = value.GetChanceForRelicsMultiplier(card); return false; } @@ -388,9 +388,9 @@ private static bool TarotCards_GetChanceForRelicsMultiplier(TarotCards.TarotCard [HarmonyPrefix] private static bool TarotCards_GetRelicChargeMultiplier(TarotCards.TarotCard card, ref float __result) { - if (!CustomTarotCardList.ContainsKey(card.CardType)) return true; + if (!CustomTarotCardList.TryGetValue(card.CardType, out var value)) return true; - __result = CustomTarotCardList[card.CardType].GetRelicChargeMultiplier(card); + __result = value.GetRelicChargeMultiplier(card); return false; } diff --git a/COTL_API/Debug/DebugFollowerSkin.cs b/COTL_API/Debug/DebugFollowerSkin.cs index 7280fb43..ea2ec125 100644 --- a/COTL_API/Debug/DebugFollowerSkin.cs +++ b/COTL_API/Debug/DebugFollowerSkin.cs @@ -66,4 +66,4 @@ public class DebugFollowerSkin : CustomFollowerSkin } } }; -} +} \ No newline at end of file diff --git a/COTL_API/Guid/TypeManager.cs b/COTL_API/Guid/TypeManager.cs index 520b8a05..e3b7f270 100644 --- a/COTL_API/Guid/TypeManager.cs +++ b/COTL_API/Guid/TypeManager.cs @@ -32,8 +32,8 @@ internal static void Replace(string key, Type value) private static string GetModIdFromAssembly(Assembly assembly) { - if (ModIds.ContainsKey(assembly.FullName)) - return ModIds[assembly.FullName]; + if (ModIds.TryGetValue(assembly.FullName, out var fromAssembly)) + return fromAssembly; foreach (var t in assembly.GetTypes()) {