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 shop prices modifier v1.0.3
ShopPriceModifier.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("shopprice2")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("shopprice2")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("2367ad22-5cd7-4c6e-84f5-442fa9408d56")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace ShopPriceModifier; internal class Manager { private static Random random = new Random(); private static readonly FieldInfo upgInc = AccessTools.Field(typeof(ShopManager), "upgradeValueIncrease"); private static readonly FieldInfo hpInc = AccessTools.Field(typeof(ShopManager), "healthPackValueIncrease"); private static readonly FieldInfo cryInc = AccessTools.Field(typeof(ShopManager), "crystalValueIncrease"); public static void ModifyUpgradePrice(float _value, Item item, ref float __result, ShopManager __instance) { float num = _value; int count = GameDirector.instance.PlayerList.Count; float num2 = SetConfig.UpgPlayerInfluence.Value * (float)(count - 1); num2 = Mathf.Max(num2, -0.9f); num += num * num2; float num3 = (SetConfig.CustomIncEnable.Value ? SetConfig.UpgInc.Value : ((float)upgInc.GetValue(__instance))); num += num * num3 * (float)StatsManager.instance.GetItemsUpgradesPurchased(((Object)item).name); float globalRandomMultiplier = GetGlobalRandomMultiplier(); float num4 = SetConfig.UpgBaseMult.Value + globalRandomMultiplier - 1f; num4 = Mathf.Max(num4, 0.1f); num *= num4; num = Mathf.Ceil(num); num = (__result = Mathf.Max(num, 1f)); if (SetConfig.DebugLog.Value) { string text = ((num2 > 0f) ? $"涨{num2 * 100f:F1}%" : ((num2 < 0f) ? $"降{Math.Abs(num2) * 100f:F1}%" : "无调整")); string text2 = (SetConfig.RandEnable.Value ? $"随机倍率:{globalRandomMultiplier:F2}" : "无随机倍率(1.0)"); ShopPrice.Log.LogDebug((object)($"[升级物品:{((Object)item).name}] 基础值:{_value:F2} | 玩家数:{count}({text})→ " + $"总倍率(基础{SetConfig.UpgBaseMult.Value:F2} + {text2} - 1)={num4:F2} → 最终价:{num:F2}")); } } public static void ModifyHealthPackPrice(float _value, ref float __result, ShopManager __instance) { float num = _value; int count = GameDirector.instance.PlayerList.Count; int num2 = Mathf.Min(RunManager.instance.levelsCompleted, SetConfig.MaxLevel.Value); float num3 = SetConfig.HpPlayerInfluence.Value * (float)(count - 1); num3 = Mathf.Max(num3, -0.9f); num += num * num3; float num4 = (SetConfig.CustomIncEnable.Value ? SetConfig.HpInc.Value : ((float)hpInc.GetValue(__instance))); num += num * num4 * (float)num2; float globalRandomMultiplier = GetGlobalRandomMultiplier(); float num5 = SetConfig.HpBaseMult.Value + globalRandomMultiplier - 1f; num5 = Mathf.Max(num5, 0.1f); num *= num5; num = Mathf.Ceil(num); num = (__result = Mathf.Max(num, 1f)); if (SetConfig.DebugLog.Value) { string text = ((num3 > 0f) ? $"涨{num3 * 100f:F1}%" : ((num3 < 0f) ? $"降{Math.Abs(num3) * 100f:F1}%" : "无调整")); string text2 = (SetConfig.RandEnable.Value ? $"随机倍率:{globalRandomMultiplier:F2}" : "无随机倍率(1.0)"); ShopPrice.Log.LogDebug((object)($"[医疗包] 基础值:{_value:F2} | 玩家数:{count}({text})| 通关数:{num2} → " + $"总倍率(基础{SetConfig.HpBaseMult.Value:F2} + {text2} - 1)={num5:F2} → 最终价:{num:F2}")); } } public static void ModifyCrystalPrice(float _value, ref float __result, ShopManager __instance) { float num = _value; int num2 = Mathf.Min(RunManager.instance.levelsCompleted, SetConfig.MaxLevel.Value); float num3 = (SetConfig.CustomIncEnable.Value ? SetConfig.CryInc.Value : ((float)cryInc.GetValue(__instance))); num += num * num3 * (float)num2; float globalRandomMultiplier = GetGlobalRandomMultiplier(); float num4 = SetConfig.CryBaseMult.Value + globalRandomMultiplier - 1f; num4 = Mathf.Max(num4, 0.1f); num *= num4; num = Mathf.Ceil(num); num = (__result = Mathf.Max(num, 1f)); if (SetConfig.DebugLog.Value) { string text = (SetConfig.RandEnable.Value ? $"随机倍率:{globalRandomMultiplier:F2}" : "无随机倍率(1.0)"); ShopPrice.Log.LogDebug((object)($"[能量水晶] 基础值:{_value:F2} | 通关数:{num2} → " + $"总倍率(基础{SetConfig.CryBaseMult.Value:F2} + {text} - 1)={num4:F2} → 最终价:{num:F2}")); } } internal static float GetGlobalRandomMultiplier() { if (!SetConfig.RandEnable.Value) { return 1f; } return (float)(random.NextDouble() * (double)(SetConfig.RandMaxMult.Value - SetConfig.RandMinMult.Value) + (double)SetConfig.RandMinMult.Value); } } internal class SetConfig { internal static ConfigEntry<float> UpgBaseMult; internal static ConfigEntry<float> UpgPlayerInfluence; internal static ConfigEntry<float> HpBaseMult; internal static ConfigEntry<float> HpPlayerInfluence; internal static ConfigEntry<float> CryBaseMult; internal static ConfigEntry<bool> RandEnable; internal static ConfigEntry<float> RandMinMult; internal static ConfigEntry<float> RandMaxMult; internal static ConfigEntry<bool> DebugLog; internal static ConfigEntry<int> MaxLevel; internal static ConfigEntry<bool> CustomIncEnable; internal static ConfigEntry<float> UpgInc; internal static ConfigEntry<float> HpInc; internal static ConfigEntry<float> CryInc; public static void InitConfig(ConfigFile Config) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Expected O, but got Unknown //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Expected O, but got Unknown //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Expected O, but got Unknown UpgBaseMult = Config.Bind<float>("Upgrade Price", "BaseMultiplier", 1f, new ConfigDescription("升级物品基础价格倍率 (0.01~10,0.5=半价,1=原价)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), Array.Empty<object>())); UpgPlayerInfluence = Config.Bind<float>("Upgrade Price", "PlayerInfluence", 0.1f, new ConfigDescription("玩家数量对价格的影响 (-0.1~1,0.1=每人+10%,-0.05=每人-5%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.1f, 1f), Array.Empty<object>())); HpBaseMult = Config.Bind<float>("Health Pack Price", "BaseMultiplier", 1f, new ConfigDescription("医疗包基础价格倍率 (0.01~10,0.5=半价,1=原价)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), Array.Empty<object>())); HpPlayerInfluence = Config.Bind<float>("Health Pack Price", "PlayerInfluence", 0.1f, new ConfigDescription("玩家数量对价格的影响 (-0.1~1,0.1=每人+10%,-0.05=每人-5%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.1f, 1f), Array.Empty<object>())); CryBaseMult = Config.Bind<float>("Energy Crystal Price", "BaseMultiplier", 1f, new ConfigDescription("能量水晶基础价格倍率 (0.01~10,0.5=半价,1=原价)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), Array.Empty<object>())); RandEnable = Config.Bind<bool>("Random Price", "RandomEnable", false, new ConfigDescription("是否启用全局商品价格随机波动(总开关)", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>())); RandMinMult = Config.Bind<float>("Random Price", "RandomMinMultiplier", 0.8f, new ConfigDescription("随机价格最小倍率 (0.1~2,默认0.8)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>())); RandMaxMult = Config.Bind<float>("Random Price", "RandomMaxMultiplier", 1.2f, new ConfigDescription("随机价格最大倍率 (0.1~2,默认1.2)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>())); CustomIncEnable = Config.Bind<bool>("Advanced", "EnableCustomBaseIncrease", false, new ConfigDescription("是否启用自定义成长值(覆盖游戏原生的升级/医疗包/水晶成长数值)", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>())); UpgInc = Config.Bind<float>("Advanced", "UpgradeValueOwnedIncrease", 0.5f, new ConfigDescription("升级物品购买次数成长值 (0.1~1,默认0.5)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); HpInc = Config.Bind<float>("Advanced", "HealthPackValueLevelIncrease", 0.05f, new ConfigDescription("医疗包等级成长值 (0.01~0.1,默认0.05)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.1f), Array.Empty<object>())); CryInc = Config.Bind<float>("Advanced", "CrystalValueLevelIncrease", 0.2f, new ConfigDescription("能量水晶等级成长值 (0.01~0.5,默认0.01)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.5f), Array.Empty<object>())); MaxLevel = Config.Bind<int>("Advanced", "MaxLevelLimit", 15, new ConfigDescription("价格计算最大等级限制 (15~50,默认15)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(15, 50), Array.Empty<object>())); DebugLog = Config.Bind<bool>("Logging Settings", "EnableDebugLogging", false, new ConfigDescription("是否启用调试日志输出(启用后打印每件商品价格计算详情)", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>())); UpgBaseMult.Value = Mathf.Clamp(UpgBaseMult.Value, 0.01f, 10f); UpgPlayerInfluence.Value = Mathf.Clamp(UpgPlayerInfluence.Value, -0.1f, 1f); HpBaseMult.Value = Mathf.Clamp(HpBaseMult.Value, 0.01f, 10f); HpPlayerInfluence.Value = Mathf.Clamp(HpPlayerInfluence.Value, -0.1f, 1f); CryBaseMult.Value = Mathf.Clamp(CryBaseMult.Value, 0.01f, 10f); RandMinMult.Value = Mathf.Clamp(RandMinMult.Value, 0.1f, 2f); RandMaxMult.Value = Mathf.Clamp(RandMaxMult.Value, 0.1f, 2f); MaxLevel.Value = Mathf.Clamp(MaxLevel.Value, 15, 50); UpgInc.Value = Mathf.Clamp(UpgInc.Value, 0.1f, 1f); HpInc.Value = Mathf.Clamp(HpInc.Value, 0.01f, 0.1f); CryInc.Value = Mathf.Clamp(CryInc.Value, 0.01f, 0.5f); if (RandMinMult.Value > RandMaxMult.Value) { RandMinMult.Value = RandMaxMult.Value; } ShopPrice.Log.LogInfo((object)("配置加载成功 → " + $"升级物品[倍率:{UpgBaseMult.Value}, 玩家影响:{UpgPlayerInfluence.Value * 100f}%/人] | " + $"医疗包[倍率:{HpBaseMult.Value}, 玩家影响:{HpPlayerInfluence.Value * 100f}%/人] | " + $"能量水晶[倍率:{CryBaseMult.Value}] | " + "随机价格[" + (RandEnable.Value ? $"开启({RandMinMult.Value}~{RandMaxMult.Value})" : "关闭") + "] | " + $"最大等级限制:{MaxLevel.Value} | " + "自定义基础成长[" + (CustomIncEnable.Value ? $"开启(升级:{UpgInc.Value}, 医疗包:{HpInc.Value}, 水晶:{CryInc.Value})" : "关闭") + "] | 调试日志[" + (DebugLog.Value ? "开启" : "关闭") + "]")); } } [BepInPlugin("ShopPriceModifier", "ShopPriceModifier", "1.0.4")] public class ShopPrice : BaseUnityPlugin { [HarmonyPatch(typeof(ShopManager), "UpgradeValueGet")] private static class UpgradeValueGetPatch { private static bool Prefix(float _value, Item item, ref float __result, ShopManager __instance) { Manager.ModifyUpgradePrice(_value, item, ref __result, __instance); return false; } } [HarmonyPatch(typeof(ShopManager), "HealthPackValueGet")] private static class HealthPackValueGetPatch { private static bool Prefix(float _value, ref float __result, ShopManager __instance) { Manager.ModifyHealthPackPrice(_value, ref __result, __instance); return false; } } [HarmonyPatch(typeof(ShopManager), "CrystalValueGet")] private static class CrystalValueGetPatch { private static bool Prefix(float _value, ref float __result, ShopManager __instance) { Manager.ModifyCrystalPrice(_value, ref __result, __instance); return false; } } internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("ShopPriceModifier").PatchAll(); SetConfig.InitConfig(((BaseUnityPlugin)this).Config); } } public static class PluginInfo { public const string GUID = "ShopPriceModifier"; public const string Name = "ShopPriceModifier"; public const string Version = "1.0.4"; }