Decompiled source of CustomGameModes v1.2.2

BepInEx/plugins/lammas123.CustomGameModes.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.IL2CPP;
using BepInEx.IL2CPP.Utils;
using BepInEx.Logging;
using CrabDevKit.Intermediary;
using CrabDevKit.Utilities;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using SteamworksNative;
using TMPro;
using UnhollowerBaseLib;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 CustomGameModes
{
	public static class Api
	{
		internal static Dictionary<string, CustomGameMode> customGameModes = new Dictionary<string, CustomGameMode>();

		internal static CustomGameMode currentCustomGameMode = null;

		public static int VanillaGameModesCount { get; internal set; } = -1;


		public static int SkippedGameModesCount { get; internal set; } = -1;


		public static bool RegisterCustomGameMode(CustomGameMode customGameMode)
		{
			//IL_0035: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0084: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Invalid comparison between Unknown and I4
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Invalid comparison between Unknown and I4
			if (VanillaGameModesCount != -1 || customGameModes.ContainsKey(customGameMode.Name) || customGameModes.ContainsValue(customGameMode) || !Enum.IsDefined(typeof(EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique), customGameMode.GameModeType) || (int)customGameMode.GameModeType == 0 || (int)customGameMode.GameModeType == 14 || !Enum.IsDefined(typeof(EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique), customGameMode.VanillaGameModeType) || (int)customGameMode.VanillaGameModeType == 0 || (int)customGameMode.VanillaGameModeType == 14 || (int)customGameMode.VanillaGameModeType == 2 || (int)customGameMode.VanillaGameModeType == 15)
			{
				return false;
			}
			customGameModes.Add(customGameMode.Name, customGameMode);
			return true;
		}

		internal static void AddCustomGameModes()
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Expected O, but got Unknown
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Expected O, but got Unknown
			if (VanillaGameModesCount != -1)
			{
				return;
			}
			VanillaGameModesCount = ((Il2CppArrayBase<GameModeData>)(object)MonoBehaviourPublicGadealGaLi1pralObInUnique.Instance.allGameModes).Count;
			LinkedList<GameModeData> linkedList = new LinkedList<GameModeData>((IEnumerable<GameModeData>)MonoBehaviourPublicGadealGaLi1pralObInUnique.Instance.allGameModes);
			HashSet<string> hashSet = new HashSet<string>();
			foreach (string item in ((IEnumerable<GameModeData>)MonoBehaviourPublicGadealGaLi1pralObInUnique.Instance.allGameModes).Select((GameModeData gameModeData) => gameModeData.modeName))
			{
				hashSet.Add(item);
			}
			HashSet<string> hashSet2 = hashSet;
			int vanillaGameModesCount = VanillaGameModesCount;
			CustomGameMode[] array = customGameModes.Values.ToArray();
			bool flag = default(bool);
			foreach (CustomGameMode customGameMode in array)
			{
				if (hashSet2.Contains(customGameMode.Name))
				{
					customGameModes.Remove(customGameMode.Name);
					continue;
				}
				GameModeData val = ScriptableObject.CreateInstance<GameModeData>();
				customGameMode.GameModeId = vanillaGameModesCount++;
				val.id = customGameMode.GameModeId;
				((Object)val).name = customGameMode.Name;
				val.modeName = customGameMode.Name;
				val.modeDescription = customGameMode.Description;
				val.musicType = customGameMode.MusicType;
				val.waitForRoundOverToDeclareSoloWinner = customGameMode.WaitForRoundOverToDeclareSoloWinner;
				val.type = customGameMode.GameModeType;
				val.minPlayers = customGameMode.MinPlayers;
				val.maxPlayers = customGameMode.MaxPlayers;
				val.shortModeTime = customGameMode.ShortModeTime;
				val.mediumModeTime = customGameMode.MediumModeTime;
				val.longModeTime = customGameMode.LongModeTime;
				val.smallMapsOnlyPlayers = customGameMode.SmallMapPlayers;
				val.mediumAndSmallMapPlayers = customGameMode.MediumAndSmallMapPlayers;
				val.bigAndMediumMapPlayers = customGameMode.LargeAndMediumMapPlayers;
				val.bigOnlyMapPlayers = customGameMode.LargeMapPlayers;
				val.isPlayable = true;
				val.skipAsString = false;
				val.modeTime = 20;
				val.smallMaps = new Il2CppReferenceArray<Map>(0L);
				val.mediumMaps = new Il2CppReferenceArray<Map>(0L);
				val.largeMaps = new Il2CppReferenceArray<Map>(0L);
				foreach (GameModeData item2 in (Il2CppArrayBase<GameModeData>)(object)MonoBehaviourPublicGadealGaLi1pralObInUnique.Instance.allGameModes)
				{
					if (item2.id < VanillaGameModesCount && item2.type == customGameMode.VanillaGameModeType)
					{
						customGameMode.VanillaGameModeId = item2.id;
						break;
					}
				}
				if (customGameMode.PreloadMapName != null)
				{
					foreach (Map item3 in (Il2CppArrayBase<Map>)(object)MonoBehaviourPublicObInMamaLi1plMadeMaUnique.Instance.maps)
					{
						if (item3.mapName == customGameMode.PreloadMapName)
						{
							customGameMode.PreloadMapId = item3.id;
							break;
						}
					}
				}
				LinkedList<string> linkedList2 = new LinkedList<string>(customGameMode.CompatibleMapNames);
				LinkedList<Map> linkedList3 = new LinkedList<Map>();
				foreach (Map item4 in (Il2CppArrayBase<Map>)(object)MonoBehaviourPublicObInMamaLi1plMadeMaUnique.Instance.maps)
				{
					LinkedListNode<string> linkedListNode = null;
					for (LinkedListNode<string> linkedListNode2 = linkedList2.First; linkedListNode2 != null; linkedListNode2 = linkedListNode2.Next)
					{
						if (linkedListNode2.Value == item4.mapName)
						{
							linkedListNode = linkedListNode2;
							break;
						}
					}
					if (linkedListNode != null)
					{
						linkedList2.Remove(linkedListNode);
						linkedList3.AddLast(item4);
					}
				}
				foreach (string item5 in linkedList2)
				{
					ManualLogSource log = ((BasePlugin)CustomGameModes.Instance).Log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(67, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Could not find a map by the name of '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(item5);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' for the custom game mode '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(val.modeName);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'.");
					}
					log.LogWarning(val2);
				}
				if (linkedList3.Count == 0)
				{
					ManualLogSource log2 = ((BasePlugin)CustomGameModes.Instance).Log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(80, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("The custom game mode '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(val.modeName);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' does not have any compatible maps, giving it the map '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(MonoBehaviourPublicObInMamaLi1plMadeMaUnique.Instance.GetMap(0).mapName);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'.");
					}
					log2.LogWarning(val2);
					linkedList3.AddLast(MonoBehaviourPublicObInMamaLi1plMadeMaUnique.Instance.GetMap(0));
				}
				val.compatibleMaps = Il2CppReferenceArray<Map>.op_Implicit(linkedList3.ToArray());
				linkedList.AddLast(val);
				MonoBehaviourPublicGadealGaLi1pralObInUnique.Instance.allPlayableGameModes.Add(val);
				if (customGameMode.IsSmallMode)
				{
					MonoBehaviourPublicObInLi1GagasmLi1GaUnique.Instance.smallModes.Add(val);
				}
			}
			SkippedGameModesCount = 0;
			foreach (GameModeData item6 in linkedList)
			{
				if (item6.skipAsString)
				{
					SkippedGameModesCount++;
				}
			}
			MonoBehaviourPublicGadealGaLi1pralObInUnique.Instance.allGameModes = Il2CppReferenceArray<GameModeData>.op_Implicit(linkedList.ToArray());
		}
	}
	public abstract class CustomGameMode
	{
		public string Name { get; internal set; }

		public string Description { get; internal set; }

		public EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique GameModeType { get; internal set; }

		public EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique VanillaGameModeType { get; internal set; }

		public string PreloadMapName { get; internal set; }

		public string Version { get; protected set; }

		public int GameModeId { get; internal set; }

		public int VanillaGameModeId { get; internal set; }

		public int PreloadMapId { get; internal set; }

		public bool IsSmallMode { get; internal set; }

		public EnumNPublicSealedvaNoInMeFuScWi7vUnique MusicType { get; internal set; }

		public bool WaitForRoundOverToDeclareSoloWinner { get; internal set; }

		public int MinPlayers { get; internal set; }

		public int MaxPlayers { get; internal set; }

		public int ShortModeTime { get; internal set; }

		public int MediumModeTime { get; internal set; }

		public int LongModeTime { get; internal set; }

		public string[] CompatibleMapNames { get; internal set; }

		public int SmallMapPlayers { get; internal set; }

		public int MediumAndSmallMapPlayers { get; internal set; }

		public int LargeAndMediumMapPlayers { get; internal set; }

		public int LargeMapPlayers { get; internal set; }

		public Dictionary<ulong, int> ClientsWithGameMode { get; internal set; }

		public Dictionary<ulong, string> ClientGameModeVersions { get; internal set; }

		protected CustomGameMode(string name, string description, EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique gameModeType, EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique vanillaGameModeType, string preloadMapName = null, bool isSmallMode = true, EnumNPublicSealedvaNoInMeFuScWi7vUnique musicType = 1, bool waitForRoundOverToDeclareSoloWinner = false, int minPlayers = 0, int maxPlayers = int.MaxValue, int shortModeTime = 60, int mediumModeTime = 90, int longModeTime = 120, IEnumerable<string> compatibleMapNames = null, int smallMapPlayers = 4, int mediumAndSmallMapPlayers = 5, int largeAndMediumMapPlayers = 9, int largeMapPlayers = 100)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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)
			Name = name;
			Description = description;
			GameModeType = gameModeType;
			VanillaGameModeType = vanillaGameModeType;
			PreloadMapName = preloadMapName;
			Version = "0.0.0";
			GameModeId = -1;
			VanillaGameModeId = -1;
			PreloadMapId = -1;
			IsSmallMode = isSmallMode;
			MusicType = musicType;
			WaitForRoundOverToDeclareSoloWinner = waitForRoundOverToDeclareSoloWinner;
			MinPlayers = minPlayers;
			MaxPlayers = maxPlayers;
			ShortModeTime = shortModeTime;
			MediumModeTime = mediumModeTime;
			LongModeTime = longModeTime;
			CompatibleMapNames = (compatibleMapNames ?? Array.Empty<string>()).ToArray();
			SmallMapPlayers = smallMapPlayers;
			MediumAndSmallMapPlayers = mediumAndSmallMapPlayers;
			LargeAndMediumMapPlayers = largeAndMediumMapPlayers;
			LargeMapPlayers = largeMapPlayers;
			ClientsWithGameMode = new Dictionary<ulong, int>();
			ClientGameModeVersions = new Dictionary<ulong, string>();
			base..ctor();
		}

		public virtual void PreInit()
		{
		}

		public virtual void PostEnd()
		{
		}
	}
	public sealed class CustomGameModeBaseball : CustomGameMode
	{
		public CustomGameModeBaseball()
			: base("Baseball", "• Baseball without balls, players must try to get other players out of bounds to eliminate them.", (EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique)2, (EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique)8, null, isSmallMode: true, (EnumNPublicSealedvaNoInMeFuScWi7vUnique)1, waitForRoundOverToDeclareSoloWinner: false, 0, int.MaxValue, 60, 75, 90, new <>z__ReadOnlyArray<string>(new string[20]
			{
				"Bitter Beach", "Cocky Containers", "Islands", "Lanky Lava", "Return to Monke", "Snowtop", "Toxic Train", "Mini Monke", "Small Beach", "Small Containers",
				"Sandy Islands", "Lava Dump", "Salty Island", "Lava Climb", "Macaroni Mountain", "Sussy Sandcastle", "Sussy Slope", "Crabfields", "Crabheat", "Crabland"
			}), 3, 4, 7, 12)
		{
		}
	}
	public sealed class CustomGameModeStandoff : CustomGameMode
	{
		[CompilerGenerated]
		private sealed class <SyncVanillaPenalties>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SyncVanillaPenalties>d__10(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0165: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Expected O, but got Unknown
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Expected O, but got Unknown
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
				}
				if (MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID.Count - Instance.ClientsWithGameMode.Count != 0)
				{
					List<byte> list = new List<byte>();
					list.AddRange(BitConverter.GetBytes(64));
					list.AddRange(BitConverter.GetBytes(Standoff.standoffPlayers.Count));
					Enumerator<ulong, ObjectNPublicInObInUnique> enumerator = Standoff.standoffPlayers.Keys.GetEnumerator();
					while (enumerator.MoveNext())
					{
						ulong current = enumerator.Current;
						list.AddRange(BitConverter.GetBytes(current));
						list.AddRange(BitConverter.GetBytes(-Standoff.standoffPlayers[current].Method_Public_Int32_0()));
					}
					list.InsertRange(0, BitConverter.GetBytes(list.Count));
					ObjectPublicIDisposableLi1ByInByBoUnique val = new ObjectPublicIDisposableLi1ByInByBoUnique();
					val.field_Private_List_1_Byte_0 = new List<byte>();
					foreach (byte item in list)
					{
						val.field_Private_List_1_Byte_0.Add(item);
					}
					Enumerator<ulong, int> enumerator3 = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID.Keys.GetEnumerator();
					while (enumerator3.MoveNext())
					{
						ulong current3 = enumerator3.Current;
						if (!Instance.ClientsWithGameMode.ContainsKey(current3))
						{
							MonoBehaviourPublicInStInpabyDiInpaby2Unique.SendPacket(new CSteamID(current3), val, 8, (EnumNPublicSealedvaTo3vToUnique)0);
						}
					}
				}
				<>2__current = (object)new WaitForSeconds(5f);
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal static CustomGameModeStandoff Instance;

		internal static GameModePublicDi2UIObstBocaSiacwaUnique Standoff;

		internal static bool processStandoffFiredShot = true;

		internal static bool shouldDrop = true;

		internal static bool replaceCurrentAmmo = false;

		internal Harmony patches;

		public CustomGameModeStandoff()
			: base("Standoff", "• You can only shoot when signaled\n\n• Hit someone to give them a \"mark\"\n\n• Bullets left in your gun count as \"marks\"\n\n• Most marked players are eliminated", (EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique)15, (EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique)11, null, isSmallMode: true, (EnumNPublicSealedvaNoInMeFuScWi7vUnique)1, waitForRoundOverToDeclareSoloWinner: false, 0, int.MaxValue, 45, 55, 60, new <>z__ReadOnlyArray<string>(new string[19]
			{
				"Blueline", "Return to Monke", "Funky Field", "Sandstorm", "Small Beach", "Tiny Town", "Playground2", "Twisted Towers", "Lanky Lava", "Bitter Beach",
				"Karlson", "Mini Monke", "Sunny Saloon", "Tiny Town 2", "Small Saloon", "Toxic Train", "Cocky Containers", "Small Containers", "Icy Crack"
			}))
		{
			Instance = this;
		}

		public override void PreInit()
		{
			patches = Harmony.CreateAndPatchAll(GetType(), (string)null);
		}

		public override void PostEnd()
		{
			Harmony obj = patches;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		internal bool CanShoot(ulong clientId)
		{
			if (!base.ClientsWithGameMode.ContainsKey(clientId))
			{
				return Standoff.canShoot;
			}
			return true;
		}

		[IteratorStateMachine(typeof(<SyncVanillaPenalties>d__10))]
		internal IEnumerator SyncVanillaPenalties()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SyncVanillaPenalties>d__10(0);
		}

		[HarmonyPatch(typeof(GameModePublicDi2UIObstBocaSiacwaUnique), "InitMode")]
		[HarmonyPostfix]
		internal static void PostInitMode(GameModePublicDi2UIObstBocaSiacwaUnique __instance)
		{
			Standoff = __instance;
			if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
			{
				MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)__instance, Instance.SyncVanillaPenalties());
			}
		}

		[HarmonyPatch(typeof(GameModePublicDi2UIObstBocaSiacwaUnique), "FindPlayersToKill")]
		[HarmonyPrefix]
		internal static bool PreFindPlayersToKill(ref int __result)
		{
			__result = Mathf.RoundToInt((float)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.GetPlayersAlive() * 0.3f);
			return false;
		}

		[HarmonyPatch(typeof(GameModePublicDi2UIObstBocaSiacwaUnique), "OnPlayerSpawnOrDespawn")]
		[HarmonyPostfix]
		internal static void PostOnPlayerSpawnOrDespawn(GameModePublicDi2UIObstBocaSiacwaUnique __instance, ulong param_1)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			if (MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.ContainsKey(param_1) && !__instance.standoffPlayers.ContainsKey(param_1) && !MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers[param_1].dead)
			{
				__instance.standoffPlayers.Add(param_1, new ObjectNPublicInObInUnique(MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers[param_1]));
			}
			else if (!MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.ContainsKey(param_1) && __instance.standoffPlayers.ContainsKey(param_1))
			{
				__instance.standoffPlayers.Remove(param_1);
			}
		}

		[HarmonyPatch(typeof(GameModePublicDi2UIObstBocaSiacwaUnique), "OnFreezeOver")]
		[HarmonyPrefix]
		internal static bool PreOnFreezeOver(GameModePublicDi2UIObstBocaSiacwaUnique __instance)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			__instance.field_Private_Int32_0 = __instance.FindPlayersToKill();
			Enumerator<ulong, MonoBehaviourPublicCSstReshTrheObplBojuUnique> enumerator = MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.Keys.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ulong current = enumerator.Current;
				if (MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.ContainsKey(current) && !MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers[current].dead && !__instance.standoffPlayers.ContainsKey(current))
				{
					__instance.standoffPlayers.Add(current, new ObjectNPublicInObInUnique(MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers[current]));
				}
			}
			if (!MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
			{
				return false;
			}
			shouldDrop = false;
			MonoBehaviourPublicObInCoIE85SiAwVoFoCoUnique.ForceGiveAllWeapon(2);
			shouldDrop = true;
			((MonoBehaviour)__instance).Invoke("SendToggle", __instance.activeTime);
			ChatUtil.SendMessage("Hold your fire until the next notice! You have 6 shots.", (MessageType)2, "Standoff", (IEnumerable<ulong>)null);
			return false;
		}

		[HarmonyPatch(typeof(GameModePublicDi2UIObstBocaSiacwaUnique), "ToggleShoot")]
		[HarmonyPostfix]
		internal static void PostToggleShoot(GameModePublicDi2UIObstBocaSiacwaUnique __instance)
		{
			if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
			{
				ChatUtil.SendMessage("You can " + (__instance.canShoot ? "NOW" : "NO LONGER") + " shoot!", (MessageType)2, "Standoff", (IEnumerable<ulong>)null);
			}
		}

		[HarmonyPatch(typeof(GameModePublicDi2UIObstBocaSiacwaUnique), "ShotPlayer")]
		[HarmonyPrefix]
		internal static bool PreShotPlayer(GameModePublicDi2UIObstBocaSiacwaUnique __instance, ulong param_1, ulong param_2)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.CanFire(param_1) || !Instance.CanShoot(param_1))
			{
				return false;
			}
			ObjectNPublicInObInUnique obj = __instance.standoffPlayers[param_2];
			int field_Public_Int32_ = obj.field_Public_Int32_1;
			obj.field_Public_Int32_1 = field_Public_Int32_ + 1;
			ObjectNPublicInObInUnique obj2 = __instance.standoffPlayers[param_1];
			field_Public_Int32_ = obj2.field_Public_Int32_1;
			obj2.field_Public_Int32_1 = field_Public_Int32_ - 1;
			MonoBehaviourPublicInInUnique.StandoffUpdate(-1, __instance.standoffPlayers[param_2].field_Public_Int32_1, param_2, param_1);
			ChatUtil.SendMessage(param_1, "Hit " + SteamFriends.GetFriendPersonaName(new CSteamID(param_2)) + "!", (MessageType)2, "Standoff");
			return false;
		}

		[HarmonyPatch(typeof(GameModePublicDi2UIObstBocaSiacwaUnique), "ShotFired")]
		[HarmonyPrefix]
		internal static bool PreShotFired(GameModePublicDi2UIObstBocaSiacwaUnique __instance, ulong param_1)
		{
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected I4, but got Unknown
			if (!processStandoffFiredShot)
			{
				return false;
			}
			if (!Instance.CanShoot(param_1))
			{
				ChatUtil.SendMessage(param_1, "Shots do not count at this time.", (MessageType)2, "Standoff");
				shouldDrop = false;
				MonoBehaviourPublicObInCoIE85SiAwVoFoCoUnique.ForceGiveWeapon(param_1, 2, MonoBehaviourPublicDi2InObInObInUnique.Instance.GetNextId());
				shouldDrop = true;
				return false;
			}
			ObjectNPublicInObInUnique obj = __instance.standoffPlayers[param_1];
			int field_Public_Int32_ = obj.field_Public_Int32_0;
			obj.field_Public_Int32_0 = field_Public_Int32_ - 1;
			ObjectNPublicInObInUnique obj2 = __instance.standoffPlayers[param_1];
			field_Public_Int32_ = obj2.field_Public_Int32_1;
			obj2.field_Public_Int32_1 = field_Public_Int32_ + 1;
			MonoBehaviourPublicInInUnique.StandoffUpdate(__instance.standoffPlayers[param_1].field_Public_Int32_0, __instance.standoffPlayers[param_1].field_Public_Int32_1, param_1, 0uL);
			ChatUtil.SendMessage(param_1, $"Remaining shots: {__instance.standoffPlayers[param_1].field_Public_Int32_0}/6", (MessageType)2, "Standoff");
			if (!__instance.CanFire(param_1))
			{
				MonoBehaviourPublicObInCoIE85SiAwVoFoCoUnique.ForceRemoveItemItemId(param_1, 2);
				ChatUtil.SendMessage(param_1, "You've ran out of bullets, avoid getting shot by others!", (MessageType)2, "Standoff");
			}
			if (__instance.Method_Private_Boolean_0())
			{
				((MonoBehaviour)__instance).CancelInvoke("SendToggle");
				MonoBehaviourPublicInInUnique.StandoffToggle(false);
				if (((GameMode)__instance).freezeTimer.field_Private_Single_0 > 5f)
				{
					((GameMode)__instance).freezeTimer.field_Private_Single_0 = 5f;
					MonoBehaviourPublicInInUnique.SendGameModeTimer(((GameMode)__instance).freezeTimer.field_Private_Single_0, (int)((GameMode)__instance).modeState);
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(GameModePublicDi2UIObstBocaSiacwaUnique), "StandoffUpdate")]
		[HarmonyPostfix]
		internal static void PostStandoffUpdate(int param_1, ulong param_3)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (param_3 == SteamManagerExtensions[MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance].m_SteamID && param_1 != -1)
			{
				MonoBehaviourPublicItDi2ObIninInTrweGaUnique.Instance.UpdateAmmoUI();
			}
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicPlVoUI9GaVoUI9UsPlUnique), "UseItem")]
		[HarmonyPrefix]
		internal static void PreServerHandleUseItem(ObjectPublicIDisposableLi1ByInByBoUnique param_1)
		{
			processStandoffFiredShot = BitConverter.ToInt32(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)param_1.field_Private_ArrayOf_Byte_0), 8) == 2;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicPlVoUI9GaVoUI9UsPlUnique), "TryDropItem")]
		[HarmonyPrefix]
		internal static bool PreServerHandleTryDropItem()
		{
			return false;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "UseItem")]
		[HarmonyPrefix]
		internal static bool PreServerSendUseItem(ulong param_0, int param_1)
		{
			if (param_1 == 2)
			{
				if (Instance.CanShoot(param_0))
				{
					return Standoff.CanFire(param_0);
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "PlayerDamage")]
		[HarmonyPrefix]
		internal static bool PreServerSendPlayerDamage(ulong param_0, int param_4)
		{
			if (param_4 == 2)
			{
				if (Instance.CanShoot(param_0))
				{
					return Standoff.CanFire(param_0);
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "DropItem")]
		[HarmonyPrefix]
		internal static bool PreServerSendDropItem()
		{
			return shouldDrop;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "StandoffToggle")]
		[HarmonyPrefix]
		internal static bool PreServerSendStandoffToggle(bool param_0)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			List<byte> list = new List<byte>();
			list.AddRange(BitConverter.GetBytes(70));
			list.AddRange(BitConverter.GetBytes(param_0));
			list.InsertRange(0, BitConverter.GetBytes(list.Count));
			ObjectPublicIDisposableLi1ByInByBoUnique val = new ObjectPublicIDisposableLi1ByInByBoUnique();
			val.field_Private_List_1_Byte_0 = new List<byte>();
			foreach (byte item in list)
			{
				val.field_Private_List_1_Byte_0.Add(item);
			}
			foreach (ulong key in Instance.ClientsWithGameMode.Keys)
			{
				MonoBehaviourPublicInStInpabyDiInpaby2Unique.SendPacket(new CSteamID(key), val, 8, (EnumNPublicSealedvaTo3vToUnique)0);
			}
			if (!param_0)
			{
				shouldDrop = false;
				Enumerator<ulong, int> enumerator3 = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID.Keys.GetEnumerator();
				while (enumerator3.MoveNext())
				{
					ulong current2 = enumerator3.Current;
					if (Standoff.standoffPlayers.ContainsKey(current2) && Standoff.CanFire(current2))
					{
						MonoBehaviourPublicObInCoIE85SiAwVoFoCoUnique.ForceGiveWeapon(current2, 2, MonoBehaviourPublicDi2InObInObInUnique.Instance.GetNextId());
					}
				}
				shouldDrop = true;
			}
			return false;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "StandoffUpdate")]
		[HarmonyPrefix]
		internal static bool PreServerSendStandoffUpdate(int param_0, int param_1, ulong param_2, ulong param_3)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			List<byte> list = new List<byte>();
			list.AddRange(BitConverter.GetBytes(69));
			list.AddRange(BitConverter.GetBytes(param_0));
			list.AddRange(BitConverter.GetBytes(param_1));
			list.AddRange(BitConverter.GetBytes(param_2));
			list.AddRange(BitConverter.GetBytes(param_3));
			list.InsertRange(0, BitConverter.GetBytes(list.Count));
			ObjectPublicIDisposableLi1ByInByBoUnique val = new ObjectPublicIDisposableLi1ByInByBoUnique();
			val.field_Private_List_1_Byte_0 = new List<byte>();
			foreach (byte item in list)
			{
				val.field_Private_List_1_Byte_0.Add(item);
			}
			foreach (ulong key in Instance.ClientsWithGameMode.Keys)
			{
				MonoBehaviourPublicInStInpabyDiInpaby2Unique.SendPacket(new CSteamID(key), val, 8, (EnumNPublicSealedvaTo3vToUnique)0);
			}
			list = new List<byte>();
			list.AddRange(BitConverter.GetBytes(64));
			list.AddRange(BitConverter.GetBytes(1));
			list.AddRange(BitConverter.GetBytes(param_2));
			list.AddRange(BitConverter.GetBytes(-Standoff.standoffPlayers[param_2].Method_Public_Int32_0()));
			list.InsertRange(0, BitConverter.GetBytes(list.Count));
			val = new ObjectPublicIDisposableLi1ByInByBoUnique();
			val.field_Private_List_1_Byte_0 = new List<byte>();
			foreach (byte item2 in list)
			{
				val.field_Private_List_1_Byte_0.Add(item2);
			}
			Enumerator<ulong, int> enumerator3 = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID.Keys.GetEnumerator();
			while (enumerator3.MoveNext())
			{
				ulong current3 = enumerator3.Current;
				if (!Instance.ClientsWithGameMode.ContainsKey(current3))
				{
					MonoBehaviourPublicInStInpabyDiInpaby2Unique.SendPacket(new CSteamID(current3), val, 8, (EnumNPublicSealedvaTo3vToUnique)0);
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicItDi2ObIninInTrweGaUnique), "UpdateAmmoUI")]
		[HarmonyPrefix]
		internal static void PrePlayerInventoryUpdateAmmoUI()
		{
			replaceCurrentAmmo = true;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicImciTetemaTeSiInSiBoUnique), "SetRatio")]
		[HarmonyPrefix]
		internal static void PreCircleRatioUISetRatio(ref int param_1)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (replaceCurrentAmmo)
			{
				ObjectNPublicInObInUnique obj = Standoff.standoffPlayers[SteamManagerExtensions[MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance].m_SteamID];
				param_1 = ((obj != null) ? obj.field_Public_Int32_0 : 0);
			}
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicItDi2ObIninInTrweGaUnique), "UpdateAmmoUI")]
		[HarmonyPostfix]
		internal static void PostPlayerInventoryUpdateAmmoUI()
		{
			replaceCurrentAmmo = false;
		}
	}
	internal static class Patches
	{
		internal static float defaultGameModesAndMapsTextSpacing;

		internal static float defaultMapsTextAndContainerSpacing;

		[HarmonyPatch(typeof(MonoBehaviourPublicGadealGaLi1pralObInUnique), "Awake")]
		[HarmonyPostfix]
		[HarmonyPriority(800)]
		internal static void PostGameModeManagerAwake()
		{
			Api.AddCustomGameModes();
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicGamomaGaTrmoTrmaUnique), "Start")]
		[HarmonyPostfix]
		internal static void PostDeobf_MenuUiCreateLobbyGameModesAndMapsStart(MonoBehaviourPublicGamomaGaTrmoTrmaUnique __instance)
		{
			//IL_0013: 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)
			//IL_0061: 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)
			GridLayoutGroup component = ((Component)__instance.modeContainer).GetComponent<GridLayoutGroup>();
			int num = Mathf.FloorToInt(((LayoutGroup)component).preferredWidth / component.cellSize.x);
			int num2 = Mathf.CeilToInt((float)(((Il2CppArrayBase<GameModeData>)(object)MonoBehaviourPublicGadealGaLi1pralObInUnique.Instance.allGameModes).Length - Api.SkippedGameModesCount) / (float)num);
			((Component)__instance.modeContainer.parent).GetComponent<LayoutElement>().minHeight = (float)num2 * (component.cellSize.y + component.spacing.y) + component.spacing.y;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicGaprTrmomaTrTehegaGaUnique), "SetModes")]
		[HarmonyPrefix]
		internal static bool PreDeobf_MenuUiServerListingGameModesAndMapsInfoSetModes(MonoBehaviourPublicGaprTrmomaTrTehegaGaUnique __instance, string param_1)
		{
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			for (int i = 0; i < Api.VanillaGameModesCount; i++)
			{
				GameModeData val = ((Il2CppArrayBase<GameModeData>)(object)MonoBehaviourPublicGadealGaLi1pralObInUnique.Instance.allGameModes)[i];
				if (!val.skipAsString)
				{
					((TMP_Text)Object.Instantiate<GameObject>(__instance.prefabText, __instance.modeContainer).GetComponent<TextMeshProUGUI>()).text = "<color=" + ((param_1[num++] == '1') ? __instance.blueCol : __instance.redCol) + ">" + val.modeName;
				}
			}
			Dictionary<string, bool> dictionary = new Dictionary<string, bool>();
			string[] array = param_1.Split(':', StringSplitOptions.RemoveEmptyEntries);
			if (array.Length != 1)
			{
				array = array[1..];
				string[] array2 = array;
				for (int j = 0; j < array2.Length; j++)
				{
					string text;
					string text2 = (text = array2[j]);
					string text3 = text.Substring(1, text.Length - 1);
					bool flag = text2[0] == '1';
					((TMP_Text)Object.Instantiate<GameObject>(__instance.prefabText, __instance.modeContainer).GetComponent<TextMeshProUGUI>()).text = "<color=" + (flag ? __instance.blueCol : __instance.redCol) + ">" + text3;
					dictionary.Add(text3, flag);
				}
			}
			foreach (string key in Api.customGameModes.Keys)
			{
				if (!dictionary.ContainsKey(key))
				{
					((TMP_Text)Object.Instantiate<GameObject>(__instance.prefabText, __instance.modeContainer).GetComponent<TextMeshProUGUI>()).text = "<color=" + __instance.redCol + ">" + key;
					dictionary.Add(key, value: false);
				}
			}
			GridLayoutGroup component = ((Component)__instance.modeContainer).GetComponent<GridLayoutGroup>();
			float num2 = (float)Mathf.CeilToInt((float)(Api.VanillaGameModesCount + dictionary.Count - Api.SkippedGameModesCount) / 2f) * (component.cellSize.y + component.spacing.y) - component.spacing.y;
			float num3 = (float)Mathf.CeilToInt((float)(Api.VanillaGameModesCount - Api.SkippedGameModesCount) / 2f) * (component.cellSize.y + component.spacing.y) - component.spacing.y;
			if (defaultGameModesAndMapsTextSpacing == 0f)
			{
				defaultGameModesAndMapsTextSpacing = __instance.gameModeText.transform.localPosition.y - __instance.mapsModeText.transform.localPosition.y;
			}
			if (defaultMapsTextAndContainerSpacing == 0f)
			{
				defaultMapsTextAndContainerSpacing = __instance.mapsModeText.transform.localPosition.y - __instance.mapContainer.localPosition.y;
			}
			Vector3 localPosition = __instance.mapsModeText.transform.localPosition;
			localPosition.y = __instance.gameModeText.transform.localPosition.y - defaultGameModesAndMapsTextSpacing + num3 - num2;
			__instance.mapsModeText.transform.localPosition = localPosition;
			localPosition = __instance.mapContainer.localPosition;
			localPosition.y = __instance.mapsModeText.transform.localPosition.y - defaultMapsTextAndContainerSpacing;
			__instance.mapContainer.localPosition = localPosition;
			return false;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicGadealGaLi1pralObInUnique), "GetAvailableModesString")]
		[HarmonyPrefix]
		internal static bool PreGameModeManagerGetAvailableModesString(MonoBehaviourPublicGadealGaLi1pralObInUnique __instance, ref string __result)
		{
			char[] array = new char[Api.VanillaGameModesCount];
			foreach (GameModeData item in (Il2CppArrayBase<GameModeData>)(object)__instance.allGameModes)
			{
				if (item.id >= Api.VanillaGameModesCount)
				{
					break;
				}
				if (item.skipAsString)
				{
					array[item.id] = ' ';
				}
				else if (__instance.allPlayableGameModes.Contains(item))
				{
					array[item.id] = '1';
				}
				else
				{
					array[item.id] = '0';
				}
			}
			__result = new string(array).Replace(" ", "");
			foreach (CustomGameMode value in Api.customGameModes.Values)
			{
				if (__instance.allPlayableGameModes.Contains(((Il2CppArrayBase<GameModeData>)(object)__instance.allGameModes)[value.GameModeId]))
				{
					__result = __result + ":1" + value.Name;
				}
				else
				{
					__result = __result + ":0" + value.Name;
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicDi2UIObacspDi2UIObUnique), "Awake")]
		[HarmonyPostfix]
		internal static void PostGameManagerAwake()
		{
			if (Api.currentCustomGameMode != null)
			{
				Api.currentCustomGameMode.PostEnd();
				Api.currentCustomGameMode = null;
			}
			if (MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.gameMode.id >= Api.VanillaGameModesCount)
			{
				Api.currentCustomGameMode = Api.customGameModes[MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.gameMode.modeName];
				Api.currentCustomGameMode.PreInit();
			}
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "LoadMap", new Type[]
		{
			typeof(int),
			typeof(int)
		})]
		[HarmonyPrefix]
		internal static bool PreServerSendLoadMap(int param_0, int param_1)
		{
			CustomGameModes.Instance.preloadingState = PreloadingState.None;
			CustomGameModes.Instance.clientIdsPreloading.Clear();
			if (param_1 >= Api.VanillaGameModesCount)
			{
				CustomGameModes.Instance.preloadingMapId = Api.customGameModes[((Il2CppArrayBase<GameModeData>)(object)MonoBehaviourPublicGadealGaLi1pralObInUnique.Instance.allGameModes)[param_1].modeName].PreloadMapId;
				if (CustomGameModes.Instance.preloadingMapId != -1)
				{
					CustomGameModes.Instance.preloadingState = PreloadingState.InProgress;
					CustomGameModes.Instance.postloadingMapId = param_0;
				}
			}
			Enumerator<ulong, int> enumerator = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID.Keys.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ulong current = enumerator.Current;
				MonoBehaviourPublicInInUnique.LoadMap(param_0, param_1, current);
			}
			return false;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "LoadMap", new Type[]
		{
			typeof(int),
			typeof(int),
			typeof(ulong)
		})]
		[HarmonyPrefix]
		internal static void PreServerSendLoadMapClient(ref int param_0, ref int param_1, ulong param_2)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (param_1 >= Api.VanillaGameModesCount)
			{
				CustomGameMode customGameMode = Api.customGameModes[((Il2CppArrayBase<GameModeData>)(object)MonoBehaviourPublicGadealGaLi1pralObInUnique.Instance.allGameModes)[param_1].modeName];
				if (param_2 != SteamManagerExtensions[MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance].m_SteamID)
				{
					param_1 = (customGameMode.ClientsWithGameMode.ContainsKey(param_2) ? customGameMode.ClientsWithGameMode[param_2] : customGameMode.VanillaGameModeId);
				}
				if (CustomGameModes.Instance.preloadingState == PreloadingState.InProgress && !CustomGameModes.Instance.clientIdsPreloading.Contains(param_2))
				{
					CustomGameModes.Instance.clientIdsPreloading.Add(param_2);
					param_0 = CustomGameModes.Instance.preloadingMapId;
				}
			}
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicPlVoUI9GaVoUI9UsPlUnique), "GameModeLoaded")]
		[HarmonyPostfix]
		internal static void PostServerHandleGameModeLoaded(ulong param_0)
		{
			if (CustomGameModes.Instance.preloadingState == PreloadingState.InProgress)
			{
				CustomGameModes.Instance.clientIdsPreloading.Remove(param_0);
				CustomGameModes.Instance.CheckPreloadingFinished();
			}
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicInInUnique), "SendModeState")]
		[HarmonyPrefix]
		internal static bool PreServerSendSendModeState(int param_0)
		{
			if (CustomGameModes.Instance.preloadingState != 0 || param_0 == 0)
			{
				return true;
			}
			CustomGameModes.Instance.FinishedPreloading();
			return false;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicDi2UIObacspDi2UIObUnique), "SpawnPlayer")]
		[HarmonyPatch(typeof(MonoBehaviourPublicDi2UIObacspDi2UIObUnique), "SpawnSpectator")]
		[HarmonyPostfix]
		internal static void PostGameManagerSpawn(ulong param_1)
		{
			if (!MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner() || MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.gameMode.id < Api.VanillaGameModesCount)
			{
				return;
			}
			if (CustomGameModes.Instance.preloadingState == PreloadingState.InProgress)
			{
				ChatUtil.SendMessage(param_1, "This map is being preloaded before the next game mode, please be patient.", (MessageType)2, "Preloading");
				return;
			}
			ChatUtil.SendMessage(param_1, "The current mode is actually " + MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.gameMode.modeName + "!", (MessageType)2, "NOTICE");
			string[] array = ChatUtil.FormatGameModeDescription(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.gameMode.modeDescription);
			foreach (string text in array)
			{
				ChatUtil.SendMessage(param_1, text, (MessageType)2, (string)null);
			}
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique), "JoinLobby")]
		[HarmonyPrefix]
		internal static void PreSteamManagerJoinLobby()
		{
			CustomGameModes.Instance.shouldSendHostCustomGameModes = true;
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicUIInUIByUIUnique), "LoadMap")]
		[HarmonyPrefix]
		internal static void PreClientHandleLoadMap()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner() || !CustomGameModes.Instance.shouldSendHostCustomGameModes)
			{
				return;
			}
			CustomGameModes.Instance.shouldSendHostCustomGameModes = false;
			ObjectPublicIDisposableLi1ByInByBoUnique val = new ObjectPublicIDisposableLi1ByInByBoUnique();
			PacketExtensions.Write(val, Api.customGameModes.Count);
			foreach (CustomGameMode value in Api.customGameModes.Values)
			{
				PacketExtensions.Write(val, value.Name);
				PacketExtensions.Write(val, value.Version);
				PacketExtensions.Write(val, value.GameModeId);
			}
			CrabNet.SendMessage("lammas123.CustomGameModes:CustomGameModes", val, (IEnumerable<ulong>)new <>z__ReadOnlySingleElementList<ulong>(SteamManagerExtensions[MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance].m_SteamID));
			val.Dispose();
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique), "StartLobby")]
		[HarmonyPatch(typeof(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique), "StartPracticeLobby")]
		[HarmonyPostfix]
		internal static void PostLobbyManagerStartLobby()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			CustomGameModes.Instance.clientCustomGameModes.Clear();
			CustomGameModes.Instance.clientCustomGameModes[SteamManagerExtensions[MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance].m_SteamID] = new Dictionary<string, int>();
			foreach (CustomGameMode value in Api.customGameModes.Values)
			{
				CustomGameModes.Instance.clientCustomGameModes[SteamManagerExtensions[MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance].m_SteamID][value.Name] = value.GameModeId;
				value.ClientsWithGameMode.Clear();
				value.ClientGameModeVersions.Clear();
				value.ClientsWithGameMode[SteamManagerExtensions[MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance].m_SteamID] = value.GameModeId;
				value.ClientGameModeVersions[SteamManagerExtensions[MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance].m_SteamID] = value.Version;
			}
			CustomGameModes.Instance.preloadingState = PreloadingState.None;
			CustomGameModes.Instance.preloadingMapId = -1;
			CustomGameModes.Instance.clientIdsPreloading.Clear();
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique), "OnPlayerJoinLeaveUpdate")]
		[HarmonyPostfix]
		internal static void PostLobbyManagerOnPlayerJoinLeaveUpdate(CSteamID param_1, bool param_2)
		{
			//IL_001c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (!MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner() || param_2)
			{
				return;
			}
			CustomGameModes.Instance.clientCustomGameModes.Remove(param_1.m_SteamID);
			foreach (CustomGameMode value in Api.customGameModes.Values)
			{
				value.ClientsWithGameMode.Remove(param_1.m_SteamID);
				value.ClientGameModeVersions.Remove(param_1.m_SteamID);
			}
			if (CustomGameModes.Instance.preloadingState == PreloadingState.InProgress)
			{
				CustomGameModes.Instance.clientIdsPreloading.Remove(param_1.m_SteamID);
				CustomGameModes.Instance.CheckPreloadingFinished();
			}
		}

		[HarmonyPatch(typeof(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique), "CloseLobby")]
		[HarmonyPostfix]
		internal static void PostLobbyManagerCloseLobby()
		{
			CustomGameModes.Instance.clientCustomGameModes.Clear();
			foreach (CustomGameMode value in Api.customGameModes.Values)
			{
				value.ClientsWithGameMode.Clear();
				value.ClientGameModeVersions.Clear();
			}
			CustomGameModes.Instance.preloadingState = PreloadingState.None;
			CustomGameModes.Instance.preloadingMapId = -1;
			CustomGameModes.Instance.clientIdsPreloading.Clear();
		}
	}
	[BepInPlugin("lammas123.CustomGameModes", "CustomGameModes", "1.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CustomGameModes : BasePlugin
	{
		internal static CustomGameModes Instance;

		internal Dictionary<ulong, Dictionary<string, int>> clientCustomGameModes = new Dictionary<ulong, Dictionary<string, int>>();

		internal bool shouldSendHostCustomGameModes;

		internal PreloadingState preloadingState = PreloadingState.None;

		internal int preloadingMapId = -1;

		internal int postloadingMapId = -1;

		internal HashSet<ulong> clientIdsPreloading = new HashSet<ulong>();

		internal const string CLIENT_CUSTOM_GAME_MODES = "lammas123.CustomGameModes:CustomGameModes";

		public override void Load()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
			CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
			CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
			CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
			Instance = this;
			Api.RegisterCustomGameMode(new CustomGameModeBaseball());
			Api.RegisterCustomGameMode(new CustomGameModeStandoff());
			CrabNet.RegisterMessageHandler("lammas123.CustomGameModes:CustomGameModes", new MessageHandler(ClientCustomGameModes));
			Harmony.CreateAndPatchAll(typeof(Patches), (string)null);
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Initialized [");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CustomGameModes");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.2.2");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]");
			}
			log.LogInfo(val);
		}

		internal void CheckPreloadingFinished()
		{
			if (clientIdsPreloading.Count == 0)
			{
				FinishedPreloading();
				return;
			}
			foreach (ulong item in clientIdsPreloading)
			{
				if (MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.GetClient(item).field_Public_Boolean_0)
				{
					return;
				}
			}
			FinishedPreloading();
		}

		internal void FinishedPreloading()
		{
			preloadingState = PreloadingState.Finished;
			foreach (ulong item in Instance.clientIdsPreloading)
			{
				MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.GetClient(item).field_Public_Boolean_0 = false;
			}
			clientIdsPreloading.Clear();
			Enumerator<ulong, int> enumerator2 = MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.steamIdToUID.Keys.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				ulong current2 = enumerator2.Current;
				MonoBehaviourPublicInInUnique.LoadMap(postloadingMapId, MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.gameMode.id, current2);
			}
			preloadingMapId = -1;
			postloadingMapId = -1;
		}

		internal void ClientCustomGameModes(ulong clientId, ObjectPublicIDisposableLi1ByInByBoUnique packet)
		{
			if (!MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
			{
				return;
			}
			int num = PacketExtensions.ReadInt(packet, true);
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			for (int i = 0; i < num; i++)
			{
				string key = PacketExtensions.ReadString(packet, true);
				string value = PacketExtensions.ReadString(packet, true);
				int value2 = (dictionary[key] = PacketExtensions.ReadInt(packet, true));
				if (Api.customGameModes.ContainsKey(key))
				{
					Api.customGameModes[key].ClientsWithGameMode[clientId] = value2;
					Api.customGameModes[key].ClientGameModeVersions[clientId] = value;
				}
			}
			clientCustomGameModes[clientId] = dictionary;
			MonoBehaviourPublicInInUnique.LoadMap(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.map.id, MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.gameMode.id, clientId);
		}
	}
	internal enum PreloadingState
	{
		None = -1,
		InProgress,
		Finished
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "lammas123.CustomGameModes";

		public const string PLUGIN_NAME = "CustomGameModes";

		public const string PLUGIN_VERSION = "1.2.2";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

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

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

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

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	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 ((IEnumerable<T>)_items).GetEnumerator();
	}

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

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

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

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

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

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

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

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
[CompilerGenerated]
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();
	}
}