Decompiled source of MoreValuablesUpgrade v1.0.2

MoreValuablesUpgrade.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreUpgrades.Classes;
using MoreValuablesUpgrade.Patches;
using Sirenix.Utilities;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MoreValuablesUpgrade")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("More Valuables Upgrade")]
[assembly: AssemblyTitle("MoreValuablesUpgrade")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 MoreValuablesUpgrade
{
	[BepInPlugin("MoreValuablesUpgrade", "More Valuables Upgrade", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("MoreValuablesUpgrade");

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		public UpgradeItem increasedValuablesUpgrade { get; private set; }

		private void Awake()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			Instance = CheckInstance();
			Logger = ((BaseUnityPlugin)this).Logger;
			AssetBundle val = LoadAssetBundle("morevaluablesupgrade_assets.file");
			GameObject val2 = LoadAssetFromBundle(val, "Increased Valuables Prefab");
			Item val3 = val.LoadAsset<Item>("Increased Valuables Item");
			UpgradeItemBase val4 = new UpgradeItemBase
			{
				name = "Increased Valuables",
				maxAmount = 2,
				maxAmountInShop = 2,
				minPrice = 15000f,
				maxPrice = 20000f,
				maxPurchaseAmount = 0,
				priceIncreaseScaling = 0.75f
			};
			increasedValuablesUpgrade = MoreUpgradesLib.Register("MoreValuablesUpgrade", val3, val2, val4);
			increasedValuablesUpgrade.AddConfig<float>("Increase factor", 1.1f, new ConfigDescription("The amount of valuables to increase per upgrade bought.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2f), Array.Empty<object>()));
			_harmony.PatchAll(typeof(LevelGeneratorPatch));
			Logger.LogInfo((object)"MoreValuablesUpgrade is loaded!");
		}

		private Plugin CheckInstance()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return this;
			}
			return Instance;
		}

		private AssetBundle LoadAssetBundle(string filename)
		{
			return AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), filename));
		}

		private GameObject LoadAssetFromBundle(AssetBundle bundle, string name)
		{
			return bundle.LoadAsset<GameObject>(name);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MoreValuablesUpgrade";

		public const string PLUGIN_NAME = "More Valuables Upgrade";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace MoreValuablesUpgrade.Constants
{
	public static class Strings
	{
		public const string UPGRADE_1_NAME = "Increased Valuables";

		public const string UPGRADE_2_NAME = "Expensive Valuables";

		public const string BundleName = "morevaluablesupgrade_assets.file";
	}
	public static class Integers
	{
		public const int UPGRADE_1_MAXAMOUNT_AND_INSHOP = 2;

		public const int UPGRADE_1_MAX_PURCHASE_AMOUNT = 0;
	}
	public static class Floats
	{
		public const float UPGRADE_1_MIN_PRICE = 15000f;

		public const float UPGRADE_1_MAX_PRICE = 20000f;

		public const float UPGRADE_1_PRICE_SCALING = 0.75f;

		public const float UPGRADE_1_INCREASE_FACTOR = 1.1f;
	}
}
namespace MoreValuablesUpgrade.Patches
{
	[HarmonyPatch(typeof(LevelGenerator))]
	internal static class LevelGeneratorPatch
	{
		private static AnimationCurve total_default = ValuableDirector.instance.totalMaxAmountCurve;

		private static AnimationCurve tiny_default = ValuableDirector.instance.tinyMaxAmountCurve;

		private static AnimationCurve small_default = ValuableDirector.instance.smallMaxAmountCurve;

		private static AnimationCurve medium_default = ValuableDirector.instance.mediumMaxAmountCurve;

		private static AnimationCurve big_default = ValuableDirector.instance.bigMaxAmountCurve;

		private static AnimationCurve wide_default = ValuableDirector.instance.wideMaxAmountCurve;

		private static AnimationCurve tall_default = ValuableDirector.instance.tallMaxAmountCurve;

		private static AnimationCurve veryTall_default = ValuableDirector.instance.veryTallMaxAmountCurve;

		private static int previousValue = 0;

		private static float increaseFactor = 1.1f;

		private static int upgradesPurchased = 0;

		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void IncreaseAnimationKeys()
		{
			if (!SemiFunc.IsMasterClient() && SemiFunc.IsMultiplayer())
			{
				return;
			}
			if (RunManager.instance.levelCurrent.ResourcePath == "Arena" || RunManager.instance.levelCurrent.ResourcePath == "Lobby" || RunManager.instance.levelCurrent.ResourcePath == "Lobby Menu" || RunManager.instance.levelCurrent.ResourcePath == "Main Menu" || RunManager.instance.levelCurrent.ResourcePath == "Recording" || RunManager.instance.levelCurrent.ResourcePath == "Tutorial")
			{
				ValuableDirector.instance.totalMaxAmountCurve = total_default;
				ValuableDirector.instance.tinyMaxAmountCurve = tiny_default;
				ValuableDirector.instance.smallMaxAmountCurve = small_default;
				ValuableDirector.instance.mediumMaxAmountCurve = medium_default;
				ValuableDirector.instance.bigMaxAmountCurve = big_default;
				ValuableDirector.instance.wideMaxAmountCurve = wide_default;
				ValuableDirector.instance.tallMaxAmountCurve = tall_default;
				ValuableDirector.instance.veryTallMaxAmountCurve = veryTall_default;
				previousValue = 0;
				upgradesPurchased = 0;
				increaseFactor = 0f;
			}
			else
			{
				if (RunManager.instance.levelCurrent.ResourcePath != "Arctic" && RunManager.instance.levelCurrent.ResourcePath != "Wizard" && RunManager.instance.levelCurrent.ResourcePath != "Manor")
				{
					return;
				}
				increaseFactor = Plugin.Instance.increasedValuablesUpgrade.GetConfig<float>("Increase factor");
				if (StatsManager.instance.itemsPurchasedTotal.ContainsKey("Modded Item Upgrade Player Increased Valuables"))
				{
					upgradesPurchased = StatsManager.instance.itemsPurchasedTotal["Modded Item Upgrade Player Increased Valuables"];
					if (upgradesPurchased > previousValue)
					{
						ValuableDirector.instance.totalMaxAmountCurve = ReplaceCurve(ValuableDirector.instance.totalMaxAmountCurve, upgradesPurchased, increaseFactor);
						ValuableDirector.instance.tinyMaxAmountCurve = ReplaceCurve(ValuableDirector.instance.tinyMaxAmountCurve, upgradesPurchased, increaseFactor);
						ValuableDirector.instance.smallMaxAmountCurve = ReplaceCurve(ValuableDirector.instance.smallMaxAmountCurve, upgradesPurchased, increaseFactor);
						ValuableDirector.instance.mediumMaxAmountCurve = ReplaceCurve(ValuableDirector.instance.mediumMaxAmountCurve, upgradesPurchased, increaseFactor);
						ValuableDirector.instance.bigMaxAmountCurve = ReplaceCurve(ValuableDirector.instance.bigMaxAmountCurve, upgradesPurchased, increaseFactor);
						ValuableDirector.instance.wideMaxAmountCurve = ReplaceCurve(ValuableDirector.instance.wideMaxAmountCurve, upgradesPurchased, increaseFactor);
						ValuableDirector.instance.tallMaxAmountCurve = ReplaceCurve(ValuableDirector.instance.tallMaxAmountCurve, upgradesPurchased, increaseFactor);
						ValuableDirector.instance.veryTallMaxAmountCurve = ReplaceCurve(ValuableDirector.instance.veryTallMaxAmountCurve, upgradesPurchased, increaseFactor);
						previousValue = upgradesPurchased;
					}
				}
			}
		}

		private static AnimationCurve ReplaceCurve(AnimationCurve target, int factor, float increment)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			AnimationCurve newCurve = new AnimationCurve();
			LinqExtensions.ForEach<Keyframe>((IEnumerable<Keyframe>)target.GetKeys(), (Action<Keyframe>)delegate(Keyframe key)
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				((Keyframe)(ref key)).value = ((Keyframe)(ref key)).value * Mathf.Pow(increment, (float)factor);
				newCurve.AddKey(key);
			});
			return newCurve;
		}
	}
}