Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of JettsShopConfig v1.2.2
JettsShopConfig.dll
Decompiled a month agousing 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.2.2")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.2.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<string, ConfigFile> _categoryConfigFiles = new Dictionary<string, ConfigFile>(); public static Dictionary<string, string> DisplayNameToFullName = new Dictionary<string, string>(); public static Dictionary<string, ItemDefaultValues> ItemDefaultValues = new Dictionary<string, ItemDefaultValues>(); public static Dictionary<itemType, ItemTypeDefaultValues> ItemTypeDefaultValues = new Dictionary<itemType, ItemTypeDefaultValues>(); public static Dictionary<string, bool> ItemHasCustomOverride = new Dictionary<string, bool>(); public static Dictionary<string, ConfigEntry<int>> ItemMinAmountConfigs = new Dictionary<string, ConfigEntry<int>>(); public static Dictionary<string, ConfigEntry<int>> ItemMaxAmountConfigs = new Dictionary<string, ConfigEntry<int>>(); public static Dictionary<string, ConfigEntry<int>> ItemPriceConfigs = new Dictionary<string, ConfigEntry<int>>(); public static Dictionary<string, ConfigEntry<float>> ItemMultiplierConfigs = new Dictionary<string, ConfigEntry<float>>(); public static Dictionary<string, ConfigEntry<bool>> ItemMaxPurchaseConfigs = new Dictionary<string, ConfigEntry<bool>>(); public static Dictionary<string, ConfigEntry<int>> ItemMaxPurchaseAmountConfigs = new Dictionary<string, ConfigEntry<int>>(); public static Dictionary<itemType, ConfigEntry<int>> ItemTypeMinAmountConfigs = new Dictionary<itemType, ConfigEntry<int>>(); public static Dictionary<itemType, ConfigEntry<int>> ItemTypeMaxAmountConfigs = new Dictionary<itemType, ConfigEntry<int>>(); public static Dictionary<itemType, ConfigEntry<int>> ItemTypePriceConfigs = new Dictionary<itemType, ConfigEntry<int>>(); public static Dictionary<itemType, ConfigEntry<float>> ItemTypeMultiplierConfigs = new Dictionary<itemType, ConfigEntry<float>>(); public static Dictionary<itemType, ConfigEntry<bool>> ItemTypeMaxPurchaseConfigs = new Dictionary<itemType, ConfigEntry<bool>>(); public static Dictionary<itemType, ConfigEntry<int>> ItemTypeMaxPurchaseAmountConfigs = new Dictionary<itemType, ConfigEntry<int>>(); public static bool IsInitialized { get; private set; } = false; public static ConfigEntry<bool> ConfigEnabled { get; private set; } public static ConfigEntry<bool> OverrideAllShopLogic { get; private set; } public static ConfigEntry<bool> UseItemTypeConfig { get; private set; } public static ConfigEntry<bool> ItemOverrideItemType { get; private set; } public static ConfigEntry<bool> DebugLogging { get; private set; } public static ConfigEntry<bool> CheckMode { get; private set; } public static ConfigEntry<bool> HasMigratedMSI { get; private set; } public static void Initialize(ConfigFile mainConfig, PluginInfo info) { _mainPluginInfo = info; ConfigEnabled = mainConfig.Bind<bool>("General", "Enabled", true, "Enable/disable Jett'sShopConfig"); OverrideAllShopLogic = mainConfig.Bind<bool>("General", "OverrideAllShopLogic", true, "Override all shop logic with custom configuration"); UseItemTypeConfig = mainConfig.Bind<bool>("General", "UseItemTypeConfig", true, "When enabled, item type config overrides individual item config."); ItemOverrideItemType = mainConfig.Bind<bool>("General", "ItemOverrideItemType", false, "Allows individual items to override type config if true."); DebugLogging = mainConfig.Bind<bool>("Dev General", "DebugLogging", true, "Enable basic debug logging"); CheckMode = mainConfig.Bind<bool>("Dev General", "Check Mode", false, "Enable verbose logging to check which mod is controlling item values."); HasMigratedMSI = mainConfig.Bind<bool>("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_0043: 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", _ => "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<int>("ItemType " + text, "MinAmountInShop", itemTypeDefaultValues.MinAmountInShop, new ConfigDescription("Min", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())); ItemTypeMaxAmountConfigs[val] = configFileForCategory.Bind<int>("ItemType " + text, "MaxAmountInShop", itemTypeDefaultValues.MaxAmountInShop, new ConfigDescription("Max", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 20), Array.Empty<object>())); ItemTypePriceConfigs[val] = configFileForCategory.Bind<int>("ItemType " + text, "Price", itemTypeDefaultValues.Price, new ConfigDescription("Price", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 999999), Array.Empty<object>())); ItemTypeMultiplierConfigs[val] = configFileForCategory.Bind<float>("ItemType " + text, "Multiplier", itemTypeDefaultValues.Multiplier, new ConfigDescription("Mult", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 100f), Array.Empty<object>())); ItemTypeMaxPurchaseConfigs[val] = configFileForCategory.Bind<bool>("ItemType " + text, "MaxPurchase", itemTypeDefaultValues.MaxPurchase, new ConfigDescription("Limit", (AcceptableValueBase)null, Array.Empty<object>())); ItemTypeMaxPurchaseAmountConfigs[val] = configFileForCategory.Bind<int>("ItemType " + text, "MaxPurchaseAmount", itemTypeDefaultValues.MaxPurchaseAmount, new ConfigDescription("Limit Amount", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 999), Array.Empty<object>())); } } } 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<string, Item> 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<int>(text ?? "", "MinAmountInShop", itemDefaultValues.MinAmountInShop, new ConfigDescription("Min", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())); ItemMaxAmountConfigs[text] = configFileForCategory.Bind<int>(text ?? "", "MaxAmountInShop", itemDefaultValues.MaxAmountInShop, new ConfigDescription("Max", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 20), Array.Empty<object>())); ItemPriceConfigs[text] = configFileForCategory.Bind<int>(text ?? "", "Price", itemDefaultValues.Price, new ConfigDescription("Price", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 999999), Array.Empty<object>())); ItemMultiplierConfigs[text] = configFileForCategory.Bind<float>(text ?? "", "Multiplier", itemDefaultValues.Multiplier, new ConfigDescription("Mult", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 100f), Array.Empty<object>())); ItemMaxPurchaseConfigs[text] = configFileForCategory.Bind<bool>(text ?? "", "MaxPurchase", itemDefaultValues.MaxPurchase, new ConfigDescription("Limit", (AcceptableValueBase)null, Array.Empty<object>())); ItemMaxPurchaseAmountConfigs[text] = configFileForCategory.Bind<int>(text ?? "", "MaxPurchaseAmount", itemDefaultValues.MaxPurchaseAmount, new ConfigDescription("Limit Amount", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 999), Array.Empty<object>())); 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); 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<int> val2 = default(ConfigEntry<int>); if (msiConfig.TryGetEntry<int>(section, key, ref val2)) { if (shouldCopyValues && ItemTypeMaxAmountConfigs.TryGetValue(type, out ConfigEntry<int> 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<int> val = default(ConfigEntry<int>); if (msiConfig.TryGetEntry<int>(section, key, ref val)) { if (shouldCopyValues && ItemTypeMaxPurchaseConfigs.TryGetValue(type, out ConfigEntry<bool> value2) && ItemTypeMaxPurchaseAmountConfigs.TryGetValue(type, out ConfigEntry<int> 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<int> value3) && value3.Value != value.MinAmountInShop) { value2 = true; } if (ItemMaxAmountConfigs.TryGetValue(configSection, out ConfigEntry<int> value4) && value4.Value != value.MaxAmountInShop) { value2 = true; } if (ItemPriceConfigs.TryGetValue(configSection, out ConfigEntry<int> value5) && (float)Math.Abs(value5.Value - value.Price) > 0.001f) { value2 = true; } if (ItemMultiplierConfigs.TryGetValue(configSection, out ConfigEntry<float> value6) && Math.Abs(value6.Value - value.Multiplier) > 0.001f) { value2 = true; } if (ItemMaxPurchaseConfigs.TryGetValue(configSection, out ConfigEntry<bool> value7) && value7.Value != value.MaxPurchase) { value2 = true; } if (ItemMaxPurchaseAmountConfigs.TryGetValue(configSection, out ConfigEntry<int> 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<int> value2) && value2.Value != value.MinAmountInShop) { result = true; } if (ItemTypeMaxAmountConfigs.TryGetValue(itemType, out ConfigEntry<int> value3) && value3.Value != value.MaxAmountInShop) { result = true; } if (ItemTypePriceConfigs.TryGetValue(itemType, out ConfigEntry<int> value4) && (float)Math.Abs(value4.Value - value.Price) > 0.001f) { result = true; } if (ItemTypeMultiplierConfigs.TryGetValue(itemType, out ConfigEntry<float> value5) && Math.Abs(value5.Value - value.Multiplier) > 0.001f) { result = true; } if (ItemTypeMaxPurchaseConfigs.TryGetValue(itemType, out ConfigEntry<bool> value6) && value6.Value != value.MaxPurchase) { result = true; } if (ItemTypeMaxPurchaseAmountConfigs.TryGetValue(itemType, out ConfigEntry<int> 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<int> value2) && value2.Value != -1) { num = value2.Value; arg = "Item Override"; } } else if (HasItemTypeConfigChanged(item.itemType)) { ConfigEntry<int> val = ItemTypeMinAmountConfigs[item.itemType]; if (val.Value != -1) { num = val.Value; arg = $"ItemType ({item.itemType})"; } } } if (num == -1 && ItemMinAmountConfigs.TryGetValue(displayName, out ConfigEntry<int> 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<int> value2) && value2.Value != -1) { num = value2.Value; arg = "Item Override"; } } else if (HasItemTypeConfigChanged(item.itemType)) { ConfigEntry<int> val = ItemTypeMaxAmountConfigs[item.itemType]; if (val.Value != -1) { num = val.Value; arg = $"ItemType ({item.itemType})"; } } } if (num == -1 && ItemMaxAmountConfigs.TryGetValue(displayName, out ConfigEntry<int> 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<int> value2) && (float)value2.Value != -1f) { num = value2.Value; arg = "Item Override"; } } else if (HasItemTypeConfigChanged(item.itemType)) { ConfigEntry<int> val = ItemTypePriceConfigs[item.itemType]; if ((float)val.Value != -1f) { num = val.Value; arg = $"ItemType ({item.itemType})"; } } } if (num == -1f && ItemPriceConfigs.TryGetValue(displayName, out ConfigEntry<int> 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<float> value2) && value2.Value != -1f) { num = value2.Value; arg = "Item Override"; } } else if (HasItemTypeConfigChanged(item.itemType)) { ConfigEntry<float> 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<float> 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<bool> value)) { flag = value.Value; arg = $"ItemType ({item.itemType})"; } bool value2 = default(bool); ConfigEntry<bool> value4; if (ItemOverrideItemType.Value && ItemHasCustomOverride.TryGetValue(displayName, out value2) && value2) { if (ItemMaxPurchaseConfigs.TryGetValue(displayName, out ConfigEntry<bool> 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<int> value)) { num = value.Value; text = $"ItemType ({item.itemType})"; } bool value2 = default(bool); ConfigEntry<int> value4; if (ItemOverrideItemType.Value && ItemHasCustomOverride.TryGetValue(displayName, out value2) && value2) { if (ItemMaxPurchaseAmountConfigs.TryGetValue(displayName, out ConfigEntry<int> 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.2.2")] [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 <InitializeConfigsDelayed>d__10 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <InitializeConfigsDelayed>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; } 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.2.2 loaded successfully."); ((MonoBehaviour)this).StartCoroutine(InitializeConfigsDelayed()); } [IteratorStateMachine(typeof(<InitializeConfigsDelayed>d__10))] private IEnumerator InitializeConfigsDelayed() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <InitializeConfigsDelayed>d__10(0) { <>4__this = this }; } private void OnDestroy() { Harmony.UnpatchID("Jettcodey.JettsShopConfig"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Jettcodey.JettsShopConfig"; public const string PLUGIN_NAME = "JettsShopConfig"; public const string PLUGIN_VERSION = "1.2.2"; } 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("<Config>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.2.2"; 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>(); 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown if (Chainloader.PluginInfos.ContainsKey("Jettcodey.MoreShopItems")) { if (ConfigManager.DebugLogging.Value) { 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"); UnpatchMethod(harmony, typeof(ShopManager), "UpgradeValueGet"); UnpatchMethod(harmony, typeof(ShopManager), "HealthPackValueGet"); UnpatchMethod(harmony, typeof(ShopManager), "CrystalValueGet"); UnpatchMethod(harmony, typeof(ItemAttributes), "GetValue"); } } 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"); if (ConfigManager.DebugLogging.Value) { Plugin.Logger.LogInfo((object)("[MSIConflictPatcher] Unpatched " + targetType.Name + "." + methodName + " from MoreShopItems")); } } } catch (Exception ex) { if (ConfigManager.DebugLogging.Value) { 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<ItemVolume> 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 GetAllItemsFromStatsManager_Prefix(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<string, int> dictionary = new Dictionary<string, int>(); foreach (KeyValuePair<string, Item> 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<Item>((IList<Item>)__instance.potentialItems); ListExtension.Shuffle<Item>((IList<Item>)__instance.potentialItemConsumables); ListExtension.Shuffle<Item>((IList<Item>)__instance.potentialItemUpgrades); ListExtension.Shuffle<Item>((IList<Item>)__instance.potentialItemHealthPacks); foreach (List<Item> value3 in __instance.potentialSecretItems.Values) { ListExtension.Shuffle<Item>((IList<Item>)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<Item>()); } 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<string, float> FixedPrices = new Dictionary<string, float>(); public static Dictionary<string, float> Multipliers = new Dictionary<string, float>(); private static Dictionary<itemType, float> TypeMultipliers = new Dictionary<itemType, float>(); 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<itemType, ConfigEntry<float>> 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<int, int> instancePrices = new Dictionary<int, int>(); private static Dictionary<string, List<int>> itemInstanceIds = new Dictionary<string, List<int>>(); [HarmonyPrefix] [HarmonyPatch("ItemPurchase")] private static bool Prefix_ItemPurchase(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 Postfix_ItemPurchase(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 Postfix_ShoppingListItemAdd(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<int>(); } 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 Postfix_ShoppingListItemRemove(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}"); } } } }