Decompiled source of ShopPriceMultiplier v1.0.1

Shop Price Multiplier.dll

Decompiled a month ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Photon.Pun;
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("Shop Price Multiplier")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Shop Price Multiplier")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("972e53e5-4eb6-486a-9432-61ce86428963")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ShopPriceMultiplier;

[BepInPlugin("DougHRito.REPO.ShopPriceMultiplier", "Shop Price Multiplier", "1.0.0")]
public class ShopPriceMultiplierPlugin : BaseUnityPlugin
{
	public const string PluginName = "Shop Price Multiplier";

	private static readonly Harmony _harmony = new Harmony("DougHRito.REPO.ShopPriceMultiplier");

	private ConfigEntry<float> _priceMultiplier;

	public static ShopPriceMultiplierPlugin Instance;

	private void Awake()
	{
		Instance = this;
		_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PriceMultiplier", 1f, "Multiplier to apply to item prices in the shop");
		_harmony.PatchAll(typeof(ShopPriceMultiplierPatch));
	}

	public static float GetPriceMultiplier()
	{
		return Instance._priceMultiplier.Value;
	}
}
[HarmonyPatch(typeof(ItemAttributes), "GetValue")]
public class ShopPriceMultiplierPatch
{
	private static readonly FieldRef<ShopManager, float> _getItemValueMultiplier;

	private static readonly FieldRef<ShopManager, float> _getUpgradeValueIncrease;

	private static readonly FieldRef<ShopManager, float> _getHealthPackValueIncrease;

	private static readonly FieldRef<ShopManager, float> _getCrystalValueIncrease;

	static ShopPriceMultiplierPatch()
	{
		FieldInfo field = typeof(ShopManager).GetField("itemValueMultiplier", BindingFlags.Instance | BindingFlags.NonPublic);
		_getItemValueMultiplier = AccessTools.FieldRefAccess<ShopManager, float>(field);
		FieldInfo field2 = typeof(ShopManager).GetField("upgradeValueIncrease", BindingFlags.Instance | BindingFlags.NonPublic);
		_getUpgradeValueIncrease = AccessTools.FieldRefAccess<ShopManager, float>(field2);
		FieldInfo field3 = typeof(ShopManager).GetField("healthPackValueIncrease", BindingFlags.Instance | BindingFlags.NonPublic);
		_getHealthPackValueIncrease = AccessTools.FieldRefAccess<ShopManager, float>(field3);
		FieldInfo field4 = typeof(ShopManager).GetField("crystalValueIncrease", BindingFlags.Instance | BindingFlags.NonPublic);
		_getCrystalValueIncrease = AccessTools.FieldRefAccess<ShopManager, float>(field4);
	}

	public static bool Prefix(ref int ___value, float ___itemValueMin, float ___itemValueMax, itemType ___itemType, string ___itemAssetName, PhotonView ___photonView, string ___itemName)
	{
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Invalid comparison between Unknown and I4
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Invalid comparison between Unknown and I4
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Invalid comparison between Unknown and I4
		if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)
		{
			return true;
		}
		if (!SemiFunc.RunIsShop())
		{
			return true;
		}
		float num = Random.Range(___itemValueMin, ___itemValueMax) * _getItemValueMultiplier.Invoke(ShopManager.instance);
		if (num < 1000f)
		{
			num = 1000f;
		}
		if (num >= 1000f)
		{
			num = Mathf.Ceil(num / 1000f);
		}
		if ((int)___itemType == 3)
		{
			num += num * _getUpgradeValueIncrease.Invoke(ShopManager.instance) * (float)StatsManager.instance.GetItemsUpgradesPurchased(___itemAssetName);
		}
		else if ((int)___itemType == 8)
		{
			num += num * _getHealthPackValueIncrease.Invoke(ShopManager.instance) * (float)RunManager.instance.levelsCompleted;
		}
		else if ((int)___itemType == 5)
		{
			num += num * _getCrystalValueIncrease.Invoke(ShopManager.instance) * (float)RunManager.instance.levelsCompleted;
		}
		float num2 = num * ShopPriceMultiplierPlugin.GetPriceMultiplier();
		___value = (int)num2;
		___value = Mathf.Max(1, Mathf.RoundToInt(num2));
		if (GameManager.Multiplayer())
		{
			___photonView.RPC("GetValueRPC", (RpcTarget)1, new object[1] { ___value });
		}
		return false;
	}

	public static void Postfix()
	{
	}
}