Decompiled source of GupLimiter v1.0.2

GupLimiter.dll

Decompiled 3 months ago
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
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("GupLimiter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c1ab96f0cf6dddf53614f177282a7062a29b6ee4")]
[assembly: AssemblyProduct("GupLimiter")]
[assembly: AssemblyTitle("GupLimiter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GupLimiter
{
	[BepInPlugin("com.Moffein.GupLimiter", "GupLimiter", "1.0.1")]
	public class GupLimiter : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

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

			public static Func<int, MasterSummon, TeamIndex, int> <>9__4_2;

			public static Manipulator <>9__4_0;

			internal void <Awake>b__4_0(ILContext il)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<TeamComponent>(x, "GetTeamMembers")
				});
				int index = val.Index;
				val.Index = index + 1;
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc_0);
				val.EmitDelegate<Func<int, MasterSummon, TeamIndex, int>>((Func<int, MasterSummon, TeamIndex, int>)delegate(int memberCount, MasterSummon self, TeamIndex teamIndex)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_000a: Invalid comparison between Unknown and I4
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					//IL_004b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0050: Unknown result type (might be due to invalid IL or missing references)
					//IL_006c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0071: Unknown result type (might be due to invalid IL or missing references)
					if (!ignorePlayerTeam || (int)teamIndex != 1)
					{
						ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers(teamIndex);
						foreach (TeamComponent item in teamMembers)
						{
							if (Object.op_Implicit((Object)(object)item.body))
							{
								if (item.body.bodyIndex == geepIndex)
								{
									memberCount++;
								}
								else if (item.body.bodyIndex == gupIndex)
								{
									memberCount += ((!aggressive) ? 1 : 3);
								}
							}
						}
					}
					return memberCount;
				});
			}

			internal bool <Awake>b__4_1(Instruction x)
			{
				return ILPatternMatchingExt.MatchCall<TeamComponent>(x, "GetTeamMembers");
			}

			internal int <Awake>b__4_2(int memberCount, MasterSummon self, TeamIndex teamIndex)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Invalid comparison between Unknown and I4
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				if (!ignorePlayerTeam || (int)teamIndex != 1)
				{
					ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers(teamIndex);
					foreach (TeamComponent item in teamMembers)
					{
						if (Object.op_Implicit((Object)(object)item.body))
						{
							if (item.body.bodyIndex == geepIndex)
							{
								memberCount++;
							}
							else if (item.body.bodyIndex == gupIndex)
							{
								memberCount += ((!aggressive) ? 1 : 3);
							}
						}
					}
				}
				return memberCount;
			}
		}

		public static bool aggressive = false;

		public static bool ignorePlayerTeam = true;

		private static BodyIndex gupIndex;

		private static BodyIndex geepIndex;

		public void Awake()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			aggressive = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Aggressive Limiting", false, "Count Gups as 4 enemies instead of 2.").Value;
			ignorePlayerTeam = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Ignore Player Team", true, "Don't apply changes to Gups/Geeps on the Player team.").Value;
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				Manipulator val = delegate(ILContext il)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Expected O, but got Unknown
					//IL_004a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0056: Unknown result type (might be due to invalid IL or missing references)
					ILCursor val2 = new ILCursor(il);
					val2.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
					{
						(Instruction x) => ILPatternMatchingExt.MatchCall<TeamComponent>(x, "GetTeamMembers")
					});
					int index = val2.Index;
					val2.Index = index + 1;
					val2.Emit(OpCodes.Ldarg_0);
					val2.Emit(OpCodes.Ldloc_0);
					val2.EmitDelegate<Func<int, MasterSummon, TeamIndex, int>>((Func<int, MasterSummon, TeamIndex, int>)delegate(int memberCount, MasterSummon self, TeamIndex teamIndex)
					{
						//IL_0008: Unknown result type (might be due to invalid IL or missing references)
						//IL_000a: Invalid comparison between Unknown and I4
						//IL_001a: Unknown result type (might be due to invalid IL or missing references)
						//IL_004b: Unknown result type (might be due to invalid IL or missing references)
						//IL_0050: Unknown result type (might be due to invalid IL or missing references)
						//IL_006c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0071: Unknown result type (might be due to invalid IL or missing references)
						if (!ignorePlayerTeam || (int)teamIndex != 1)
						{
							ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers(teamIndex);
							foreach (TeamComponent item in teamMembers)
							{
								if (Object.op_Implicit((Object)(object)item.body))
								{
									if (item.body.bodyIndex == geepIndex)
									{
										memberCount++;
									}
									else if (item.body.bodyIndex == gupIndex)
									{
										memberCount += ((!aggressive) ? 1 : 3);
									}
								}
							}
						}
						return memberCount;
					});
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			MasterSummon.Perform += (Manipulator)obj;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(GetBodyIndices));
		}

		private void GetBodyIndices()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			gupIndex = BodyCatalog.FindBodyIndex("GupBody");
			geepIndex = BodyCatalog.FindBodyIndex("GeepBody");
		}
	}
}
namespace R2API.Utils
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class ManualNetworkRegistrationAttribute : Attribute
	{
	}
}