Decompiled source of BetterPotPowerUp v0.1.0

BetterPotPowerUp.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Assets.Scripts.Inventory__Items__Pickups.Interactables;
using Assets.Scripts.Inventory__Items__Pickups.Pickups;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BetterPotPowerUp")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Improves pot pickups")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("BetterPotPowerUp")]
[assembly: AssemblyTitle("BetterPotPowerUp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.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 BetterPotPowerUp
{
	[BepInPlugin("YourName_BetterPotPowerUp", "BetterPotPowerUp", "0.1.0")]
	public class Plugin : BasePlugin
	{
		public const string MODNAME = "BetterPotPowerUp";

		public const string AUTHOR = "YourName";

		public const string GUID = "YourName_BetterPotPowerUp";

		public const string VERSION = "0.1.0";

		public static ManualLogSource log;

		private static Harmony harmony;

		public Plugin()
		{
			log = ((BasePlugin)this).Log;
		}

		public override void Load()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			ManualLogSource val = log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(14, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loading ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("BetterPotPowerUp");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("0.1.0");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" by ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("YourName");
			}
			val.LogInfo(val2);
			harmony = new Harmony("YourName_BetterPotPowerUp");
			harmony.PatchAll(typeof(InteractablePotPatches));
			ManualLogSource val3 = log;
			val2 = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("BetterPotPowerUp");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" patches applied successfully!");
			}
			val3.LogInfo(val2);
		}

		public override bool Unload()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			return ((BasePlugin)this).Unload();
		}
	}
	[HarmonyPatch(typeof(InteractablePot))]
	public static class InteractablePotPatches
	{
		[HarmonyPatch("SpawnStuff")]
		[HarmonyPrefix]
		public static void SpawnStuffPrefix(ref EPickup ePickup, ref int amount)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			try
			{
				if ((int)ePickup == 2)
				{
					EPickup[] array = new EPickup[8];
					RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
					EPickup[] array2 = (EPickup[])(object)array;
					int num = Random.Range(0, array2.Length);
					ePickup = array2[num];
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in SpawnStuffPrefix: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogError(val);
			}
		}
	}
}