Decompiled source of BetterPresents v1.0.3

GiftBoxRevert.dll

Decompiled 11 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GiftBoxRevert.Patches;
using HarmonyLib;

[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 = "")]
[assembly: AssemblyCompany("GiftBoxRevert")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Reverts the giftboxes content back to being double the intended amount")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("GiftBoxRevert")]
[assembly: AssemblyTitle("GiftBoxRevert")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
namespace GiftBoxRevert
{
	[BepInPlugin("GiftBoxRevert", "GiftBoxRevert", "1.0.3")]
	public class Plugin : BaseUnityPlugin
	{
		private bool _patched;

		public static ManualLogSource Logger { get; set; }

		private void Awake()
		{
			if (_patched)
			{
				Logger.LogWarning((object)"Already loaded");
				return;
			}
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(typeof(GiftBoxPatch), "GiftBoxRevert");
			Logger.LogInfo((object)"GiftBoxRevert is loaded!");
			_patched = true;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "GiftBoxRevert";

		public const string PLUGIN_NAME = "GiftBoxRevert";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}
namespace GiftBoxRevert.Patches
{
	internal class GiftBoxPatch
	{
		[HarmonyTranspiler]
		[HarmonyPatch(typeof(GiftBoxItem), "OpenGiftBoxServerRpc")]
		private static IEnumerable<CodeInstruction> TranspileOpenGiftBoxServerRpc(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(RoundManager), "scrapValueMultiplier"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Conv_I4, (object)null, (string)null)
			}).Advance(2).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldc_R4, (object)2f),
				new CodeInstruction(OpCodes.Mul, (object)null)
			})
				.InstructionEnumeration();
		}
	}
}