Decompiled source of AvatarInfection v1.0.0

Mods/AvatarInfection.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using AvatarInfection;
using AvatarInfection.Patches;
using AvatarInfection.Utilities;
using BoneLib;
using HarmonyLib;
using Il2CppCysharp.Threading.Tasks;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Bonelab.SaveData;
using Il2CppSLZ.Interaction;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.SaveData;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VRMK;
using Il2CppSystem;
using LabFusion.Entities;
using LabFusion.Extensions;
using LabFusion.Marrow;
using LabFusion.Marrow.Proxies;
using LabFusion.Menu.Data;
using LabFusion.Menu.Gamemodes;
using LabFusion.Network;
using LabFusion.Player;
using LabFusion.SDK.Gamemodes;
using LabFusion.SDK.Metadata;
using LabFusion.SDK.Modules;
using LabFusion.SDK.Points;
using LabFusion.SDK.Triggers;
using LabFusion.Scene;
using LabFusion.Senders;
using LabFusion.Utilities;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "AvatarInfection", "1.0.0", "HAHOOS", "https://thunderstore.io/c/bonelab/p/HAHOOS/AvatarInfection")]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonColor(0, 255, 0, 255)]
[assembly: MelonAuthorColor(0, 255, 165, 0)]
[assembly: AssemblyTitle("A fusion gamemode where you infect others and they turn into a selected avatar until the gamemode ends!")]
[assembly: AssemblyDescription("A fusion gamemode where you infect others and they turn into a selected avatar until the gamemode ends!")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HAHOOS")]
[assembly: AssemblyProduct("AvatarInfection")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: ComVisible(false)]
[assembly: Guid("4bf6c046-91bd-4503-93ca-5ef3b7d6c95e")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 AvatarInfection
{
	public class Core : MelonMod
	{
		public const string Version = "1.0.0";

		public static Instance Logger { get; private set; }

		public static Texture2D Icon { get; private set; }

		public override void OnInitializeMelon()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			Logger = ((MelonBase)this).LoggerInstance;
			((MelonBase)this).LoggerInstance.Msg("Loading icon");
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetName().Name + ".Embedded.Icons.AvatarInfection.png";
			Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(name);
			List<byte> list = new List<byte>();
			manifestResourceStream.Position = 0L;
			while (true)
			{
				int num = manifestResourceStream.ReadByte();
				if (num == -1)
				{
					break;
				}
				list.Add((byte)num);
			}
			Texture2D val = new Texture2D(2, 2);
			Il2CppImageConversionManager.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(list.ToArray()), false);
			((Object)val).name = "AvatarInfectionIcon";
			((Object)val).hideFlags = (HideFlags)32;
			Icon = val;
			ModuleManager.RegisterModule<FusionModule>();
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
			((MelonBase)this).HarmonyInstance.PatchAll(typeof(GrabPatches));
		}

		public override void OnFixedUpdate()
		{
			TimeUtilities.OnEarlyFixedUpdate();
		}

		public override void OnUpdate()
		{
			TimeUtilities.OnEarlyUpdate();
			GrabPatches.Update();
		}
	}
	public class FusionModule : Module
	{
		internal static ModuleLogger Logger;

		public override string Name => "Avatar Infection";

		public override string Author => "HAHOOS";

		public override ConsoleColor Color => ConsoleColor.Magenta;

		public override Version Version => new Version(1, 0, 0);

		protected override void OnModuleRegistered()
		{
			((Module)this).OnModuleRegistered();
			Logger = ((Module)this).LoggerInstance;
			GamemodeRegistration.RegisterGamemode<Infection>();
		}
	}
	public class Infection : Gamemode
	{
		internal static class Defaults
		{
			public const string Barcode = "HAHOOS.AvatarInfection.Gamemode.AvatarInfection";

			public const int TimeLimit = 10;

			public const int InfectedBitReward = 50;

			public const int UnInfectedBitReward = 75;

			public const bool UntilAllFound = false;

			public static readonly TeamConfig InfectedStats = new TeamConfig
			{
				Vitality = 0.5f,
				JumpPower = 1.5f,
				Speed = 2.8f,
				Agility = 2f,
				StrengthUpper = 0.5f,
				JumpPower_Enabled = true,
				Speed_Enabled = true,
				Vitality_Enabled = true,
				Agility_Enabled = true,
				StrengthUpper_Enabled = true,
				Mortality = true,
				CanUseGuns = false
			};

			public static readonly TeamConfig UnInfectedStats = new TeamConfig
			{
				Vitality = 1f,
				JumpPower = 1f,
				Speed = 1.2f,
				Agility = 1f,
				StrengthUpper = 1.5f,
				JumpPower_Enabled = true,
				Speed_Enabled = true,
				Vitality_Enabled = true,
				Agility_Enabled = true,
				StrengthUpper_Enabled = true,
				Mortality = true,
				CanUseGuns = true
			};

			public const bool DisableSpawnGun = true;

			public const bool DisableDevTools = true;

			public const bool AllowKeepInventory = false;

			public const int InfectedCount = 1;

			public const bool ShouldTeleportToHost = true;

			public const int CountdownLength = 30;

			public const InfectTypeEnum InfectType = InfectTypeEnum.TOUCH;

			public const bool SuicideInfects = true;

			public const int HoldTime = 0;

			public const bool TeleportOnEnd = false;

			public static readonly MonoDiscReference[] Tracks = (MonoDiscReference[])(object)new MonoDiscReference[6]
			{
				BONELABMonoDiscReferences.TheRecurringDreamReference,
				BONELABMonoDiscReferences.HeavyStepsReference,
				BONELABMonoDiscReferences.StankFaceReference,
				BONELABMonoDiscReferences.AlexInWonderlandReference,
				BONELABMonoDiscReferences.ItDoBeGroovinReference,
				BONELABMonoDiscReferences.ConcreteCryptReference
			};
		}

		public enum InfectTypeEnum
		{
			TOUCH,
			DEATH
		}

		internal MetadataBool __DisableSpawnGun;

		private static bool _DisableSpawnGun = true;

		internal MetadataBool __DisableDevTools;

		private static bool _DisableDevTools = true;

		internal static TeamMetadata InfectedMetadata;

		internal static TeamMetadata UnInfectedMetadata;

		private const string TeamConfigName = "{0} Config";

		internal static MetadataVariableT<string> _SelectedAvatar;

		internal static string SelectedAvatar;

		internal TriggerEvent InfectEvent;

		internal TriggerEvent OneMinuteLeftEvent;

		internal TriggerEvent InfectedVictoryEvent;

		internal TriggerEvent UninfectedVictoryEvent;

		internal static TriggerEvent RefreshStatsEvent;

		internal MetadataBool InfectedLooking;

		private float _elapsedTime;

		internal static MetadataInt _CountdownLength;

		private List<ElementData> InfectedElements;

		private List<ElementData> UnInfectedElements;

		private readonly IReadOnlyList<float> IncrementValues = new <>z__ReadOnlyArray<float>(new float[4] { 0.2f, 0.5f, 1f, 5f });

		private int IncrementIndex;

		internal bool _oneMinuteLeft;

		private int _lastCheckedMinutes;

		private readonly Dictionary<PlayerId, PlayerActionType> lastActions = new Dictionary<PlayerId, PlayerActionType>();

		public override string Title => "Avatar Infection";

		public override string Author => "HAHOOS";

		public override string Barcode => "HAHOOS.AvatarInfection.Gamemode.AvatarInfection";

		public override Texture Logo => (Texture)(object)Core.Icon;

		public override bool DisableSpawnGun => _DisableSpawnGun;

		public override bool DisableDevTools => _DisableDevTools;

		public override bool AutoHolsterOnDeath => true;

		public override bool DisableManualUnragdoll => true;

		public override bool AutoStopOnSceneLoad => true;

		public override bool ManualReady => false;

		public static Infection Instance { get; private set; }

		internal static Team Infected { get; } = new Team("Infected");


		internal static Team UnInfected { get; } = new Team("Uninfected");


		internal static TeamManager TeamManager { get; } = new TeamManager();


		public MusicPlaylist Playlist { get; } = new MusicPlaylist();


		private bool UntilAllFound { get; set; }

		internal int TimeLimit { get; private set; } = 10;


		internal int InfectedCount { get; private set; } = 1;


		internal bool InitialTeam { get; private set; } = true;


		internal bool HasBeenInfected { get; private set; }

		private static ModuleLogger Logger => FusionModule.Logger;

		internal float ElapsedSeconds => _elapsedTime;

		internal int ElapsedMinutes => Mathf.FloorToInt(ElapsedSeconds / 60f);

		internal static bool HideVision { get; private set; }

		internal static TriggerEvent Teleport { get; private set; }

		internal static bool ShouldTeleportToHost { get; private set; } = true;


		internal static InfectTypeEnum InfectType { get; private set; } = InfectTypeEnum.TOUCH;


		internal MetadataBool AKI { get; private set; }

		internal static int CountdownLength { get; private set; } = 30;


		internal bool AllowKeepInventory { get; private set; }

		internal bool SuicideInfects { get; private set; } = true;


		internal int HoldTime { get; private set; }

		internal MetadataBool _TeleportOnEnd { get; private set; }

		internal bool TeleportOnEnd { get; private set; }

		internal float Increment => IncrementValues[IncrementIndex];

		private static MenuElement GetElement(string groupName, string elementName, bool startsWith = true)
		{
			if (MenuGamemode.SelectedGamemode != Instance)
			{
				return null;
			}
			MenuElement? obj = ((IEnumerable<MenuElement>)((GroupElement)MenuGamemode.SettingsPageElement).Elements).FirstOrDefault((Func<MenuElement, bool>)((MenuElement x) => x.Title == groupName));
			GroupElement val = (GroupElement)(object)((obj is GroupElement) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				Logger.Warn("Cannot find group");
				return null;
			}
			MenuElement val2 = val.Elements?.FirstOrDefault((Func<MenuElement, bool>)((MenuElement x) => (!startsWith) ? x.Title.Contains(elementName) : x.Title.StartsWith(elementName)));
			if ((Object)(object)val2 == (Object)null)
			{
				Logger.Warn("Cannot find element");
				return null;
			}
			return val2;
		}

		private static void ChangeElementTitle(string groupName, string elementTitle, string newTitle, bool startsWith = true)
		{
			MenuElement element = GetElement(groupName, elementTitle, startsWith);
			if ((Object)(object)element != (Object)null)
			{
				element.Title = newTitle;
			}
		}

		private static void ChangeElementIncrement(string groupName, string elementTitle, float increment, bool startsWith = true)
		{
			MenuElement element = GetElement(groupName, elementTitle, startsWith);
			if ((Object)(object)element != (Object)null && ((object)element).GetType() == typeof(FloatElement))
			{
				((FloatElement)((element is FloatElement) ? element : null)).Increment = increment;
			}
		}

		private static void ChangeElementColor(string groupName, string elementTitle, Color? color, bool startsWith = true)
		{
			if (MenuGamemode.SelectedGamemode != Instance)
			{
				return;
			}
			MenuElement? obj = ((IEnumerable<MenuElement>)((GroupElement)MenuGamemode.SettingsPageElement).Elements).FirstOrDefault((Func<MenuElement, bool>)((MenuElement x) => x.Title == groupName));
			GroupElement val = (GroupElement)(object)((obj is GroupElement) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				Logger.Warn("Cannot find group");
				return;
			}
			bool flag = false;
			foreach (MenuElement element in val.Elements)
			{
				string text = RemoveColor(element.Title);
				if (startsWith ? text.StartsWith(elementTitle) : text.Contains(elementTitle))
				{
					flag = true;
					if (color.HasValue)
					{
						element.Title = $"<color=#{color.Value.R:X2}{color.Value.G:X2}{color.Value.B:X2}>{text}</color>";
					}
					else
					{
						element.Title = text;
					}
				}
			}
			if (!flag)
			{
				Logger.Warn("Cannot find element");
			}
		}

		private static string RemoveColor(string text)
		{
			return Regex.Replace(text, "<color=#(.*?)>(.*?)<\\/color>", match);
			static string match(Match match)
			{
				if (match.Success && match.Groups.Count > 2)
				{
					return match.Groups[2].Value;
				}
				return string.Empty;
			}
		}

		public override GroupElementData CreateSettingsGroup()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_0094: Expected O, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Expected O, but got Unknown
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Expected O, but got Unknown
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: 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_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Expected O, but got Unknown
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: 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_0326: Expected O, but got Unknown
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Expected O, but got Unknown
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Expected O, but got Unknown
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Expected O, but got Unknown
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Expected O, but got Unknown
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Expected O, but got Unknown
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Expected O, but got Unknown
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Expected O, but got Unknown
			GroupElementData val2 = new GroupElementData
			{
				Title = ((Gamemode)this).Title
			};
			if (val2 == null)
			{
				Logger.Error("Group is null");
				return null;
			}
			GroupElementData avatarGroup = new GroupElementData("Avatar");
			val2.AddElement<GroupElementData>(avatarGroup);
			FunctionElementData val3 = new FunctionElementData();
			object obj;
			if (string.IsNullOrWhiteSpace(SelectedAvatar) || !(SelectedAvatar != Barcode.EMPTY))
			{
				obj = "N/A";
			}
			else
			{
				AvatarCrateReference val4 = new AvatarCrateReference(SelectedAvatar);
				if ((int)val4 == 0)
				{
					obj = null;
				}
				else
				{
					Crate scannable = ((ScannableReference<Crate>)val4).Scannable;
					obj = ((scannable != null) ? ((Scannable)scannable).Title : null);
				}
				if (obj == null)
				{
					obj = "N/A";
				}
			}
			((ElementData)val3).Title = "Selected Avatar: " + (string?)obj;
			val3.OnPressed = delegate
			{
				//IL_024f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0254: Unknown result type (might be due to invalid IL or missing references)
				//IL_025a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0264: Unknown result type (might be due to invalid IL or missing references)
				//IL_026a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0274: Unknown result type (might be due to invalid IL or missing references)
				//IL_027f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0286: Unknown result type (might be due to invalid IL or missing references)
				//IL_0292: Expected O, but got Unknown
				//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f7: 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_0207: Unknown result type (might be due to invalid IL or missing references)
				//IL_020d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0217: Unknown result type (might be due to invalid IL or missing references)
				//IL_0222: Unknown result type (might be due to invalid IL or missing references)
				//IL_0229: Unknown result type (might be due to invalid IL or missing references)
				//IL_0230: Unknown result type (might be due to invalid IL or missing references)
				//IL_023c: Expected O, but got Unknown
				//IL_0053: 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_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Expected O, but got Unknown
				//IL_0139: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: Unknown result type (might be due to invalid IL or missing references)
				//IL_014a: Expected O, but got Unknown
				//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d6: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f0: Expected O, but got Unknown
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				//IL_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_017c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_018e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a1: Expected O, but got Unknown
				try
				{
					if (!((Gamemode)this).IsStarted)
					{
						RigManager rigManager = Player.RigManager;
						object obj2;
						if (rigManager == null)
						{
							obj2 = null;
						}
						else
						{
							AvatarCrateReference avatarCrate = rigManager.AvatarCrate;
							obj2 = ((avatarCrate != null) ? ((ScannableReference)avatarCrate).Barcode : null);
						}
						if ((Barcode)obj2 != (Barcode)null)
						{
							string iD = ((ScannableReference)rigManager.AvatarCrate).Barcode.ID;
							if (string.IsNullOrWhiteSpace(iD))
							{
								FusionNotifier.Send(new FusionNotification
								{
									Title = NotificationText.op_Implicit("Failure"),
									Message = NotificationText.op_Implicit("Could not retrieve your current avatar :("),
									PopupLength = 2.5f,
									ShowPopup = true,
									Type = (NotificationType)2,
									SaveToMenu = false
								});
							}
							SelectedAvatar = iD;
							if (((Gamemode)this).IsStarted)
							{
								((MetadataVariable)_SelectedAvatar).SetValue<string>(SelectedAvatar);
							}
							AvatarCrateReference avatarCrate2 = rigManager.AvatarCrate;
							object value;
							if (avatarCrate2 == null)
							{
								value = null;
							}
							else
							{
								Crate scannable2 = ((ScannableReference<Crate>)(object)avatarCrate2).Scannable;
								value = ((scannable2 != null) ? ((Scannable)scannable2).Title : null);
							}
							string text = ((!string.IsNullOrWhiteSpace((string?)value)) ? ((Scannable)((ScannableReference<Crate>)(object)rigManager.AvatarCrate).Scannable).Title : "N/A");
							if (MenuGamemode.SelectedGamemode == this)
							{
								ChangeElementTitle(((ElementData)avatarGroup).Title, "Selected Avatar:", "Selected Avatar: " + text);
							}
							Barcode val19 = new Barcode(((ScannableReference)rigManager.AvatarCrate).Barcode.ID);
							if ((int)val19 != 0 && BarcodeExtensions.IsValid(val19))
							{
								FusionNotifier.Send(new FusionNotification
								{
									Title = NotificationText.op_Implicit("Success"),
									Message = NotificationText.op_Implicit("Successfully selected avatar '" + text + "' as the infected one!"),
									PopupLength = 2.5f,
									Type = (NotificationType)3,
									SaveToMenu = false,
									ShowPopup = true
								});
							}
							else
							{
								FusionNotifier.Send(new FusionNotification
								{
									Title = NotificationText.op_Implicit("Failure"),
									Message = NotificationText.op_Implicit("Failed to select a new infected avatar :("),
									PopupLength = 2.5f,
									Type = (NotificationType)2,
									SaveToMenu = false,
									ShowPopup = true
								});
							}
						}
						else
						{
							FusionNotifier.Send(new FusionNotification
							{
								Title = NotificationText.op_Implicit("Failure"),
								Message = NotificationText.op_Implicit("Failed to select a new infected avatar :( RigManager for local player was not found!"),
								PopupLength = 2.5f,
								Type = (NotificationType)2,
								SaveToMenu = false,
								ShowPopup = true
							});
						}
					}
				}
				catch (Exception ex)
				{
					Logger.LogException("Select new Avatar", ex);
					FusionNotifier.Send(new FusionNotification
					{
						Title = NotificationText.op_Implicit("Failure"),
						Message = NotificationText.op_Implicit("An unexpected error has occured while trying to select a new avatar. Check console or logs for more information"),
						PopupLength = 3f,
						Type = (NotificationType)2,
						SaveToMenu = false
					});
				}
			};
			FunctionElementData val5 = val3;
			avatarGroup.AddElement<FunctionElementData>(val5);
			GroupElementData gr = new GroupElementData($"{Infected.DisplayName} Config");
			val2.AddElement<GroupElementData>(gr);
			if (InfectedElements == null)
			{
				InfectedElements = GetElementsForTeam(InfectedTeam: true);
			}
			InfectedElements.ForEach(delegate(ElementData x)
			{
				gr.AddElement<ElementData>(x);
			});
			GroupElementData gr2 = new GroupElementData($"{UnInfected.DisplayName} Config");
			val2.AddElement<GroupElementData>(gr2);
			if (UnInfectedElements == null)
			{
				UnInfectedElements = GetElementsForTeam(InfectedTeam: false);
			}
			UnInfectedElements.ForEach(delegate(ElementData x)
			{
				gr2.AddElement<ElementData>(x);
			});
			GroupElementData generalGroup = new GroupElementData("General");
			val2.AddElement<GroupElementData>(generalGroup);
			IntElementData val6 = new IntElementData
			{
				Title = "Infected Start Number",
				Increment = 1,
				MinValue = 1,
				MaxValue = 5,
				Value = InfectedCount,
				OnValueChanged = delegate(int val)
				{
					InfectedCount = val;
				}
			};
			generalGroup.AddElement<IntElementData>(val6);
			IntElementData val7 = new IntElementData
			{
				Title = "Time Limit",
				Value = TimeLimit,
				Increment = 1,
				MinValue = 1,
				MaxValue = 60,
				OnValueChanged = delegate(int val)
				{
					TimeLimit = val;
				}
			};
			generalGroup.AddElement<IntElementData>(val7);
			BoolElementData val8 = new BoolElementData
			{
				Title = "Disable Spawn Gun",
				Value = ((Gamemode)this).DisableSpawnGun,
				OnValueChanged = delegate(bool val)
				{
					_DisableSpawnGun = val;
					((MetadataVariableT<bool>)(object)__DisableSpawnGun).SetValue(val);
				}
			};
			generalGroup.AddElement<BoolElementData>(val8);
			BoolElementData val9 = new BoolElementData
			{
				Title = "Disable Dev Tools",
				Value = ((Gamemode)this).DisableDevTools,
				OnValueChanged = delegate(bool val)
				{
					_DisableDevTools = val;
					((MetadataVariableT<bool>)(object)__DisableDevTools).SetValue(val);
				}
			};
			generalGroup.AddElement<BoolElementData>(val9);
			BoolElementData val10 = new BoolElementData
			{
				Title = "Allow Keep Inventory",
				Value = AllowKeepInventory,
				OnValueChanged = delegate(bool val)
				{
					AllowKeepInventory = val;
					if (((Gamemode)this).IsStarted)
					{
						((MetadataVariableT<bool>)(object)AKI).SetValue(val);
					}
				}
			};
			generalGroup.AddElement<BoolElementData>(val10);
			BoolElementData val11 = new BoolElementData
			{
				Title = "Play Until All Found (No Time Limit)",
				Value = UntilAllFound,
				OnValueChanged = delegate(bool val)
				{
					UntilAllFound = val;
				}
			};
			generalGroup.AddElement<BoolElementData>(val11);
			BoolElementData val12 = new BoolElementData
			{
				Title = "Teleport To Host On Start",
				Value = ShouldTeleportToHost,
				OnValueChanged = delegate(bool val)
				{
					ShouldTeleportToHost = val;
				}
			};
			generalGroup.AddElement<BoolElementData>(val12);
			BoolElementData val13 = new BoolElementData
			{
				Title = "Teleport To Host On End",
				Value = TeleportOnEnd,
				OnValueChanged = delegate(bool val)
				{
					TeleportOnEnd = val;
					if (((Gamemode)this).IsStarted)
					{
						((MetadataVariableT<bool>)(object)_TeleportOnEnd).SetValue(val);
					}
				}
			};
			generalGroup.AddElement<BoolElementData>(val13);
			IntElementData val14 = new IntElementData
			{
				Title = "Countdown Length",
				Increment = 5,
				MaxValue = 3600,
				MinValue = 0,
				Value = CountdownLength,
				OnValueChanged = delegate(int val)
				{
					CountdownLength = val;
					if (((Gamemode)this).IsStarted)
					{
						((MetadataVariableT<int>)(object)_CountdownLength).SetValue(val);
					}
				}
			};
			generalGroup.AddElement<IntElementData>(val14);
			FunctionElementData val15 = new FunctionElementData
			{
				Title = $"Infect Type: {InfectType}",
				OnPressed = delegate
				{
					Array values = Enum.GetValues(typeof(InfectTypeEnum));
					int infectType = (int)InfectType;
					infectType++;
					infectType %= values.Length;
					InfectType = (InfectTypeEnum)values.GetValue(infectType);
					ChangeElementTitle(((ElementData)generalGroup).Title, "Infect Type:", $"Infect Type: {InfectType}");
				}
			};
			BoolElementData val16 = new BoolElementData
			{
				Title = "Suicide Infects (Death Infect Type)",
				Value = true,
				OnValueChanged = delegate(bool val)
				{
					SuicideInfects = val;
				}
			};
			generalGroup.AddElement<BoolElementData>(val16);
			IntElementData val17 = new IntElementData
			{
				Title = "Hold Time (Touch Infect Type)",
				Value = HoldTime,
				Increment = 1,
				MaxValue = 60,
				MinValue = 0,
				OnValueChanged = delegate(int val)
				{
					HoldTime = val;
				}
			};
			generalGroup.AddElement<IntElementData>(val17);
			generalGroup.AddElement<FunctionElementData>(val15);
			FunctionElementData val18 = new FunctionElementData
			{
				Title = "Reset To Default Settings",
				OnPressed = delegate
				{
					if (!((Gamemode)this).IsStarted)
					{
						InfectedMetadata.Config = new TeamConfig(Defaults.InfectedStats);
						UnInfectedMetadata.Config = new TeamConfig(Defaults.UnInfectedStats);
						UntilAllFound = false;
						SelectedAvatar = string.Empty;
						TimeLimit = 10;
						InfectType = InfectTypeEnum.TOUCH;
						SuicideInfects = true;
						HoldTime = 0;
						InfectedCount = 1;
						CountdownLength = 30;
						_DisableSpawnGun = true;
						_DisableDevTools = true;
						AllowKeepInventory = false;
						ShouldTeleportToHost = true;
						TeleportOnEnd = false;
						ChangeElementTitle("Avatar", "Selected Avatar:", "Selected Avatar: N/A");
						ChangeElementTitle("General", "Infect Type:", "Infect Type: " + Enum.GetName(InfectType));
					}
				}
			};
			generalGroup.AddElement<FunctionElementData>(val18);
			return val2;
		}

		private List<ElementData> GetElementsForTeam(bool InfectedTeam)
		{
			//IL_0033: 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)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_009d: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: 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_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Expected O, but got Unknown
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Expected O, but got Unknown
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Expected O, but got Unknown
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Expected O, but got Unknown
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Expected O, but got Unknown
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Expected O, but got Unknown
			TeamMetadata metadata = (InfectedTeam ? InfectedMetadata : UnInfectedMetadata);
			List<ElementData> list = new List<ElementData>();
			FunctionElementData item = new FunctionElementData
			{
				Title = "Apply new settings (use when the gamemode is already started)",
				OnPressed = delegate
				{
					if (((Gamemode)this).IsStarted && !(metadata.GetConfigFromMetadata() == metadata.Config))
					{
						metadata.ApplyConfig();
						TriggerEvent refreshStatsEvent = RefreshStatsEvent;
						if (refreshStatsEvent != null)
						{
							refreshStatsEvent.TryInvoke(InfectedTeam.ToString());
						}
					}
				}
			};
			list.Add((ElementData)(object)item);
			BoolElementData item2 = new BoolElementData
			{
				Title = "Mortality",
				Value = metadata.Config.Mortality,
				OnValueChanged = delegate(bool val)
				{
					metadata.Config.Mortality = val;
				}
			};
			list.Add((ElementData)(object)item2);
			BoolElementData item3 = new BoolElementData
			{
				Title = "Can Use Guns",
				Value = metadata.Config.CanUseGuns,
				OnValueChanged = delegate(bool val)
				{
					metadata.Config.CanUseGuns = val;
				}
			};
			list.Add((ElementData)(object)item3);
			BoolElementData item4 = new BoolElementData
			{
				Title = "Override Vitality",
				Value = metadata.Config.Vitality_Enabled,
				OnValueChanged = delegate(bool val)
				{
					metadata.Config.Vitality_Enabled = val;
				}
			};
			list.Add((ElementData)(object)item4);
			FloatElementData item5 = new FloatElementData
			{
				Title = "Vitality",
				Value = metadata.Config.Vitality,
				Increment = Increment,
				MinValue = 0.2f,
				MaxValue = 100f,
				OnValueChanged = delegate(float v)
				{
					metadata.Config.Vitality = v;
				}
			};
			list.Add((ElementData)(object)item5);
			BoolElementData item6 = new BoolElementData
			{
				Title = "Override Speed",
				Value = metadata.Config.Speed_Enabled,
				OnValueChanged = delegate(bool val)
				{
					metadata.Config.Speed_Enabled = val;
				}
			};
			list.Add((ElementData)(object)item6);
			FloatElementData item7 = new FloatElementData
			{
				Title = "Speed",
				Value = metadata.Config.Speed,
				Increment = Increment,
				MinValue = 0.2f,
				MaxValue = 100f,
				OnValueChanged = delegate(float v)
				{
					metadata.Config.Speed = v;
				}
			};
			list.Add((ElementData)(object)item7);
			BoolElementData item8 = new BoolElementData
			{
				Title = "Override Jump Power",
				Value = metadata.Config.JumpPower_Enabled,
				OnValueChanged = delegate(bool val)
				{
					metadata.Config.JumpPower_Enabled = val;
				}
			};
			list.Add((ElementData)(object)item8);
			FloatElementData item9 = new FloatElementData
			{
				Title = "Jump Power",
				Value = metadata.Config.JumpPower,
				Increment = Increment,
				MinValue = 0.2f,
				MaxValue = 100f,
				OnValueChanged = delegate(float v)
				{
					metadata.Config.JumpPower = v;
				}
			};
			list.Add((ElementData)(object)item9);
			BoolElementData item10 = new BoolElementData
			{
				Title = "Override Agility",
				Value = metadata.Config.Agility_Enabled,
				OnValueChanged = delegate(bool val)
				{
					metadata.Config.Agility_Enabled = val;
				}
			};
			list.Add((ElementData)(object)item10);
			FloatElementData item11 = new FloatElementData
			{
				Title = "Agility",
				Value = metadata.Config.Agility,
				Increment = Increment,
				MinValue = 0.2f,
				MaxValue = 100f,
				OnValueChanged = delegate(float v)
				{
					metadata.Config.Agility = v;
				}
			};
			list.Add((ElementData)(object)item11);
			BoolElementData item12 = new BoolElementData
			{
				Title = "Override Strength Upper",
				Value = metadata.Config.StrengthUpper_Enabled,
				OnValueChanged = delegate(bool val)
				{
					metadata.Config.StrengthUpper_Enabled = val;
				}
			};
			list.Add((ElementData)(object)item12);
			FloatElementData item13 = new FloatElementData
			{
				Title = "Strength Upper",
				Value = metadata.Config.StrengthUpper,
				Increment = Increment,
				MinValue = 0.2f,
				MaxValue = 100f,
				OnValueChanged = delegate(float v)
				{
					metadata.Config.StrengthUpper = v;
				}
			};
			list.Add((ElementData)(object)item13);
			FunctionElementData item14 = new FunctionElementData
			{
				Title = $"Increment: {Increment}",
				OnPressed = delegate
				{
					string groupName = $"{metadata.Team.DisplayName} Config";
					IncrementIndex++;
					IncrementIndex %= IncrementValues.Count;
					ChangeElementTitle(groupName, "Increment:", $"Increment: {Increment}");
					ChangeElementIncrement(groupName, "Strength Upper", Increment);
					ChangeElementIncrement(groupName, "Agility", Increment);
					ChangeElementIncrement(groupName, "Jump Power", Increment);
					ChangeElementIncrement(groupName, "Speed", Increment);
					ChangeElementIncrement(groupName, "Vitality", Increment);
				}
			};
			list.Add((ElementData)(object)item14);
			return list;
		}

		public override void OnGamemodeRegistered()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Expected O, but got Unknown
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Expected O, but got Unknown
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Expected O, but got Unknown
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Expected O, but got Unknown
			Instance = this;
			FusionOverrides.OnValidateNametag += new UserOverride(OnValidateNametag);
			MultiplayerHooking.OnPlayerAction += new PlayerAction(OnPlayerAction);
			TeamManager.Register((Gamemode)(object)this);
			TeamManager.AddTeam(Infected);
			TeamManager.AddTeam(UnInfected);
			TeamManager.OnAssignedToTeam += OnAssignedToTeam;
			__DisableDevTools = new MetadataBool("DisableDevTools", ((Gamemode)this).Metadata);
			__DisableSpawnGun = new MetadataBool("DisableSpawnGun", ((Gamemode)this).Metadata);
			InfectedMetadata = new TeamMetadata(Infected, ((Gamemode)this).Metadata, new TeamConfig(Defaults.InfectedStats));
			UnInfectedMetadata = new TeamMetadata(UnInfected, ((Gamemode)this).Metadata, new TeamConfig(Defaults.UnInfectedStats));
			_SelectedAvatar = new MetadataVariableT<string>("SelectedAvatar", ((Gamemode)this).Metadata);
			_CountdownLength = new MetadataInt("CountdownLength", ((Gamemode)this).Metadata);
			AKI = new MetadataBool("AllowKeepInventory", ((Gamemode)this).Metadata);
			InfectedLooking = new MetadataBool("InfectedLooking", ((Gamemode)this).Metadata);
			_TeleportOnEnd = new MetadataBool("TeleportOnEnd", ((Gamemode)this).Metadata);
			((Gamemode)this).Metadata.OnMetadataChanged += OnMetadataChanged;
			InfectEvent = new TriggerEvent("InfectPlayer", ((Gamemode)this).Relay, true);
			InfectEvent.OnTriggeredWithValue += PlayerInfected;
			OneMinuteLeftEvent = new TriggerEvent("OneMinuteLeft", ((Gamemode)this).Relay, true);
			OneMinuteLeftEvent.OnTriggered += OneMinuteLeft;
			InfectedVictoryEvent = new TriggerEvent("InfectedVictory", ((Gamemode)this).Relay, true);
			InfectedVictoryEvent.OnTriggered += InfectedVictory;
			UninfectedVictoryEvent = new TriggerEvent("UninfectedVictory", ((Gamemode)this).Relay, true);
			UninfectedVictoryEvent.OnTriggered += UnInfectedVictory;
			RefreshStatsEvent = new TriggerEvent("RefreshEvent", ((Gamemode)this).Relay, true);
			RefreshStatsEvent.OnTriggeredWithValue += RefreshStats;
			Teleport = new TriggerEvent("TeleportToHost", ((Gamemode)this).Relay, true);
			Teleport.OnTriggered += TeleportToHost;
		}

		private void RefreshStats(string isInfectedTeam)
		{
			if (bool.TryParse(isInfectedTeam, out var result) && TeamManager.GetLocalTeam() == (result ? Infected : UnInfected))
			{
				SetStats();
			}
		}

		private void InfectedLookingEvent()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0064: Expected O, but got Unknown
			if (((Gamemode)this).IsStarted && TeamManager.GetLocalTeam() != Infected)
			{
				FusionNotifier.Send(new FusionNotification
				{
					Title = NotificationText.op_Implicit("Run..."),
					Message = NotificationText.op_Implicit("The infected have awaken... you have to run... save yourselves.. please"),
					PopupLength = 5f,
					SaveToMenu = false,
					ShowPopup = true,
					Type = (NotificationType)1
				});
			}
		}

		public override void OnGamemodeUnregistered()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			FusionOverrides.OnValidateNametag -= new UserOverride(OnValidateNametag);
			InfectedElements = null;
			UnInfectedElements = null;
			TeamManager.Unregister();
			((Gamemode)this).Metadata.OnMetadataChanged -= OnMetadataChanged;
			TriggerEvent infectEvent = InfectEvent;
			if (infectEvent != null)
			{
				infectEvent.UnregisterEvent();
			}
			InfectEvent = null;
			TriggerEvent oneMinuteLeftEvent = OneMinuteLeftEvent;
			if (oneMinuteLeftEvent != null)
			{
				oneMinuteLeftEvent.UnregisterEvent();
			}
			OneMinuteLeftEvent = null;
			TriggerEvent infectedVictoryEvent = InfectedVictoryEvent;
			if (infectedVictoryEvent != null)
			{
				infectedVictoryEvent.UnregisterEvent();
			}
			InfectedVictoryEvent = null;
			TriggerEvent uninfectedVictoryEvent = UninfectedVictoryEvent;
			if (uninfectedVictoryEvent != null)
			{
				uninfectedVictoryEvent.UnregisterEvent();
			}
			UninfectedVictoryEvent = null;
			TriggerEvent refreshStatsEvent = RefreshStatsEvent;
			if (refreshStatsEvent != null)
			{
				refreshStatsEvent.UnregisterEvent();
			}
			RefreshStatsEvent = null;
			TriggerEvent teleport = Teleport;
			if (teleport != null)
			{
				teleport.UnregisterEvent();
			}
			Teleport = null;
		}

		private void PlayerInfected(string stringID)
		{
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_0158: Expected O, but got Unknown
			if (!((Gamemode)this).IsStarted || !ulong.TryParse(stringID, out var result))
			{
				return;
			}
			PlayerId playerId = PlayerIdManager.GetPlayerId(result);
			if (playerId == null)
			{
				return;
			}
			if (NetworkInfo.IsServer && UnInfected.HasPlayer(playerId))
			{
				if (UnInfected.PlayerCount <= 1)
				{
					InfectedVictoryEvent.TryInvoke();
					GamemodeManager.StopGamemode();
				}
				else
				{
					TeamManager.TryAssignTeam(playerId, Infected);
				}
			}
			if (playerId.IsMe && !HasBeenInfected)
			{
				if (UnInfected.PlayerCount > 1)
				{
					SwapAvatar(SelectedAvatar);
				}
				FusionNotifier.Send(new FusionNotification
				{
					ShowPopup = true,
					Title = NotificationText.op_Implicit("Infected"),
					Message = NotificationText.op_Implicit("Oh no, you got infected! Now you have to infect others..."),
					PopupLength = 4f,
					Type = (NotificationType)0
				});
				HasBeenInfected = true;
			}
			else if (!playerId.IsMe)
			{
				string text = default(string);
				MetadataHelper.TryGetDisplayName(playerId, ref text);
				FusionNotifier.Send(new FusionNotification
				{
					ShowPopup = true,
					Title = NotificationText.op_Implicit("Infected"),
					Message = NotificationText.op_Implicit((string.IsNullOrWhiteSpace(text) ? "N/A" : text) + " is now infected, " + ((UnInfected.PlayerCount > 1) ? "look out for them..." : "the last survivor has fallen...")),
					PopupLength = 4f,
					Type = (NotificationType)0
				});
			}
		}

		private static void SwapAvatar(string barcode)
		{
			//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)
			//IL_004e: Expected O, but got Unknown
			if (string.IsNullOrWhiteSpace(barcode) || barcode == Barcode.EMPTY)
			{
				Logger.Error("ALERT! ALERT! This is not supposed to fucking happen, what the fuck did you do that the SelectedAvatar is empty. Now relax, calm down and fix this issue");
			}
			else if (!((Object)(object)Player.RigManager == (Object)null))
			{
				PullCordForceChange obj = new GameObject("AI_PCFC").AddComponent<PullCordForceChange>();
				obj.avatarCrate = new AvatarCrateReference(barcode);
				obj.rigManager = Player.RigManager;
				PullCordSender.SendBodyLogEffect();
				obj.ForceChange(((Component)obj.rigManager).gameObject);
			}
		}

		private IEnumerator InfectedLookingWait()
		{
			int target = CountdownLength;
			float passed = 0f;
			while (passed < (float)target)
			{
				passed += TimeUtilities.DeltaTime;
				yield return null;
			}
			((MetadataVariableT<bool>)(object)InfectedLooking).SetValue(true);
		}

		private void OnAssignedToTeam(PlayerId player, Team team)
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			FusionOverrides.ForceUpdateOverrides();
			if (team == null || player == null || !player.IsValid || !player.IsMe)
			{
				return;
			}
			SetStats();
			((team == Infected) ? InfectedMetadata : UnInfectedMetadata).CanUseGunsChanged();
			if (team == Infected)
			{
				IEnumerableExtensions.ForEach<PullCordDevice>((IEnumerable<PullCordDevice>)((Component)Player.RigManager).gameObject.GetComponentsInChildren<PullCordDevice>(), (Action<PullCordDevice>)delegate(PullCordDevice x)
				{
					x._bodyLogEnabled = false;
				});
			}
			else
			{
				IEnumerableExtensions.ForEach<PullCordDevice>((IEnumerable<PullCordDevice>)((Component)Player.RigManager).gameObject.GetComponentsInChildren<PullCordDevice>(), (Action<PullCordDevice>)delegate(PullCordDevice x)
				{
					x._bodyLogEnabled = true;
				});
			}
			if (InitialTeam)
			{
				if (team == Infected)
				{
					SwapAvatar(SelectedAvatar);
					MelonCoroutines.Start(HideVisionAndReveal());
				}
				else
				{
					FusionNotifier.Send(new FusionNotification
					{
						ShowPopup = true,
						Title = NotificationText.op_Implicit("Uninfected"),
						Message = NotificationText.op_Implicit("Woah! You were lucky to not be infected. You have to make sure you don't get infected!"),
						PopupLength = 4f,
						Type = (NotificationType)0
					});
				}
				InitialTeam = false;
			}
		}

		private void OneMinuteLeft()
		{
			//IL_0009: 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)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			if (((Gamemode)this).IsStarted)
			{
				FusionNotifier.Send(new FusionNotification
				{
					Title = NotificationText.op_Implicit("Avatar Infection"),
					Message = NotificationText.op_Implicit("One minute left!"),
					PopupLength = 3.5f,
					ShowPopup = true,
					Type = (NotificationType)0
				});
			}
		}

		private void InfectedVictory()
		{
			//IL_0009: 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)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			if (((Gamemode)this).IsStarted)
			{
				FusionNotifier.Send(new FusionNotification
				{
					ShowPopup = true,
					Title = NotificationText.op_Implicit("Infected Won"),
					Message = NotificationText.op_Implicit("Everyone has been infected!"),
					PopupLength = 4f,
					Type = (NotificationType)0
				});
			}
		}

		private void UnInfectedVictory()
		{
			//IL_0009: 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)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			if (((Gamemode)this).IsStarted)
			{
				FusionNotifier.Send(new FusionNotification
				{
					ShowPopup = true,
					Title = NotificationText.op_Implicit("UnInfected Won"),
					Message = NotificationText.op_Implicit("There were people not infected in time!"),
					PopupLength = 4f,
					Type = (NotificationType)0
				});
			}
		}

		private IEnumerator HideVisionAndReveal()
		{
			if (!((Gamemode)this).IsStarted)
			{
				yield break;
			}
			try
			{
				CountdownLength = ((MetadataVariableT<int>)(object)_CountdownLength).GetValue();
				if (CountdownLength != 0)
				{
					HideVision = true;
					LocalVision.Blind = true;
					LocalVision.BlindColor = Color.black;
					LocalControls.LockMovement();
					float elapsed = 0f;
					float totalElapsed = 0f;
					int seconds = 0;
					bool secondPassed = true;
					while (seconds < CountdownLength && ((Gamemode)this).IsStarted)
					{
						float num = Mathf.Max((float)CountdownLength - 1f, 0f);
						float num2 = Mathf.Max(totalElapsed - num, 0f) / 1f;
						LocalVision.BlindColor = Color.Lerp(Color.black, Color.clear, num2);
						if (secondPassed)
						{
							int num3 = CountdownLength - seconds;
							Sprite val = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 0f, 0f), new Vector2(0.5f, 0.5f), 100f);
							TutorialRig instance = TutorialRig.Instance;
							HeadTitles headTitles = instance.headTitles;
							((Component)instance).gameObject.SetActive(true);
							((Component)headTitles).gameObject.SetActive(true);
							float timeToScale = Mathf.Lerp(0.05f, 0.4f, Mathf.Clamp01((float)CountdownLength - 1f));
							instance.headTitles.timeToScale = timeToScale;
							instance.headTitles.CUSTOMDISPLAY("Countdown, get ready...", num3.ToString(), val, (float)CountdownLength, (AudioClip)null, false, (Sprite)null, (Sprite)null, (Sprite)null, (Sprite)null);
							instance.headTitles.sr_element.sprite = val;
							secondPassed = false;
						}
						elapsed += TimeUtilities.DeltaTime;
						totalElapsed += TimeUtilities.DeltaTime;
						if (elapsed >= 1f)
						{
							elapsed -= 1f;
							seconds++;
							secondPassed = true;
						}
						yield return null;
					}
					LocalControls.UnlockMovement();
					TutorialRig.Instance.headTitles.CLOSEDISPLAY();
					LocalVision.Blind = false;
				}
				FusionNotifier.Send(new FusionNotification
				{
					ShowPopup = true,
					Title = NotificationText.op_Implicit("Countdown Over"),
					Message = NotificationText.op_Implicit("GO AND INFECT THEM ALL!"),
					PopupLength = 2f,
					Type = (NotificationType)0
				});
			}
			finally
			{
				HideVision = false;
			}
		}

		protected override void OnUpdate()
		{
			if (!((Gamemode)this).IsStarted)
			{
				ChangeElementColor($"{Infected.DisplayName} Config", "Apply new settings", null, startsWith: false);
				ChangeElementColor($"{UnInfected.DisplayName} Config", "Apply new settings", null, startsWith: false);
				return;
			}
			if (InfectedMetadata.GetConfigFromMetadata() != InfectedMetadata.Config)
			{
				ChangeElementColor($"{Infected.DisplayName} Config", "Apply new settings", Color.Red, startsWith: false);
			}
			else
			{
				ChangeElementColor($"{Infected.DisplayName} Config", "Apply new settings", null, startsWith: false);
			}
			if (UnInfectedMetadata.GetConfigFromMetadata() != UnInfectedMetadata.Config)
			{
				ChangeElementColor($"{UnInfected.DisplayName} Config", "Apply new settings", Color.Red, startsWith: false);
			}
			else
			{
				ChangeElementColor($"{UnInfected.DisplayName} Config", "Apply new settings", null, startsWith: false);
			}
			if (HideVision && !LocalVision.Blind)
			{
				LocalVision.Blind = true;
			}
			_elapsedTime += TimeUtilities.DeltaTime;
			if (TeamManager.GetLocalTeam() == UnInfected)
			{
				UninfectedUpdate();
			}
			Il2CppArrayBase<PullCordDevice> componentsInChildren = ((Component)Player.RigManager).gameObject.GetComponentsInChildren<PullCordDevice>();
			if (TeamManager.GetLocalTeam() == Infected)
			{
				IEnumerableExtensions.ForEach<PullCordDevice>((IEnumerable<PullCordDevice>)componentsInChildren, (Action<PullCordDevice>)delegate(PullCordDevice x)
				{
					x._bodyLogEnabled = false;
				});
			}
			else
			{
				IEnumerableExtensions.ForEach<PullCordDevice>((IEnumerable<PullCordDevice>)componentsInChildren, (Action<PullCordDevice>)delegate(PullCordDevice x)
				{
					x._bodyLogEnabled = true;
				});
			}
			if (UntilAllFound)
			{
				return;
			}
			if (!_oneMinuteLeft && TimeLimit - ElapsedMinutes == 1)
			{
				if (NetworkInfo.IsServer)
				{
					OneMinuteLeftEvent.TryInvoke();
				}
				_oneMinuteLeft = true;
			}
			if (NetworkInfo.IsServer && ElapsedMinutes >= TimeLimit)
			{
				TriggerEvent uninfectedVictoryEvent = UninfectedVictoryEvent;
				if (uninfectedVictoryEvent != null)
				{
					uninfectedVictoryEvent.TryInvoke();
				}
				GamemodeManager.StopGamemode();
			}
		}

		private void UninfectedUpdate()
		{
			if (_lastCheckedMinutes != ElapsedMinutes)
			{
				_lastCheckedMinutes = ElapsedMinutes;
				PointItemManager.RewardBits(75, true);
			}
		}

		public override bool CheckReadyConditions()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			if (NetworkPlayer.Players.Count < 2)
			{
				return false;
			}
			if (string.IsNullOrWhiteSpace(SelectedAvatar))
			{
				return false;
			}
			Barcode val = new Barcode(SelectedAvatar);
			if (val == null || !BarcodeExtensions.IsValid(val) || val == null || !BarcodeExtensions.IsValidSize(val))
			{
				return false;
			}
			if (InfectedCount > NetworkPlayer.Players.Count - 1)
			{
				return false;
			}
			return true;
		}

		private static void Internal_SetStats(TeamMetadata metadata)
		{
			FusionOverrides.ForceUpdateOverrides();
			float? jumpPower = (metadata.Config.JumpPower_Enabled ? new float?(metadata.Config.JumpPower) : null);
			float? speed = (metadata.Config.Speed_Enabled ? new float?(metadata.Config.Speed) : null);
			float? agility = (metadata.Config.Agility_Enabled ? new float?(metadata.Config.Agility) : null);
			float? strengthUpper = (metadata.Config.StrengthUpper_Enabled ? new float?(metadata.Config.StrengthUpper) : null);
			FusionPlayerExtended.SetOverrides(jumpPower, speed, agility, strengthUpper);
			FusionPlayer.SetMortality(metadata.Config.Mortality);
			if (metadata.Config.Vitality_Enabled)
			{
				FusionPlayer.SetPlayerVitality(metadata.Config.Vitality);
			}
		}

		internal void SetStats()
		{
			if (((Gamemode)this).IsStarted)
			{
				if (TeamManager.GetLocalTeam() == null)
				{
					ClearOverrides();
				}
				else
				{
					Internal_SetStats((TeamManager.GetLocalTeam() == UnInfected) ? UnInfectedMetadata : InfectedMetadata);
				}
			}
		}

		private void UpdateDevToolsSpawnGunBlacklist()
		{
			if (!NetworkInfo.IsServer)
			{
				_DisableDevTools = ((MetadataVariableT<bool>)(object)__DisableDevTools).GetValue();
				_DisableSpawnGun = ((MetadataVariableT<bool>)(object)__DisableSpawnGun).GetValue();
			}
		}

		private void SelectedPlayerOverride()
		{
			if (((Gamemode)this).IsStarted && TeamManager.GetLocalTeam() == Infected)
			{
				SwapAvatar(SelectedAvatar);
			}
		}

		private void OnMetadataChanged(string key, string value)
		{
			if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(value) || !((Gamemode)this).IsStarted)
			{
				return;
			}
			switch (key)
			{
			case "DisableDevTools":
			case "DisableSpawnGun":
				UpdateDevToolsSpawnGunBlacklist();
				break;
			case "SelectedAvatar":
				if (!(SelectedAvatar == value))
				{
					SelectedAvatar = _SelectedAvatar.GetValue();
					SelectedPlayerOverride();
				}
				break;
			case "CountdownLength":
				CountdownLength = ((MetadataVariableT<int>)(object)_CountdownLength).GetValue();
				break;
			case "InfectedLooking":
				if (((MetadataVariableT<bool>)(object)InfectedLooking).GetValue())
				{
					InfectedLookingEvent();
				}
				break;
			case "TeleportOnEnd":
				TeleportOnEnd = ((MetadataVariableT<bool>)(object)_TeleportOnEnd).GetValue();
				break;
			}
		}

		private void ApplyGamemodeSettings()
		{
			_SelectedAvatar.SetValue(SelectedAvatar);
			((MetadataVariableT<bool>)(object)__DisableDevTools).SetValue(_DisableDevTools);
			((MetadataVariableT<bool>)(object)__DisableSpawnGun).SetValue(_DisableSpawnGun);
			((MetadataVariableT<int>)(object)_CountdownLength).SetValue(CountdownLength);
			((MetadataVariableT<bool>)(object)_TeleportOnEnd).SetValue(TeleportOnEnd);
			InfectedMetadata.ApplyConfig();
			UnInfectedMetadata.ApplyConfig();
			((MetadataVariableT<bool>)(object)AKI).SetValue(AllowKeepInventory);
			((MetadataVariableT<bool>)(object)InfectedLooking).SetValue(false);
		}

		public override void OnGamemodeStarted()
		{
			((Gamemode)this).OnGamemodeStarted();
			Playlist.SetPlaylist(AudioReference.CreateReferences(Defaults.Tracks));
			Playlist.Shuffle();
			HasBeenInfected = false;
			_elapsedTime = 0f;
			_lastCheckedMinutes = 0;
			_oneMinuteLeft = false;
			if (NetworkInfo.IsServer)
			{
				ApplyGamemodeSettings();
				AssignTeams();
				MelonCoroutines.Start(InfectedLookingWait());
				if (ShouldTeleportToHost)
				{
					Teleport.TryInvoke();
				}
			}
			Playlist.StartPlaylist();
			FusionSceneManager.HookOnTargetLevelLoad((Action)delegate
			{
				if (!NetworkInfo.IsServer)
				{
					InfectedMetadata.RefreshConfig(setStats: false);
					UnInfectedMetadata.RefreshConfig(setStats: false);
				}
				SetStats();
				UpdateDevToolsSpawnGunBlacklist();
				if (!NetworkInfo.IsServer)
				{
					SelectedAvatar = _SelectedAvatar.GetValue();
				}
				SelectedPlayerOverride();
			});
		}

		private static void ClearOverrides()
		{
			FusionPlayer.ResetMortality();
			FusionPlayer.ClearPlayerVitality();
			FusionPlayerExtended.ClearAllOverrides();
			FusionPlayerExtended.ClearAvatarOverride();
		}

		public override void OnGamemodeStopped()
		{
			((Gamemode)this).OnGamemodeStopped();
			HasBeenInfected = false;
			InitialTeam = true;
			Playlist.StopPlaylist();
			if (NetworkInfo.IsServer)
			{
				TeamManager.UnassignAllPlayers();
			}
			else if (TeleportOnEnd)
			{
				TeleportToHost();
			}
			IEnumerableExtensions.ForEach<PullCordDevice>((IEnumerable<PullCordDevice>)((Component)Player.RigManager).gameObject.GetComponentsInChildren<PullCordDevice>(), (Action<PullCordDevice>)delegate(PullCordDevice x)
			{
				x._bodyLogEnabled = true;
			});
			FusionOverrides.ForceUpdateOverrides();
			_elapsedTime = 0f;
			_lastCheckedMinutes = 0;
			_oneMinuteLeft = false;
			ClearOverrides();
		}

		private static void TeleportToHost()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			NetworkPlayer val = default(NetworkPlayer);
			if (!NetworkInfo.IsServer && NetworkPlayerManager.TryGetPlayer(PlayerId.op_Implicit(PlayerIdManager.GetHostId()), ref val) && val.HasRig)
			{
				FusionPlayer.Teleport(val.RigRefs.RigManager.physicsRig.feet.transform.position, Vector3.forward, true);
			}
		}

		protected bool OnValidateNametag(PlayerId id)
		{
			if (!((Gamemode)this).IsStarted)
			{
				return true;
			}
			if (TeamManager.GetPlayerTeam(id) != null)
			{
				return TeamManager.GetPlayerTeam(id) == TeamManager.GetLocalTeam();
			}
			return true;
		}

		private void AssignTeams()
		{
			List<PlayerId> list = new List<PlayerId>(PlayerIdManager.PlayerIds);
			IEnumerableExtensions.Shuffle<PlayerId>((IList<PlayerId>)list);
			Random random = new Random();
			for (int i = 0; i < InfectedCount; i++)
			{
				PlayerId val = list[random.Next(0, list.Count)];
				TeamManager.TryAssignTeam(val, Infected);
				list.Remove(val);
			}
			foreach (PlayerId item in list)
			{
				TeamManager.TryAssignTeam(item, UnInfected);
			}
		}

		protected void OnPlayerAction(PlayerId player, PlayerActionType type, PlayerId otherPlayer = null)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Invalid comparison between Unknown and I4
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Invalid comparison between Unknown and I4
			if (!((Gamemode)this).IsStarted)
			{
				return;
			}
			if ((int)type == 5)
			{
				if (!NetworkInfo.IsServer || otherPlayer == null || InfectType != InfectTypeEnum.DEATH)
				{
					return;
				}
				if (TeamManager.GetPlayerTeam(player) == UnInfected && TeamManager.GetPlayerTeam(otherPlayer) == Infected)
				{
					InfectEvent.TryInvoke(player.LongId.ToString());
				}
			}
			else if ((int)type == 3)
			{
				if (!NetworkInfo.IsServer || InfectType != InfectTypeEnum.DEATH || !SuicideInfects || (lastActions.ContainsKey(player) && (int)lastActions[player] == 5))
				{
					return;
				}
				if (TeamManager.GetPlayerTeam(player) == UnInfected)
				{
					InfectEvent.TryInvoke(player.LongId.ToString());
				}
			}
			lastActions[player] = type;
		}
	}
	public struct TeamConfig
	{
		public bool Vitality_Enabled;

		public float Vitality;

		public bool Speed_Enabled;

		public float Speed;

		public bool JumpPower_Enabled;

		public float JumpPower;

		public bool StrengthUpper_Enabled;

		public float StrengthUpper;

		public bool Agility_Enabled;

		public float Agility;

		public bool Mortality;

		public bool CanUseGuns;

		public TeamConfig()
		{
			Vitality_Enabled = false;
			Vitality = 0f;
			Speed_Enabled = false;
			Speed = 0f;
			JumpPower_Enabled = false;
			JumpPower = 0f;
			StrengthUpper_Enabled = false;
			StrengthUpper = 0f;
			Agility_Enabled = false;
			Agility = 0f;
			Mortality = false;
			CanUseGuns = false;
		}

		public TeamConfig(TeamConfig old)
		{
			Vitality_Enabled = old.Vitality_Enabled;
			Vitality = old.Vitality;
			Speed = old.Speed;
			Speed_Enabled = old.Speed_Enabled;
			JumpPower = old.JumpPower;
			JumpPower_Enabled = old.JumpPower_Enabled;
			Agility = old.Agility;
			Agility_Enabled = old.Agility_Enabled;
			Mortality = old.Mortality;
			StrengthUpper_Enabled = old.StrengthUpper_Enabled;
			StrengthUpper = old.StrengthUpper;
			CanUseGuns = old.CanUseGuns;
		}

		public override readonly bool Equals([NotNullWhen(true)] object obj)
		{
			if (!(obj is TeamConfig teamConfig))
			{
				return false;
			}
			if (Vitality != teamConfig.Vitality)
			{
				return false;
			}
			if (Vitality_Enabled != teamConfig.Vitality_Enabled)
			{
				return false;
			}
			if (Speed != teamConfig.Speed)
			{
				return false;
			}
			if (Speed_Enabled != teamConfig.Speed_Enabled)
			{
				return false;
			}
			if (Agility != teamConfig.Agility)
			{
				return false;
			}
			if (Agility_Enabled != teamConfig.Agility_Enabled)
			{
				return false;
			}
			if (Mortality != teamConfig.Mortality)
			{
				return false;
			}
			if (CanUseGuns != teamConfig.CanUseGuns)
			{
				return false;
			}
			if (StrengthUpper != teamConfig.StrengthUpper)
			{
				return false;
			}
			if (StrengthUpper_Enabled != teamConfig.StrengthUpper_Enabled)
			{
				return false;
			}
			if (JumpPower_Enabled != teamConfig.JumpPower_Enabled)
			{
				return false;
			}
			if (JumpPower != teamConfig.JumpPower)
			{
				return false;
			}
			return true;
		}

		public override readonly int GetHashCode()
		{
			return Vitality.GetHashCode() + Vitality_Enabled.GetHashCode() + Agility.GetHashCode() + Agility_Enabled.GetHashCode() + Speed.GetHashCode() + Speed_Enabled.GetHashCode() + StrengthUpper.GetHashCode() + StrengthUpper_Enabled.GetHashCode() + JumpPower.GetHashCode() + JumpPower_Enabled.GetHashCode() + Mortality.GetHashCode() + CanUseGuns.GetHashCode();
		}

		public static bool operator ==(TeamConfig left, TeamConfig right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(TeamConfig left, TeamConfig right)
		{
			return !(left == right);
		}

		public override readonly string ToString()
		{
			return $"==========================================\r\nVitality: {Vitality} (Enabled: {Vitality_Enabled})\r\nSpeed: {Speed} (Enabled: {Speed_Enabled})\r\nJump Power: {JumpPower} (Enabled: {JumpPower_Enabled})\r\nAgility: {Agility} (Enabled: {Agility_Enabled})\r\nStrength Upper: {StrengthUpper} (Enabled: {StrengthUpper_Enabled})\r\n\r\nMortality: {Mortality}\r\nCan Use Guns: {CanUseGuns}\r\n==========================================";
		}
	}
	public class TeamMetadata
	{
		public readonly Team Team;

		public TeamConfig Config;

		public MetadataBool Mortality;

		public MetadataBool CanUseGuns;

		public ToggleMetadataVariableT<float> Vitality;

		public ToggleMetadataVariableT<float> Speed;

		public ToggleMetadataVariableT<float> JumpPower;

		public ToggleMetadataVariableT<float> Agility;

		public ToggleMetadataVariableT<float> StrengthUpper;

		public TeamMetadata(Team team, NetworkMetadata metadata, TeamConfig config)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			Team = team;
			Config = config;
			metadata.OnMetadataChanged += OnMetadataChanged;
			Mortality = new MetadataBool(team.TeamName + "_Mortality", metadata);
			CanUseGuns = new MetadataBool(team.TeamName + "_CanUseGuns", metadata);
			Vitality = new ToggleMetadataVariableT<float>(team.TeamName + "_Vitality", metadata);
			Speed = new ToggleMetadataVariableT<float>(team.TeamName + "_Speed", metadata);
			JumpPower = new ToggleMetadataVariableT<float>(team.TeamName + "_JumpPower", metadata);
			Agility = new ToggleMetadataVariableT<float>(team.TeamName + "_Agility", metadata);
			StrengthUpper = new ToggleMetadataVariableT<float>(team.TeamName + "_StrengthUpper", metadata);
		}

		public void ApplyConfig()
		{
			if (NetworkInfo.IsServer)
			{
				((MetadataVariableT<bool>)(object)Mortality).SetValue(Config.Mortality);
				Vitality.SetValue(Config.Vitality);
				Speed.SetValue(Config.Speed);
				JumpPower.SetValue(Config.JumpPower);
				Agility.SetValue(Config.Agility);
				StrengthUpper.SetValue(Config.StrengthUpper);
				Vitality.SetEnabled(Config.Vitality_Enabled);
				Speed.SetEnabled(Config.Speed_Enabled);
				JumpPower.SetEnabled(Config.JumpPower_Enabled);
				Agility.SetEnabled(Config.Agility_Enabled);
				StrengthUpper.SetEnabled(Config.StrengthUpper_Enabled);
				((MetadataVariableT<bool>)(object)CanUseGuns).SetValue(Config.CanUseGuns);
			}
		}

		public void RefreshConfig(bool setStats = true)
		{
			Config.Mortality = ((MetadataVariableT<bool>)(object)Mortality).GetValue();
			Config.Vitality = Vitality.GetValue();
			Config.Speed = Speed.GetValue();
			Config.JumpPower = JumpPower.GetValue();
			Config.Agility = Agility.GetValue();
			Config.StrengthUpper = StrengthUpper.GetValue();
			Config.Vitality_Enabled = Vitality.IsEnabled;
			Config.Speed_Enabled = Speed.IsEnabled;
			Config.JumpPower_Enabled = JumpPower.IsEnabled;
			Config.Agility_Enabled = Agility.IsEnabled;
			Config.StrengthUpper_Enabled = StrengthUpper.IsEnabled;
			Config.CanUseGuns = ((MetadataVariableT<bool>)(object)CanUseGuns).GetValue();
			if (((Gamemode)Infection.Instance).IsStarted && setStats)
			{
				Infection.Instance.SetStats();
			}
		}

		public TeamConfig GetConfigFromMetadata()
		{
			TeamConfig result = new TeamConfig();
			result.Agility = Agility.GetValue();
			result.Vitality = Vitality.GetValue();
			result.Speed = Speed.GetValue();
			result.JumpPower = JumpPower.GetValue();
			result.StrengthUpper = StrengthUpper.GetValue();
			result.CanUseGuns = ((MetadataVariableT<bool>)(object)CanUseGuns).GetValue();
			result.Agility_Enabled = Agility.IsEnabled;
			result.Speed_Enabled = Speed.IsEnabled;
			result.Vitality_Enabled = Vitality.IsEnabled;
			result.StrengthUpper_Enabled = StrengthUpper.IsEnabled;
			result.JumpPower_Enabled = JumpPower.IsEnabled;
			result.Mortality = ((MetadataVariableT<bool>)(object)Mortality).GetValue();
			return result;
		}

		private static void CheckForGun(Hand hand)
		{
			GameObject currentAttachedGO = hand.m_CurrentAttachedGO;
			object obj = ((currentAttachedGO != null) ? currentAttachedGO.GetComponent<Gun>() : null);
			if (obj == null)
			{
				GameObject currentAttachedGO2 = hand.m_CurrentAttachedGO;
				obj = ((currentAttachedGO2 != null) ? currentAttachedGO2.GetComponentInParent<Gun>() : null);
			}
			if ((Object)obj != (Object)null)
			{
				HandExtensions.TryDetach(hand);
			}
		}

		internal void CanUseGunsChanged()
		{
			if (Infection.TeamManager.GetLocalTeam() == Team && !Config.CanUseGuns)
			{
				CheckForGun(Player.LeftHand);
				CheckForGun(Player.RightHand);
			}
		}

		internal void OnMetadataChanged(string name, string value)
		{
			if (!string.IsNullOrWhiteSpace(name) && !string.IsNullOrWhiteSpace(value) && ((Gamemode)Infection.Instance).IsStarted)
			{
				if (name == ((MetadataVariable)Mortality).Key)
				{
					Config.Mortality = ((MetadataVariableT<bool>)(object)Mortality).GetValue();
				}
				else if (name == Vitality.Key)
				{
					Config.Vitality = Vitality.GetValue();
				}
				else if (name == Speed.Key)
				{
					Config.Speed = Speed.GetValue();
				}
				else if (name == JumpPower.Key)
				{
					Config.JumpPower = JumpPower.GetValue();
				}
				else if (name == Agility.Key)
				{
					Config.Agility = Agility.GetValue();
				}
				else if (name == StrengthUpper.Key)
				{
					Config.StrengthUpper = StrengthUpper.GetValue();
				}
				else if (name == Vitality.ToggledKey)
				{
					Config.Vitality_Enabled = Vitality.IsEnabled;
				}
				else if (name == Speed.ToggledKey)
				{
					Config.Speed_Enabled = Speed.IsEnabled;
				}
				else if (name == JumpPower.ToggledKey)
				{
					Config.JumpPower_Enabled = JumpPower.IsEnabled;
				}
				else if (name == Agility.ToggledKey)
				{
					Config.Agility_Enabled = Agility.IsEnabled;
				}
				else if (name == StrengthUpper.ToggledKey)
				{
					Config.StrengthUpper_Enabled = StrengthUpper.IsEnabled;
				}
				else if (name == ((MetadataVariable)CanUseGuns).Key)
				{
					Config.CanUseGuns = ((MetadataVariableT<bool>)(object)CanUseGuns).GetValue();
					CanUseGunsChanged();
				}
			}
		}
	}
}
namespace AvatarInfection.Utilities
{
	public static class FusionPlayerExtended
	{
		public static float? SpeedOverride { get; private set; }

		public static float? JumpPowerOverride { get; private set; }

		public static float? AgilityOverride { get; private set; }

		public static float? StrengthUpperOverride { get; private set; }

		public static string AvatarOverride { get; private set; }

		public static string LastAvatar { get; private set; }

		internal static void UpdateSpeed(bool refreshAvatar = true)
		{
			if (!((Object)(object)Player.RigManager != (Object)null))
			{
				return;
			}
			RigManager rigManager = Player.RigManager;
			Avatar avatar = rigManager._avatar;
			if (!((Object)(object)avatar != (Object)null))
			{
				return;
			}
			if (SpeedOverride.HasValue)
			{
				if (avatar._speed != SpeedOverride.Value)
				{
					avatar._speed = SpeedOverride.Value;
					if (refreshAvatar)
					{
						rigManager.SwapAvatarCrate(((ScannableReference)rigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
					}
				}
			}
			else if (refreshAvatar)
			{
				rigManager.SwapAvatarCrate(((ScannableReference)rigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
			}
		}

		internal static void UpdateAgility(bool refreshAvatar = true)
		{
			if (!((Object)(object)Player.RigManager != (Object)null))
			{
				return;
			}
			RigManager rigManager = Player.RigManager;
			Avatar avatar = rigManager._avatar;
			if (!((Object)(object)avatar != (Object)null))
			{
				return;
			}
			if (AgilityOverride.HasValue)
			{
				if (avatar._agility != AgilityOverride.Value)
				{
					avatar._agility = AgilityOverride.Value;
					if (refreshAvatar)
					{
						rigManager.SwapAvatarCrate(((ScannableReference)rigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
					}
				}
			}
			else if (refreshAvatar)
			{
				rigManager.SwapAvatarCrate(((ScannableReference)rigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
			}
		}

		internal static void UpdateStrengthUpper(bool refreshAvatar = true)
		{
			if (!((Object)(object)Player.RigManager != (Object)null))
			{
				return;
			}
			RigManager rigManager = Player.RigManager;
			Avatar avatar = rigManager._avatar;
			if (!((Object)(object)avatar != (Object)null))
			{
				return;
			}
			if (StrengthUpperOverride.HasValue)
			{
				if (avatar._strengthUpper != StrengthUpperOverride.Value)
				{
					avatar._strengthUpper = StrengthUpperOverride.Value;
					avatar._strengthGrip = StrengthUpperOverride.Value;
					if (refreshAvatar)
					{
						rigManager.SwapAvatarCrate(((ScannableReference)rigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
					}
				}
			}
			else
			{
				rigManager.SwapAvatarCrate(((ScannableReference)rigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
			}
		}

		internal static void SetOverrides(float? jumpPower, float? speed, float? agility, float? strengthUpper)
		{
			SpeedOverride = speed;
			JumpPowerOverride = jumpPower;
			AgilityOverride = agility;
			StrengthUpperOverride = strengthUpper;
			if (!((Object)(object)Player.RigManager != (Object)null))
			{
				return;
			}
			RigManager rigManager = Player.RigManager;
			Avatar avatar = rigManager._avatar;
			if ((Object)(object)avatar != (Object)null)
			{
				bool flag = false;
				if (AgilityOverride.HasValue && avatar._agility != AgilityOverride.Value)
				{
					flag = true;
					avatar._agility = AgilityOverride.Value;
				}
				if (JumpPowerOverride.HasValue && avatar._strengthLower != JumpPowerOverride.Value)
				{
					flag = true;
					avatar._strengthLower = JumpPowerOverride.Value;
				}
				if (SpeedOverride.HasValue && avatar._speed != SpeedOverride.Value)
				{
					flag = true;
					avatar._speed = SpeedOverride.Value;
				}
				if (StrengthUpperOverride.HasValue && avatar._strengthUpper != StrengthUpperOverride.Value)
				{
					flag = true;
					avatar._strengthUpper = StrengthUpperOverride.Value;
					avatar._strengthGrip = StrengthUpperOverride.Value;
				}
				if (flag)
				{
					rigManager.SwapAvatarCrate(((ScannableReference)rigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
				}
			}
		}

		internal static void ClearAllOverrides()
		{
			if (!AgilityOverride.HasValue && !SpeedOverride.HasValue && !StrengthUpperOverride.HasValue && !JumpPowerOverride.HasValue && !SpeedOverride.HasValue)
			{
				return;
			}
			AgilityOverride = null;
			SpeedOverride = null;
			StrengthUpperOverride = null;
			JumpPowerOverride = null;
			SpeedOverride = null;
			if ((Object)(object)Player.RigManager != (Object)null)
			{
				RigManager rigManager = Player.RigManager;
				if (rigManager.AvatarCrate != null)
				{
					rigManager.SwapAvatarCrate(((ScannableReference)rigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
				}
			}
		}

		public static void ClearAgilityOverride()
		{
			AgilityOverride = null;
			UpdateAgility();
		}

		public static void SetAgilityOverride(float agility, bool refreshAvatar = true)
		{
			AgilityOverride = agility;
			UpdateAgility(refreshAvatar);
		}

		public static void ClearStrengthUpperOverride()
		{
			StrengthUpperOverride = null;
			UpdateAgility();
		}

		public static void SetStrengthUpperOverride(float strengthUpper, bool refreshAvatar = true)
		{
			AgilityOverride = strengthUpper;
			UpdateAgility(refreshAvatar);
		}

		public static void SetAvatarOverride(string barcode)
		{
			bool flag = string.IsNullOrWhiteSpace(AvatarOverride);
			AvatarOverride = barcode;
			if ((Object)(object)Player.RigManager != (Object)null && AssetWarehouse.ready && AvatarOverride != null)
			{
				if (flag)
				{
					LastAvatar = ((ScannableReference)Player.RigManager.AvatarCrate).Barcode.ID ?? "c3534c5a-94b2-40a4-912a-24a8506f6c79";
				}
				FusionPlayer.SetAvatarOverride(barcode);
			}
		}

		public static void ClearAvatarOverride()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			AvatarOverride = null;
			FusionPlayer.ClearAvatarOverride();
			if ((Object)(object)Player.RigManager != (Object)null && LastAvatar != null && AssetWarehouse.ready)
			{
				Player.RigManager.SwapAvatarCrate(new Barcode(LastAvatar), true, (Action<bool>)null);
				DataManager.ActiveSave.PlayerSettings.CurrentAvatar = LastAvatar;
				DataManager.TrySaveActiveSave((SaveFlags)0);
			}
		}

		public static void ClearSpeedOverride()
		{
			SpeedOverride = null;
			UpdateSpeed();
		}

		public static void SetSpeedOverride(float speed, bool refreshAvatar = true)
		{
			SpeedOverride = speed;
			UpdateSpeed(refreshAvatar);
		}

		internal static void UpdateJumpPower(bool refreshAvatar = true)
		{
			if (!((Object)(object)Player.RigManager != (Object)null))
			{
				return;
			}
			RigManager rigManager = Player.RigManager;
			Avatar avatar = rigManager._avatar;
			if (!((Object)(object)avatar != (Object)null))
			{
				return;
			}
			if (JumpPowerOverride.HasValue)
			{
				if (avatar._strengthLower != JumpPowerOverride.Value)
				{
					avatar._strengthLower = JumpPowerOverride.Value;
					if (refreshAvatar)
					{
						rigManager.SwapAvatarCrate(((ScannableReference)rigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
					}
				}
			}
			else
			{
				rigManager.SwapAvatarCrate(((ScannableReference)rigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
			}
		}

		public static void ClearJumpPowerOverride()
		{
			JumpPowerOverride = null;
			UpdateJumpPower();
		}

		public static void SetJumpPowerOverride(float jumpPower, bool refreshAvatar = true)
		{
			JumpPowerOverride = jumpPower;
			UpdateJumpPower(refreshAvatar);
		}
	}
	internal static class TimeUtilities
	{
		private static float _deltaTime = 1f;

		private static float _fixedDeltaTime = 0.02f;

		private static float _timeSinceStartup = 0f;

		private static float _timeScale = 1f;

		private static int _frameCount = 0;

		public static float DeltaTime => _deltaTime;

		public static float FixedDeltaTime => _fixedDeltaTime;

		public static float TimeSinceStartup => _timeSinceStartup;

		public static float TimeScale => _timeScale;

		public static int FrameCount => _frameCount;

		internal static void OnEarlyUpdate()
		{
			_timeScale = Time.timeScale;
			_deltaTime = Time.deltaTime;
			_timeSinceStartup += _deltaTime;
			_frameCount++;
		}

		internal static void OnEarlyFixedUpdate()
		{
			_fixedDeltaTime = Time.fixedDeltaTime;
		}

		public static bool IsMatchingFrame(int interval)
		{
			return FrameCount % interval == 0;
		}

		public static bool IsMatchingFrame(int interval, int offset)
		{
			return (FrameCount + offset) % interval == 0;
		}
	}
	public class ToggleMetadataVariable
	{
		private static readonly JsonSerializerOptions SerializerOptions = new JsonSerializerOptions
		{
			IncludeFields = true
		};

		public NetworkMetadata Metadata { get; }

		public string Key { get; }

		[JsonIgnore]
		public bool IsEnabled
		{
			get
			{
				if (!bool.TryParse(Metadata.GetMetadata(ToggledKey), out var result))
				{
					return false;
				}
				return result;
			}
		}

		public string ToggledKey => Key + "-Toggled";

		public ToggleMetadataVariable(string key, NetworkMetadata metadata)
		{
			Metadata = metadata;
			Key = key;
			base..ctor();
		}

		public void Remove()
		{
			Metadata.TryRemoveMetadata(Key);
			Metadata.TryRemoveMetadata(ToggledKey);
		}

		public void SetValue(string value)
		{
			Metadata.TrySetMetadata(Key, value);
		}

		public void Toggle()
		{
			if (bool.TryParse(Metadata.GetMetadata(ToggledKey), out var result))
			{
				Metadata.TrySetMetadata(ToggledKey, (!result).ToString());
			}
			else
			{
				Metadata.TrySetMetadata(ToggledKey, true.ToString());
			}
		}

		public void SetEnabled(bool enabled)
		{
			Metadata.TrySetMetadata(ToggledKey, enabled.ToString());
		}

		public void SetValue<TValue>(TValue value)
		{
			SetValue(JsonSerializer.Serialize(value, SerializerOptions));
		}

		public string GetValue()
		{
			return Metadata.GetMetadata(Key);
		}

		public TValue GetValue<TValue>()
		{
			string value = GetValue();
			if (string.IsNullOrEmpty(value))
			{
				return default(TValue);
			}
			return JsonSerializer.Deserialize<TValue>(value, SerializerOptions);
		}
	}
	public class ToggleMetadataVariableT<TValue> : ToggleMetadataVariable
	{
		public ToggleMetadataVariableT(string key, NetworkMetadata metadata)
			: base(key, metadata)
		{
		}

		public void SetValue(TValue value)
		{
			base.SetValue(value);
		}

		public new TValue GetValue()
		{
			return GetValue<TValue>();
		}
	}
}
namespace AvatarInfection.Patches
{
	[HarmonyPatch(typeof(Avatar))]
	public static class AvatarPatches
	{
		[HarmonyPatch("ComputeBaseStats")]
		public static void Postfix(Avatar __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !(((Object)__instance).name == "[RealHeptaRig (Marrow1)]") && ComponentExtensions.IsPartOfPlayer((Component)(object)__instance) && ComponentExtensions.IsPartOfSelf((Component)(object)__instance))
			{
				if (FusionPlayerExtended.SpeedOverride.HasValue)
				{
					__instance._speed = FusionPlayerExtended.SpeedOverride.Value;
				}
				if (FusionPlayerExtended.JumpPowerOverride.HasValue)
				{
					__instance._strengthLower = FusionPlayerExtended.JumpPowerOverride.Value;
				}
				if (FusionPlayerExtended.AgilityOverride.HasValue)
				{
					__instance._agility = FusionPlayerExtended.AgilityOverride.Value;
				}
				if (FusionPlayerExtended.StrengthUpperOverride.HasValue)
				{
					__instance._strengthUpper = FusionPlayerExtended.StrengthUpperOverride.Value;
					__instance._strengthGrip = FusionPlayerExtended.StrengthUpperOverride.Value;
				}
			}
		}
	}
	public static class GrabPatches
	{
		internal static Dictionary<Grip, float> HoldTime = new Dictionary<Grip, float>();

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Grip), "OnAttachedToHand")]
		public static void Postfix(Grip __instance, Hand hand)
		{
			Grabbed(__instance, hand);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Grip), "OnDetachedFromHand")]
		public static void Postfix2(Grip __instance)
		{
			if (HoldTime.ContainsKey(__instance))
			{
				HoldTime.Remove(__instance);
			}
		}

		private static void Grabbed(Grip grip, Hand hand)
		{
			if (!NetworkInfo.IsServer || Infection.Instance == null || !((Gamemode)Infection.Instance).IsStarted || Infection.InfectType != 0 || !((MetadataVariableT<bool>)(object)Infection.Instance.InfectedLooking).GetValue())
			{
				return;
			}
			RigManager manager = hand.manager;
			object obj;
			if (manager == null)
			{
				obj = null;
			}
			else
			{
				PhysicsRig physicsRig = manager.physicsRig;
				obj = ((physicsRig != null) ? physicsRig.marrowEntity : null);
			}
			MarrowEntity val = (MarrowEntity)obj;
			NetworkPlayer val2 = default(NetworkPlayer);
			NetworkPlayer val3 = default(NetworkPlayer);
			if (!((Object)(object)val == (Object)null) && NetworkPlayerManager.TryGetPlayer(val, ref val2) && Infection.TeamManager.GetPlayerTeam(val2.PlayerId) != Infection.UnInfected && Object.op_Implicit((Object)(object)grip._marrowEntity) && NetworkPlayerManager.TryGetPlayer(grip._marrowEntity, ref val3) && Infection.TeamManager.GetPlayerTeam(val3.PlayerId) == Infection.UnInfected)
			{
				ulong longId = val3.PlayerId.LongId;
				if (Infection.Instance.HoldTime == 0)
				{
					Infection.Instance.InfectEvent.TryInvoke(longId.ToString());
				}
				else
				{
					HoldTime.Add(grip, 0f);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Hand), "AttachObject")]
		[HarmonyPatch(typeof(Hand), "AttachJoint")]
		[HarmonyPatch(typeof(Hand), "AttachIgnoreBodyJoints")]
		[HarmonyPatch(typeof(Hand), "PrepareJoint")]
		[HarmonyPriority(10000)]
		public static bool GrabAttempt(Hand __instance, GameObject objectToAttach)
		{
			return CanGrab(__instance, objectToAttach);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(InventorySlotReceiver), "OnHandHoverBegin")]
		[HarmonyPatch(typeof(InventorySlotReceiver), "OnHandHoverEnd")]
		[HarmonyPriority(10000)]
		public static bool InventoryGrabAttempt(InventorySlotReceiver __instance, Hand hand)
		{
			IGrippable weaponHost = __instance._weaponHost;
			GameObject val = ((weaponHost != null) ? weaponHost.GetHostGameObject() : null);
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			return CanGrab(hand, val);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(InventorySlotReceiver), "OnHandGrab")]
		[HarmonyPriority(10000)]
		public static bool InventoryGrabAttempt2(InventorySlotReceiver __instance, Hand hand)
		{
			IGrippable weaponHost = __instance._weaponHost;
			GameObject val = ((weaponHost != null) ? weaponHost.GetHostGameObject() : null);
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			bool num = CanGrab(hand, val);
			if (!num)
			{
				__instance.DropWeapon();
			}
			return num;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(InteractableIcon), "MyFarHandHoverBegin")]
		[HarmonyPatch(typeof(InteractableIcon), "MyHandHoverBegin")]
		[HarmonyPriority(10000)]
		public static bool IconAttempt(InteractableIcon __instance, Hand hand)
		{
			GameObject gameObject = ((Component)__instance).gameObject;
			if ((Object)(object)gameObject == (Object)null || (Object)(object)hand == (Object)null)
			{
				return true;
			}
			return CanGrab(hand, gameObject);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ForcePullGrip), "CoPull")]
		[HarmonyPatch(typeof(ForcePullGrip), "OnStartAttach")]
		[HarmonyPatch(typeof(ForcePullGrip), "OnFarHandHoverBegin")]
		[HarmonyPatch(typeof(ForcePullGrip), "OnFarHandHoverUpdate")]
		[HarmonyPatch(typeof(ForcePullGrip), "OnFarHandHoverEnd")]
		[HarmonyPatch(typeof(ForcePullGrip), "OnForcePullComplete")]
		[HarmonyPriority(10000)]
		public static bool ForceGrabAttempt(Hand hand, ForcePullGrip __instance)
		{
			GameObject val = ((__instance != null) ? ((Component)__instance).gameObject : null);
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			return CanGrab(hand, val);
		}

		private static bool CanGrab(Hand hand, GameObject gameObject)
		{
			if (!NetworkInfo.HasServer)
			{
				return true;
			}
			if (Infection.Instance == null)
			{
				return true;
			}
			if (!((Gamemode)Infection.Instance).IsStarted)
			{
				return true;
			}
			if ((Object)(object)gameObject == (Object)null || (Object)(object)hand == (Object)null)
			{
				return true;
			}
			if (!ComponentExtensions.IsPartOfPlayer((Component)(object)hand) || !ComponentExtensions.IsPartOfSelf((Component)(object)hand))
			{
				return true;
			}
			TeamMetadata teamMetadata = ((Infection.TeamManager.GetLocalTeam() == Infection.Infected) ? Infection.InfectedMetadata : Infection.UnInfectedMetadata);
			if (teamMetadata == null)
			{
				return true;
			}
			Gun val = gameObject.GetComponent<Gun>() ?? gameObject.GetComponentInParent<Gun>();
			if ((Object)(object)(