Decompiled source of NoShopInflation v1.0.0

NoShopInflation.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoShopInflation")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Disables shop price inflation for upgrades, health packs, crystals, and rerolls in R.E.P.O.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+acf50f7095eed3ed236b176fe7f36cfe19de3d2f")]
[assembly: AssemblyProduct("NoShopInflation")]
[assembly: AssemblyTitle("NoShopInflation")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NoShopInflation
{
	[BepInPlugin("com.kuziletki.noshopinflation", "No Shop Inflation", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string MOD_GUID = "com.kuziletki.noshopinflation";

		public const string MOD_NAME = "No Shop Inflation";

		public const string MOD_VERSION = "1.0.0";

		public static ConfigEntry<bool> DisableUpgradeInflation;

		public static ConfigEntry<bool> DisableHealthPackInflation;

		public static ConfigEntry<bool> DisableCrystalInflation;

		public static ConfigEntry<bool> DisableRerollInflation;

		public static Plugin Instance;

		private Harmony harmony;

		private void Awake()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			Instance = this;
			DisableUpgradeInflation = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableUpgradeInflation", true, "Disables price increase for upgrades when purchased. Upgrades stay at base price.");
			DisableHealthPackInflation = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableHealthPackInflation", true, "Disables price increase for health packs across completed levels.");
			DisableCrystalInflation = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableCrystalInflation", true, "Disables price increase for power crystals across completed levels.");
			DisableRerollInflation = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableRerollInflation", true, "Disables price increase for the upgrade stand reroll button (keeps cost at fixed 5k).");
			harmony = new Harmony("com.kuziletki.noshopinflation");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"No Shop Inflation v1.0.0 loaded! Shop price inflation is disabled.");
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(ShopManager), "Awake")]
	public static class Patch_ShopManager_Awake
	{
		public static void Postfix(ShopManager __instance)
		{
			Traverse val = Traverse.Create((object)__instance);
			if (Plugin.DisableUpgradeInflation.Value)
			{
				val.Field("upgradeValueIncrease").SetValue((object)0f);
			}
			if (Plugin.DisableHealthPackInflation.Value)
			{
				val.Field("healthPackValueIncrease").SetValue((object)0f);
			}
			if (Plugin.DisableCrystalInflation.Value)
			{
				val.Field("crystalValueIncrease").SetValue((object)0f);
			}
		}
	}
	[HarmonyPatch(typeof(ShopManager), "UpgradeValueGet")]
	public static class Patch_UpgradeValueGet
	{
		public static bool Prefix(ShopManager __instance, ref float _value, Item item, ref float __result)
		{
			if (!Plugin.DisableUpgradeInflation.Value)
			{
				return true;
			}
			int num = ((!((Object)(object)GameDirector.instance != (Object)null) || GameDirector.instance.PlayerList == null) ? 1 : Mathf.Min(6, GameDirector.instance.PlayerList.Count));
			_value -= _value * 0.1f * (float)(num - 1);
			_value = Mathf.Ceil(_value);
			__result = _value;
			return false;
		}
	}
	[HarmonyPatch(typeof(ShopManager), "HealthPackValueGet")]
	public static class Patch_HealthPackValueGet
	{
		public static bool Prefix(ShopManager __instance, ref float _value, ref float __result)
		{
			if (!Plugin.DisableHealthPackInflation.Value)
			{
				return true;
			}
			int num = ((!((Object)(object)GameDirector.instance != (Object)null) || GameDirector.instance.PlayerList == null) ? 1 : Mathf.Min(6, GameDirector.instance.PlayerList.Count));
			_value -= _value * 0.1f * (float)(num - 1);
			_value = Mathf.Ceil(_value);
			__result = _value;
			return false;
		}
	}
	[HarmonyPatch(typeof(ShopManager), "CrystalValueGet")]
	public static class Patch_CrystalValueGet
	{
		public static bool Prefix(ShopManager __instance, ref float _value, ref float __result)
		{
			if (!Plugin.DisableCrystalInflation.Value)
			{
				return true;
			}
			_value = Mathf.Ceil(_value);
			__result = _value;
			return false;
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public static class Patch_UpgradeStand_RerollCost
	{
		public static bool Prefix(ref int __result)
		{
			if (!Plugin.DisableRerollInflation.Value)
			{
				return true;
			}
			__result = 5;
			return false;
		}
	}
}