Decompiled source of ScalingPrices v1.1.2

ScalingPrices.dll

Decompiled 3 weeks 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 BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using ScalingPrices.Config;
using ScalingPrices.Helpers;
using ScalingPrices.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ScalingPrices")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ScalingPrices")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b44f6998-ed7b-478f-a3b6-3791193d4005")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ScalingPrices
{
	[BepInPlugin("EvilCheetah.REPO.PlayerCountPricing", "Scaling Prices", "1.1.2")]
	public class ScalingPricingBase : BaseUnityPlugin
	{
		private const string mod_guid = "EvilCheetah.REPO.PlayerCountPricing";

		private const string mod_name = "Scaling Prices";

		private const string mod_version = "1.1.2";

		private readonly Harmony harmony = new Harmony("EvilCheetah.REPO.PlayerCountPricing");

		private static ScalingPricingBase instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("EvilCheetah.REPO.PlayerCountPricing");
			Configuration.Init(((BaseUnityPlugin)this).Config);
			mls.LogInfo((object)"Player Count Pricing mod has been activated");
			harmony.PatchAll(typeof(ScalingPricingBase));
			harmony.PatchAll(typeof(ShopManagerPatch));
			harmony.PatchAll(typeof(ItemAttributesPatch));
		}
	}
}
namespace ScalingPrices.Patches
{
	[HarmonyPatch(typeof(ItemAttributes), "GetValue")]
	internal class ItemAttributesPatch
	{
		public static bool Prefix(ItemAttributes __instance)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			ItemAttributesHelper.Instance = __instance;
			if (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient)
			{
				float num = Random.Range(ItemAttributesHelper.ItemValueMin, ItemAttributesHelper.ItemValueMax) * ShopManagerHelper.ItemValueMultiplier;
				if (num < 1000f)
				{
					num = 1000f;
				}
				if (num >= 1000f)
				{
					num = Mathf.Ceil(num / 1000f);
				}
				itemType itemType = ItemAttributesHelper.ItemType;
				if ((int)itemType != 3)
				{
					if ((int)itemType != 5)
					{
						if ((int)itemType == 8)
						{
							num += num * ShopManagerHelper.HealthPackIncrease * (float)RunManager.instance.levelsCompleted + (float)SemiFunc.PlayerGetAll().Count * Configuration.HealthPackIncreasePerPlayer.Value;
						}
					}
					else
					{
						num += num * ShopManagerHelper.CrystalIncrease * (float)RunManager.instance.levelsCompleted + (float)SemiFunc.PlayerGetAll().Count * Configuration.CrystalIncreasePerPlayer.Value;
					}
				}
				else
				{
					num += num * ShopManagerHelper.UpgradeIncrease * (float)StatsManager.instance.GetItemsUpgradesPurchased(ItemAttributesHelper.ItemAssetName) + (float)SemiFunc.PlayerGetAll().Count * Configuration.UpgradeIncreasePerPlayer.Value;
				}
				ItemAttributesHelper.ItemValue = (int)num;
				if (GameManager.Multiplayer())
				{
					ItemAttributesHelper.PhotonView.RPC("GetValueRPC", (RpcTarget)1, new object[1] { ItemAttributesHelper.ItemValue });
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(ShopManager), "Update")]
	internal class ShopManagerPatch
	{
		private static void Postfix(ShopManager __instance)
		{
			ShopManagerHelper.Instance = __instance;
			ShopManagerHelper.ItemValueMultiplier = Configuration.ItemValueMultiplier.Value;
			ShopManagerHelper.UpgradeIncrease = Configuration.UpgradeIncrease.Value;
			ShopManagerHelper.HealthPackIncrease = Configuration.HealthPackIncrease.Value;
			ShopManagerHelper.CrystalIncrease = Configuration.CrystalIncrease.Value;
		}
	}
}
namespace ScalingPrices.Helpers
{
	internal class ItemAttributesHelper
	{
		private static readonly FieldRef<ItemAttributes, PhotonView> photon_view_ref = AccessTools.FieldRefAccess<ItemAttributes, PhotonView>("photonView");

		private static readonly FieldRef<ItemAttributes, string> item_asset_name_ref = AccessTools.FieldRefAccess<ItemAttributes, string>("itemAssetName");

		private static readonly FieldRef<ItemAttributes, itemType> item_type_ref = AccessTools.FieldRefAccess<ItemAttributes, itemType>("itemType");

		private static readonly FieldRef<ItemAttributes, int> item_value_ref = AccessTools.FieldRefAccess<ItemAttributes, int>("value");

		private static readonly FieldRef<ItemAttributes, float> item_value_min_ref = AccessTools.FieldRefAccess<ItemAttributes, float>("itemValueMin");

		private static readonly FieldRef<ItemAttributes, float> item_value_max_ref = AccessTools.FieldRefAccess<ItemAttributes, float>("itemValueMax");

		public static ItemAttributes Instance { get; set; }

		public static PhotonView PhotonView => photon_view_ref.Invoke(Instance);

		public static string ItemAssetName
		{
			get
			{
				return item_asset_name_ref.Invoke(Instance);
			}
			set
			{
				item_asset_name_ref.Invoke(Instance) = value;
			}
		}

		public static itemType ItemType
		{
			get
			{
				return item_type_ref.Invoke(Instance);
			}
			set
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected I4, but got Unknown
				item_type_ref.Invoke(Instance) = (itemType)(int)value;
			}
		}

		public static int ItemValue
		{
			get
			{
				return item_value_ref.Invoke(Instance);
			}
			set
			{
				item_value_ref.Invoke(Instance) = value;
			}
		}

		public static float ItemValueMin
		{
			get
			{
				return item_value_min_ref.Invoke(Instance);
			}
			set
			{
				item_value_min_ref.Invoke(Instance) = value;
			}
		}

		public static float ItemValueMax
		{
			get
			{
				return item_value_max_ref.Invoke(Instance);
			}
			set
			{
				_ = ref item_value_max_ref.Invoke(Instance);
			}
		}
	}
	internal class ShopManagerHelper
	{
		private static readonly FieldRef<ShopManager, float> item_value_multiplier_ref = AccessTools.FieldRefAccess<ShopManager, float>("itemValueMultiplier");

		private static readonly FieldRef<ShopManager, float> upgrade_increase_ref = AccessTools.FieldRefAccess<ShopManager, float>("upgradeValueIncrease");

		private static readonly FieldRef<ShopManager, float> health_pack_increase_ref = AccessTools.FieldRefAccess<ShopManager, float>("healthPackValueIncrease");

		private static readonly FieldRef<ShopManager, float> crystal_increase_ref = AccessTools.FieldRefAccess<ShopManager, float>("crystalValueIncrease");

		public static ShopManager Instance { get; set; }

		public static float ItemValueMultiplier
		{
			get
			{
				return item_value_multiplier_ref.Invoke(Instance);
			}
			set
			{
				item_value_multiplier_ref.Invoke(Instance) = value;
			}
		}

		public static float UpgradeIncrease
		{
			get
			{
				return upgrade_increase_ref.Invoke(Instance);
			}
			set
			{
				upgrade_increase_ref.Invoke(Instance) = value;
			}
		}

		public static float HealthPackIncrease
		{
			get
			{
				return health_pack_increase_ref.Invoke(Instance);
			}
			set
			{
				health_pack_increase_ref.Invoke(Instance) = value;
			}
		}

		public static float CrystalIncrease
		{
			get
			{
				return crystal_increase_ref.Invoke(Instance);
			}
			set
			{
				crystal_increase_ref.Invoke(Instance) = value;
			}
		}
	}
}
namespace ScalingPrices.Config
{
	internal class Configuration
	{
		public static ConfigEntry<float> ItemValueMultiplier;

		public static ConfigEntry<float> UpgradeIncrease;

		public static ConfigEntry<float> HealthPackIncrease;

		public static ConfigEntry<float> CrystalIncrease;

		public static ConfigEntry<float> UpgradeIncreasePerPlayer;

		public static ConfigEntry<float> HealthPackIncreasePerPlayer;

		public static ConfigEntry<float> CrystalIncreasePerPlayer;

		public static void Init(ConfigFile config)
		{
			ItemValueMultiplier = config.Bind<float>("Default", "ValueMultiplier", 4f, "Multiplier applied to the base price of items");
			UpgradeIncrease = config.Bind<float>("Default", "UpgradeIncrease", 0.5f, "Multiplier applied to the base price of items");
			HealthPackIncrease = config.Bind<float>("Default", "HealthPackIncrease", 0.05f, "Multiplier applied to the base price of items");
			CrystalIncrease = config.Bind<float>("Default", "CrystalIncrease", 0.2f, "Multiplier applied to the base price of items");
			UpgradeIncreasePerPlayer = config.Bind<float>("PerPlayerIncrease", "UpgradeIncrease", 0f, "Multiplier applied to the base price of items");
			HealthPackIncreasePerPlayer = config.Bind<float>("PerPlayerIncrease", "HealthPackIncrease", 0f, "Multiplier applied to the base price of items");
			CrystalIncreasePerPlayer = config.Bind<float>("PerPlayerIncrease", "CrystalIncrease", 0f, "Multiplier applied to the base price of items");
		}
	}
}