using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
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.1.1")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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
{
[BepInPlugin("Jettcodey.JettsShopConfig", "JettsShopConfig", "1.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <InitializeItemConfigsDelayed>d__87 : 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 <InitializeItemConfigsDelayed>d__87(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;
}
<>4__this.InitializeItemConfigs();
<>4__this._configsInitialized = true;
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Initialized configs for {StatsManager.instance.itemDictionary.Count} items");
}
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 bool _configsInitialized = false;
public static Plugin Instance { get; private set; }
internal static ManualLogSource? Logger { get; private set; }
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 Dictionary<string, string> DisplayNameToFullName { get; private set; }
public static Dictionary<string, ConfigEntry<int>> ItemMinAmountConfigs { get; private set; }
public static Dictionary<string, ConfigEntry<int>> ItemMaxAmountConfigs { get; private set; }
public static Dictionary<string, ConfigEntry<int>> ItemPriceConfigs { get; private set; }
public static Dictionary<string, ConfigEntry<float>> ItemMultiplierConfigs { get; private set; }
public static Dictionary<string, ConfigEntry<bool>> ItemMaxPurchaseConfigs { get; private set; }
public static Dictionary<string, ConfigEntry<int>> ItemMaxPurchaseAmountConfigs { get; private set; }
public static Dictionary<itemType, ConfigEntry<int>> ItemTypeMinAmountConfigs { get; private set; }
public static Dictionary<itemType, ConfigEntry<int>> ItemTypeMaxAmountConfigs { get; private set; }
public static Dictionary<itemType, ConfigEntry<int>> ItemTypePriceConfigs { get; private set; }
public static Dictionary<itemType, ConfigEntry<float>> ItemTypeMultiplierConfigs { get; private set; }
public static Dictionary<string, ItemDefaultValues> ItemDefaultValues { get; private set; }
public static Dictionary<itemType, ItemTypeDefaultValues> ItemTypeDefaultValues { get; private set; }
public static Dictionary<string, bool> ItemHasCustomOverride { get; private set; }
private void Awake()
{
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Expected O, but got Unknown
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
DisplayNameToFullName = new Dictionary<string, string>();
ItemMinAmountConfigs = new Dictionary<string, ConfigEntry<int>>();
ItemMaxAmountConfigs = new Dictionary<string, ConfigEntry<int>>();
ItemPriceConfigs = new Dictionary<string, ConfigEntry<int>>();
ItemMultiplierConfigs = new Dictionary<string, ConfigEntry<float>>();
ItemMaxPurchaseConfigs = new Dictionary<string, ConfigEntry<bool>>();
ItemMaxPurchaseAmountConfigs = new Dictionary<string, ConfigEntry<int>>();
ItemTypeMinAmountConfigs = new Dictionary<itemType, ConfigEntry<int>>();
ItemTypeMaxAmountConfigs = new Dictionary<itemType, ConfigEntry<int>>();
ItemTypePriceConfigs = new Dictionary<itemType, ConfigEntry<int>>();
ItemTypeMultiplierConfigs = new Dictionary<itemType, ConfigEntry<float>>();
ItemDefaultValues = new Dictionary<string, ItemDefaultValues>();
ItemTypeDefaultValues = new Dictionary<itemType, ItemTypeDefaultValues>();
ItemHasCustomOverride = new Dictionary<string, bool>();
ConfigEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable/disable Jett'sShopConfig");
OverrideAllShopLogic = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OverrideAllShopLogic", true, "Override all shop logic with custom configuration");
UseItemTypeConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseItemTypeConfig", true, "When enabled, item type config overrides individual item config. When disabled, individual item config is used.");
ItemOverrideItemType = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ItemOverrideItemType", false, "When enabled and UseItemTypeConfig is true, allows individual items to override their item type config values if they have custom settings.");
DebugLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DebugLogging", false, "Enable debug logging for shop configuration");
InitializeItemTypeConfigs();
_harmony = new Harmony("Jettcodey.JettsShopConfig");
_harmony.PatchAll();
Logger.LogInfo((object)"Plugin JettsShopConfig v1.1.1 loaded successfully.");
((MonoBehaviour)this).StartCoroutine(InitializeItemConfigsDelayed());
}
[IteratorStateMachine(typeof(<InitializeItemConfigsDelayed>d__87))]
private IEnumerator InitializeItemConfigsDelayed()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InitializeItemConfigsDelayed>d__87(0)
{
<>4__this = this
};
}
private 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_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Expected O, but got Unknown
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Expected O, but got Unknown
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Expected O, but got Unknown
foreach (itemType value in Enum.GetValues(typeof(itemType)))
{
itemType key = value;
string text = ((object)(itemType)(ref key)).ToString();
ItemTypeDefaultValues itemTypeDefaultValues = new ItemTypeDefaultValues
{
MinAmountInShop = -1,
MaxAmountInShop = -1,
Price = -1,
Multiplier = 1f
};
ItemTypeDefaultValues[key] = itemTypeDefaultValues;
ItemTypeMinAmountConfigs[key] = ((BaseUnityPlugin)this).Config.Bind<int>("ItemType " + text, "MinAmountInShop", itemTypeDefaultValues.MinAmountInShop, new ConfigDescription("Minimum amount of " + text + " items to spawn in shop (-1 = use game default)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>()));
ItemTypeMaxAmountConfigs[key] = ((BaseUnityPlugin)this).Config.Bind<int>("ItemType " + text, "MaxAmountInShop", itemTypeDefaultValues.MaxAmountInShop, new ConfigDescription("Maximum amount of " + text + " items to spawn in shop (-1 = use game default)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 20), Array.Empty<object>()));
ItemTypePriceConfigs[key] = ((BaseUnityPlugin)this).Config.Bind<int>("ItemType " + text, "Price", itemTypeDefaultValues.Price, new ConfigDescription("Fixed price for all " + text + " items (-1 = use game calculation)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 999999), Array.Empty<object>()));
ItemTypeMultiplierConfigs[key] = ((BaseUnityPlugin)this).Config.Bind<float>("ItemType " + text, "Multiplier", itemTypeDefaultValues.Multiplier, new ConfigDescription("Price multiplier for all " + text + " items (1 = normal)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 100f), Array.Empty<object>()));
}
}
private void InitializeItemConfigs()
{
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Expected O, but got Unknown
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Expected O, but got Unknown
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Expected O, but got Unknown
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Expected O, but got Unknown
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Expected O, but got Unknown
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Expected O, but got Unknown
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
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))
{
if (DebugLogging.Value)
{
Logger.LogWarning((object)("Skipping item '" + key + "' - invalid config section name"));
}
continue;
}
DisplayNameToFullName[text] = key;
if (!ItemMinAmountConfigs.ContainsKey(text))
{
ItemDefaultValues itemDefaultValues = new ItemDefaultValues
{
MinAmountInShop = -1,
MaxAmountInShop = value.maxAmountInShop,
Price = -1,
Multiplier = 1f,
MaxPurchase = value.maxPurchase,
MaxPurchaseAmount = value.maxPurchaseAmount
};
ItemDefaultValues[key] = itemDefaultValues;
ItemMinAmountConfigs[text] = ((BaseUnityPlugin)this).Config.Bind<int>(text ?? "", "MinAmountInShop", itemDefaultValues.MinAmountInShop, new ConfigDescription("Minimum amount of " + displayName + " to spawn in shop (-1 = use item type/default)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>()));
ItemMaxAmountConfigs[text] = ((BaseUnityPlugin)this).Config.Bind<int>(text ?? "", "MaxAmountInShop", itemDefaultValues.MaxAmountInShop, new ConfigDescription("Maximum amount of " + displayName + " to spawn in shop (-1 = use item type/default)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 20), Array.Empty<object>()));
ItemPriceConfigs[text] = ((BaseUnityPlugin)this).Config.Bind<int>(text ?? "", "Price", itemDefaultValues.Price, new ConfigDescription("Fixed price for " + displayName + " (-1 = use item type/game calculation)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 999999), Array.Empty<object>()));
ItemMultiplierConfigs[text] = ((BaseUnityPlugin)this).Config.Bind<float>(text ?? "", "Multiplier", itemDefaultValues.Multiplier, new ConfigDescription("Price multiplier for " + displayName + " (1 = normal, applied after item type multiplier)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 100f), Array.Empty<object>()));
ItemMaxPurchaseConfigs[text] = ((BaseUnityPlugin)this).Config.Bind<bool>(text ?? "", "MaxPurchase", itemDefaultValues.MaxPurchase, new ConfigDescription("Enable purchase limit for " + displayName + " (true = limited, false = unlimited)", (AcceptableValueBase)null, Array.Empty<object>()));
ItemMaxPurchaseAmountConfigs[text] = ((BaseUnityPlugin)this).Config.Bind<int>(text ?? "", "MaxPurchaseAmount", itemDefaultValues.MaxPurchaseAmount, new ConfigDescription("Maximum purchase amount for " + displayName + " when MaxPurchase is enabled", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 999), Array.Empty<object>()));
CheckAndUpdateItemOverrideStatus(text);
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Created config for item: {key} -> Display: {displayName} -> Config Section: {text} (Type: {value.itemType})");
Logger.LogInfo((object)$" Defaults: Min={itemDefaultValues.MinAmountInShop}, Max={itemDefaultValues.MaxAmountInShop}, Price={itemDefaultValues.Price}, Multiplier={itemDefaultValues.Multiplier}, MaxPurchase={itemDefaultValues.MaxPurchase}, MaxPurchaseAmount={itemDefaultValues.MaxPurchaseAmount}");
}
}
}
}
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('_', ' ');
input = input.Trim();
if (string.IsNullOrEmpty(input))
{
input = fullItemName.Trim().Replace('_', ' ');
input = Regex.Replace(input, "^[_\\s]+", "");
}
return input;
}
public static string SanitizeConfigSection(string sectionName)
{
if (string.IsNullOrWhiteSpace(sectionName))
{
return sectionName;
}
sectionName = sectionName.Trim();
return sectionName;
}
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;
}
string text = "Item" + configSection;
if (StatsManager.instance?.itemDictionary != null && StatsManager.instance.itemDictionary.ContainsKey(text))
{
return text;
}
string text2 = "Item_" + configSection;
if (StatsManager.instance?.itemDictionary != null && StatsManager.instance.itemDictionary.ContainsKey(text2))
{
return text2;
}
return configSection;
}
public static void CheckAndUpdateItemOverrideStatus(string configSection)
{
string fullItemName = GetFullItemName(configSection);
if (!ItemDefaultValues.TryGetValue(fullItemName, out ItemDefaultValues value))
{
ItemHasCustomOverride[configSection] = false;
return;
}
bool flag = false;
if (ItemMinAmountConfigs.TryGetValue(configSection, out ConfigEntry<int> value2) && value2.Value != value.MinAmountInShop)
{
flag = true;
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Item {configSection} MinAmountInShop changed: {value.MinAmountInShop} -> {value2.Value}");
}
}
if (ItemMaxAmountConfigs.TryGetValue(configSection, out ConfigEntry<int> value3) && value3.Value != value.MaxAmountInShop)
{
flag = true;
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Item {configSection} MaxAmountInShop changed: {value.MaxAmountInShop} -> {value3.Value}");
}
}
if (ItemPriceConfigs.TryGetValue(configSection, out ConfigEntry<int> value4) && (float)Math.Abs(value4.Value - value.Price) > 0.001f)
{
flag = true;
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Item {configSection} Price changed: {value.Price} -> {value4.Value}");
}
}
if (ItemMultiplierConfigs.TryGetValue(configSection, out ConfigEntry<float> value5) && Math.Abs(value5.Value - value.Multiplier) > 0.001f)
{
flag = true;
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Item {configSection} Multiplier changed: {value.Multiplier} -> {value5.Value}");
}
}
if (ItemMaxPurchaseConfigs.TryGetValue(configSection, out ConfigEntry<bool> value6) && value6.Value != value.MaxPurchase)
{
flag = true;
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Item {configSection} MaxPurchase changed: {value.MaxPurchase} -> {value6.Value}");
}
}
if (ItemMaxPurchaseAmountConfigs.TryGetValue(configSection, out ConfigEntry<int> value7) && value7.Value != value.MaxPurchaseAmount)
{
flag = true;
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Item {configSection} MaxPurchaseAmount changed: {value.MaxPurchaseAmount} -> {value7.Value}");
}
}
ItemHasCustomOverride[configSection] = flag;
if (DebugLogging.Value && flag)
{
Logger.LogInfo((object)("Item " + configSection + " has custom overrides (different from defaults)"));
}
}
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)
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;
}
return result;
}
public static int GetItemMinAmount(string itemName, Item item = null)
{
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
string displayName = GetDisplayName(itemName);
string text = SanitizeConfigSection(displayName);
int num = -1;
bool value = UseItemTypeConfig.Value;
bool value2 = ItemOverrideItemType.Value;
if (value && (Object)(object)item != (Object)null)
{
bool value3 = default(bool);
if (value2 && ItemHasCustomOverride.TryGetValue(displayName, out value3) && value3 && ItemMinAmountConfigs.TryGetValue(displayName, out ConfigEntry<int> value4))
{
num = value4.Value;
if (num != -1)
{
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Using item override for {itemName}.MinAmountInShop: {num}");
}
return num;
}
}
if (HasItemTypeConfigChanged(item.itemType))
{
ConfigEntry<int> val = ItemTypeMinAmountConfigs[item.itemType];
num = val.Value;
if (num != -1)
{
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Using item type config for {itemName}.MinAmountInShop: {num}");
}
return num;
}
}
}
if (ItemMinAmountConfigs.TryGetValue(displayName, out ConfigEntry<int> value5))
{
num = value5.Value;
}
return num;
}
public static int GetItemMaxAmount(string itemName, Item item = null)
{
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
string displayName = GetDisplayName(itemName);
string text = SanitizeConfigSection(displayName);
int num = -1;
bool value = UseItemTypeConfig.Value;
bool value2 = ItemOverrideItemType.Value;
if (value && (Object)(object)item != (Object)null)
{
bool value3 = default(bool);
if (value2 && ItemHasCustomOverride.TryGetValue(displayName, out value3) && value3 && ItemMaxAmountConfigs.TryGetValue(displayName, out ConfigEntry<int> value4))
{
num = value4.Value;
if (num != -1)
{
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Using item override for {itemName}.MaxAmountInShop: {num}");
}
return num;
}
}
if (HasItemTypeConfigChanged(item.itemType))
{
ConfigEntry<int> val = ItemTypeMaxAmountConfigs[item.itemType];
num = val.Value;
if (num != -1)
{
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Using item type config for {itemName}.MaxAmountInShop: {num}");
}
return num;
}
}
}
if (ItemMaxAmountConfigs.TryGetValue(displayName, out ConfigEntry<int> value5))
{
num = value5.Value;
}
return num;
}
public static float GetItemPrice(string itemName, Item item = null)
{
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
string displayName = GetDisplayName(itemName);
string text = SanitizeConfigSection(displayName);
float num = -1f;
bool value = UseItemTypeConfig.Value;
bool value2 = ItemOverrideItemType.Value;
if (value && (Object)(object)item != (Object)null)
{
bool value3 = default(bool);
if (value2 && ItemHasCustomOverride.TryGetValue(displayName, out value3) && value3 && ItemPriceConfigs.TryGetValue(displayName, out ConfigEntry<int> value4))
{
num = value4.Value;
if (num != -1f)
{
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Using item override for {itemName}.Price: {num}");
}
return num;
}
}
if (HasItemTypeConfigChanged(item.itemType))
{
ConfigEntry<int> val = ItemTypePriceConfigs[item.itemType];
num = val.Value;
if (num != -1f)
{
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Using item type config for {itemName}.Price: {num}");
}
return num;
}
}
}
if (ItemPriceConfigs.TryGetValue(displayName, out ConfigEntry<int> value5))
{
num = value5.Value;
}
return num;
}
public static float GetItemMultiplier(string itemName, Item item = null)
{
//IL_00cd: 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);
string text = SanitizeConfigSection(displayName);
float result = 1f;
bool value = UseItemTypeConfig.Value;
bool value2 = ItemOverrideItemType.Value;
if (value && (Object)(object)item != (Object)null)
{
bool value3 = default(bool);
if (value2 && ItemHasCustomOverride.TryGetValue(displayName, out value3) && value3 && ItemMultiplierConfigs.TryGetValue(displayName, out ConfigEntry<float> value4))
{
float value5 = value4.Value;
if (value5 != -1f)
{
result = value5;
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Using item override for {itemName}.Multiplier: {result}");
}
return result;
}
}
if (HasItemTypeConfigChanged(item.itemType))
{
ConfigEntry<float> val = ItemTypeMultiplierConfigs[item.itemType];
float value6 = val.Value;
if (value6 != -1f && value6 != 1f)
{
result = value6;
if (DebugLogging.Value)
{
Logger.LogInfo((object)$"Using item type config for {itemName}.Multiplier: {result}");
}
return result;
}
}
}
if (ItemMultiplierConfigs.TryGetValue(displayName, out ConfigEntry<float> value7))
{
float value8 = value7.Value;
if (value8 != -1f)
{
result = value8;
}
}
return result;
}
public static bool GetItemMaxPurchase(string itemName)
{
string displayName = GetDisplayName(itemName);
string text = SanitizeConfigSection(displayName);
if (ItemMaxPurchaseConfigs.TryGetValue(displayName, out ConfigEntry<bool> value))
{
return value.Value;
}
return false;
}
public static int GetItemMaxPurchaseAmount(string itemName)
{
string displayName = GetDisplayName(itemName);
string text = SanitizeConfigSection(displayName);
if (ItemMaxPurchaseAmountConfigs.TryGetValue(displayName, out ConfigEntry<int> value))
{
return value.Value;
}
return 1;
}
private void OnDestroy()
{
Harmony.UnpatchID("Jettcodey.JettsShopConfig");
}
}
public class ItemDefaultValues
{
public int MinAmountInShop { get; set; }
public int MaxAmountInShop { get; set; }
public int Price { get; set; }
public float Multiplier { get; set; }
public bool MaxPurchase { get; set; }
public int MaxPurchaseAmount { get; set; }
}
public class ItemTypeDefaultValues
{
public int MinAmountInShop { get; set; }
public int MaxAmountInShop { get; set; }
public int Price { get; set; }
public float Multiplier { get; set; }
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Jettcodey.JettsShopConfig";
public const string PLUGIN_NAME = "JettsShopConfig";
public const string PLUGIN_VERSION = "1.1.1";
}
}
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;
((TMP_Text)__instance.labelTMP).overflowMode = (TextOverflowModes)3;
}
}
[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);
}
}
}
}
[HarmonyPatch(typeof(ShopManager))]
internal class ShopManagerPatches
{
[HarmonyPatch("GetAllItemsFromStatsManager")]
[HarmonyPrefix]
private static bool GetAllItemsFromStatsManager_Prefix(ShopManager __instance)
{
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Invalid comparison between Unknown and I4
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Invalid comparison between Unknown and I4
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Invalid comparison between Unknown and I4
if (!Plugin.ConfigEnabled.Value || !Plugin.OverrideAllShopLogic.Value)
{
return true;
}
if (!Plugin.Instance._configsInitialized)
{
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 = Plugin.GetDisplayName(key);
Plugin.CheckAndUpdateItemOverrideStatus(displayName);
int num = Plugin.GetItemMinAmount(key, value);
int num2 = Plugin.GetItemMaxAmount(key, value);
float itemPrice = Plugin.GetItemPrice(key, value);
float num3 = Plugin.GetItemMultiplier(key, value);
bool value2;
bool flag = Plugin.ItemHasCustomOverride.TryGetValue(displayName, out value2) && value2;
bool flag2 = (flag ? Plugin.GetItemMaxPurchase(key) : value.maxPurchase);
int num4 = (flag ? Plugin.GetItemMaxPurchaseAmount(key) : value.maxPurchaseAmount);
if (num == -1)
{
num = 0;
}
if (num2 == -1)
{
num2 = value.maxAmountInShop;
}
num = Mathf.Clamp(num, 0, 10);
num2 = Mathf.Clamp(num2, 0, 20);
if (num2 < num)
{
num2 = num;
}
if (num2 <= 0)
{
continue;
}
int num5 = SemiFunc.StatGetItemsPurchased(((Object)value).name);
bool flag3 = true;
if (num5 >= num2 || (flag2 && StatsManager.instance.GetItemsUpgradesPurchasedTotal(((Object)value).name) >= num4))
{
flag3 = false;
if (Plugin.DebugLogging.Value)
{
string text = ((num5 >= num2) ? $"Purchased {num5} >= Max {num2}" : $"Upgrades {StatsManager.instance.GetItemsUpgradesPurchasedTotal(((Object)value).name)} >= Purchase Limit {num4}");
Plugin.Logger.LogInfo((object)("Skipping " + key + ": " + text));
}
}
if (!flag3)
{
continue;
}
float num6 = 0f;
if (itemPrice >= 0f)
{
num6 = Mathf.Clamp(itemPrice, 0f, 999999f);
CustomPriceManager.FixedPrices[displayName] = num6;
}
else
{
float num7 = value.value.valueMax / 1000f * __instance.itemValueMultiplier;
if ((int)value.itemType == 3)
{
num7 = __instance.UpgradeValueGet(num7, value);
}
else if ((int)value.itemType == 8)
{
num7 = __instance.HealthPackValueGet(num7);
}
else if ((int)value.itemType == 5)
{
num7 = __instance.CrystalValueGet(num7);
}
num3 = Mathf.Clamp(num3, -1f, 100f);
if (num3 == -1f)
{
num3 = 1f;
}
num6 = num7 * num3;
num6 = Mathf.Clamp(num6, 0f, 999999f);
CustomPriceManager.Multipliers[displayName] = num3;
}
if (num6 > (float)__instance.totalCurrency && Random.Range(0, 100) >= 25)
{
if (Plugin.DebugLogging.Value)
{
Plugin.Logger.LogInfo((object)$"Skipping {key}: Price {num6} > Currency {__instance.totalCurrency}");
}
continue;
}
int num8 = Mathf.Min(num2 - num5, num2);
int num9 = Random.Range(num, Mathf.Min(num8, num2) + 1);
if (num9 > 0)
{
for (int i = 0; i < num9; i++)
{
AddItemToAppropriateList(__instance, value);
dictionary[key] = dictionary.GetValueOrDefault(key) + 1;
}
if (Plugin.DebugLogging.Value)
{
string configSource = GetConfigSource(key, value);
string text2 = (value2 ? " [OVERRIDE]" : "");
string text3 = (flag2 ? $" (Max Purchase: {num4})" : "");
Plugin.Logger.LogInfo((object)$"Added {num9}x {key}{text2}{text3} (Min: {num}, Max: {num2}, Price: {num6:F0}, Multiplier: {num3:F2}, Source: {configSource})");
}
}
}
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);
}
if (Plugin.DebugLogging.Value)
{
Plugin.Logger.LogInfo((object)($"Shop initialized: {__instance.potentialItems.Count} items, " + $"{__instance.potentialItemConsumables.Count} consumables, " + $"{__instance.potentialItemUpgrades.Count} upgrades, " + $"{__instance.potentialItemHealthPacks.Count} health packs"));
}
return false;
}
catch (Exception arg)
{
Plugin.Logger.LogError((object)$"Error in custom shop logic: {arg}");
return true;
}
}
private static string GetConfigSource(string itemName, Item item)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.UseItemTypeConfig.Value)
{
return "Individual Config";
}
string displayName = Plugin.GetDisplayName(itemName);
bool value = default(bool);
if (Plugin.ItemOverrideItemType.Value && Plugin.ItemHasCustomOverride.TryGetValue(displayName, out value) && value)
{
return "Item Override";
}
if (Plugin.HasItemTypeConfigChanged(item.itemType))
{
return "Item Type Config";
}
return "Default";
}
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 (!Plugin.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 (!Plugin.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 (!Plugin.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_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Invalid comparison between Unknown and I4
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Invalid comparison between Unknown and I4
if (!Plugin.ConfigEnabled.Value)
{
return true;
}
try
{
if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)
{
return true;
}
string displayName = Plugin.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);
}
num2 = Mathf.Clamp(num2, 0f, 999999f);
__instance.value = (int)num2;
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 (Plugin.ItemTypeMultiplierConfigs == null)
{
return;
}
foreach (KeyValuePair<itemType, ConfigEntry<float>> itemTypeMultiplierConfig in Plugin.ItemTypeMultiplierConfigs)
{
TypeMultipliers[itemTypeMultiplierConfig.Key] = itemTypeMultiplierConfig.Value.Value;
}
}
public static float GetMultiplierForItem(string itemName, Item item = null)
{
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
string displayName = Plugin.GetDisplayName(itemName);
float num = 1f;
bool value = default(bool);
if (Plugin.UseItemTypeConfig.Value && Plugin.ItemOverrideItemType.Value && (Object)(object)item != (Object)null && Plugin.ItemHasCustomOverride.TryGetValue(displayName, out value) && value && Multipliers.TryGetValue(displayName, out var value2))
{
num = Mathf.Clamp(value2, -1f, 100f);
if (num == -1f)
{
num = 1f;
}
if (Plugin.DebugLogging.Value)
{
Plugin.Logger.LogInfo((object)$"CustomPriceManager: Using item override multiplier for {itemName}: {num}");
}
return num;
}
if (Plugin.UseItemTypeConfig.Value && (Object)(object)item != (Object)null && Plugin.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;
}
if (Plugin.DebugLogging.Value)
{
Plugin.Logger.LogInfo((object)$"CustomPriceManager: Using item type multiplier for {itemName}: {num}");
}
return num;
}
if (Multipliers.TryGetValue(displayName, out var value4))
{
num = Mathf.Clamp(value4, -1f, 100f);
if (num == -1f)
{
num = 1f;
}
if (Plugin.DebugLogging.Value)
{
Plugin.Logger.LogInfo((object)$"CustomPriceManager: Using individual multiplier for {itemName}: {num}");
}
}
return num;
}
public static float GetMultiplierForItemType(itemType itemType)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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;
}
if (Plugin.DebugLogging.Value)
{
Plugin.Logger.LogInfo((object)$"CustomPriceManager: Using multiplier for item type {itemType}: {value}");
}
return value;
}
return 1f;
}
}
}