Decompiled source of MeridianPrimePrime v1.0.0

plugins/MeridianPrimePrime/MeridianPrimePrime.dll

Decompiled 4 hours 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 BepInEx;
using BepInEx.Logging;
using EntityStates.Geode;
using EntityStates.Missions.GeodeSecretMission;
using HarmonyLib;
using MeridianPrimePrime.IL;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
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("MeridianPrimePrime")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6266a364d6f2a1aa6ca95abef02afaee18d8d24e")]
[assembly: AssemblyProduct("MeridianPrimePrime")]
[assembly: AssemblyTitle("MeridianPrimePrime")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 MeridianPrimePrime
{
	[HarmonyPatch]
	[BepInPlugin("itsschwer.MeridianPrimePrime", "MeridianPrimePrime", "1.0.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string GUID = "itsschwer.MeridianPrimePrime";

		public const string Author = "itsschwer";

		public const string Name = "MeridianPrimePrime";

		public const string Version = "1.0.0";

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Logger.Sources.Remove((ILogSource)(object)((BaseUnityPlugin)this).Logger);
			Logger = Logger.CreateLogSource("itsschwer.MeridianPrimePrime");
			new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll();
			RemoveGeodeBuffFromAllPlayers.Apply();
			Logger.LogMessage((object)"~awake.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GeodeSecretMissionRewardState), "DropRewards")]
		private static void GeodeSecretMissionRewardState_DropRewards(GeodeSecretMissionRewardState __instance)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((GeodeSecretMissionEntityStates)__instance).geodeSecretMissionController.rewardSpawnLocation.transform.position;
			Quaternion identity = Quaternion.identity;
			foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
			{
				if (readOnlyInstances.master.IsDeadAndOutOfLivesServer())
				{
					readOnlyInstances.master.Respawn(position, identity, false);
				}
				MinionGroup val = MinionGroup.FindGroup(((NetworkBehaviour)readOnlyInstances.master).netId);
				if (val == null || val.members == null)
				{
					continue;
				}
				MinionOwnership[] members = val.members;
				foreach (MinionOwnership obj in members)
				{
					object obj2;
					if (obj == null)
					{
						obj2 = null;
					}
					else
					{
						CharacterMaster component = ((Component)obj).GetComponent<CharacterMaster>();
						obj2 = ((component != null) ? component.GetBody() : null);
					}
					CharacterBody val2 = (CharacterBody)obj2;
					if ((Object)(object)val2 != (Object)null)
					{
						Vector2 val3 = Random.insideUnitCircle * 10f;
						TeleportHelper.TeleportBody(val2, position + new Vector3(val3.x, 0f, val3.y));
						GameObject teleportEffectPrefab = Run.instance.GetTeleportEffectPrefab(((Component)val2).gameObject);
						if ((Object)(object)teleportEffectPrefab != (Object)null)
						{
							EffectManager.SimpleEffect(teleportEffectPrefab, position, identity, true);
						}
					}
				}
			}
			foreach (PurchaseInteraction instances in InstanceTracker.GetInstancesList<PurchaseInteraction>())
			{
				if (instances.displayNameToken.Contains("DRONE"))
				{
					Vector2 val4 = Random.insideUnitCircle * 10f;
					((Component)instances).transform.position = position + new Vector3(val4.x, 0f, val4.y);
				}
			}
		}
	}
}
namespace MeridianPrimePrime.IL
{
	internal static class RemoveGeodeBuffFromAllPlayers
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Instruction, bool> <>9__0_2;

			public static Func<Instruction, bool> <>9__0_4;

			public static Func<Instruction, bool> <>9__0_5;

			public static Func<Instruction, bool> <>9__0_6;

			public static Manipulator <>9__0_0;

			internal void <Apply>b__0_0(ILContext il)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Expected O, but got Unknown
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0();
				ILCursor val = new ILCursor(il);
				CS$<>8__locals0.iter = null;
				CS$<>8__locals0.curr = null;
				Func<Instruction, bool>[] array = new Func<Instruction, bool>[6]
				{
					(Instruction x) => ILPatternMatchingExt.MatchBr(x, ref CS$<>8__locals0.iter),
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 0),
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref CS$<>8__locals0.curr),
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PlayerCharacterMasterController>(x, "get_networkUser"),
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<NetworkUser>(x, "GetCurrentBody"),
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 1)
				};
				if (val.TryGotoNext((MoveType)2, array))
				{
					val.Emit(OpCodes.Ldloc_1);
					val.Emit(OpCodes.Brfalse, CS$<>8__locals0.iter.Target);
				}
				else
				{
					Plugin.Logger.LogError((object)"RemoveGeodeBuffFromAllPlayers> Cannot hook: failed to match IL instructions.");
				}
			}

			internal bool <Apply>b__0_2(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdloc(x, 0);
			}

			internal bool <Apply>b__0_4(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallOrCallvirt<PlayerCharacterMasterController>(x, "get_networkUser");
			}

			internal bool <Apply>b__0_5(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallOrCallvirt<NetworkUser>(x, "GetCurrentBody");
			}

			internal bool <Apply>b__0_6(Instruction x)
			{
				return ILPatternMatchingExt.MatchStloc(x, 1);
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass0_0
		{
			public ILLabel iter;

			public MethodReference curr;

			internal bool <Apply>b__1(Instruction x)
			{
				return ILPatternMatchingExt.MatchBr(x, ref iter);
			}

			internal bool <Apply>b__3(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallOrCallvirt(x, ref curr);
			}
		}

		internal static void Apply()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			MethodInfo? method = typeof(GeodeShatter).GetMethod("RemoveGeodeBuffFromAllPlayers", BindingFlags.Instance | BindingFlags.NonPublic);
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				Manipulator val = delegate(ILContext il)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_000d: Expected O, but got Unknown
					//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00df: Unknown result type (might be due to invalid IL or missing references)
					ILCursor val2 = new ILCursor(il);
					ILLabel iter = null;
					MethodReference curr = null;
					Func<Instruction, bool>[] array = new Func<Instruction, bool>[6]
					{
						(Instruction x) => ILPatternMatchingExt.MatchBr(x, ref iter),
						(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 0),
						(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref curr),
						(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PlayerCharacterMasterController>(x, "get_networkUser"),
						(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<NetworkUser>(x, "GetCurrentBody"),
						(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 1)
					};
					if (val2.TryGotoNext((MoveType)2, array))
					{
						val2.Emit(OpCodes.Ldloc_1);
						val2.Emit(OpCodes.Brfalse, iter.Target);
					}
					else
					{
						Plugin.Logger.LogError((object)"RemoveGeodeBuffFromAllPlayers> Cannot hook: failed to match IL instructions.");
					}
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			new ILHook((MethodBase)method, (Manipulator)obj);
		}
	}
}