using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JettsShopConfig.Patches; using MenuLib.MonoBehaviors; using Microsoft.CodeAnalysis; using Photon.Pun; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("JettsShopConfig")] [assembly: AssemblyDescription("Mod for configuring the R.E.P.O. Shop! Developed by Jettcodey.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Jettcodey")] [assembly: AssemblyProduct("JettsShopConfig")] [assembly: AssemblyCopyright("Copyright © Jettcodey 2025")] [assembly: ComVisible(false)] [assembly: Guid("dbba6712-df26-4bbf-97c5-b2737b0439bb")] [assembly: AssemblyFileVersion("1.3.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace JettsShopConfig { public static class ConfigManager { private static PluginInfo _mainPluginInfo; private static Dictionary _categoryConfigFiles = new Dictionary(); public static Dictionary DisplayNameToFullName = new Dictionary(); public static Dictionary ItemDefaultValues = new Dictionary(); public static Dictionary ItemTypeDefaultValues = new Dictionary(); public static Dictionary ItemHasCustomOverride = new Dictionary(); public static Dictionary> ItemMinAmountConfigs = new Dictionary>(); public static Dictionary> ItemMaxAmountConfigs = new Dictionary>(); public static Dictionary> ItemPriceConfigs = new Dictionary>(); public static Dictionary> ItemMultiplierConfigs = new Dictionary>(); public static Dictionary> ItemMaxPurchaseConfigs = new Dictionary>(); public static Dictionary> ItemMaxPurchaseAmountConfigs = new Dictionary>(); public static Dictionary> ItemTypeMinAmountConfigs = new Dictionary>(); public static Dictionary> ItemTypeMaxAmountConfigs = new Dictionary>(); public static Dictionary> ItemTypePriceConfigs = new Dictionary>(); public static Dictionary> ItemTypeMultiplierConfigs = new Dictionary>(); public static Dictionary> ItemTypeMaxPurchaseConfigs = new Dictionary>(); public static Dictionary> ItemTypeMaxPurchaseAmountConfigs = new Dictionary>(); public static bool IsInitialized { get; private set; } = false; public static ConfigEntry ConfigEnabled { get; private set; } public static ConfigEntry OverrideAllShopLogic { get; private set; } public static ConfigEntry UseItemTypeConfig { get; private set; } public static ConfigEntry ItemOverrideItemType { get; private set; } public static ConfigEntry DebugLogging { get; private set; } public static ConfigEntry CheckMode { get; private set; } public static ConfigEntry HasMigratedMSI { get; private set; } public static void Initialize(ConfigFile mainConfig, PluginInfo info) { _mainPluginInfo = info; ConfigEnabled = mainConfig.Bind("General", "Enabled", true, "Enable/disable Jett'sShopConfig"); OverrideAllShopLogic = mainConfig.Bind("General", "OverrideAllShopLogic", true, "Override all shop logic with custom configuration"); UseItemTypeConfig = mainConfig.Bind("General", "UseItemTypeConfig", true, "When enabled, item type config overrides individual item config."); ItemOverrideItemType = mainConfig.Bind("General", "ItemOverrideItemType", false, "Allows individual items to override type config if true."); DebugLogging = mainConfig.Bind("Dev General", "DebugLogging", false, "Enable basic debug logging"); CheckMode = mainConfig.Bind("Dev General", "Check Mode", false, "Enable verbose logging to check which mod is controlling item values."); HasMigratedMSI = mainConfig.Bind("Dev General", "MigratedMSIConfig", false, "Tracks if MoreShopItems config migration has occurred."); InitializeItemTypeConfigs(); HandleMoreShopItemsMigration(mainConfig); } private static ConfigFile GetConfigFileForCategory(string category) { if (_categoryConfigFiles.TryGetValue(category, out ConfigFile value)) { return value; } ConfigFile val = VirtualPluginManager.CreateVirtualConfig(category, _mainPluginInfo); _categoryConfigFiles[category] = val; return val; } private static string GetCategoryForItemType(itemType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected I4, but got Unknown return (int)type switch { 3 => "Upgrades", 7 => "Melees", 9 => "Guns", 6 => "Grenades", 11 => "Mines", 8 => "HealthPacks", 0 => "Drones", 1 => "Orbs", 5 => "Crystals", 10 => "Trackers", 13 => "Tools", 2 => "Cart", 12 => "PocketCart", 14 => "Vehicles", 15 => "Launchers", _ => "Misc", }; } private static void InitializeItemTypeConfigs() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Expected O, but got Unknown foreach (itemType value in Enum.GetValues(typeof(itemType))) { itemType val = value; string text = ((object)(itemType)(ref val)).ToString(); if (!(text == "player_upgrade")) { string categoryForItemType = GetCategoryForItemType(val); ConfigFile configFileForCategory = GetConfigFileForCategory(categoryForItemType); ItemTypeDefaultValues itemTypeDefaultValues = new ItemTypeDefaultValues { MinAmountInShop = -1, MaxAmountInShop = -1, Price = -1, Multiplier = 1f, MaxPurchase = false, MaxPurchaseAmount = 1 }; ItemTypeDefaultValues[val] = itemTypeDefaultValues; ItemTypeMinAmountConfigs[val] = configFileForCategory.Bind("ItemType " + text, "MinAmountInShop", itemTypeDefaultValues.MinAmountInShop, new ConfigDescription("Min", (AcceptableValueBase)(object)new AcceptableValueRange(-1, 10), Array.Empty())); ItemTypeMaxAmountConfigs[val] = configFileForCategory.Bind("ItemType " + text, "MaxAmountInShop", itemTypeDefaultValues.MaxAmountInShop, new ConfigDescription("Max", (AcceptableValueBase)(object)new AcceptableValueRange(-1, 20), Array.Empty())); ItemTypePriceConfigs[val] = configFileForCategory.Bind("ItemType " + text, "Price", itemTypeDefaultValues.Price, new ConfigDescription("Price", (AcceptableValueBase)(object)new AcceptableValueRange(-1, 999999), Array.Empty())); ItemTypeMultiplierConfigs[val] = configFileForCategory.Bind("ItemType " + text, "Multiplier", itemTypeDefaultValues.Multiplier, new ConfigDescription("Mult", (AcceptableValueBase)(object)new AcceptableValueRange(-1f, 100f), Array.Empty())); ItemTypeMaxPurchaseConfigs[val] = configFileForCategory.Bind("ItemType " + text, "MaxPurchase", itemTypeDefaultValues.MaxPurchase, new ConfigDescription("Limit", (AcceptableValueBase)null, Array.Empty())); ItemTypeMaxPurchaseAmountConfigs[val] = configFileForCategory.Bind("ItemType " + text, "MaxPurchaseAmount", itemTypeDefaultValues.MaxPurchaseAmount, new ConfigDescription("Limit Amount", (AcceptableValueBase)(object)new AcceptableValueRange(0, 999), Array.Empty())); } } } public static void InitializeItemConfigs() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Expected O, but got Unknown if (StatsManager.instance?.itemDictionary == null) { return; } foreach (KeyValuePair item in StatsManager.instance.itemDictionary) { string key = item.Key; Item value = item.Value; string displayName = GetDisplayName(key); string text = SanitizeConfigSection(displayName); if (!string.IsNullOrWhiteSpace(text)) { DisplayNameToFullName[text] = key; if (!ItemMinAmountConfigs.ContainsKey(text)) { string categoryForItemType = GetCategoryForItemType(value.itemType); ConfigFile configFileForCategory = GetConfigFileForCategory(categoryForItemType); ItemDefaultValues itemDefaultValues = new ItemDefaultValues { MinAmountInShop = -1, MaxAmountInShop = value.maxAmountInShop, Price = -1, Multiplier = 1f, MaxPurchase = value.maxPurchase, MaxPurchaseAmount = value.maxPurchaseAmount }; ItemDefaultValues[key] = itemDefaultValues; ItemMinAmountConfigs[text] = configFileForCategory.Bind(text ?? "", "MinAmountInShop", itemDefaultValues.MinAmountInShop, new ConfigDescription("Min", (AcceptableValueBase)(object)new AcceptableValueRange(-1, 10), Array.Empty())); ItemMaxAmountConfigs[text] = configFileForCategory.Bind(text ?? "", "MaxAmountInShop", itemDefaultValues.MaxAmountInShop, new ConfigDescription("Max", (AcceptableValueBase)(object)new AcceptableValueRange(-1, 20), Array.Empty())); ItemPriceConfigs[text] = configFileForCategory.Bind(text ?? "", "Price", itemDefaultValues.Price, new ConfigDescription("Price", (AcceptableValueBase)(object)new AcceptableValueRange(-1, 999999), Array.Empty())); ItemMultiplierConfigs[text] = configFileForCategory.Bind(text ?? "", "Multiplier", itemDefaultValues.Multiplier, new ConfigDescription("Mult", (AcceptableValueBase)(object)new AcceptableValueRange(-1f, 100f), Array.Empty())); ItemMaxPurchaseConfigs[text] = configFileForCategory.Bind(text ?? "", "MaxPurchase", itemDefaultValues.MaxPurchase, new ConfigDescription("Limit", (AcceptableValueBase)null, Array.Empty())); ItemMaxPurchaseAmountConfigs[text] = configFileForCategory.Bind(text ?? "", "MaxPurchaseAmount", itemDefaultValues.MaxPurchaseAmount, new ConfigDescription("Limit Amount", (AcceptableValueBase)(object)new AcceptableValueRange(0, 999), Array.Empty())); CheckAndUpdateItemOverrideStatus(text); } } } IsInitialized = true; if (DebugLogging.Value) { Plugin.Logger.LogInfo((object)$"Initialized configs for {StatsManager.instance.itemDictionary.Count} items."); } } private static void HandleMoreShopItemsMigration(ConfigFile mainConfig) { if (!Chainloader.PluginInfos.TryGetValue("Jettcodey.MoreShopItems", out var value)) { return; } bool shouldCopyValues = !HasMigratedMSI.Value; if (DebugLogging.Value || CheckMode.Value) { Plugin.Logger.LogInfo((object)$"[Migration] Detected MoreShopItems. Suppression Active. Copying values: {shouldCopyValues}"); } ConfigFile msiConfig = value.Instance.Config; int migratedCount = 0; MigrateInt("Upgrades", "Max Upgrades In Shop", (itemType)3); MigratePurchase("Upgrades", "Max Upgrade Purchase Amount", (itemType)3); MigrateInt("Weapons", "Max Melee Weapons In Shop", (itemType)7); MigratePurchase("Weapons", "Max Melee Weapon Purchase Amount", (itemType)7); MigrateInt("Weapons", "Max Guns In Shop", (itemType)9); MigratePurchase("Weapons", "Max Gun Purchase Amount", (itemType)9); MigrateInt("Weapons", "Max Grenades In Shop", (itemType)6); MigratePurchase("Weapons", "Max Grenade Purchase Amount", (itemType)6); MigrateInt("Weapons", "Max Mines In Shop", (itemType)11); MigratePurchase("Weapons", "Max Mine Purchase Amount", (itemType)11); MigrateInt("Health-Packs", "Max Health-Packs In Shop", (itemType)8); MigratePurchase("Health-Packs", "Max Health-Pack Purchase Amount", (itemType)8); MigrateInt("Utilities", "Max Drones In Shop", (itemType)0); MigratePurchase("Utilities", "Max Drone Purchase Amount", (itemType)0); MigrateInt("Utilities", "Max Orbs In Shop", (itemType)1); MigratePurchase("Utilities", "Max Orb Purchase Amount", (itemType)1); MigrateInt("Utilities", "Max Crystals In Shop", (itemType)5); MigratePurchase("Utilities", "Max Crystal Purchase Amount", (itemType)5); MigrateInt("Utilities", "Max Trackers In Shop", (itemType)10); MigratePurchase("Utilities", "Max Tracker Purchase Amount", (itemType)10); MigrateInt("Tools", "Max Tools In Shop", (itemType)13); MigratePurchase("Tools", "Max Tool Purchase Amount", (itemType)13); MigrateInt("Carts", "Max Carts In Shop", (itemType)2); MigratePurchase("Carts", "Max Cart Purchase Amount", (itemType)2); MigrateInt("Carts", "Max Pocket Carts In Shop", (itemType)12); MigratePurchase("Carts", "Max Pocket Cart Purchase Amount", (itemType)12); MigrateInt("Vehicles", "Max Vehicles In Shop", (itemType)14); MigratePurchase("Vehicles", "Max Vehicle Purchase Amount", (itemType)14); MigrateInt("Launchers", "Max Launchers In Shop", (itemType)15); MigratePurchase("Launchers", "Max Launcher Purchase Amount", (itemType)15); msiConfig.Save(); foreach (ConfigFile value5 in _categoryConfigFiles.Values) { value5.Save(); } if (shouldCopyValues) { HasMigratedMSI.Value = true; mainConfig.Save(); if (DebugLogging.Value || CheckMode.Value) { Plugin.Logger.LogInfo((object)"[Migration] Values copied from MoreShopItems. Future migrations disabled."); } } else if (DebugLogging.Value || CheckMode.Value) { Plugin.Logger.LogInfo((object)"[Migration] MoreShopItems entries suppressed (No copy performed)."); } void MigrateInt(string section, string key, itemType type) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) ConfigEntry val2 = default(ConfigEntry); if (msiConfig.TryGetEntry(section, key, ref val2)) { if (shouldCopyValues && ItemTypeMaxAmountConfigs.TryGetValue(type, out ConfigEntry value4)) { value4.Value = val2.Value; migratedCount++; } val2.Value = -1; msiConfig.Remove(((ConfigEntryBase)val2).Definition); } } void MigratePurchase(string section, string key, itemType type) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) ConfigEntry val = default(ConfigEntry); if (msiConfig.TryGetEntry(section, key, ref val)) { if (shouldCopyValues && ItemTypeMaxPurchaseConfigs.TryGetValue(type, out ConfigEntry value2) && ItemTypeMaxPurchaseAmountConfigs.TryGetValue(type, out ConfigEntry value3)) { if (val.Value > 0) { value2.Value = true; value3.Value = val.Value; } else { value2.Value = false; } migratedCount++; } val.Value = 0; msiConfig.Remove(((ConfigEntryBase)val).Definition); } } } public static string GetDisplayName(string fullItemName) { if (string.IsNullOrWhiteSpace(fullItemName)) { return fullItemName; } string input = fullItemName.Trim(); string pattern = "^(Modded[_\\s]*Item[_\\s]*|REPO[_\\s]*Roles[_\\s]*Upgrade[_\\s]*|Item[_\\s]*|Upgrade[_\\s]*|Modded[_\\s]*|REPO[_\\s]*|Roles[_\\s]*)+"; input = Regex.Replace(input, pattern, "", RegexOptions.IgnoreCase); input = Regex.Replace(input, "^[_\\s]+", ""); input = input.Replace('_', ' ').Trim(); return string.IsNullOrEmpty(input) ? fullItemName.Trim().Replace('_', ' ') : input; } public static string SanitizeConfigSection(string sectionName) { return string.IsNullOrWhiteSpace(sectionName) ? sectionName : sectionName.Trim(); } public static string GetFullItemName(string configSection) { if (DisplayNameToFullName.TryGetValue(configSection, out string value)) { return value; } if (StatsManager.instance?.itemDictionary != null && StatsManager.instance.itemDictionary.ContainsKey(configSection)) { return configSection; } return configSection; } public static void CheckAndUpdateItemOverrideStatus(string configSection) { string fullItemName = GetFullItemName(configSection); if (!ItemDefaultValues.TryGetValue(fullItemName, out ItemDefaultValues value)) { ItemHasCustomOverride[configSection] = false; return; } bool value2 = false; if (ItemMinAmountConfigs.TryGetValue(configSection, out ConfigEntry value3) && value3.Value != value.MinAmountInShop) { value2 = true; } if (ItemMaxAmountConfigs.TryGetValue(configSection, out ConfigEntry value4) && value4.Value != value.MaxAmountInShop) { value2 = true; } if (ItemPriceConfigs.TryGetValue(configSection, out ConfigEntry value5) && (float)Math.Abs(value5.Value - value.Price) > 0.001f) { value2 = true; } if (ItemMultiplierConfigs.TryGetValue(configSection, out ConfigEntry value6) && Math.Abs(value6.Value - value.Multiplier) > 0.001f) { value2 = true; } if (ItemMaxPurchaseConfigs.TryGetValue(configSection, out ConfigEntry value7) && value7.Value != value.MaxPurchase) { value2 = true; } if (ItemMaxPurchaseAmountConfigs.TryGetValue(configSection, out ConfigEntry value8) && value8.Value != value.MaxPurchaseAmount) { value2 = true; } ItemHasCustomOverride[configSection] = value2; } public static bool HasItemTypeConfigChanged(itemType itemType) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) if (!ItemTypeDefaultValues.TryGetValue(itemType, out ItemTypeDefaultValues value)) { return false; } bool result = false; if (ItemTypeMinAmountConfigs.TryGetValue(itemType, out ConfigEntry value2) && value2.Value != value.MinAmountInShop) { result = true; } if (ItemTypeMaxAmountConfigs.TryGetValue(itemType, out ConfigEntry value3) && value3.Value != value.MaxAmountInShop) { result = true; } if (ItemTypePriceConfigs.TryGetValue(itemType, out ConfigEntry value4) && (float)Math.Abs(value4.Value - value.Price) > 0.001f) { result = true; } if (ItemTypeMultiplierConfigs.TryGetValue(itemType, out ConfigEntry value5) && Math.Abs(value5.Value - value.Multiplier) > 0.001f) { result = true; } if (ItemTypeMaxPurchaseConfigs.TryGetValue(itemType, out ConfigEntry value6) && value6.Value != value.MaxPurchase) { result = true; } if (ItemTypeMaxPurchaseAmountConfigs.TryGetValue(itemType, out ConfigEntry value7) && value7.Value != value.MaxPurchaseAmount) { result = true; } return result; } public static int GetItemMinAmount(string itemName, Item item = null) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) string displayName = GetDisplayName(itemName); int num = -1; string arg = "Default/None"; if (UseItemTypeConfig.Value && (Object)(object)item != (Object)null) { bool value = default(bool); if (ItemOverrideItemType.Value && ItemHasCustomOverride.TryGetValue(displayName, out value) && value) { if (ItemMinAmountConfigs.TryGetValue(displayName, out ConfigEntry value2) && value2.Value != -1) { num = value2.Value; arg = "Item Override"; } } else if (HasItemTypeConfigChanged(item.itemType)) { ConfigEntry val = ItemTypeMinAmountConfigs[item.itemType]; if (val.Value != -1) { num = val.Value; arg = $"ItemType ({item.itemType})"; } } } if (num == -1 && ItemMinAmountConfigs.TryGetValue(displayName, out ConfigEntry value3)) { num = value3.Value; if (num != -1) { arg = "Item Config"; } } if (CheckMode.Value) { Plugin.Logger.LogInfo((object)$"[CheckMode] MinAmount for '{displayName}': {num}, Source: {arg}"); } return num; } public static int GetItemMaxAmount(string itemName, Item item = null) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) string displayName = GetDisplayName(itemName); int num = -1; string arg = "Default/None"; if (UseItemTypeConfig.Value && (Object)(object)item != (Object)null) { bool value = default(bool); if (ItemOverrideItemType.Value && ItemHasCustomOverride.TryGetValue(displayName, out value) && value) { if (ItemMaxAmountConfigs.TryGetValue(displayName, out ConfigEntry value2) && value2.Value != -1) { num = value2.Value; arg = "Item Override"; } } else if (HasItemTypeConfigChanged(item.itemType)) { ConfigEntry val = ItemTypeMaxAmountConfigs[item.itemType]; if (val.Value != -1) { num = val.Value; arg = $"ItemType ({item.itemType})"; } } } if (num == -1 && ItemMaxAmountConfigs.TryGetValue(displayName, out ConfigEntry value3)) { num = value3.Value; if (num != -1) { arg = "Item Config"; } } if (CheckMode.Value) { Plugin.Logger.LogInfo((object)$"[CheckMode] MaxAmount for '{displayName}': {num}, Source: {arg}"); } return num; } public static float GetItemPrice(string itemName, Item item = null) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) string displayName = GetDisplayName(itemName); float num = -1f; string arg = "Default/None"; if (UseItemTypeConfig.Value && (Object)(object)item != (Object)null) { bool value = default(bool); if (ItemOverrideItemType.Value && ItemHasCustomOverride.TryGetValue(displayName, out value) && value) { if (ItemPriceConfigs.TryGetValue(displayName, out ConfigEntry value2) && (float)value2.Value != -1f) { num = value2.Value; arg = "Item Override"; } } else if (HasItemTypeConfigChanged(item.itemType)) { ConfigEntry val = ItemTypePriceConfigs[item.itemType]; if ((float)val.Value != -1f) { num = val.Value; arg = $"ItemType ({item.itemType})"; } } } if (num == -1f && ItemPriceConfigs.TryGetValue(displayName, out ConfigEntry value3)) { num = value3.Value; if (num != -1f) { arg = "Item Config"; } } if (CheckMode.Value) { Plugin.Logger.LogInfo((object)$"[CheckMode] Price for '{displayName}': {num}, Source: {arg}"); } return num; } public static float GetItemMultiplier(string itemName, Item item = null) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) string displayName = GetDisplayName(itemName); float num = 1f; string arg = "Default (1.0)"; if (UseItemTypeConfig.Value && (Object)(object)item != (Object)null) { bool value = default(bool); if (ItemOverrideItemType.Value && ItemHasCustomOverride.TryGetValue(displayName, out value) && value) { if (ItemMultiplierConfigs.TryGetValue(displayName, out ConfigEntry value2) && value2.Value != -1f) { num = value2.Value; arg = "Item Override"; } } else if (HasItemTypeConfigChanged(item.itemType)) { ConfigEntry val = ItemTypeMultiplierConfigs[item.itemType]; if (val.Value != -1f && val.Value != 1f) { num = val.Value; arg = $"ItemType ({item.itemType})"; } } } if (Math.Abs(num - 1f) < 0.001f && ItemMultiplierConfigs.TryGetValue(displayName, out ConfigEntry value3) && value3.Value != -1f) { num = value3.Value; arg = "Item Config"; } if (CheckMode.Value) { Plugin.Logger.LogInfo((object)$"[CheckMode] Multiplier for '{displayName}': {num}, Source: {arg}"); } return num; } public static bool GetItemMaxPurchase(string itemName, Item item = null) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) string displayName = GetDisplayName(itemName); bool flag = false; string arg = "Default (False)"; if (UseItemTypeConfig.Value && (Object)(object)item != (Object)null && HasItemTypeConfigChanged(item.itemType) && ItemTypeMaxPurchaseConfigs.TryGetValue(item.itemType, out ConfigEntry value)) { flag = value.Value; arg = $"ItemType ({item.itemType})"; } bool value2 = default(bool); ConfigEntry value4; if (ItemOverrideItemType.Value && ItemHasCustomOverride.TryGetValue(displayName, out value2) && value2) { if (ItemMaxPurchaseConfigs.TryGetValue(displayName, out ConfigEntry value3)) { flag = value3.Value; arg = "Item Override"; } } else if (!UseItemTypeConfig.Value && ItemMaxPurchaseConfigs.TryGetValue(displayName, out value4)) { flag = value4.Value; arg = "Item Config"; } if (CheckMode.Value) { Plugin.Logger.LogInfo((object)$"[CheckMode] MaxPurchase for '{displayName}': {flag}, Source: {arg}"); } return flag; } public static int GetItemMaxPurchaseAmount(string itemName, Item item = null) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) string displayName = GetDisplayName(itemName); int num = 1; string text = "Default (1)"; if (UseItemTypeConfig.Value && (Object)(object)item != (Object)null && HasItemTypeConfigChanged(item.itemType) && ItemTypeMaxPurchaseAmountConfigs.TryGetValue(item.itemType, out ConfigEntry value)) { num = value.Value; text = $"ItemType ({item.itemType})"; } bool value2 = default(bool); ConfigEntry value4; if (ItemOverrideItemType.Value && ItemHasCustomOverride.TryGetValue(displayName, out value2) && value2) { if (ItemMaxPurchaseAmountConfigs.TryGetValue(displayName, out ConfigEntry value3)) { num = value3.Value; text = "Item Override"; } } else if (!UseItemTypeConfig.Value && ItemMaxPurchaseAmountConfigs.TryGetValue(displayName, out value4)) { num = value4.Value; text = "Item Config"; } if (CheckMode.Value || DebugLogging.Value) { Plugin.Logger.LogInfo((object)$"[CheckMode] '{displayName}': {num}, Source: {text}, maxPurchase={item?.maxPurchase}"); } return num; } } public class ItemDefaultValues { public int MinAmountInShop; public int MaxAmountInShop; public int Price; public float Multiplier; public bool MaxPurchase; public int MaxPurchaseAmount; } public class ItemTypeDefaultValues { public int MinAmountInShop; public int MaxAmountInShop; public int Price; public float Multiplier; public bool MaxPurchase; public int MaxPurchaseAmount; } [BepInPlugin("Jettcodey.JettsShopConfig", "JettsShopConfig", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__10 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if ((Object)(object)StatsManager.instance == (Object)null || StatsManager.instance.itemDictionary == null) { <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } if (StatsManager.instance.itemDictionary.Count == 0) { Logger.LogInfo((object)"Forcing StatsManager to load items..."); AccessTools.Method(typeof(StatsManager), "LoadItemsFromFolder", (Type[])null, (Type[])null)?.Invoke(StatsManager.instance, null); } ConfigManager.InitializeItemConfigs(); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Harmony _harmony; public static Plugin Instance { get; private set; } internal static ManualLogSource? Logger { get; private set; } private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)((Component)this).gameObject); Logger = ((BaseUnityPlugin)this).Logger; ConfigManager.Initialize(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Info); MSIConflictPatcher.FixConflicts(); _harmony = new Harmony("Jettcodey.JettsShopConfig"); _harmony.PatchAll(); Logger.LogInfo((object)"Plugin JettsShopConfig v1.3.0 loaded successfully."); ((MonoBehaviour)this).StartCoroutine(InitializeConfigsDelayed()); } [IteratorStateMachine(typeof(d__10))] private IEnumerator InitializeConfigsDelayed() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { <>4__this = this }; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Jettcodey.JettsShopConfig"; public const string PLUGIN_NAME = "JettsShopConfig"; public const string PLUGIN_VERSION = "1.3.0"; } internal static class VirtualPluginManager { [BepInPlugin("jetts.shop.config.virtual.dummy", "Jetts Virtual Config Dummy", "1.0.0")] internal class VirtualConfigPlugin : BaseUnityPlugin { public void SetConfig(ConfigFile config) { FieldInfo field = typeof(BaseUnityPlugin).GetField("k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(this, config); return; } FieldInfo fieldInfo = typeof(BaseUnityPlugin).GetFields(BindingFlags.Instance | BindingFlags.NonPublic).FirstOrDefault((FieldInfo f) => f.FieldType == typeof(ConfigFile)); if (fieldInfo != null) { fieldInfo.SetValue(this, config); } } } public static ConfigFile CreateVirtualConfig(string category, PluginInfo mainPluginInfo) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown string text = "Jettcodey.JettsShopConfig." + category.ToLower(); string text2 = "Jetts" + category + "Config"; string text3 = "1.3.0"; string text4 = Path.Combine(Paths.ConfigPath, "Jettcodey.JettsShopConfig." + category + ".cfg"); BepInPlugin val = new BepInPlugin(text, text2, text3); ConfigFile val2 = new ConfigFile(text4, true, val); GameObject val3 = new GameObject("_VirtualPlugin_" + category); Object.DontDestroyOnLoad((Object)(object)val3); ((Object)val3).hideFlags = (HideFlags)61; VirtualConfigPlugin virtualConfigPlugin = val3.AddComponent(); virtualConfigPlugin.SetConfig(val2); AddVirtualPlugin((BaseUnityPlugin)(object)virtualConfigPlugin, text, text2, text3); return val2; } private static void AddVirtualPlugin(BaseUnityPlugin pluginInstance, string guid, string name, string version) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Type typeFromHandle = typeof(PluginInfo); PluginInfo val = (PluginInfo)FormatterServices.GetUninitializedObject(typeFromHandle); BepInPlugin value = new BepInPlugin(guid, name, version); SetPrivateProperty(val, "Metadata", value); SetPrivateProperty(val, "Instance", pluginInstance); SetPrivateProperty(val, "Location", Assembly.GetExecutingAssembly().Location); SetPrivateProperty(pluginInstance, "Info", val); if (!Chainloader.PluginInfos.ContainsKey(guid)) { Chainloader.PluginInfos.Add(guid, val); Plugin.Logger.LogInfo((object)("Added Virtual Plugin: " + name + " (" + guid + ")")); } } private static void SetPrivateProperty(object target, string propertyName, object value) { PropertyInfo property = target.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { property.SetValue(target, value); return; } FieldInfo field = target.GetType().GetField("<" + propertyName + ">k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(target, value); } } } } namespace JettsShopConfig.Patches { [HarmonyPatch] internal class MENULibPatches { [HarmonyPatch(typeof(REPOLabel))] [HarmonyPatch("Awake")] [HarmonyPostfix] private static void REPOLabel_Awake_Postfix(REPOLabel __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.labelTMP == (Object)null)) { ((TMP_Text)__instance.labelTMP).enableAutoSizing = true; ((TMP_Text)__instance.labelTMP).fontSizeMin = 20f; ((TMP_Text)__instance.labelTMP).fontSizeMax = 30f; ((TMP_Text)__instance.labelTMP).characterWidthAdjustment = 50f; } } [HarmonyPatch(typeof(REPOLabel))] [HarmonyPatch("Start")] [HarmonyPostfix] private static void REPOLabel_Start_Postfix(REPOLabel __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.labelTMP == (Object)null)) { ((TMP_Text)__instance.labelTMP).ForceMeshUpdate(false, false); AdjustFontSizeIfNeeded(__instance); } } private static void AdjustFontSizeIfNeeded(REPOLabel label) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)label.labelTMP == (Object)null)) { Bounds textBounds = ((TMP_Text)label.labelTMP).textBounds; Rect rect = ((TMP_Text)label.labelTMP).rectTransform.rect; float width = ((Rect)(ref rect)).width; if (((Bounds)(ref textBounds)).size.x > width * 1.15f) { float num = width / ((Bounds)(ref textBounds)).size.x; float num2 = Mathf.Lerp(((TMP_Text)label.labelTMP).fontSizeMin, ((TMP_Text)label.labelTMP).fontSize, num * 0.9f); ((TMP_Text)label.labelTMP).fontSize = Mathf.Max(((TMP_Text)label.labelTMP).fontSizeMin, num2); ((TMP_Text)label.labelTMP).ForceMeshUpdate(false, false); } } } } internal static class MSIConflictPatcher { private const string MSI_GUID = "Jettcodey.MoreShopItems"; private const string MSI_HARMONY_ID = "MoreShopItems"; public static void FixConflicts() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if (Chainloader.PluginInfos.ContainsKey("Jettcodey.MoreShopItems")) { Plugin.Logger.LogInfo((object)"[MSIConflictPatcher] MoreShopItems detected. Unpatching conflicting logic..."); Harmony harmony = new Harmony("Jettcodey.JettsShopConfig"); UnpatchMethod(harmony, typeof(StatsManager), "ItemPurchase"); UnpatchMethod(harmony, typeof(ShopManager), "ShoppingListItemAdd"); UnpatchMethod(harmony, typeof(ShopManager), "ShoppingListItemRemove"); UnpatchMethod(harmony, typeof(ShopManager), "GetAllItemsFromStatsManager"); } } private static void UnpatchMethod(Harmony harmony, Type targetType, string methodName) { try { MethodInfo methodInfo = AccessTools.Method(targetType, methodName, (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Unpatch((MethodBase)methodInfo, (HarmonyPatchType)0, "MoreShopItems"); Plugin.Logger.LogInfo((object)("[MSIConflictPatcher] Unpatched " + targetType.Name + "." + methodName + " from MoreShopItems")); } } catch (Exception ex) { Plugin.Logger.LogWarning((object)("[MSIConflictPatcher] Failed to unpatch " + targetType.Name + "." + methodName + ": " + ex.Message)); } } } [HarmonyPatch(typeof(PunManager))] internal static class PunManagerPatch { [HarmonyPrefix] [HarmonyPatch("TruckPopulateItemVolumes")] private static void RemoveNullValues() { if ((Object)(object)ItemManager.instance != (Object)null && (SemiFunc.IsMasterClient() || !SemiFunc.IsMultiplayer())) { Predicate match = (ItemVolume volume) => (Object)(object)volume == (Object)null; ItemManager.instance.itemVolumes.RemoveAll(match); } } } [HarmonyPatch(typeof(ShopManager))] internal class ShopManagerPatches { [HarmonyPatch("GetAllItemsFromStatsManager")] [HarmonyPrefix] private static bool ApplyChangesToItems(ShopManager __instance) { //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Invalid comparison between Unknown and I4 //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Invalid comparison between Unknown and I4 //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Invalid comparison between Unknown and I4 if (!ConfigManager.ConfigEnabled.Value || !ConfigManager.OverrideAllShopLogic.Value) { return true; } if (!ConfigManager.IsInitialized) { if (ConfigManager.DebugLogging.Value) { Plugin.Logger.LogWarning((object)"ConfigManager is not initialized. Running vanilla logic."); } return true; } try { if (SemiFunc.IsNotMasterClient()) { return false; } __instance.potentialItems.Clear(); __instance.potentialItemConsumables.Clear(); __instance.potentialItemUpgrades.Clear(); __instance.potentialItemHealthPacks.Clear(); __instance.potentialSecretItems.Clear(); CustomPriceManager.Reset(); Dictionary dictionary = new Dictionary(); foreach (KeyValuePair item in StatsManager.instance.itemDictionary) { string key = item.Key; Item value = item.Value; if (value.disabled) { continue; } string displayName = ConfigManager.GetDisplayName(key); ConfigManager.CheckAndUpdateItemOverrideStatus(displayName); int maxAmountInShop = value.maxAmountInShop; int maxPurchaseAmount = value.maxPurchaseAmount; bool maxPurchase = value.maxPurchase; if (ConfigManager.ItemDefaultValues.TryGetValue(key, out ItemDefaultValues value2)) { maxAmountInShop = value2.MaxAmountInShop; maxPurchaseAmount = value2.MaxPurchaseAmount; maxPurchase = value2.MaxPurchase; } int num = ConfigManager.GetItemMinAmount(key, value); int num2 = ConfigManager.GetItemMaxAmount(key, value); float itemPrice = ConfigManager.GetItemPrice(key, value); float itemMultiplier = ConfigManager.GetItemMultiplier(key, value); bool itemMaxPurchase = ConfigManager.GetItemMaxPurchase(key, value); int itemMaxPurchaseAmount = ConfigManager.GetItemMaxPurchaseAmount(key, value); if (num == -1) { num = 0; } if (num2 == -1) { num2 = maxAmountInShop; } num = Mathf.Clamp(num, 0, 10); num2 = Mathf.Clamp(num2, 0, 20); if (num2 < num) { num2 = num; } if (num2 != maxAmountInShop) { value.maxAmount = num2; value.maxAmountInShop = num2; } else { value.maxAmount = maxAmountInShop; value.maxAmountInShop = maxAmountInShop; } if (itemMaxPurchaseAmount != maxPurchaseAmount || itemMaxPurchase != maxPurchase) { value.maxPurchase = itemMaxPurchase; value.maxPurchaseAmount = itemMaxPurchaseAmount; } else { value.maxPurchase = maxPurchase; value.maxPurchaseAmount = maxPurchaseAmount; } if (value.maxPurchase) { value.maxAmount = Mathf.Max(value.maxAmount, value.maxPurchaseAmount); } if (num2 <= 0) { continue; } int num3 = SemiFunc.StatGetItemsPurchased(((Object)value).name); bool flag = true; if (num3 >= num2 || (itemMaxPurchase && StatsManager.instance.GetItemsUpgradesPurchasedTotal(((Object)value).name) >= itemMaxPurchaseAmount)) { flag = false; if (ConfigManager.DebugLogging.Value) { Plugin.Logger.LogInfo((object)("Skipping " + key + ": Limit Reached.")); } } if (!flag) { continue; } float num4 = 0f; if (itemPrice >= 0f) { num4 = Mathf.Clamp(itemPrice, 0f, 999999f); CustomPriceManager.FixedPrices[displayName] = num4; } else { float num5 = value.value.valueMax / 1000f * __instance.itemValueMultiplier; if ((int)value.itemType == 3) { num5 = __instance.UpgradeValueGet(num5, value); } else if ((int)value.itemType == 8) { num5 = __instance.HealthPackValueGet(num5); } else if ((int)value.itemType == 5) { num5 = __instance.CrystalValueGet(num5); } itemMultiplier = Mathf.Clamp(itemMultiplier, -1f, 100f); if (itemMultiplier == -1f) { itemMultiplier = 1f; } num4 = num5 * itemMultiplier; num4 = Mathf.Clamp(num4, 0f, 999999f); CustomPriceManager.Multipliers[displayName] = itemMultiplier; } if (num4 > (float)__instance.totalCurrency && Random.Range(0, 100) >= 25) { continue; } int num6 = Mathf.Min(num2 - num3, num2); int num7 = Random.Range(num, Mathf.Min(num6, num2) + 1); if (num7 > 0) { for (int i = 0; i < num7; i++) { AddItemToAppropriateList(__instance, value); dictionary[key] = dictionary.GetValueOrDefault(key) + 1; } } } ListExtension.Shuffle((IList)__instance.potentialItems); ListExtension.Shuffle((IList)__instance.potentialItemConsumables); ListExtension.Shuffle((IList)__instance.potentialItemUpgrades); ListExtension.Shuffle((IList)__instance.potentialItemHealthPacks); foreach (List value3 in __instance.potentialSecretItems.Values) { ListExtension.Shuffle((IList)value3); } return false; } catch (Exception arg) { Plugin.Logger.LogError((object)$"Error in custom shop logic: {arg}"); return true; } } private static void AddItemToAppropriateList(ShopManager shopManager, Item item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Invalid comparison between Unknown and I4 if ((int)item.itemSecretShopType > 0) { if (!shopManager.potentialSecretItems.ContainsKey(item.itemSecretShopType)) { shopManager.potentialSecretItems.Add(item.itemSecretShopType, new List()); } shopManager.potentialSecretItems[item.itemSecretShopType].Add(item); } else if ((int)item.itemType == 3) { shopManager.potentialItemUpgrades.Add(item); } else if ((int)item.itemType == 8) { shopManager.potentialItemHealthPacks.Add(item); } else if ((int)item.itemType == 5) { shopManager.potentialItemConsumables.Add(item); } else { shopManager.potentialItems.Add(item); } } [HarmonyPatch("UpgradeValueGet")] [HarmonyPrefix] private static bool UpgradeValueGet_Prefix(ShopManager __instance, float _value, Item item, ref float __result) { if (!ConfigManager.ConfigEnabled.Value) { return true; } try { float multiplierForItem = CustomPriceManager.GetMultiplierForItem(((Object)item).name, item); float num = __instance.upgradeValueIncrease * multiplierForItem; _value -= _value * 0.1f * (float)(GameDirector.instance.PlayerList.Count - 1); _value += _value * num * (float)StatsManager.instance.GetItemsUpgradesPurchased(((Object)item).name); __result = Mathf.Ceil(_value); __result = Mathf.Clamp(__result, 0f, 999999f); return false; } catch { return true; } } [HarmonyPatch("HealthPackValueGet")] [HarmonyPrefix] private static bool HealthPackValueGet_Prefix(ShopManager __instance, float _value, ref float __result) { if (!ConfigManager.ConfigEnabled.Value) { return true; } try { float multiplierForItemType = CustomPriceManager.GetMultiplierForItemType((itemType)8); float num = __instance.healthPackValueIncrease * multiplierForItemType; int num2 = Mathf.Min(RunManager.instance.levelsCompleted, 15); _value -= _value * 0.1f * (float)(GameDirector.instance.PlayerList.Count - 1); _value += _value * num * (float)num2; __result = Mathf.Ceil(_value); __result = Mathf.Clamp(__result, 0f, 999999f); return false; } catch { return true; } } [HarmonyPatch("CrystalValueGet")] [HarmonyPrefix] private static bool CrystalValueGet_Prefix(ShopManager __instance, float _value, ref float __result) { if (!ConfigManager.ConfigEnabled.Value) { return true; } try { float multiplierForItemType = CustomPriceManager.GetMultiplierForItemType((itemType)5); float num = __instance.crystalValueIncrease * multiplierForItemType; int num2 = Mathf.Min(RunManager.instance.levelsCompleted, 15); _value += _value * num * (float)num2; __result = Mathf.Ceil(_value); __result = Mathf.Clamp(__result, 0f, 999999f); return false; } catch { return true; } } } [HarmonyPatch(typeof(ItemAttributes))] internal class ItemAttributesPatches { [HarmonyPatch("GetValue")] [HarmonyPrefix] private static bool GetValue_Prefix(ItemAttributes __instance) { //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Invalid comparison between Unknown and I4 //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Invalid comparison between Unknown and I4 //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Invalid comparison between Unknown and I4 if (!ConfigManager.ConfigEnabled.Value) { return true; } try { if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) { return true; } string displayName = ConfigManager.GetDisplayName(((Object)__instance.item).name); if (CustomPriceManager.FixedPrices.TryGetValue(displayName, out var value)) { __instance.value = (int)Mathf.Clamp(Mathf.Ceil(value), 0f, 999999f); if (GameManager.Multiplayer()) { __instance.photonView.RPC("GetValueRPC", (RpcTarget)1, new object[1] { __instance.value }); } return false; } float multiplierForItem = CustomPriceManager.GetMultiplierForItem(((Object)__instance.item).name, __instance.item); multiplierForItem = Mathf.Clamp(multiplierForItem, -1f, 100f); if (multiplierForItem == -1f) { multiplierForItem = 1f; } float num = Random.Range(__instance.itemValueMin, __instance.itemValueMax) * ShopManager.instance.itemValueMultiplier * multiplierForItem; if (num < 1000f) { num = 1000f; } float num2 = Mathf.Ceil(num / 1000f); if ((int)__instance.item.itemType == 3) { num2 = ShopManager.instance.UpgradeValueGet(num2, __instance.item); } else if ((int)__instance.item.itemType == 8) { num2 = ShopManager.instance.HealthPackValueGet(num2); } else if ((int)__instance.item.itemType == 5) { num2 = ShopManager.instance.CrystalValueGet(num2); } __instance.value = (int)Mathf.Clamp(num2, 0f, 999999f); if (GameManager.Multiplayer()) { __instance.photonView.RPC("GetValueRPC", (RpcTarget)1, new object[1] { __instance.value }); } return false; } catch (Exception arg) { Plugin.Logger.LogError((object)$"Error in GetValue patch: {arg}"); return true; } } } public static class CustomPriceManager { public static Dictionary FixedPrices = new Dictionary(); public static Dictionary Multipliers = new Dictionary(); private static Dictionary TypeMultipliers = new Dictionary(); public static void Reset() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) FixedPrices.Clear(); Multipliers.Clear(); TypeMultipliers.Clear(); if (ConfigManager.ItemTypeMultiplierConfigs == null) { return; } foreach (KeyValuePair> itemTypeMultiplierConfig in ConfigManager.ItemTypeMultiplierConfigs) { TypeMultipliers[itemTypeMultiplierConfig.Key] = itemTypeMultiplierConfig.Value.Value; } } public static float GetMultiplierForItem(string itemName, Item item = null) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) string displayName = ConfigManager.GetDisplayName(itemName); float num = 1f; bool value = default(bool); if (ConfigManager.UseItemTypeConfig.Value && ConfigManager.ItemOverrideItemType.Value && (Object)(object)item != (Object)null && ConfigManager.ItemHasCustomOverride.TryGetValue(displayName, out value) && value && Multipliers.TryGetValue(displayName, out var value2)) { num = Mathf.Clamp(value2, -1f, 100f); if (num == -1f) { num = 1f; } return num; } if (ConfigManager.UseItemTypeConfig.Value && (Object)(object)item != (Object)null && ConfigManager.HasItemTypeConfigChanged(item.itemType) && TypeMultipliers.TryGetValue(item.itemType, out var value3) && value3 != -1f && value3 != 1f) { num = Mathf.Clamp(value3, -1f, 100f); if (num == -1f) { num = 1f; } return num; } if (Multipliers.TryGetValue(displayName, out var value4)) { num = Mathf.Clamp(value4, -1f, 100f); if (num == -1f) { num = 1f; } } return num; } public static float GetMultiplierForItemType(itemType itemType) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (TypeMultipliers.TryGetValue(itemType, out var value)) { value = Mathf.Clamp(value, -1f, 100f); if (value == -1f) { value = 1f; } return value; } return 1f; } } [HarmonyPatch(typeof(StatsManager))] internal class StatsManagerPatches { private static Dictionary instancePrices = new Dictionary(); private static Dictionary> itemInstanceIds = new Dictionary>(); [HarmonyPrefix] [HarmonyPatch("ItemPurchase")] private static bool RefundExtraItem(string itemName, ref bool __runOriginal) { __runOriginal = true; try { if (!StatsManager.instance.itemDictionary.ContainsKey(itemName)) { return true; } Item val = StatsManager.instance.itemDictionary[itemName]; if (val.maxPurchase && val.maxPurchaseAmount > 0) { int num = StatsManager.instance.itemsPurchasedTotal[itemName]; if (num >= val.maxPurchaseAmount) { __runOriginal = false; int num2 = 0; if (itemInstanceIds.ContainsKey(itemName) && itemInstanceIds[itemName].Count > 0) { int num3 = itemInstanceIds[itemName][0]; if (instancePrices.ContainsKey(num3)) { num2 = instancePrices[num3]; instancePrices.Remove(num3); itemInstanceIds[itemName].RemoveAt(0); if (itemInstanceIds[itemName].Count == 0) { itemInstanceIds.Remove(itemName); } if (ConfigManager.DebugLogging.Value) { Plugin.Logger.LogInfo((object)$"Refunding {itemName} instance {num3} with price: {num2}"); } } } if (num2 == 0) { Plugin.Logger.LogError((object)("No price Found for " + itemName + "! Tracking failed during refund.")); return false; } if (num2 > 0 && StatsManager.instance.runStats.ContainsKey("currency")) { int num4 = StatsManager.instance.runStats["currency"]; StatsManager.instance.runStats["currency"] += num2; int num5 = StatsManager.instance.runStats["currency"]; Plugin.Logger.LogInfo((object)$"Refunded: {itemName} limit reached. Refunded {num2} currency ({num4} -> {num5})"); if (GameManager.Multiplayer() && PhotonNetwork.IsMasterClient) { PunManager.instance.SetRunStatSet("currency", num5); } } return false; } } } catch (Exception arg) { Plugin.Logger.LogError((object)$"Error in purchase check: {arg}"); } return true; } [HarmonyPostfix] [HarmonyPatch("ItemPurchase")] private static void DetetItemPurchased(string itemName, ref bool __runOriginal) { try { if (!__runOriginal) { return; } if (itemInstanceIds.ContainsKey(itemName) && itemInstanceIds[itemName].Count > 0) { int num = itemInstanceIds[itemName][0]; if (instancePrices.ContainsKey(num)) { int num2 = instancePrices[num]; instancePrices.Remove(num); if (ConfigManager.DebugLogging.Value) { Plugin.Logger.LogInfo((object)$"Successful purchase: {itemName} instance {num} for {num2}."); } } itemInstanceIds[itemName].RemoveAt(0); if (itemInstanceIds[itemName].Count == 0) { itemInstanceIds.Remove(itemName); } } if (StatsManager.instance.itemDictionary.ContainsKey(itemName)) { Item val = StatsManager.instance.itemDictionary[itemName]; int num3 = StatsManager.instance.itemsPurchasedTotal[itemName]; if (ConfigManager.DebugLogging.Value) { Plugin.Logger.LogInfo((object)$"{itemName}: {num3}/{val.maxPurchaseAmount}"); } } } catch { } } [HarmonyPostfix] [HarmonyPatch(typeof(ShopManager), "ShoppingListItemAdd")] private static void AddItemToShopList(ItemAttributes item) { try { if ((Object)(object)item != (Object)null && (Object)(object)item.item != (Object)null) { string name = ((Object)item.item).name; int instanceID = ((Object)item).GetInstanceID(); instancePrices[instanceID] = item.value; if (!itemInstanceIds.ContainsKey(name)) { itemInstanceIds[name] = new List(); } itemInstanceIds[name].Add(instanceID); if (ConfigManager.DebugLogging.Value) { Plugin.Logger.LogInfo((object)$"Added to cart: {name} instance {instanceID} for {item.value}"); } } } catch (Exception arg) { Plugin.Logger.LogError((object)$"Error tracking cart addition: {arg}"); } } [HarmonyPostfix] [HarmonyPatch(typeof(ShopManager), "ShoppingListItemRemove")] private static void RemoveItemFromShopList(ItemAttributes item) { try { if (!((Object)(object)item != (Object)null) || !((Object)(object)item.item != (Object)null)) { return; } string name = ((Object)item.item).name; int instanceID = ((Object)item).GetInstanceID(); if (instancePrices.ContainsKey(instanceID)) { instancePrices.Remove(instanceID); } if (itemInstanceIds.ContainsKey(name)) { itemInstanceIds[name].Remove(instanceID); if (itemInstanceIds[name].Count == 0) { itemInstanceIds.Remove(name); } if (ConfigManager.DebugLogging.Value) { Plugin.Logger.LogInfo((object)$"Removed from cart: {name} instance {instanceID}"); } } } catch (Exception arg) { Plugin.Logger.LogError((object)$"Error removing from cart: {arg}"); } } } }