Decompiled source of FirstPageReincarnation v1.0.0

FirstPageReincarnation.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[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("FirstPageReincarnation")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FirstPageReincarnation")]
[assembly: AssemblyTitle("FirstPageReincarnation")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[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 FirstPageReincarnation
{
	[BepInPlugin("com.firstpagereincarnation.ror2", "First Page Reincarnation", "1.0.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PickupDropletController), "CreatePickupDroplet", new Type[]
		{
			typeof(CreatePickupInfo),
			typeof(Vector3),
			typeof(Vector3)
		})]
		private static class DropletPatch
		{
			private static void Prefix(ref CreatePickupInfo __0)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				UniquePickup pickup = ((CreatePickupInfo)(ref __0)).pickup;
				if (TryReplace(ref pickup))
				{
					((CreatePickupInfo)(ref __0)).pickup = pickup;
				}
			}
		}

		[HarmonyPatch(typeof(GenericPickupController), "set_pickup", new Type[] { typeof(UniquePickup) })]
		private static class WorldPickupPatch
		{
			private static void Prefix(ref UniquePickup __0)
			{
				TryReplace(ref __0);
			}
		}

		public const string PluginGuid = "com.firstpagereincarnation.ror2";

		public const string PluginName = "First Page Reincarnation";

		public const string PluginVersion = "1.0.0";

		private static Run? observedRun;

		private static bool firstPageHandled;

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.firstpagereincarnation.ror2").PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"First Page Reincarnation enabled (server authoritative).");
		}

		private static bool TryReplace(ref UniquePickup pickup)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return false;
			}
			Run instance = Run.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return false;
			}
			if ((Object)(object)observedRun != (Object)(object)instance)
			{
				observedRun = instance;
				firstPageHandled = false;
			}
			if (firstPageHandled || !((PickupIndex)(ref pickup.pickupIndex)).isValid)
			{
				return false;
			}
			PickupDef pickupDef = PickupCatalog.GetPickupDef(pickup.pickupIndex);
			if (pickupDef == null || (int)pickupDef.itemTier != 12)
			{
				return false;
			}
			PickupIndex val = PickupCatalog.FindPickupIndex(ItemCatalog.FindItemIndex("PageDie"));
			if (!((PickupIndex)(ref val)).isValid)
			{
				return false;
			}
			pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(val);
			pickup.ignoreArtifactBasedPickupReplacements = true;
			firstPageHandled = true;
			return true;
		}
	}
}