Decompiled source of R2API Teams v1.0.0

plugins/R2API.Teams/R2API.Teams.dll

Decompiled 6 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HG;
using HarmonyLib;
using IL.EntityStates.GrandParentBoss;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using MonoMod.Utils;
using On.RoR2;
using R2API.AutoVersionGen;
using R2API.Utils;
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("R2API.Teams")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+184681b4876959fd205e7b50858d97ce3fc813fb")]
[assembly: AssemblyProduct("R2API.Teams")]
[assembly: AssemblyTitle("R2API.Teams")]
[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.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]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
}
namespace R2API
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		public static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[Conditional("DEBUG")]
		public static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void Error(object data)
		{
			_logSource.LogError(data);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}
	}
	[AutoVersion]
	public static class TeamsAPI
	{
		private class TeamManagerModdedTeamsHelper : MonoBehaviour
		{
			public byte[] ModdedTeamsDirtyBits;

			internal void SetDirtyBit(int moddedTeamIndex)
			{
				CompressedFlagArrayUtilities.AddImmutable(ref ModdedTeamsDirtyBits, moddedTeamIndex);
			}

			internal void ClearDirtyBits()
			{
				ModdedTeamsDirtyBits = null;
			}
		}

		public class TeamBehavior
		{
			public string Name { get; }

			public TeamClassification Classification { get; }

			public virtual LayerIndex TeamLayer
			{
				get
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_000a: Unknown result type (might be due to invalid IL or missing references)
					if ((Classification & TeamClassification.Player) == 0)
					{
						return LayerIndex.enemyBody;
					}
					return LayerIndex.playerBody;
				}
			}

			public virtual LayerIndex TeamFakeLayer
			{
				get
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_000a: Unknown result type (might be due to invalid IL or missing references)
					if ((Classification & TeamClassification.Player) == 0)
					{
						return LayerIndex.fakeActor;
					}
					return LayerIndex.playerFakeActor;
				}
			}

			public TeamBehavior(string name, TeamClassification teamClassification)
			{
				if (string.IsNullOrWhiteSpace(name))
				{
					throw new ArgumentException("'name' cannot be null or whitespace.", "name");
				}
				Name = name;
				Classification = teamClassification;
			}
		}

		[Flags]
		public enum TeamClassification
		{
			None = 0,
			Neutral = 1,
			Enemy = 2,
			Player = 4
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__ReplaceTeamIndexCount;

			public static hook_Start <1>__TeamManager_Start;

			public static Manipulator <2>__TeamManager_SetTeamExperience;

			public static hook_OnSerialize <3>__TeamManager_OnSerialize;

			public static hook_OnDeserialize <4>__TeamManager_OnDeserialize;

			public static hook_GetAppropriateLayerForTeam <5>__LayerIndex_GetAppropriateLayerForTeam;

			public static hook_GetAppropriateFakeLayerForTeam <6>__LayerIndex_GetAppropriateFakeLayerForTeam;

			public static hook_HasTeam <7>__TeamMask_HasTeam;

			public static hook_AddTeam <8>__TeamMask_AddTeam;

			public static hook_RemoveTeam <9>__TeamMask_RemoveTeam;

			public static Manipulator <10>__ReplaceTeamArraySize;

			public static Func<TeamIndex, bool> <11>__IsValidTeam;

			public static Func<TeamIndex, bool> <12>__IsModdedTeam;

			public static Action<TeamManager, TeamIndex> <13>__setModdedTeamDirtyBit;
		}

		public const string PluginGUID = "com.bepis.r2api.teams";

		public const string PluginName = "R2API.Teams";

		private static readonly int _vanillaTeamsCount = TeamCatalog.teamDefs.Length;

		private static readonly int _allVanillaTeamsDirtyBits = (1 << _vanillaTeamsCount) - 1;

		private static byte[] _allModdedTeamsDirtyBits = Array.Empty<byte>();

		private static TeamBehavior[] _moddedTeamBehaviors = new TeamBehavior[4];

		private static EnumValueHandle _teamCountHandle;

		private static bool _hooksEnabled;

		private static readonly List<IDetour> _hookInstances = new List<IDetour>();

		public const string PluginVersion = "1.0.0";

		public static int TeamCountLimit => 126;

		public static int TeamCount => TeamCatalog.teamDefs.Length;

		public static int ModdedTeamCountLimit => TeamCountLimit - _vanillaTeamsCount;

		public static int ModdedTeamCount => Math.Max(0, TeamCount - _vanillaTeamsCount);

		internal static void Init()
		{
			_ = TeamCatalog.teamDefs;
		}

		internal static void SetHooks()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//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_00c3: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0158: 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_0163: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Expected O, but got Unknown
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Expected O, but got Unknown
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Expected O, but got Unknown
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Expected O, but got Unknown
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Expected O, but got Unknown
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Expected O, but got Unknown
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Expected O, but got Unknown
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Expected O, but got Unknown
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Expected O, but got Unknown
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Expected O, but got Unknown
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Expected O, but got Unknown
			if (_hooksEnabled)
			{
				return;
			}
			object obj = <>O.<0>__ReplaceTeamIndexCount;
			if (obj == null)
			{
				Manipulator val = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val;
				obj = (object)val;
			}
			Offspring.FindTargetFarthest += (Manipulator)obj;
			object obj2 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj2 == null)
			{
				Manipulator val2 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val2;
				obj2 = (object)val2;
			}
			AffixBeadAttachment.ClearEnemyLunarRuinDamage += (Manipulator)obj2;
			object obj3 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj3 == null)
			{
				Manipulator val3 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val3;
				obj3 = (object)val3;
			}
			BuffWard.FixedUpdate += (Manipulator)obj3;
			object obj4 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj4 == null)
			{
				Manipulator val4 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val4;
				obj4 = (object)val4;
			}
			FogDamageController.MyFixedUpdate += (Manipulator)obj4;
			object obj5 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj5 == null)
			{
				Manipulator val5 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val5;
				obj5 = (object)val5;
			}
			GhostGunController.FindTarget += (Manipulator)obj5;
			object obj6 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj6 == null)
			{
				Manipulator val6 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val6;
				obj6 = (object)val6;
			}
			GoldTitanManager.CalcTitanPowerAndBestTeam += (Manipulator)obj6;
			object obj7 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj7 == null)
			{
				Manipulator val7 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val7;
				obj7 = (object)val7;
			}
			HoldoutZoneController.UpdateHealingNovas += (Manipulator)obj7;
			object obj8 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj8 == null)
			{
				Manipulator val8 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val8;
				obj8 = (object)val8;
			}
			TeamComponent.TeamIsValid += (Manipulator)obj8;
			object obj9 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj9 == null)
			{
				Manipulator val9 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val9;
				obj9 = (object)val9;
			}
			TeamManager.Start += (Manipulator)obj9;
			object obj10 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj10 == null)
			{
				Manipulator val10 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val10;
				obj10 = (object)val10;
			}
			TeamManager.GetTeamExperience += (Manipulator)obj10;
			object obj11 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj11 == null)
			{
				Manipulator val11 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val11;
				obj11 = (object)val11;
			}
			TeamManager.GetTeamCurrentLevelExperience += (Manipulator)obj11;
			object obj12 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj12 == null)
			{
				Manipulator val12 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val12;
				obj12 = (object)val12;
			}
			TeamManager.GetTeamNextLevelExperience += (Manipulator)obj12;
			object obj13 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj13 == null)
			{
				Manipulator val13 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val13;
				obj13 = (object)val13;
			}
			TeamManager.GetTeamLevel += (Manipulator)obj13;
			object obj14 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj14 == null)
			{
				Manipulator val14 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val14;
				obj14 = (object)val14;
			}
			TeamManager.SetTeamLevel += (Manipulator)obj14;
			object obj15 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj15 == null)
			{
				Manipulator val15 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val15;
				obj15 = (object)val15;
			}
			TeamManager.GiveTeamMoney_TeamIndex_int += (Manipulator)obj15;
			object obj16 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj16 == null)
			{
				Manipulator val16 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val16;
				obj16 = (object)val16;
			}
			TeamManager.GiveTeamItem += (Manipulator)obj16;
			object obj17 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj17 == null)
			{
				Manipulator val17 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val17;
				obj17 = (object)val17;
			}
			Util.GetEnemyEasyTarget += (Manipulator)obj17;
			object obj18 = <>O.<1>__TeamManager_Start;
			if (obj18 == null)
			{
				hook_Start val18 = TeamManager_Start;
				<>O.<1>__TeamManager_Start = val18;
				obj18 = (object)val18;
			}
			TeamManager.Start += (hook_Start)obj18;
			object obj19 = <>O.<2>__TeamManager_SetTeamExperience;
			if (obj19 == null)
			{
				Manipulator val19 = TeamManager_SetTeamExperience;
				<>O.<2>__TeamManager_SetTeamExperience = val19;
				obj19 = (object)val19;
			}
			TeamManager.SetTeamExperience += (Manipulator)obj19;
			object obj20 = <>O.<3>__TeamManager_OnSerialize;
			if (obj20 == null)
			{
				hook_OnSerialize val20 = TeamManager_OnSerialize;
				<>O.<3>__TeamManager_OnSerialize = val20;
				obj20 = (object)val20;
			}
			TeamManager.OnSerialize += (hook_OnSerialize)obj20;
			object obj21 = <>O.<4>__TeamManager_OnDeserialize;
			if (obj21 == null)
			{
				hook_OnDeserialize val21 = TeamManager_OnDeserialize;
				<>O.<4>__TeamManager_OnDeserialize = val21;
				obj21 = (object)val21;
			}
			TeamManager.OnDeserialize += (hook_OnDeserialize)obj21;
			object obj22 = <>O.<5>__LayerIndex_GetAppropriateLayerForTeam;
			if (obj22 == null)
			{
				hook_GetAppropriateLayerForTeam val22 = LayerIndex_GetAppropriateLayerForTeam;
				<>O.<5>__LayerIndex_GetAppropriateLayerForTeam = val22;
				obj22 = (object)val22;
			}
			LayerIndex.GetAppropriateLayerForTeam += (hook_GetAppropriateLayerForTeam)obj22;
			object obj23 = <>O.<6>__LayerIndex_GetAppropriateFakeLayerForTeam;
			if (obj23 == null)
			{
				hook_GetAppropriateFakeLayerForTeam val23 = LayerIndex_GetAppropriateFakeLayerForTeam;
				<>O.<6>__LayerIndex_GetAppropriateFakeLayerForTeam = val23;
				obj23 = (object)val23;
			}
			LayerIndex.GetAppropriateFakeLayerForTeam += (hook_GetAppropriateFakeLayerForTeam)obj23;
			object obj24 = <>O.<7>__TeamMask_HasTeam;
			if (obj24 == null)
			{
				hook_HasTeam val24 = TeamMask_HasTeam;
				<>O.<7>__TeamMask_HasTeam = val24;
				obj24 = (object)val24;
			}
			TeamMask.HasTeam += (hook_HasTeam)obj24;
			object obj25 = <>O.<8>__TeamMask_AddTeam;
			if (obj25 == null)
			{
				hook_AddTeam val25 = TeamMask_AddTeam;
				<>O.<8>__TeamMask_AddTeam = val25;
				obj25 = (object)val25;
			}
			TeamMask.AddTeam += (hook_AddTeam)obj25;
			object obj26 = <>O.<9>__TeamMask_RemoveTeam;
			if (obj26 == null)
			{
				hook_RemoveTeam val26 = TeamMask_RemoveTeam;
				<>O.<9>__TeamMask_RemoveTeam = val26;
				obj26 = (object)val26;
			}
			TeamMask.RemoveTeam += (hook_RemoveTeam)obj26;
			MethodInfo methodInfo = null;
			MethodInfo methodInfo2 = SymbolExtensions.GetMethodInfo<FogDamageController>((Expression<Action<FogDamageController>>)((FogDamageController _) => _.GetAffectedBodies()));
			if (methodInfo2 != null)
			{
				methodInfo = AccessTools.EnumeratorMoveNext((MethodBase)methodInfo2);
			}
			if (methodInfo != null)
			{
				List<IDetour> hookInstances = _hookInstances;
				MethodInfo methodInfo3 = methodInfo;
				object obj27 = <>O.<0>__ReplaceTeamIndexCount;
				if (obj27 == null)
				{
					Manipulator val27 = ReplaceTeamIndexCount;
					<>O.<0>__ReplaceTeamIndexCount = val27;
					obj27 = (object)val27;
				}
				hookInstances.Add((IDetour)new ILHook((MethodBase)methodInfo3, (Manipulator)obj27));
			}
			else
			{
				Log.Error("Failed to find FogDamageController.GetAffectedBodies enumerator MoveNext method for patches");
			}
			ConstructorInfo constructorInfo = AccessTools.DeclaredConstructor(typeof(HoldoutZoneController), (Type[])null, false);
			if (constructorInfo != null)
			{
				List<IDetour> hookInstances2 = _hookInstances;
				object obj28 = <>O.<10>__ReplaceTeamArraySize;
				if (obj28 == null)
				{
					Manipulator val28 = ReplaceTeamArraySize;
					<>O.<10>__ReplaceTeamArraySize = val28;
					obj28 = (object)val28;
				}
				hookInstances2.Add((IDetour)new ILHook((MethodBase)constructorInfo, (Manipulator)obj28));
			}
			else
			{
				Log.Error("Failed to find HoldoutZoneController constructor for patches");
			}
			ConstructorInfo constructorInfo2 = AccessTools.DeclaredConstructor(typeof(TeamManager), (Type[])null, false);
			if (constructorInfo2 != null)
			{
				List<IDetour> hookInstances3 = _hookInstances;
				object obj29 = <>O.<10>__ReplaceTeamArraySize;
				if (obj29 == null)
				{
					Manipulator val29 = ReplaceTeamArraySize;
					<>O.<10>__ReplaceTeamArraySize = val29;
					obj29 = (object)val29;
				}
				hookInstances3.Add((IDetour)new ILHook((MethodBase)constructorInfo2, (Manipulator)obj29));
			}
			else
			{
				Log.Error("Failed to find TeamManager constructor for patches");
			}
			_hooksEnabled = true;
		}

		internal static void UnsetHooks()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//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_00c3: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0158: 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_0163: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Expected O, but got Unknown
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Expected O, but got Unknown
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Expected O, but got Unknown
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Expected O, but got Unknown
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Expected O, but got Unknown
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Expected O, but got Unknown
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Expected O, but got Unknown
			if (!_hooksEnabled)
			{
				return;
			}
			object obj = <>O.<0>__ReplaceTeamIndexCount;
			if (obj == null)
			{
				Manipulator val = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val;
				obj = (object)val;
			}
			Offspring.FindTargetFarthest -= (Manipulator)obj;
			object obj2 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj2 == null)
			{
				Manipulator val2 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val2;
				obj2 = (object)val2;
			}
			AffixBeadAttachment.ClearEnemyLunarRuinDamage -= (Manipulator)obj2;
			object obj3 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj3 == null)
			{
				Manipulator val3 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val3;
				obj3 = (object)val3;
			}
			BuffWard.FixedUpdate -= (Manipulator)obj3;
			object obj4 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj4 == null)
			{
				Manipulator val4 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val4;
				obj4 = (object)val4;
			}
			FogDamageController.MyFixedUpdate -= (Manipulator)obj4;
			object obj5 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj5 == null)
			{
				Manipulator val5 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val5;
				obj5 = (object)val5;
			}
			GhostGunController.FindTarget -= (Manipulator)obj5;
			object obj6 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj6 == null)
			{
				Manipulator val6 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val6;
				obj6 = (object)val6;
			}
			GoldTitanManager.CalcTitanPowerAndBestTeam -= (Manipulator)obj6;
			object obj7 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj7 == null)
			{
				Manipulator val7 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val7;
				obj7 = (object)val7;
			}
			HoldoutZoneController.UpdateHealingNovas -= (Manipulator)obj7;
			object obj8 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj8 == null)
			{
				Manipulator val8 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val8;
				obj8 = (object)val8;
			}
			TeamComponent.TeamIsValid -= (Manipulator)obj8;
			object obj9 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj9 == null)
			{
				Manipulator val9 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val9;
				obj9 = (object)val9;
			}
			TeamManager.Start -= (Manipulator)obj9;
			object obj10 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj10 == null)
			{
				Manipulator val10 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val10;
				obj10 = (object)val10;
			}
			TeamManager.OnSerialize -= (Manipulator)obj10;
			object obj11 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj11 == null)
			{
				Manipulator val11 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val11;
				obj11 = (object)val11;
			}
			TeamManager.OnDeserialize -= (Manipulator)obj11;
			object obj12 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj12 == null)
			{
				Manipulator val12 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val12;
				obj12 = (object)val12;
			}
			TeamManager.GetTeamExperience -= (Manipulator)obj12;
			object obj13 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj13 == null)
			{
				Manipulator val13 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val13;
				obj13 = (object)val13;
			}
			TeamManager.GetTeamCurrentLevelExperience -= (Manipulator)obj13;
			object obj14 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj14 == null)
			{
				Manipulator val14 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val14;
				obj14 = (object)val14;
			}
			TeamManager.GetTeamNextLevelExperience -= (Manipulator)obj14;
			object obj15 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj15 == null)
			{
				Manipulator val15 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val15;
				obj15 = (object)val15;
			}
			TeamManager.GetTeamLevel -= (Manipulator)obj15;
			object obj16 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj16 == null)
			{
				Manipulator val16 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val16;
				obj16 = (object)val16;
			}
			TeamManager.SetTeamLevel -= (Manipulator)obj16;
			object obj17 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj17 == null)
			{
				Manipulator val17 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val17;
				obj17 = (object)val17;
			}
			TeamManager.GiveTeamMoney_TeamIndex_int -= (Manipulator)obj17;
			object obj18 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj18 == null)
			{
				Manipulator val18 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val18;
				obj18 = (object)val18;
			}
			TeamManager.GiveTeamItem -= (Manipulator)obj18;
			object obj19 = <>O.<0>__ReplaceTeamIndexCount;
			if (obj19 == null)
			{
				Manipulator val19 = ReplaceTeamIndexCount;
				<>O.<0>__ReplaceTeamIndexCount = val19;
				obj19 = (object)val19;
			}
			Util.GetEnemyEasyTarget -= (Manipulator)obj19;
			object obj20 = <>O.<1>__TeamManager_Start;
			if (obj20 == null)
			{
				hook_Start val20 = TeamManager_Start;
				<>O.<1>__TeamManager_Start = val20;
				obj20 = (object)val20;
			}
			TeamManager.Start -= (hook_Start)obj20;
			object obj21 = <>O.<2>__TeamManager_SetTeamExperience;
			if (obj21 == null)
			{
				Manipulator val21 = TeamManager_SetTeamExperience;
				<>O.<2>__TeamManager_SetTeamExperience = val21;
				obj21 = (object)val21;
			}
			TeamManager.SetTeamExperience -= (Manipulator)obj21;
			object obj22 = <>O.<3>__TeamManager_OnSerialize;
			if (obj22 == null)
			{
				hook_OnSerialize val22 = TeamManager_OnSerialize;
				<>O.<3>__TeamManager_OnSerialize = val22;
				obj22 = (object)val22;
			}
			TeamManager.OnSerialize -= (hook_OnSerialize)obj22;
			object obj23 = <>O.<4>__TeamManager_OnDeserialize;
			if (obj23 == null)
			{
				hook_OnDeserialize val23 = TeamManager_OnDeserialize;
				<>O.<4>__TeamManager_OnDeserialize = val23;
				obj23 = (object)val23;
			}
			TeamManager.OnDeserialize -= (hook_OnDeserialize)obj23;
			object obj24 = <>O.<5>__LayerIndex_GetAppropriateLayerForTeam;
			if (obj24 == null)
			{
				hook_GetAppropriateLayerForTeam val24 = LayerIndex_GetAppropriateLayerForTeam;
				<>O.<5>__LayerIndex_GetAppropriateLayerForTeam = val24;
				obj24 = (object)val24;
			}
			LayerIndex.GetAppropriateLayerForTeam -= (hook_GetAppropriateLayerForTeam)obj24;
			object obj25 = <>O.<6>__LayerIndex_GetAppropriateFakeLayerForTeam;
			if (obj25 == null)
			{
				hook_GetAppropriateFakeLayerForTeam val25 = LayerIndex_GetAppropriateFakeLayerForTeam;
				<>O.<6>__LayerIndex_GetAppropriateFakeLayerForTeam = val25;
				obj25 = (object)val25;
			}
			LayerIndex.GetAppropriateFakeLayerForTeam -= (hook_GetAppropriateFakeLayerForTeam)obj25;
			object obj26 = <>O.<7>__TeamMask_HasTeam;
			if (obj26 == null)
			{
				hook_HasTeam val26 = TeamMask_HasTeam;
				<>O.<7>__TeamMask_HasTeam = val26;
				obj26 = (object)val26;
			}
			TeamMask.HasTeam -= (hook_HasTeam)obj26;
			object obj27 = <>O.<8>__TeamMask_AddTeam;
			if (obj27 == null)
			{
				hook_AddTeam val27 = TeamMask_AddTeam;
				<>O.<8>__TeamMask_AddTeam = val27;
				obj27 = (object)val27;
			}
			TeamMask.AddTeam -= (hook_AddTeam)obj27;
			object obj28 = <>O.<9>__TeamMask_RemoveTeam;
			if (obj28 == null)
			{
				hook_RemoveTeam val28 = TeamMask_RemoveTeam;
				<>O.<9>__TeamMask_RemoveTeam = val28;
				obj28 = (object)val28;
			}
			TeamMask.RemoveTeam -= (hook_RemoveTeam)obj28;
			foreach (IDetour hookInstance in _hookInstances)
			{
				((IDisposable)hookInstance)?.Dispose();
			}
			_hookInstances.Clear();
			_hooksEnabled = false;
		}

		private static void ReplaceTeamArraySize(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(TeamsAPI), "TeamCount");
			int num = 0;
			TypeReference val2 = default(TypeReference);
			while (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, _vanillaTeamsCount),
				(Instruction x) => ILPatternMatchingExt.MatchNewarr(x, ref val2)
			}))
			{
				int index = val.Index;
				val.Index = index + 1;
				val.MoveAfterLabels();
				val.Emit(OpCodes.Pop);
				val.Emit(OpCodes.Call, (MethodBase)methodInfo);
				num++;
			}
			if (num == 0)
			{
				Log.Error("Failed to find any TeamIndex.Count array size patch locations for " + ((MemberReference)il.Method).FullName);
			}
		}

		private static void ReplaceTeamIndexCount(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_004c: Invalid comparison between Unknown and I4
			//IL_00b5: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int num = 0;
			ILLabel val2 = default(ILLabel);
			while (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, _vanillaTeamsCount),
				(Instruction x) => matchCompareOrBranch(x)
			}))
			{
				Instruction next = val.Next.Next;
				val.EmitDelegate<Func<TeamIndex, bool>>((Func<TeamIndex, bool>)IsValidTeam);
				OpCode opCode = next.OpCode;
				if ((int)((OpCode)(ref opCode)).FlowControl == 3)
				{
					bool flag = ILPatternMatchingExt.MatchBlt(next, ref val2) || ILPatternMatchingExt.MatchBltUn(next, ref val2) || ILPatternMatchingExt.MatchBneUn(next, ref val2);
					val.Emit(flag ? OpCodes.Brtrue : OpCodes.Brfalse, next.Operand);
				}
				else if (!ILPatternMatchingExt.MatchClt(next) && !ILPatternMatchingExt.MatchCltUn(next))
				{
					val.Emit(OpCodes.Not);
				}
				ILLabel val3 = val.DefineLabel();
				val.Emit(OpCodes.Br, (object)val3);
				val.Emit(OpCodes.Ldc_I4_M1);
				val.Index += 2;
				val.MarkLabel(val3);
				num++;
			}
			if (num == 0)
			{
				Log.Error("Failed to find any TeamIndex.Count patch locations for " + ((MemberReference)il.Method).FullName);
			}
			static bool matchCompareOrBranch(Instruction x)
			{
				//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_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Invalid comparison between Unknown and I4
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				OpCode opCode2 = x.OpCode;
				if ((int)((OpCode)(ref opCode2)).FlowControl != 3 && !(x.OpCode == OpCodes.Ceq) && !(x.OpCode == OpCodes.Cgt) && !(x.OpCode == OpCodes.Cgt_Un) && !(x.OpCode == OpCodes.Clt))
				{
					return x.OpCode == OpCodes.Clt_Un;
				}
				return true;
			}
		}

		private static int LayerIndex_GetAppropriateLayerForTeam(orig_GetAppropriateLayerForTeam orig, TeamIndex teamIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			int result = orig.Invoke(teamIndex);
			int moddedTeamIndex = GetModdedTeamIndex(teamIndex);
			if (moddedTeamIndex >= 0 && moddedTeamIndex < ModdedTeamCount)
			{
				TeamBehavior safe = ArrayUtils.GetSafe<TeamBehavior>(_moddedTeamBehaviors, moddedTeamIndex);
				if (safe != null)
				{
					result = safe.TeamLayer.intVal;
				}
			}
			return result;
		}

		private static LayerIndex LayerIndex_GetAppropriateFakeLayerForTeam(orig_GetAppropriateFakeLayerForTeam orig, TeamIndex teamIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			LayerIndex result = orig.Invoke(teamIndex);
			int moddedTeamIndex = GetModdedTeamIndex(teamIndex);
			if (moddedTeamIndex >= 0 && moddedTeamIndex < ModdedTeamCount)
			{
				TeamBehavior safe = ArrayUtils.GetSafe<TeamBehavior>(_moddedTeamBehaviors, moddedTeamIndex);
				if (safe != null)
				{
					result = safe.TeamFakeLayer;
				}
			}
			return result;
		}

		private static bool TeamMask_HasTeam(orig_HasTeam orig, ref TeamMask self, TeamIndex teamIndex)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			bool result = orig.Invoke(ref self, teamIndex);
			int moddedTeamIndex = GetModdedTeamIndex(teamIndex);
			if (moddedTeamIndex >= 0 && moddedTeamIndex < ModdedTeamCount)
			{
				result = GetModdedTeamMaskBit(in self, moddedTeamIndex);
			}
			return result;
		}

		private static void TeamMask_AddTeam(orig_AddTeam orig, ref TeamMask self, TeamIndex teamIndex)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(ref self, teamIndex);
			int moddedTeamIndex = GetModdedTeamIndex(teamIndex);
			if (moddedTeamIndex >= 0 && moddedTeamIndex < ModdedTeamCount)
			{
				SetModdedTeamMaskBit(ref self, moddedTeamIndex, bitState: true);
			}
		}

		private static void TeamMask_RemoveTeam(orig_RemoveTeam orig, ref TeamMask self, TeamIndex teamIndex)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(ref self, teamIndex);
			int moddedTeamIndex = GetModdedTeamIndex(teamIndex);
			if (moddedTeamIndex >= 0 && moddedTeamIndex < ModdedTeamCount)
			{
				SetModdedTeamMaskBit(ref self, moddedTeamIndex, bitState: false);
			}
		}

		private static void TeamManager_Start(orig_Start orig, TeamManager self)
		{
			UnityObjectExtensions.EnsureComponent<TeamManagerModdedTeamsHelper>(((Component)self).gameObject);
			orig.Invoke(self);
		}

		private static void TeamManager_SetTeamExperience(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ParameterDefinition val2 = ((IEnumerable<ParameterDefinition>)((MethodReference)il.Method).Parameters).FirstOrDefault((Func<ParameterDefinition, bool>)((ParameterDefinition p) => Extensions.Is((MemberReference)(object)((ParameterReference)p).ParameterType, (MemberInfo)typeof(TeamIndex))));
			if (val2 == null)
			{
				Log.Error("TeamManager.SetTeamExperience hook failed to find TeamIndex parameter");
				return;
			}
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<NetworkBehaviour>(x, "SetDirtyBit")
			}))
			{
				Log.Error("Failed to find TeamManager.SetTeamExperience SetDirtyBit call");
				return;
			}
			ILLabel val3 = val.MarkLabel();
			if (!val.TryGotoPrev((MoveType)1, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0)
			}))
			{
				Log.Error("Failed to find TeamManager.SetTeamExperience SetDirtyBit patch location");
				return;
			}
			ILLabel val4 = val.MarkLabel();
			val.MoveBeforeLabels();
			val.Emit(OpCodes.Ldarg, val2);
			val.EmitDelegate<Func<TeamIndex, bool>>((Func<TeamIndex, bool>)IsModdedTeam);
			val.Emit(OpCodes.Brfalse, (object)val4);
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Ldarg, val2);
			val.EmitDelegate<Action<TeamManager, TeamIndex>>((Action<TeamManager, TeamIndex>)setModdedTeamDirtyBit);
			val.Emit(OpCodes.Br, (object)val3);
			static void setModdedTeamDirtyBit(TeamManager self, TeamIndex teamIndex)
			{
				//IL_001c: 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)
				TeamManagerModdedTeamsHelper teamManagerModdedTeamsHelper = default(TeamManagerModdedTeamsHelper);
				if (((Component)self).TryGetComponent<TeamManagerModdedTeamsHelper>(ref teamManagerModdedTeamsHelper))
				{
					teamManagerModdedTeamsHelper.SetDirtyBit(GetModdedTeamIndex(teamIndex));
				}
				else
				{
					Log.Error($"TeamManager wants to set dirty bit of modded team '{teamIndex}', but modded teams helper is not attached!");
				}
			}
		}

		private static bool TeamManager_OnSerialize(orig_OnSerialize orig, TeamManager self, NetworkWriter writer, bool initialState)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			bool result = orig.Invoke(self, writer, initialState);
			TeamManagerModdedTeamsHelper teamManagerModdedTeamsHelper = default(TeamManagerModdedTeamsHelper);
			if (((Component)self).TryGetComponent<TeamManagerModdedTeamsHelper>(ref teamManagerModdedTeamsHelper))
			{
				byte[] array;
				if (initialState)
				{
					array = null;
				}
				else
				{
					array = teamManagerModdedTeamsHelper.ModdedTeamsDirtyBits ?? Array.Empty<byte>();
					CompressedFlagArrayUtilities.WriteToNetworkWriter(array, writer, ModdedTeamCount);
				}
				for (int i = 0; i < ModdedTeamCount; i++)
				{
					if (initialState || CompressedFlagArrayUtilities.Has(array, i))
					{
						writer.WritePackedUInt64(self.teamExperience[GetTeamIndex(i)]);
					}
				}
				result = true;
				teamManagerModdedTeamsHelper.ClearDirtyBits();
			}
			return result;
		}

		private static void TeamManager_OnDeserialize(orig_OnDeserialize orig, TeamManager self, NetworkReader reader, bool initialState)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, reader, initialState);
			TeamManagerModdedTeamsHelper teamManagerModdedTeamsHelper = default(TeamManagerModdedTeamsHelper);
			if (!((Component)self).TryGetComponent<TeamManagerModdedTeamsHelper>(ref teamManagerModdedTeamsHelper))
			{
				return;
			}
			byte[] array = (initialState ? null : CompressedFlagArrayUtilities.ReadFromNetworkReader(reader, ModdedTeamCount));
			for (int i = 0; i < ModdedTeamCount; i++)
			{
				if (initialState || CompressedFlagArrayUtilities.Has(array, i))
				{
					ulong num = reader.ReadPackedUInt64();
					self.SetTeamExperience(GetTeamIndex(i), num);
				}
			}
		}

		private static bool GetModdedTeamMaskBit(in TeamMask teamMask, int moddedTeamIndex)
		{
			return CompressedFlagArrayUtilities.Has(TeamsInterop.GetModdedMask(ref teamMask), moddedTeamIndex);
		}

		private static void SetModdedTeamMaskBit(ref TeamMask teamMask, int moddedTeamIndex, bool bitState)
		{
			ref byte[] moddedMaskRef = ref TeamsInterop.GetModdedMaskRef(ref teamMask);
			if (bitState)
			{
				CompressedFlagArrayUtilities.AddImmutable(ref moddedMaskRef, moddedTeamIndex);
			}
			else
			{
				CompressedFlagArrayUtilities.RemoveImmutable(ref moddedMaskRef, moddedTeamIndex);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static int GetModdedTeamIndex(TeamIndex teamIndex)
		{
			//IL_0000: 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_0008: Expected I4, but got Unknown
			return teamIndex - _vanillaTeamsCount;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static TeamIndex GetTeamIndex(int moddedTeamIndex)
		{
			return (TeamIndex)(sbyte)(_vanillaTeamsCount + moddedTeamIndex);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsModdedTeam(TeamIndex teamIndex)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if ((int)teamIndex != -1 && (byte)teamIndex >= (byte)_vanillaTeamsCount)
			{
				return (byte)teamIndex < TeamCount;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsValidTeam(TeamIndex teamIndex)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			if ((int)teamIndex != -1)
			{
				return (byte)teamIndex < TeamCount;
			}
			return false;
		}

		public static IEnumerable<TeamIndex> TeamsEnumerator()
		{
			for (int i = 0; i < TeamCount; i++)
			{
				yield return (TeamIndex)(sbyte)i;
			}
		}

		public static TeamIndex RegisterTeam(TeamDef teamDef, TeamBehavior teamBehavior)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			if (teamDef == null)
			{
				throw new ArgumentNullException("teamDef");
			}
			if (teamBehavior == null)
			{
				throw new ArgumentNullException("teamBehavior");
			}
			if (RoR2Application.loadFinished)
			{
				throw new InvalidOperationException("Cannot register a new team post initialization");
			}
			int num = TeamCatalog.teamDefs.Length;
			int num2 = num + 1;
			if (num >= TeamCountLimit)
			{
				Log.Fatal($"Failed to add team '{teamBehavior.Name}': Modded team limit of {ModdedTeamCountLimit} has been reached.");
				return (TeamIndex)(-1);
			}
			if (Enum.TryParse<TeamIndex>(teamBehavior.Name, out TeamIndex result))
			{
				Log.Error("Attempting to register team with name '" + teamBehavior.Name + "' multiple times, previously assigned TeamIndex will be returned, TeamDef and TeamBehavior will be discarded");
				return result;
			}
			if (Enum.TryParse<TeamIndex>(teamBehavior.Name, ignoreCase: true, out TeamIndex result2))
			{
				Log.Warning($"Registering team '{teamBehavior.Name}' with the same case-insensitive name as an existing team '{result2}', consider re-naming your team to avoid name clashes.");
			}
			SetHooks();
			ArrayUtils.EnsureCapacity<TeamDef>(ref TeamCatalog.teamDefs, num2);
			TeamCatalog.Register((TeamIndex)(sbyte)num, teamDef);
			ArrayUtils.EnsureCapacity<Team>(ref TeamComponent.teamsList, num2);
			((Team)(ref TeamComponent.teamsList[num])).Init((TeamIndex)(sbyte)num);
			if (EnumPatcher.IsValid(ref _teamCountHandle))
			{
				EnumPatcher.RemoveEnumValueEntry(ref _teamCountHandle);
			}
			EnumPatcher.SetEnumValue<TeamIndex>(teamBehavior.Name, (TeamIndex)(sbyte)num);
			_teamCountHandle = EnumPatcher.SetEnumValue<TeamIndex>("Count", (TeamIndex)(sbyte)num2);
			((TeamMask)(ref TeamMask.all)).AddTeam((TeamIndex)(sbyte)num);
			if ((teamBehavior.Classification & TeamClassification.Neutral) == 0)
			{
				((TeamMask)(ref TeamMask.allButNeutral)).AddTeam((TeamIndex)(sbyte)num);
			}
			int moddedTeamIndex = GetModdedTeamIndex((TeamIndex)(sbyte)num);
			if (moddedTeamIndex >= _moddedTeamBehaviors.Length)
			{
				Array.Resize(ref _moddedTeamBehaviors, Math.Clamp(_moddedTeamBehaviors.Length * 2, moddedTeamIndex + 1, ModdedTeamCountLimit));
			}
			_moddedTeamBehaviors[moddedTeamIndex] = teamBehavior;
			CompressedFlagArrayUtilities.AddImmutable(ref _allModdedTeamsDirtyBits, moddedTeamIndex);
			return (TeamIndex)(sbyte)num;
		}

		public static TeamBehavior GetTeamBehavior(TeamIndex teamIndex)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			int moddedTeamIndex = GetModdedTeamIndex(teamIndex);
			if (moddedTeamIndex < 0)
			{
				return null;
			}
			return ArrayUtils.GetSafe<TeamBehavior>(_moddedTeamBehaviors, moddedTeamIndex);
		}
	}
	[BepInPlugin("com.bepis.r2api.teams", "R2API.Teams", "1.0.0")]
	public sealed class TeamsPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			TeamsAPI.Init();
		}

		private void OnDestroy()
		{
			TeamsAPI.UnsetHooks();
		}
	}
}
namespace R2API.AutoVersionGen
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	internal class AutoVersionAttribute : Attribute
	{
	}
}
namespace R2API.Utils
{
	public static class TeamsAPINetworkExtensions
	{
		public static void Write(this NetworkWriter writer, in TeamMask teamMask)
		{
			writer.Write(teamMask.a);
			if (TeamsAPI.ModdedTeamCount > 0)
			{
				CompressedFlagArrayUtilities.WriteToNetworkWriter(TeamsInterop.GetModdedMask(ref teamMask) ?? Array.Empty<byte>(), writer, TeamsAPI.ModdedTeamCount);
			}
		}

		public static TeamMask ReadTeamMask(this NetworkReader reader)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			TeamMask result = default(TeamMask);
			result.a = reader.ReadByte();
			if (TeamsAPI.ModdedTeamCount > 0)
			{
				byte[] array = CompressedFlagArrayUtilities.ReadFromNetworkReader(reader, TeamsAPI.ModdedTeamCount);
				if (array != null && array.Length != 0)
				{
					TeamsInterop.SetModdedMask(ref result, array);
				}
			}
			return result;
		}
	}
}

plugins/R2API.Teams/R2API.Teams.Interop.dll

Decompiled 6 days 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 Microsoft.CodeAnalysis;
using RoR2;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("R2API.Teams")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("R2API.Teams.Interop")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+184681b4876959fd205e7b50858d97ce3fc813fb")]
[assembly: AssemblyProduct("R2API.Teams.Interop")]
[assembly: AssemblyTitle("R2API.Teams.Interop")]
[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.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]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 R2API
{
	internal static class TeamsInterop
	{
		public static byte[] GetModdedMask(in TeamMask teamMask)
		{
			return teamMask.r2api_moddedMask;
		}

		public static ref byte[] GetModdedMaskRef(ref TeamMask teamMask)
		{
			return ref teamMask.r2api_moddedMask;
		}

		public static void SetModdedMask(ref TeamMask teamMask, byte[] value)
		{
			teamMask.r2api_moddedMask = value;
		}
	}
}

patchers/R2API.Teams/R2API.Teams.Patcher.dll

Decompiled 6 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using Mono.Cecil;

[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("R2API.Teams.Patcher")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+184681b4876959fd205e7b50858d97ce3fc813fb")]
[assembly: AssemblyProduct("R2API.Teams.Patcher")]
[assembly: AssemblyTitle("R2API.Teams.Patcher")]
[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.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]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 R2API
{
	internal static class TeamsPatcher
	{
		public static IEnumerable<string> TargetDLLs { get; } = new <>z__ReadOnlySingleElementList<string>("RoR2.dll");


		public static void Patch(AssemblyDefinition assembly)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			TypeDefinition type = assembly.MainModule.GetType("RoR2", "TeamMask");
			if (type != null)
			{
				type.Fields.Add(new FieldDefinition("r2api_moddedMask", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(byte[]))));
			}
		}
	}
}
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			if (!_moveNextCalled)
			{
				return _moveNextCalled = true;
			}
			return false;
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection.CopyTo(Array array, int index)
	{
		array.SetValue(_item, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
		{
			return -1;
		}
		return 0;
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		array[arrayIndex] = _item;
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, item))
		{
			return -1;
		}
		return 0;
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}