Decompiled source of YuMods v1.1.0

plugins/YuMods.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Localization;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace YuMods;

public class BiggerLobbyModule : YuModule
{
	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPatch(typeof(GameManager), "SetMaxPlayers")]
		[HarmonyPrefix]
		private static void SetMaxPlayersPrefix(GameManager __instance, ref int _target)
		{
			if (!_gameCapRead)
			{
				_gameCapRead = true;
				GameCap = __instance.maxPlayersPhoton;
			}
			if (I != null && I.Enabled.Value)
			{
				_target = Math.Min(val2: __instance.maxPlayersPhoton = ServerCap, val1: MaxPlayers.Value);
			}
		}

		[HarmonyPatch(typeof(GameManager), "Awake")]
		[HarmonyPrefix]
		private static void GameManagerAwakePre(GameManager __instance)
		{
			if (!_gameCapRead)
			{
				_gameCapRead = true;
				GameCap = __instance.maxPlayersPhoton;
			}
		}

		[HarmonyPatch(typeof(GameManager), "Awake")]
		[HarmonyPostfix]
		private static void GameManagerAwake(GameManager __instance)
		{
			if ((Object)(object)GameManager.instance == (Object)(object)__instance)
			{
				Apply();
			}
		}

		[HarmonyPatch(typeof(NetworkConnect), "OnConnectedToMaster")]
		[HarmonyPrefix]
		private static void BeforeConnect()
		{
			Apply();
		}

		[HarmonyPatch(typeof(SteamLobbyManager), "HostLobby")]
		[HarmonyPrefix]
		private static void BeforeHostLobby()
		{
			Apply();
		}

		[HarmonyPatch(typeof(NetworkConnect), "OnCreateRoomFailed")]
		[HarmonyPostfix]
		private static void CreateFailed()
		{
			ReadPhotonCap();
		}

		[HarmonyPatch(typeof(NetworkConnect), "OnJoinRoomFailed")]
		[HarmonyPostfix]
		private static void JoinFailed()
		{
			ReadPhotonCap();
		}

		private static void ReadPhotonCap()
		{
			GameManager instance = GameManager.instance;
			if ((Object)(object)instance != (Object)null && instance.maxPlayersPhoton < ServerCap)
			{
				PhotonLimit = instance.maxPlayersPhoton;
				Plugin.Log.LogWarning((object)$"Photon server limits rooms to {PhotonLimit} players. YuMods will cap at that.");
			}
		}
	}

	public const int Vanilla = 6;

	public const int Max = 250;

	public const int KnownServerCap = 20;

	internal static BiggerLobbyModule I;

	internal static ConfigEntry<int> MaxPlayers;

	internal static int GameCap = 20;

	private static bool _gameCapRead;

	internal static int PhotonLimit = -1;

	public override string Id => "BiggerLobby";

	public override string Title => "Bigger Lobby";

	public override bool HostOnly => true;

	public override string Description => "Raises the max player count of lobbies you host (vanilla: 6). Friends join without the mod.";

	public override string Summary => "More players in your lobby.";

	public override string[] Details => new string[5] { "Sets how many players can join lobbies you host (vanilla: 6).", "Friends don't need the mod - only the host.", "Real max right now is 20: R.E.P.O.'s servers refuse bigger rooms. Above 20 you get a warning and it's capped.", "Changes apply instantly, even with the lobby open.", "Switches off other \"more players\" mods so they don't fight." };

	internal static int ServerCap
	{
		get
		{
			int val = Math.Max(20, GameCap);
			if (PhotonLimit > 0)
			{
				val = Math.Min(val, PhotonLimit);
			}
			return Math.Min(val, 250);
		}
	}

	internal static int Wanted
	{
		get
		{
			if (I == null || !I.Enabled.Value)
			{
				return 6;
			}
			return MaxPlayers.Value;
		}
	}

	internal static int Effective => Math.Min(Wanted, ServerCap);

	public override string Status
	{
		get
		{
			GameManager instance = GameManager.instance;
			string text = "Set: " + MaxPlayers.Value + "   Active: " + (((Object)(object)instance != (Object)null) ? instance.maxPlayers.ToString() : "?");
			if (PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null)
			{
				text += $"   Room: {PhotonNetwork.CurrentRoom.PlayerCount}/{PhotonNetwork.CurrentRoom.MaxPlayers}";
			}
			return text;
		}
	}

	protected override void Setup()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		I = this;
		MaxPlayers = base.Config.Bind<int>(Id, "MaxPlayers", 20, new ConfigDescription("Max players in lobbies you host. Above 20 is capped by R.E.P.O.'s Photon servers.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 250), Array.Empty<object>()));
		MaxPlayers.SettingChanged += delegate
		{
			Apply();
		};
		Plugin.Harmony.PatchAll(typeof(Patches));
	}

	protected override void OnToggled(bool on)
	{
		if (on)
		{
			ConflictGuard.Run();
		}
		Apply();
	}

	internal static void Apply()
	{
		GameManager instance = GameManager.instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		try
		{
			instance.SetMaxPlayers(Wanted);
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("BiggerLobby apply failed: " + ex.Message));
		}
	}

	private void SetFromMenu(int value)
	{
		value = Mathf.Clamp(value, 1, 250);
		if (value != MaxPlayers.Value)
		{
			bool flag = MaxPlayers.Value > ServerCap;
			MaxPlayers.Value = value;
			if (value > ServerCap && !flag)
			{
				ShowCapWarning();
			}
		}
	}

	internal static void ShowCapWarning()
	{
		int serverCap = ServerCap;
		YuMenu.ShowWarning($"MORE THAN {serverCap} PLAYERS WON'T WORK (YET)", $"R.E.P.O. multiplayer runs on Photon servers, and the game's Photon app only allows {serverCap} players per room. " + "That limit lives on Photon's servers, not in the game, so no mod can get around it.\n\n" + $"Your lobby will be capped at {serverCap} players.\n\n" + $"More than {serverCap} players can only work if:\n" + "  - semiwork (the R.E.P.O. devs) raise the room limit of the game's Photon app, or\n  - the game adds support for your own / dedicated servers.\n\nWant bigger lobbies? Tell the devs! YuMods already supports up to 250 and will use it the moment they allow it.");
	}

	public override void BuildSettings(YuSettings s)
	{
		s.Slider("Max players", () => MaxPlayers.Value, delegate(float v)
		{
			SetFromMenu(Mathf.RoundToInt(v));
		}, 1f, 250f, 1f, (float v) => Mathf.RoundToInt(v).ToString());
		int[] presets = new int[9] { 6, 8, 10, 12, 16, 20, 50, 100, 250 };
		s.Buttons(Array.ConvertAll(presets, (int p) => p.ToString()), delegate(int i)
		{
			SetFromMenu(presets[i]);
		}, 52f);
		s.Buttons(new string[4] { "-10", "-1", "+1", "+10" }, delegate(int i)
		{
			SetFromMenu(MaxPlayers.Value + (new int[4] { -10, -1, 1, 10 })[i]);
		}, 64f);
		s.Note(() => (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient) ? null : "<color=#ffb347>You are not the host - only the host's setting counts.</color>");
		s.Note(() => (MaxPlayers.Value <= ServerCap) ? null : $"<color=#ff5555>Capped at {ServerCap} by R.E.P.O.'s Photon servers.</color>");
		s.Note(() => (ConflictGuard.TakenOver.Count <= 0) ? null : ("<color=#99aadd>Took over from: " + string.Join(", ", ConflictGuard.TakenOver) + "</color>"), 14f);
		s.Note(() => "Applies instantly, even in an open lobby.", 14f);
	}
}
public class CompassModule : YuModule
{
	private enum Kind
	{
		Enemy,
		Ally,
		DeadHead,
		Extraction,
		Truck
	}

	private struct Blip
	{
		public Kind kind;

		public Vector3 pos;

		public bool done;

		public bool active;
	}

	internal static CompassModule I;

	internal static ConfigEntry<int> Range;

	internal static ConfigEntry<float> Size;

	internal static ConfigEntry<int> Lift;

	internal static ConfigEntry<bool> ShowEnemies;

	internal static ConfigEntry<bool> ShowAllies;

	internal static ConfigEntry<bool> ShowDeadHeads;

	internal static ConfigEntry<bool> ShowExtractions;

	internal static ConfigEntry<bool> ShowTruck;

	private static readonly List<EnemyParent> Enemies = new List<EnemyParent>();

	private static readonly List<ExtractionPoint> Extractions = new List<ExtractionPoint>();

	private static Transform _truck;

	private static float _scanAt;

	private static readonly List<Blip> Blips = new List<Blip>();

	private static Texture2D _disk;

	private static Texture2D _dot;

	private static Texture2D _ring;

	private static readonly Color Red = new Color(1f, 0.25f, 0.25f);

	private static readonly Color Blue = new Color(0.3f, 0.65f, 1f);

	private static readonly Color Green = new Color(0.3f, 1f, 0.42f);

	private static TextMeshProUGUI[] _letters;

	private static readonly List<TextMeshProUGUI> _arrows = new List<TextMeshProUGUI>();

	private static readonly List<Vector3> _arrowPos = new List<Vector3>();

	private static readonly List<Color> _arrowCol = new List<Color>();

	public override string Id => "Compass";

	public override string Title => "Compass Radar";

	public override bool HostOnly => false;

	protected override bool EnabledByDefault => false;

	public override string Description => "Half-compass at the bottom of the screen showing what's in front of you: monsters (red), teammates (blue), dead teammates' heads (grey), extraction points (green), truck (blinking green).";

	public override string Summary => "A mini radar of what's in front of you.";

	public override string[] Details => new string[5] { "Half-compass at the bottom of the screen, like holding a compass in your hand.", "Red = monsters, blue = teammates, grey = dead teammates' heads, blinking green ring + dot = the truck.", "Extraction points: solid green = not opened yet, blinking green ring = opened, dim ring = finished.", "^ / v next to a dot = it's on a floor above / below you.", "Things further than \"Range\" sit on the rim." };

	protected override void Setup()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Expected O, but got Unknown
		I = this;
		Range = base.Config.Bind<int>(Id, "Range", 40, new ConfigDescription("How far the compass sees (meters). Things further away sit on the rim.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 150), Array.Empty<object>()));
		Lift = base.Config.Bind<int>(Id, "HeightFromBottom", 130, new ConfigDescription("How high above the bottom of the screen the compass sits (so it doesn't cover your inventory).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 700), Array.Empty<object>()));
		Size = base.Config.Bind<float>(Id, "Size", 1f, new ConfigDescription("Compass size multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
		ShowEnemies = base.Config.Bind<bool>(Id, "ShowMonsters", true, "Show monsters (red).");
		ShowAllies = base.Config.Bind<bool>(Id, "ShowTeammates", true, "Show teammates (blue).");
		ShowDeadHeads = base.Config.Bind<bool>(Id, "ShowDeadHeads", true, "Show dead teammates' heads (grey), so you can find and revive them.");
		ShowExtractions = base.Config.Bind<bool>(Id, "ShowExtractionPoints", true, "Show extraction points (green).");
		ShowTruck = base.Config.Bind<bool>(Id, "ShowTruck", true, "Show the truck (blinking green).");
	}

	public override void BuildSettings(YuSettings s)
	{
		s.Toggle("<color=#ff4a4a>Monsters</color>", ShowEnemies);
		s.Toggle("<color=#4aa8ff>Teammates</color>", ShowAllies);
		s.Toggle("<color=#b0b0b0>Dead teammates' heads</color>", ShowDeadHeads);
		s.Toggle("<color=#4aff6a>Extraction points</color>", ShowExtractions);
		s.Toggle("<color=#4aff6a>Truck (blinking)</color>", ShowTruck);
		s.Slider("Range", () => Range.Value, delegate(float v)
		{
			Range.Value = Mathf.RoundToInt(v);
		}, 10f, 150f, 5f, (float v) => Mathf.RoundToInt(v) + " m");
		s.Slider("Size", () => Size.Value, delegate(float v)
		{
			Size.Value = v;
		}, 0.5f, 2f, 0.1f, (float v) => v.ToString("0.0") + "x");
		s.Slider("Height from bottom", () => Lift.Value, delegate(float v)
		{
			Lift.Value = Mathf.RoundToInt(v);
		}, 0f, 700f, 10f, (float v) => Mathf.RoundToInt(v).ToString());
	}

	private static bool ShouldShow()
	{
		if (I == null || !I.Enabled.Value)
		{
			return false;
		}
		if ((Object)(object)GameManager.instance == (Object)null || (Object)(object)Camera.main == (Object)null)
		{
			return false;
		}
		try
		{
			if (SemiFunc.MenuLevel() || SemiFunc.RunIsLobby())
			{
				return false;
			}
		}
		catch
		{
			return false;
		}
		return true;
	}

	private static void Scan()
	{
		if (!(Time.unscaledTime < _scanAt))
		{
			_scanAt = Time.unscaledTime + 0.5f;
			Enemies.Clear();
			Enemies.AddRange(Object.FindObjectsOfType<EnemyParent>());
			Extractions.Clear();
			Extractions.AddRange(Object.FindObjectsOfType<ExtractionPoint>());
			_truck = null;
			TruckDoor val = Object.FindObjectOfType<TruckDoor>();
			if ((Object)(object)val != (Object)null)
			{
				_truck = ((Component)val).transform;
			}
			else if ((Object)(object)LevelGenerator.Instance != (Object)null && (Object)(object)LevelGenerator.Instance.LevelPathTruck != (Object)null)
			{
				_truck = ((Component)LevelGenerator.Instance.LevelPathTruck).transform;
			}
		}
	}

	private static void Collect()
	{
		//IL_0336: Unknown result type (might be due to invalid IL or missing references)
		//IL_033b: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: 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_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Invalid comparison between Unknown and I4
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: 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_027e: Invalid comparison between Unknown and I4
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Invalid comparison between Unknown and I4
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Invalid comparison between Unknown and I4
		//IL_00a2: 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_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Invalid comparison between Unknown and I4
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		Blips.Clear();
		if (ShowEnemies.Value)
		{
			foreach (EnemyParent enemy in Enemies)
			{
				if (!((Object)(object)enemy == (Object)null) && !((Object)(object)enemy.EnableObject == (Object)null) && enemy.EnableObject.activeInHierarchy && G.Spawned(enemy))
				{
					Enemy val = G.Enemy(enemy);
					if (!((Object)(object)val == (Object)null))
					{
						Transform val2 = (((Object)(object)val.CenterTransform != (Object)null) ? val.CenterTransform : ((Component)val).transform);
						Blips.Add(new Blip
						{
							kind = Kind.Enemy,
							pos = val2.position
						});
					}
				}
			}
		}
		if (ShowAllies.Value && (Object)(object)GameDirector.instance != (Object)null)
		{
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (!((Object)(object)player == (Object)null) && !G.Local(player) && !G.Dead(player))
				{
					Blips.Add(new Blip
					{
						kind = Kind.Ally,
						pos = ((Component)player).transform.position
					});
				}
			}
		}
		if (ShowDeadHeads.Value && (Object)(object)GameDirector.instance != (Object)null)
		{
			foreach (PlayerAvatar player2 in GameDirector.instance.PlayerList)
			{
				if (!((Object)(object)player2 == (Object)null) && !G.Local(player2) && G.Dead(player2))
				{
					PlayerDeathHead val3 = G.Head(player2);
					if (!((Object)(object)val3 == (Object)null) && ((Component)val3).gameObject.activeInHierarchy)
					{
						Blips.Add(new Blip
						{
							kind = Kind.DeadHead,
							pos = ((Component)val3).transform.position
						});
					}
				}
			}
		}
		if (ShowExtractions.Value)
		{
			foreach (ExtractionPoint extraction in Extractions)
			{
				if (!((Object)(object)extraction == (Object)null) && ((Behaviour)extraction).isActiveAndEnabled)
				{
					State val4 = G.State(extraction);
					bool flag = (int)val4 == 7 || (int)val4 == 8 || (int)val4 == 9;
					bool flag2 = (int)val4 == 1 || (int)val4 == 0;
					Blips.Add(new Blip
					{
						kind = Kind.Extraction,
						pos = ((Component)extraction).transform.position,
						done = flag,
						active = (!flag && !flag2)
					});
				}
			}
		}
		if (ShowTruck.Value && (Object)(object)_truck != (Object)null)
		{
			Blips.Add(new Blip
			{
				kind = Kind.Truck,
				pos = _truck.position
			});
		}
	}

	private static Texture2D MakeDisk(int w, int h)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(w, h, (TextureFormat)4, false)
		{
			hideFlags = (HideFlags)61,
			wrapMode = (TextureWrapMode)1
		};
		float num = (float)w / 2f;
		float num2 = h;
		Color32[] array = (Color32[])(object)new Color32[w * h];
		Color val2 = default(Color);
		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				float num3 = ((float)j + 0.5f - num) / num;
				float num4 = ((float)i + 0.5f) / num2;
				float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4);
				((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
				if (num5 <= 1f)
				{
					((Color)(ref val2))..ctor(0.05f, 0.05f, 0.08f, 0.55f * Mathf.Clamp01(0.4f + num5));
					if (Mathf.Abs(num5 - 0.5f) < 0.006f)
					{
						((Color)(ref val2))..ctor(1f, 0.55f, 0.1f, 0.35f);
					}
					if (Mathf.Abs(Mathf.Abs(Mathf.Atan2(num3, num4) * 57.29578f) - 45f) < 0.4f && num5 > 0.08f)
					{
						((Color)(ref val2))..ctor(1f, 0.55f, 0.1f, 0.2f);
					}
					if (num5 > 0.975f)
					{
						((Color)(ref val2))..ctor(1f, 0.55f, 0.1f, 0.95f);
					}
				}
				array[i * w + j] = Color32.op_Implicit(val2);
			}
		}
		val.SetPixels32(array);
		val.Apply();
		return val;
	}

	private static Texture2D MakeDot(int s, bool ring)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//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_0086: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(s, s, (TextureFormat)4, false)
		{
			hideFlags = (HideFlags)61
		};
		float num = (float)s / 2f;
		for (int i = 0; i < s; i++)
		{
			for (int j = 0; j < s; j++)
			{
				float num2 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num)) / num;
				float num3 = ((!ring) ? Mathf.Clamp01((1f - num2) * 4f) : ((num2 <= 1f && num2 >= 0.6f) ? 1f : 0f));
				Color white = Color.white;
				if (!ring && num2 > 0.75f && num2 <= 1f)
				{
					((Color)(ref white))..ctor(0f, 0f, 0f, 1f);
				}
				val.SetPixel(j, i, new Color(white.r, white.g, white.b, num3));
			}
		}
		val.Apply();
		return val;
	}

	private static void Geometry(out float scale, out float a, out float b, out float cx, out float by)
	{
		scale = (float)Screen.height / 1080f * Size.Value;
		a = 230f * scale;
		b = 90f * scale;
		cx = (float)Screen.width / 2f;
		by = (float)Screen.height - (6f + (float)Lift.Value) * ((float)Screen.height / 1080f);
	}

	internal static void UpdateLetters()
	{
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Unknown result type (might be due to invalid IL or missing references)
		//IL_0389: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03df: Unknown result type (might be due to invalid IL or missing references)
		if (!ShouldShow())
		{
			if (_letters != null)
			{
				TextMeshProUGUI[] letters = _letters;
				foreach (TextMeshProUGUI val in letters)
				{
					if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf)
					{
						((Component)val).gameObject.SetActive(false);
					}
				}
			}
			{
				foreach (TextMeshProUGUI arrow in _arrows)
				{
					if ((Object)(object)arrow != (Object)null && ((Component)arrow).gameObject.activeSelf)
					{
						((Component)arrow).gameObject.SetActive(false);
					}
				}
				return;
			}
		}
		if (!YuUi.Ensure())
		{
			return;
		}
		if (_letters == null || (Object)(object)_letters[0] == (Object)null)
		{
			_letters = (TextMeshProUGUI[])(object)new TextMeshProUGUI[4];
			string[] array = new string[4] { "N", "E", "S", "W" };
			for (int j = 0; j < 4; j++)
			{
				TextMeshProUGUI val2 = YuUi.Text((Transform)(object)YuUi.Root, array[j], 22f, (Color)((j == 0) ? YuUi.Orange : new Color(1f, 1f, 1f, 0.8f)), (TextAlignmentOptions)514);
				((TMP_Text)val2).fontStyle = (FontStyles)1;
				((TMP_Text)val2).rectTransform.sizeDelta = new Vector2(40f, 30f);
				((TMP_Text)val2).transform.SetAsFirstSibling();
				_letters[j] = val2;
			}
		}
		Geometry(out var _, out var a, out var b, out var cx, out var by);
		float y = ((Component)Camera.main).transform.eulerAngles.y;
		for (int k = 0; k < 4; k++)
		{
			float num = Mathf.DeltaAngle(y, (float)k * 90f);
			bool flag = Mathf.Abs(num) <= 85f;
			TextMeshProUGUI val3 = _letters[k];
			if (((Component)val3).gameObject.activeSelf != flag)
			{
				((Component)val3).gameObject.SetActive(flag);
			}
			if (flag)
			{
				float num2 = num * ((float)Math.PI / 180f);
				float num3 = cx + Mathf.Sin(num2) * a * 1.07f;
				float num4 = by - Mathf.Cos(num2) * b * 1.15f;
				((Transform)((TMP_Text)val3).rectTransform).position = new Vector3(num3, (float)Screen.height - num4, 0f);
				((TMP_Text)val3).fontSize = 22f * Size.Value;
			}
		}
		while (_arrows.Count < _arrowPos.Count)
		{
			TextMeshProUGUI val4 = YuUi.Text((Transform)(object)YuUi.Root, "", 16f, Color.white, (TextAlignmentOptions)514);
			((TMP_Text)val4).rectTransform.sizeDelta = new Vector2(24f, 24f);
			((TMP_Text)val4).transform.SetAsFirstSibling();
			_arrows.Add(val4);
		}
		for (int l = 0; l < _arrows.Count; l++)
		{
			bool flag2 = l < _arrowPos.Count;
			if (((Component)_arrows[l]).gameObject.activeSelf != flag2)
			{
				((Component)_arrows[l]).gameObject.SetActive(flag2);
			}
			if (flag2)
			{
				Vector3 val5 = _arrowPos[l];
				((TMP_Text)_arrows[l]).text = ((val5.z > 0f) ? "^" : "v");
				((Graphic)_arrows[l]).color = _arrowCol[l];
				((TMP_Text)_arrows[l]).fontSize = 16f * Size.Value;
				((Transform)((TMP_Text)_arrows[l]).rectTransform).position = new Vector3(val5.x, (float)Screen.height - val5.y, 0f);
			}
		}
	}

	internal static void Draw()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Invalid comparison between Unknown and I4
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: 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_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_01b9: 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_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: 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_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: 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_039d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f8: 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_03e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0423: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Unknown result type (might be due to invalid IL or missing references)
		//IL_0451: Unknown result type (might be due to invalid IL or missing references)
		//IL_0460: Unknown result type (might be due to invalid IL or missing references)
		if (!ShouldShow() || (int)Event.current.type != 7)
		{
			return;
		}
		Scan();
		Collect();
		if ((Object)(object)_disk == (Object)null)
		{
			_disk = MakeDisk(512, 200);
			_dot = MakeDot(32, ring: false);
			_ring = MakeDot(32, ring: true);
		}
		Geometry(out var scale, out var a, out var b, out var cx, out var by);
		GUI.DrawTexture(new Rect(cx - a, by - b, a * 2f, b), (Texture)(object)_disk);
		Transform transform = ((Component)Camera.main).transform;
		float y = transform.eulerAngles.y;
		Quaternion val = Quaternion.Euler(0f, 0f - y, 0f);
		Vector3 position = transform.position;
		Color color = GUI.color;
		GUI.color = new Color(1f, 0.55f, 0.1f, 0.85f);
		GUI.DrawTexture(new Rect(cx - 1.5f * scale, by - b * 0.9f, 3f * scale, b * 0.9f), (Texture)(object)Texture2D.whiteTexture);
		GUI.color = color;
		DrawDot(new Vector2(cx, by - 3f * scale), 11f * scale, Color.white, _dot);
		_arrowPos.Clear();
		_arrowCol.Clear();
		float num = Range.Value;
		float num2 = 0.3f + 0.7f * Mathf.Abs(Mathf.Sin(Time.unscaledTime * 4f));
		Vector2 val3 = default(Vector2);
		Color val4 = default(Color);
		foreach (Blip blip in Blips)
		{
			Vector3 val2 = val * (blip.pos - position);
			val2.y = 0f;
			if (val2.z < -0.5f)
			{
				continue;
			}
			float magnitude = ((Vector3)(ref val2)).magnitude;
			float num3 = Mathf.Min(magnitude / num, 1f);
			float num4 = Mathf.Atan2(val2.x, val2.z);
			((Vector2)(ref val3))..ctor(cx + Mathf.Sin(num4) * num3 * a * 0.97f, by - Mathf.Cos(num4) * num3 * b * 0.95f);
			float num5 = ((magnitude > num) ? 8f : 12f) * scale;
			switch (blip.kind)
			{
			case Kind.Enemy:
				val4 = Red;
				num5 *= 1.1f;
				break;
			case Kind.Ally:
				val4 = Blue;
				break;
			case Kind.DeadHead:
				((Color)(ref val4))..ctor(0.72f, 0.72f, 0.72f, 0.95f);
				break;
			case Kind.Truck:
				((Color)(ref val4))..ctor(Green.r, Green.g, Green.b, num2);
				num5 *= 1.4f;
				break;
			default:
				if (blip.done)
				{
					((Color)(ref val4))..ctor(0.2f, 0.55f, 0.28f, 0.45f);
				}
				else if (blip.active)
				{
					((Color)(ref val4))..ctor(Green.r, Green.g, Green.b, 0.25f + 0.75f * Mathf.Abs(Mathf.Sin(Time.unscaledTime * 6f)));
				}
				else
				{
					val4 = Green;
				}
				num5 *= 1.15f;
				break;
			}
			if (magnitude > num)
			{
				val4.a *= 0.6f;
			}
			bool flag = blip.kind == Kind.Extraction && !blip.done && !blip.active;
			DrawDot(val3, num5, val4, ((blip.kind == Kind.Extraction && !flag) || blip.kind == Kind.Truck) ? _ring : _dot);
			if (blip.kind == Kind.Truck)
			{
				DrawDot(val3, num5 * 0.45f, val4, _dot);
			}
			float num6 = blip.pos.y - position.y;
			if (Mathf.Abs(num6) > 2.5f && _arrowPos.Count < 24)
			{
				_arrowPos.Add(new Vector3(val3.x + num5 * 0.7f, val3.y - num5 * 0.5f, (float)((num6 > 0f) ? 1 : (-1))));
				_arrowCol.Add(val4);
			}
		}
	}

	private static void DrawDot(Vector2 p, float size, Color c, Texture2D tex)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		Color color = GUI.color;
		GUI.color = c;
		GUI.DrawTexture(new Rect(p.x - size / 2f, p.y - size / 2f, size, size), (Texture)(object)tex);
		GUI.color = color;
	}
}
internal static class ConflictGuard
{
	private static readonly string[] LimitOnlyMods = new string[3] { "ozoka.moreplayers", "zelofi.MorePlayers", "dyxc666.MorePlayersSimple" };

	private static readonly string[][] LimitSwitches = new string[1][] { new string[3] { "ricketywrecked.repo.latejoinplus", "Players", "MaxPlayersEnabled" } };

	internal static readonly List<string> TakenOver = new List<string>();

	private static readonly HashSet<string> Stripped = new HashSet<string>();

	internal static void Run()
	{
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Expected O, but got Unknown
		RunDeadPlayers();
		if (BiggerLobbyModule.I == null || !BiggerLobbyModule.I.Enabled.Value)
		{
			return;
		}
		string[] limitOnlyMods = LimitOnlyMods;
		foreach (string text in limitOnlyMods)
		{
			if (!Stripped.Contains(text) && Chainloader.PluginInfos.TryGetValue(text, out var value) && !((Object)(object)value.Instance == (Object)null))
			{
				int num = UnpatchAssembly(((object)value.Instance).GetType().Assembly);
				Stripped.Add(text);
				Note($"{value.Metadata.Name} ({num} patches off)");
			}
		}
		string[][] limitSwitches = LimitSwitches;
		ConfigEntry<bool> val = default(ConfigEntry<bool>);
		foreach (string[] array in limitSwitches)
		{
			if (!Chainloader.PluginInfos.TryGetValue(array[0], out var value2) || (Object)(object)value2.Instance == (Object)null)
			{
				continue;
			}
			try
			{
				if (value2.Instance.Config.TryGetEntry<bool>(new ConfigDefinition(array[1], array[2]), ref val) && val.Value)
				{
					val.Value = false;
					Note(value2.Metadata.Name + " (its Max Players switched off)");
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not switch off " + array[0] + " player limit: " + ex.Message));
			}
		}
		BiggerLobbyModule.Apply();
	}

	private static void RunDeadPlayers()
	{
		if (DeadPlayersModule.I == null || !DeadPlayersModule.I.Enabled.Value || Stripped.Contains("Hypn.ListDeadPlayers") || !Chainloader.PluginInfos.TryGetValue("Hypn.ListDeadPlayers", out var value) || (Object)(object)value.Instance == (Object)null)
		{
			return;
		}
		int num = UnpatchAssembly(((object)value.Instance).GetType().Assembly);
		try
		{
			object? obj = AccessTools.Field(((object)value.Instance).GetType(), "screenLabel")?.GetValue(value.Instance);
			GameObject val = (GameObject)((obj is GameObject) ? obj : null);
			if (val != null && (Object)(object)val != (Object)null)
			{
				val.SetActive(false);
			}
		}
		catch
		{
		}
		Stripped.Add("Hypn.ListDeadPlayers");
		Plugin.Log.LogInfo((object)$"Dead Players List took over from {value.Metadata.Name} ({num} patches off).");
	}

	private static void Note(string what)
	{
		if (!TakenOver.Contains(what))
		{
			TakenOver.Add(what);
		}
		Plugin.Log.LogInfo((object)("Bigger Lobby took over the player limit from: " + what));
	}

	private static int UnpatchAssembly(Assembly asm)
	{
		int num = 0;
		foreach (MethodBase item in Harmony.GetAllPatchedMethods().ToList())
		{
			Patches patchInfo = Harmony.GetPatchInfo(item);
			if (patchInfo == null)
			{
				continue;
			}
			foreach (Patch item2 in patchInfo.Prefixes.Concat(patchInfo.Postfixes).Concat(patchInfo.Transpilers).Concat(patchInfo.Finalizers)
				.ToList())
			{
				if (item2.PatchMethod?.DeclaringType?.Assembly == asm)
				{
					Plugin.Harmony.Unpatch(item, item2.PatchMethod);
					num++;
				}
			}
		}
		return num;
	}
}
public class CustomLevelsModule : YuModule
{
	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPatch(typeof(LevelGenerator), "Start")]
		[HarmonyPrefix]
		private static void BeforeGenerate()
		{
			try
			{
				if ((Object)(object)RunManager.instance != (Object)null)
				{
					Complete(RunManager.instance.levelCurrent);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Yu level setup: " + ex.Message));
			}
		}

		[HarmonyPatch(typeof(RunManager), "SetRunLevel")]
		[HarmonyPostfix]
		private static void AfterPick(RunManager __instance)
		{
			if (I != null && I.Enabled.Value && I.Force.Value && SemiFunc.IsMasterClientOrSingleplayer())
			{
				List<Level> list = __instance.levels.Where(IsYu).ToList();
				if (list.Count != 0)
				{
					__instance.levelCurrent = list[Random.Range(0, list.Count)];
					Plugin.Log.LogInfo((object)("Forced Yu level: " + ((Object)__instance.levelCurrent).name));
				}
			}
		}
	}

	internal static CustomLevelsModule I;

	internal ConfigEntry<bool> Force;

	internal const string Prefix = "Level - Yu";

	public override string Id => "CustomLevels";

	public override string Title => "Yu Levels";

	public override bool HostOnly => true;

	public override YuCategory Category => YuCategory.Big;

	protected override bool EnabledByDefault => true;

	public override string Description => "Support for YuMods custom maps (like the Japan test level). Host can force the next level to be a Yu map.";

	public override string Summary => "Custom YuMods maps + force them for testing.";

	public override string[] Details => new string[3] { "Needs a Yu map pack installed (everyone in the lobby needs it too).", "Force Yu map: every new level will be a Yu map instead of a random one.", "Missing parts (truck room, doors, extraction rooms, music) are taken from a normal level." };

	public override string Status
	{
		get
		{
			RunManager instance = RunManager.instance;
			if ((Object)(object)instance == (Object)null || instance.levels == null)
			{
				return null;
			}
			int num = instance.levels.Count((Level l) => (Object)(object)l != (Object)null && ((Object)l).name.StartsWith("Level - Yu"));
			if (num != 0)
			{
				return num + " Yu map(s) installed";
			}
			return "No Yu maps installed";
		}
	}

	protected override void Setup()
	{
		I = this;
		Force = base.Config.Bind<bool>(Id, "ForceYuLevel", false, "Host: every new level is a Yu map.");
		Plugin.Harmony.PatchAll(typeof(Patches));
	}

	public override void BuildSettings(YuSettings s)
	{
		s.Toggle("Force Yu map on every new level (host)", Force);
	}

	internal static bool IsYu(Level l)
	{
		if ((Object)(object)l != (Object)null)
		{
			return ((Object)l).name.StartsWith("Level - Yu");
		}
		return false;
	}

	private static Level Donor(Level self)
	{
		List<Level> levels = RunManager.instance.levels;
		Level val = ((IEnumerable<Level>)levels).FirstOrDefault((Func<Level, bool>)((Level l) => (Object)(object)l != (Object)null && ((Object)l).name.Contains("Manor")));
		if ((Object)(object)val == (Object)null || val.StartRooms == null || val.StartRooms.Count == 0)
		{
			val = ((IEnumerable<Level>)levels).FirstOrDefault((Func<Level, bool>)((Level l) => (Object)(object)l != (Object)null && (Object)(object)l != (Object)(object)self && !IsYu(l) && l.StartRooms != null && l.StartRooms.Count > 0 && l.ModulesExtraction1 != null && l.ModulesExtraction1.Count > 0));
		}
		return val;
	}

	private static bool Empty<T>(List<T> l)
	{
		if (l != null)
		{
			return l.Count == 0;
		}
		return true;
	}

	internal static void Complete(Level l)
	{
		if (!IsYu(l))
		{
			return;
		}
		Level val = Donor(l);
		if ((Object)(object)val == (Object)null)
		{
			Plugin.Log.LogWarning((object)"Yu level: no vanilla level to borrow from");
			return;
		}
		if (Empty(l.StartRooms))
		{
			l.StartRooms = val.StartRooms;
		}
		if (l.ConnectObject == null || !((PrefabRef<GameObject>)(object)l.ConnectObject).IsValid())
		{
			l.ConnectObject = val.ConnectObject;
		}
		if (l.BlockObject == null || !((PrefabRef<GameObject>)(object)l.BlockObject).IsValid())
		{
			l.BlockObject = val.BlockObject;
		}
		if (Empty(l.ModulesExtraction1))
		{
			l.ModulesExtraction1 = val.ModulesExtraction1;
		}
		if (Empty(l.ModulesExtraction2))
		{
			l.ModulesExtraction2 = val.ModulesExtraction2;
		}
		if (Empty(l.ModulesExtraction3))
		{
			l.ModulesExtraction3 = val.ModulesExtraction3;
		}
		if (Empty(l.ModulesDeadEnd1))
		{
			l.ModulesDeadEnd1 = val.ModulesDeadEnd1;
		}
		if (Empty(l.ModulesDeadEnd2))
		{
			l.ModulesDeadEnd2 = val.ModulesDeadEnd2;
		}
		if (Empty(l.ModulesDeadEnd3))
		{
			l.ModulesDeadEnd3 = val.ModulesDeadEnd3;
		}
		if (Empty(l.ModulesPassage1))
		{
			l.ModulesPassage1 = val.ModulesPassage1;
		}
		if (Empty(l.ModulesPassage2))
		{
			l.ModulesPassage2 = val.ModulesPassage2;
		}
		if (Empty(l.ModulesPassage3))
		{
			l.ModulesPassage3 = val.ModulesPassage3;
		}
		if ((Object)(object)l.MusicPreset == (Object)null)
		{
			l.MusicPreset = val.MusicPreset;
		}
		if ((Object)(object)l.ConstantMusicPreset == (Object)null)
		{
			l.ConstantMusicPreset = val.ConstantMusicPreset;
		}
		if (Empty(l.AmbiencePresets))
		{
			l.AmbiencePresets = val.AmbiencePresets;
		}
		if (Empty(l.ValuablePresets))
		{
			l.ValuablePresets = val.ValuablePresets;
		}
		Plugin.Log.LogInfo((object)("Yu level '" + ((Object)l).name + "' completed with parts from '" + ((Object)val).name + "'"));
	}
}
public class DeadPlayersModule : YuModule
{
	internal static DeadPlayersModule I;

	internal static ConfigEntry<bool> LeaveNotices;

	internal static ConfigEntry<float> TextSize;

	private static TextMeshProUGUI _label;

	private static float _tickAt;

	private static readonly Dictionary<int, string> RoomPlayers = new Dictionary<int, string>();

	private static readonly List<KeyValuePair<string, float>> Notices = new List<KeyValuePair<string, float>>();

	private static readonly List<string> Dead = new List<string>();

	private static int _alive;

	private static int _total;

	private const float NoticeTime = 7f;

	public override string Id => "DeadPlayers";

	public override string Title => "Dead Players List";

	public override bool HostOnly => false;

	protected override bool EnabledByDefault => false;

	public override string Description => "Bottom-right list of who is dead. Players who leave aren't counted as dead: you get a \"left the lobby\" notice instead.";

	public override string Summary => "See who is dead.";

	public override string[] Details => new string[3] { "Bottom-right list of dead teammates with \"Dead: X/Y\".", "Players who LEAVE aren't counted as dead - you get a \"[name] left the lobby\" notice instead.", "Replaces the ListDeadPlayers mod if you have it." };

	public override string Status
	{
		get
		{
			if (!base.Enabled.Value || _total <= 0)
			{
				return null;
			}
			return $"Alive: {_alive}/{_total}";
		}
	}

	protected override void Setup()
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Expected O, but got Unknown
		I = this;
		LeaveNotices = base.Config.Bind<bool>(Id, "LeaveNotices", true, "Show \"<name> left the lobby\" when someone leaves.");
		TextSize = base.Config.Bind<float>(Id, "TextSize", 22f, new ConfigDescription("Text size.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(14f, 36f), Array.Empty<object>()));
	}

	protected override void OnToggled(bool on)
	{
		if (on)
		{
			ConflictGuard.Run();
		}
		else if ((Object)(object)_label != (Object)null)
		{
			((Component)_label).gameObject.SetActive(false);
		}
	}

	public override void BuildSettings(YuSettings s)
	{
		s.Toggle("\"Left the lobby\" notices", LeaveNotices);
		s.Slider("Text size", () => TextSize.Value, delegate(float v)
		{
			TextSize.Value = v;
		}, 14f, 36f, 1f, (float v) => Mathf.RoundToInt(v).ToString());
		s.Button("Test notice", delegate
		{
			Notices.Add(new KeyValuePair<string, float>("Test player", Time.unscaledTime));
		});
	}

	internal static void Tick()
	{
		if (I == null || !I.Enabled.Value)
		{
			return;
		}
		if (!((Object)(object)GameDirector.instance != (Object)null) || !((Object)(object)HUDCanvas.instance != (Object)null) || SafeMenuLevel())
		{
			if ((Object)(object)_label != (Object)null)
			{
				((Component)_label).gameObject.SetActive(false);
			}
			RoomPlayers.Clear();
		}
		else if (EnsureLabel())
		{
			if (Time.unscaledTime >= _tickAt)
			{
				_tickAt = Time.unscaledTime + 0.25f;
				CheckRoster();
				CheckDead();
			}
			Notices.RemoveAll((KeyValuePair<string, float> n) => Time.unscaledTime - n.Value > 7f);
			Render();
		}
	}

	private static bool SafeMenuLevel()
	{
		try
		{
			return SemiFunc.MenuLevel();
		}
		catch
		{
			return true;
		}
	}

	private static void CheckRoster()
	{
		if (!PhotonNetwork.InRoom || PhotonNetwork.CurrentRoom == null)
		{
			RoomPlayers.Clear();
			return;
		}
		Dictionary<int, string> dictionary = new Dictionary<int, string>();
		Player[] playerList = PhotonNetwork.PlayerList;
		foreach (Player val in playerList)
		{
			dictionary[val.ActorNumber] = (string.IsNullOrEmpty(val.NickName) ? ("Player " + val.ActorNumber) : val.NickName);
		}
		if (RoomPlayers.Count > 0 && LeaveNotices.Value)
		{
			foreach (KeyValuePair<int, string> roomPlayer in RoomPlayers)
			{
				if (!dictionary.ContainsKey(roomPlayer.Key))
				{
					Notices.Add(new KeyValuePair<string, float>(roomPlayer.Value, Time.unscaledTime));
					Plugin.Log.LogInfo((object)(roomPlayer.Value + " left the lobby."));
				}
			}
		}
		RoomPlayers.Clear();
		foreach (KeyValuePair<int, string> item in dictionary)
		{
			RoomPlayers[item.Key] = item.Value;
		}
	}

	private static bool StillInRoom(PlayerAvatar p)
	{
		if (!PhotonNetwork.InRoom)
		{
			return true;
		}
		Player val = (((Object)(object)p.photonView != (Object)null) ? p.photonView.Owner : null);
		if (val != null)
		{
			return PhotonNetwork.CurrentRoom.Players.ContainsKey(val.ActorNumber);
		}
		return false;
	}

	private static void CheckDead()
	{
		Dead.Clear();
		_alive = 0;
		_total = 0;
		foreach (PlayerAvatar item2 in GameDirector.instance.PlayerList.ToList())
		{
			if (!((Object)(object)item2 == (Object)null) && StillInRoom(item2))
			{
				_total++;
				if (G.Dead(item2))
				{
					string text = G.Name(item2);
					string item = (string.IsNullOrWhiteSpace(text) ? "?" : text.Trim());
					Dead.Add(item);
				}
				else
				{
					_alive++;
				}
			}
		}
	}

	private static void Render()
	{
		StringBuilder stringBuilder = new StringBuilder();
		foreach (KeyValuePair<string, float> notice in Notices)
		{
			float num = Time.unscaledTime - notice.Value;
			string text = ((int)(Mathf.Clamp01((7f - num) / 1.5f) * 255f)).ToString("X2");
			stringBuilder.Append("<color=#ffb347" + text + "><size=85%>" + Escape(notice.Key) + " left the lobby</size></color>\n");
		}
		if (Dead.Count > 0)
		{
			stringBuilder.Append($"<color=#ff4040>Dead: {Dead.Count}/{_total}</color>\n");
			foreach (string item in Dead)
			{
				stringBuilder.Append("<color=#ff8080>" + Escape(item) + "</color>\n");
			}
		}
		string text2 = stringBuilder.ToString().TrimEnd('\n');
		((Component)_label).gameObject.SetActive(text2.Length > 0);
		((TMP_Text)_label).fontSize = TextSize.Value;
		if (((TMP_Text)_label).text != text2)
		{
			((TMP_Text)_label).text = text2;
		}
	}

	private static string Escape(string s)
	{
		return "<noparse>" + s.Replace("</noparse>", "") + "</noparse>";
	}

	private static bool EnsureLabel()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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_00f8: 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_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_label != (Object)null)
		{
			return true;
		}
		HUDCanvas instance = HUDCanvas.instance;
		if ((Object)(object)instance == (Object)null)
		{
			return false;
		}
		GameObject val = new GameObject("YuMods.DeadPlayers", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(((Component)instance).transform, false);
		_label = val.AddComponent<TextMeshProUGUI>();
		TMP_FontAsset val2 = (from t in ((Component)instance).GetComponentsInChildren<TextMeshProUGUI>(true)
			select ((TMP_Text)t).font).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => (Object)(object)f != (Object)null));
		if ((Object)(object)val2 != (Object)null)
		{
			((TMP_Text)_label).font = val2;
		}
		((TMP_Text)_label).richText = true;
		((TMP_Text)_label).enableWordWrapping = false;
		((TMP_Text)_label).alignment = (TextAlignmentOptions)1028;
		((Graphic)_label).raycastTarget = false;
		RectTransform val3 = (RectTransform)val.transform;
		Vector2 val4 = default(Vector2);
		((Vector2)(ref val4))..ctor(1f, 0f);
		val3.anchorMax = val4;
		val3.anchorMin = val4;
		val3.pivot = new Vector2(1f, 0f);
		val3.anchoredPosition = new Vector2(-14f, 14f);
		val3.sizeDelta = new Vector2(420f, 500f);
		return true;
	}
}
public class DeathRecapModule : YuModule
{
	private struct Hit
	{
		public float time;

		public int dmg;

		public string source;

		public int hpAfter;
	}

	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPatch(typeof(HurtCollider), "PlayerHurt")]
		[HarmonyPrefix]
		private static void BeforeColliderHurt(HurtCollider __instance, PlayerAvatar _player)
		{
			if (I == null || !I.Enabled.Value || (Object)(object)_player == (Object)null || !G.Local(_player))
			{
				return;
			}
			try
			{
				EnemyParent componentInParent = ((Component)__instance).GetComponentInParent<EnemyParent>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					_pendingSource = MonsterTagsModule.NameOf(componentInParent);
					return;
				}
				PhysGrabObject componentInParent2 = ((Component)__instance).GetComponentInParent<PhysGrabObject>();
				if ((Object)(object)componentInParent2 != (Object)null)
				{
					_pendingSource = Pretty(((Object)componentInParent2).name);
				}
				else
				{
					_pendingSource = Pretty(((Object)((Component)__instance).transform.root).name);
				}
			}
			catch
			{
			}
		}

		[HarmonyPatch(typeof(HurtCollider), "PlayerHurt")]
		[HarmonyPostfix]
		private static void AfterColliderHurt()
		{
			_pendingSource = null;
		}

		[HarmonyPatch(typeof(PlayerHealth), "Hurt")]
		[HarmonyPrefix]
		private static void BeforeHurt(PlayerHealth __instance, out int __state)
		{
			__state = _hp.Invoke(__instance);
		}

		[HarmonyPatch(typeof(PlayerHealth), "Hurt")]
		[HarmonyPostfix]
		private static void AfterHurt(PlayerHealth __instance, int enemyIndex, int __state)
		{
			if (I == null || !I.Enabled.Value)
			{
				return;
			}
			try
			{
				PlayerAvatar val = _avatar.Invoke(__instance);
				if ((Object)(object)val == (Object)null || !G.Local(val))
				{
					return;
				}
				int num = _hp.Invoke(__instance);
				int num2 = __state - num;
				if (num2 <= 0)
				{
					return;
				}
				string text = null;
				if (enemyIndex >= 0)
				{
					Enemy val2 = SemiFunc.EnemyGetFromIndex(enemyIndex);
					EnemyParent val3 = (((Object)(object)val2 != (Object)null) ? G.Parent(val2) : null);
					if ((Object)(object)val3 != (Object)null)
					{
						text = MonsterTagsModule.NameOf(val3);
					}
				}
				if (text == null)
				{
					text = _pendingSource ?? "fall / impact";
				}
				Hits.Add(new Hit
				{
					time = Time.time,
					dmg = num2,
					source = text,
					hpAfter = num
				});
				Hits.RemoveAll((Hit h) => Time.time - h.time > 20f);
			}
			catch
			{
			}
		}

		[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeathRPC")]
		[HarmonyPrefix]
		private static void BeforeDeath(PlayerAvatar __instance, out bool __state)
		{
			__state = G.DeadSet(__instance);
		}

		[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeathRPC")]
		[HarmonyPostfix]
		private static void AfterDeath(PlayerAvatar __instance, int enemyIndex, bool __state)
		{
			if (I == null || !I.Enabled.Value || __state || !G.DeadSet(__instance) || !G.Local(__instance))
			{
				return;
			}
			try
			{
				_killer = null;
				Enemy val = ((enemyIndex >= 0) ? SemiFunc.EnemyGetFromIndex(enemyIndex) : null);
				EnemyParent val2 = (((Object)(object)val != (Object)null) ? G.Parent(val) : null);
				if ((Object)(object)val2 != (Object)null)
				{
					_killer = MonsterTagsModule.NameOf(val2);
				}
				_showAt = Time.unscaledTime + 0.3f;
			}
			catch
			{
			}
		}
	}

	internal static DeathRecapModule I;

	internal static ConfigEntry<float> ShowFor;

	internal static ConfigEntry<float> TextSize;

	private static readonly FieldRef<PlayerHealth, int> _hp = AccessTools.FieldRefAccess<PlayerHealth, int>("health");

	private static readonly FieldRef<PlayerHealth, PlayerAvatar> _avatar = AccessTools.FieldRefAccess<PlayerHealth, PlayerAvatar>("playerAvatar");

	private static readonly List<Hit> Hits = new List<Hit>();

	private static string _pendingSource;

	private static string _killer;

	private static float _showAt = -1f;

	private static float _hideAt = -1f;

	private static float _shownAt = -1f;

	private static RectTransform _panel;

	private static TextMeshProUGUI _text;

	public override string Id => "DeathRecap";

	public override string Title => "Death Recap";

	public override bool HostOnly => false;

	protected override bool EnabledByDefault => false;

	public override string Description => "After you die, a panel shows what killed you, every hit before it and how fast it went.";

	public override string Summary => "Find out what killed you.";

	public override string[] Details => new string[4] { "When you die, a panel on the left shows: KILLED BY ..., then every hit you took in the last 20 seconds.", "Each line: damage, what hit you (monster name, item, fall...), how long before death, and your HP after it.", "At the bottom: total damage and how many seconds it took.", "Closes by itself after a while, when you're revived, or with the button in this menu." };

	protected override void Setup()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: 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
		I = this;
		ShowFor = base.Config.Bind<float>(Id, "ShowFor", 15f, new ConfigDescription("How long the recap stays on screen (seconds).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 60f), Array.Empty<object>()));
		TextSize = base.Config.Bind<float>(Id, "TextSize", 20f, new ConfigDescription("Text size.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(14f, 32f), Array.Empty<object>()));
		Plugin.Harmony.PatchAll(typeof(Patches));
	}

	protected override void OnToggled(bool on)
	{
		if (!on)
		{
			Hide();
		}
	}

	public override void BuildSettings(YuSettings s)
	{
		s.Slider("Stays on screen", () => ShowFor.Value, delegate(float v)
		{
			ShowFor.Value = v;
		}, 3f, 60f, 1f, (float v) => Mathf.RoundToInt(v) + " s");
		s.Slider("Text size", () => TextSize.Value, delegate(float v)
		{
			TextSize.Value = v;
		}, 14f, 32f, 1f, (float v) => Mathf.RoundToInt(v).ToString());
		s.Button("Show last recap again", delegate
		{
			if ((Object)(object)_panel != (Object)null && (Object)(object)_text != (Object)null && ((TMP_Text)_text).text.Length > 0)
			{
				((Component)_panel).gameObject.SetActive(true);
				_shownAt = Time.unscaledTime;
				_hideAt = Time.unscaledTime + ShowFor.Value;
			}
		});
		s.Button("Close recap", Hide);
	}

	private static void Hide()
	{
		_hideAt = -1f;
		_showAt = -1f;
		if ((Object)(object)_panel != (Object)null)
		{
			((Component)_panel).gameObject.SetActive(false);
		}
	}

	private static string Pretty(string n)
	{
		if (string.IsNullOrEmpty(n))
		{
			return "?";
		}
		n = n.Replace("(Clone)", "");
		n = Regex.Replace(n, "^(Valuable|Item|Enemy)[ _-]*", "", RegexOptions.IgnoreCase);
		n = n.Replace('_', ' ').Trim();
		if (n.Length <= 0)
		{
			return "?";
		}
		return n;
	}

	internal static void Tick()
	{
		if (I != null && I.Enabled.Value)
		{
			PlayerAvatar instance = PlayerAvatar.instance;
			if ((Object)(object)_panel != (Object)null && ((Component)_panel).gameObject.activeSelf && Time.unscaledTime - _shownAt > 2f && (Object)(object)instance != (Object)null && !G.Dead(instance) && !G.DeadSet(instance) && Hits.Count > 0)
			{
				Hide();
			}
			if (_showAt > 0f && Time.unscaledTime >= _showAt)
			{
				_showAt = -1f;
				Build();
				_hideAt = Time.unscaledTime + ShowFor.Value;
				_shownAt = Time.unscaledTime;
			}
			if (_hideAt > 0f && Time.unscaledTime >= _hideAt)
			{
				Hide();
			}
		}
	}

	private static string Fmt(float s)
	{
		if (!(s < 0.05f))
		{
			return s.ToString("0.0") + "s";
		}
		return "0.0s";
	}

	private static void Build()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: 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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0437: Unknown result type (might be due to invalid IL or missing references)
		if (!YuUi.Ensure())
		{
			return;
		}
		if ((Object)(object)_panel == (Object)null)
		{
			_panel = ((Graphic)YuUi.Box("YuMods.DeathRecap", (Transform)(object)YuUi.Root, new Color(0.06f, 0.06f, 0.08f, 0.78f))).rectTransform;
			RectTransform panel = _panel;
			RectTransform panel2 = _panel;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0f, 0.5f);
			panel2.anchorMax = val;
			panel.anchorMin = val;
			_panel.pivot = new Vector2(0f, 0.5f);
			_panel.anchoredPosition = new Vector2(24f, 40f);
			Image obj = YuUi.Box("Edge", (Transform)(object)_panel, new Color(1f, 0.25f, 0.25f, 0.9f));
			((Graphic)obj).rectTransform.anchorMin = new Vector2(0f, 0f);
			((Graphic)obj).rectTransform.anchorMax = new Vector2(0f, 1f);
			((Graphic)obj).rectTransform.pivot = new Vector2(0f, 0.5f);
			((Graphic)obj).rectTransform.sizeDelta = new Vector2(4f, 0f);
			_text = YuUi.Text((Transform)(object)_panel, "", 20f, YuUi.TextCol, (TextAlignmentOptions)257);
			((TMP_Text)_text).enableWordWrapping = false;
			YuUi.Stretch(((TMP_Text)_text).rectTransform, 18f, 14f, 12f, 12f);
			((Transform)_panel).SetAsFirstSibling();
		}
		float death = ((Hits.Count > 0) ? Hits[Hits.Count - 1].time : Time.time);
		List<Hit> list = Hits.Where((Hit h) => death - h.time <= 20f).ToList();
		string text = _killer ?? ((list.Count > 0) ? list[list.Count - 1].source : "something");
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.Append("<size=130%><b><color=#ff4040>KILLED BY ").Append(Esc((text ?? "?").ToUpperInvariant())).Append("</color></b></size>\n");
		if (list.Count == 0)
		{
			stringBuilder.Append("<color=#aaaaaa>No hits recorded.</color>\n");
		}
		else
		{
			stringBuilder.Append("<color=#888888>dmg   from                     before death   HP</color>\n");
			foreach (Hit item in list.Skip(Mathf.Max(0, list.Count - 10)))
			{
				stringBuilder.Append("<color=#ff6060>-").Append(item.dmg.ToString().PadRight(4)).Append("</color> ")
					.Append(Esc(item.source))
					.Append("   <color=#aaaaaa>")
					.Append(Fmt(death - item.time))
					.Append("</color>   ")
					.Append((item.hpAfter <= 0) ? "<color=#ff4040>0</color>" : ("<color=#7CFC00>" + item.hpAfter + "</color>"))
					.Append('\n');
			}
			int value = list.Sum((Hit h) => h.dmg);
			float s = death - list[0].time;
			stringBuilder.Append("\n<color=#ffb347>").Append(value).Append(" damage in ")
				.Append(Fmt(s))
				.Append("</color>");
		}
		((TMP_Text)_text).fontSize = TextSize.Value;
		((TMP_Text)_text).text = stringBuilder.ToString();
		int num = ((TMP_Text)_text).text.Split('\n').Length;
		_panel.sizeDelta = new Vector2(520f * TextSize.Value / 20f, ((float)num + 1.5f) * TextSize.Value * 1.35f + 24f);
		((Component)_panel).gameObject.SetActive(true);
		Hits.Clear();
	}

	private static string Esc(string s)
	{
		return "<noparse>" + (s ?? "?").Replace("</noparse>", "") + "</noparse>";
	}
}
public class DoubleJumpModule : YuModule
{
	internal static DoubleJumpModule I;

	internal ConfigEntry<int> Extra;

	private static readonly FieldRef<PlayerController, int> _jumpExtra = AccessTools.FieldRefAccess<PlayerController, int>("JumpExtra");

	public override string Id => "DoubleJump";

	public override string Title => "Double Jump";

	public override bool HostOnly => false;

	protected override bool EnabledByDefault => false;

	public override string Description => "Jump again while in the air (on top of any Extra Jump upgrades you bought). Works in any lobby.";

	public override string Summary => "Jump again in the air.";

	public override string[] Details => new string[2] { "Your jumps are done by your own game (the same way the Extra Jump upgrade works), so the host doesn't have to have the mod.", "Works in any lobby." };

	public override string Status
	{
		get
		{
			PlayerController instance = PlayerController.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				return "Extra jumps: " + _jumpExtra.Invoke(instance);
			}
			return null;
		}
	}

	protected override void Setup()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		I = this;
		Extra = base.Config.Bind<int>(Id, "ExtraJumps", 1, new ConfigDescription("Extra jumps in the air.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
	}

	public override void BuildSettings(YuSettings s)
	{
		s.Slider("Extra jumps in the air", () => Extra.Value, delegate(float v)
		{
			Extra.Value = Mathf.RoundToInt(v);
		}, 1f, 5f, 1f, (float v) => Mathf.RoundToInt(v).ToString());
	}

	protected override void OnToggled(bool on)
	{
		if (!on)
		{
			Apply(on: false);
		}
	}

	private static int Upgrades(PlayerController pc)
	{
		try
		{
			string text = SemiFunc.PlayerGetSteamID(pc.playerAvatarScript);
			Dictionary<string, int> playerUpgradeExtraJump = StatsManager.instance.playerUpgradeExtraJump;
			int value;
			return (playerUpgradeExtraJump != null && text != null && playerUpgradeExtraJump.TryGetValue(text, out value)) ? value : 0;
		}
		catch
		{
			return 0;
		}
	}

	private static void Apply(bool on)
	{
		PlayerController instance = PlayerController.instance;
		if (!((Object)(object)instance == (Object)null) && !((Object)(object)StatsManager.instance == (Object)null))
		{
			int num = Upgrades(instance) + ((on && I != null) ? I.Extra.Value : 0);
			if (_jumpExtra.Invoke(instance) != num)
			{
				_jumpExtra.Invoke(instance) = num;
			}
		}
	}

	internal static void Tick()
	{
		if (I == null || !I.Enabled.Value)
		{
			return;
		}
		try
		{
			if ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated)
			{
				return;
			}
		}
		catch
		{
			return;
		}
		Apply(on: true);
	}
}
public class ExtraSlotsModule : YuModule
{
	internal static ExtraSlotsModule I;

	internal ConfigEntry<int> Slots;

	internal ConfigEntry<KeyCode> Key4;

	internal ConfigEntry<KeyCode> Key5;

	internal ConfigEntry<KeyCode> Key6;

	private static readonly FieldRef<Inventory, List<InventorySpot>> _spots = AccessTools.FieldRefAccess<Inventory, List<InventorySpot>>("inventorySpots");

	private static readonly MethodInfo _handleInput = AccessTools.Method(typeof(InventorySpot), "HandleInput", (Type[])null, (Type[])null);

	private static readonly MethodInfo _layoutSetup = AccessTools.Method(typeof(InventoryUI), "LayoutSetup", (Type[])null, (Type[])null);

	private static readonly FieldInfo _slotCenterX = AccessTools.Field(typeof(InventoryUI), "slotCenterX");

	private static readonly FieldInfo _itemWidth = AccessTools.Field(typeof(InventoryUI), "itemWidth");

	private static InventoryUI _doneFor;

	private static readonly List<InventorySpot> _extra = new List<InventorySpot>();

	private static int _otherMod = -1;

	public override string Id => "ExtraSlots";

	public override string Title => "Extra Slots";

	public override bool HostOnly => false;

	protected override bool EnabledByDefault => false;

	public override string Description => "More inventory slots: 5 instead of 3 (or up to 6). Keys 4, 5, 6.";

	public override string Summary => "5 inventory slots instead of 3.";

	public override string[] Details => new string[4] { "Adds slots next to your normal 3, keys 4 / 5 / 6 (change them in settings).", "The host decides if an item may go into a slot: in your own lobby (or a host with YuMods + Extra Slots) all slots work.", "With a host without it, only the normal 3 slots accept items.", "Turn off other 'more slots' mods (like ExtraSlots by RevanTeam) so they don't fight." };

	public override string Status
	{
		get
		{
			Inventory instance = Inventory.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			return "Slots: " + _spots.Invoke(instance).Count + (SemiFunc.IsMasterClientOrSingleplayer() ? "" : "  (slots 4+ need the host to run Extra Slots too)");
		}
	}

	protected override void Setup()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		I = this;
		Slots = base.Config.Bind<int>(Id, "Slots", 5, new ConfigDescription("Total inventory slots.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(4, 6), Array.Empty<object>()));
		Key4 = base.Config.Bind<KeyCode>(Id, "Slot4Key", (KeyCode)52, "Key for slot 4.");
		Key5 = base.Config.Bind<KeyCode>(Id, "Slot5Key", (KeyCode)53, "Key for slot 5.");
		Key6 = base.Config.Bind<KeyCode>(Id, "Slot6Key", (KeyCode)54, "Key for slot 6.");
	}

	public override void BuildSettings(YuSettings s)
	{
		s.Slider("Slots", () => Slots.Value, delegate(float v)
		{
			Slots.Value = Mathf.RoundToInt(v);
		}, 4f, 6f, 1f, (float v) => Mathf.RoundToInt(v).ToString());
		s.Note(() => "New slot count applies from the next level.");
	}

	internal static bool OtherSlotsMod()
	{
		if (_otherMod < 0)
		{
			_otherMod = 0;
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				string text = pluginInfo.Value.Metadata.Name ?? "";
				if (pluginInfo.Value.Metadata.GUID != "yu.yumods" && text.Replace(" ", "").ToLower().Contains("extraslot"))
				{
					_otherMod = 1;
					Plugin.Log.LogWarning((object)("Extra Slots: another slots mod (" + text + ") is installed - YuMods slots are off. Remove that mod to use these."));
				}
			}
		}
		return _otherMod == 1;
	}

	internal static void Tick(bool menuOpen)
	{
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Expected I4, but got Unknown
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Expected I4, but got Unknown
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Expected I4, but got Unknown
		if (I == null || !I.Enabled.Value)
		{
			return;
		}
		InventoryUI instance = InventoryUI.instance;
		Inventory instance2 = Inventory.instance;
		if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null || OtherSlotsMod())
		{
			return;
		}
		try
		{
			if (SemiFunc.RunIsArena() || SemiFunc.MenuLevel())
			{
				return;
			}
		}
		catch
		{
		}
		if ((Object)(object)_doneFor != (Object)(object)instance)
		{
			Extend(instance, instance2);
		}
		bool flag = false;
		try
		{
			flag = !SemiFunc.NoTextInputsActive();
		}
		catch
		{
		}
		if (menuOpen || flag)
		{
			return;
		}
		KeyCode[] array = (KeyCode[])(object)new KeyCode[3]
		{
			(KeyCode)(int)I.Key4.Value,
			(KeyCode)(int)I.Key5.Value,
			(KeyCode)(int)I.Key6.Value
		};
		for (int i = 0; i < _extra.Count && i < array.Length; i++)
		{
			if ((Object)(object)_extra[i] != (Object)null && YuMenu.KeyPressed(array[i]))
			{
				_handleInput.Invoke(_extra[i], null);
			}
		}
	}

	private static void Extend(InventoryUI ui, Inventory inv)
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		_doneFor = ui;
		_extra.Clear();
		int num = Mathf.Clamp(I.Slots.Value, 4, 6);
		List<InventorySpot> list = _spots.Invoke(inv);
		InventorySpot[] componentsInChildren = ((Component)ui).GetComponentsInChildren<InventorySpot>(true);
		InventorySpot val = null;
		InventorySpot val2 = null;
		InventorySpot[] array = componentsInChildren;
		foreach (InventorySpot val3 in array)
		{
			if (val3.inventorySpotIndex == 1)
			{
				val = val3;
			}
			if (val3.inventorySpotIndex == 2)
			{
				val2 = val3;
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			return;
		}
		float num2 = (((Object)(object)val != (Object)null) ? (((Component)val2).transform.localPosition.x - ((Component)val).transform.localPosition.x) : 60f);
		int num3 = 0;
		array = componentsInChildren;
		foreach (InventorySpot val4 in array)
		{
			num3 = Mathf.Max(num3, val4.inventorySpotIndex + 1);
		}
		while (list.Count < num)
		{
			list.Add(null);
		}
		for (int j = num3; j < num; j++)
		{
			GameObject obj = Object.Instantiate<GameObject>(((Component)val2).gameObject, ((Component)val2).transform.parent);
			((Object)obj).name = "Inventory Spot " + (j + 1) + " (YuMods)";
			obj.transform.localPosition = ((Component)val2).transform.localPosition + new Vector3(num2 * (float)(j - 2), 0f, 0f);
			InventorySpot component = obj.GetComponent<InventorySpot>();
			component.inventorySpotIndex = j;
			InputGlyphText[] componentsInChildren2 = obj.GetComponentsInChildren<InputGlyphText>(true);
			foreach (InputGlyphText val5 in componentsInChildren2)
			{
				TMP_Text component2 = ((Component)val5).GetComponent<TMP_Text>();
				if (!((Object)(object)component2 == (Object)null) && !((Object)(object)component2 == (Object)(object)component.noItem))
				{
					((Behaviour)val5).enabled = false;
					component2.text = KeyLabel((KeyCode)(j switch
					{
						4 => I.Key5.Value, 
						3 => I.Key4.Value, 
						_ => I.Key6.Value, 
					}));
				}
			}
			_extra.Add(component);
		}
		try
		{
			_slotCenterX.SetValue(ui, 0f);
			_itemWidth.SetValue(ui, 0f);
			_layoutSetup.Invoke(ui, null);
		}
		catch (Exception ex)
		{
			Plugin.Log.LogDebug((object)("ExtraSlots layout: " + ex.Message));
		}
		Plugin.Log.LogInfo((object)("Extra Slots: " + list.Count + " inventory slots"));
	}

	private unsafe static string KeyLabel(KeyCode k)
	{
		string text = ((object)(*(KeyCode*)(&k))/*cast due to .constrained prefix*/).ToString();
		if (!text.StartsWith("Alpha"))
		{
			return text;
		}
		return text.Substring(5);
	}
}
public class FpsBoostModule : YuModule
{
	internal static FpsBoostModule I;

	internal ConfigEntry<bool> CutAtFog;

	internal ConfigEntry<bool> FarShadowsOff;

	internal ConfigEntry<float> ShadowDistance;

	internal ConfigEntry<float> LightShadowRange;

	internal ConfigEntry<int> PixelLights;

	private static Camera _cam;

	private static float _origFar = -1f;

	private static float _origShadowDist = -1f;

	private static int _origPixel = -1;

	private static readonly Dictionary<Light, LightShadows> _shadowOff = new Dictionary<Light, LightShadows>();

	private static Light[] _lights = (Light[])(object)new Light[0];

	private static float _nextScan;

	private static float _nextLights;

	private static float _fps = 60f;

	public override string Id => "FpsBoost";

	public override string Title => "FPS Boost";

	public override bool HostOnly => false;

	protected override bool EnabledByDefault => false;

	public override string Description => "More FPS with almost no visible change: stop drawing what the fog hides, no shadows from far lights, fewer heavy lights.";

	public override string Summary => "More FPS, the game looks the same.";

	public override string[] Details => new string[5] { "Cut at the fog: the game draws everything up to far away, even behind the fog where you can't see it. This stops at the fog.", "Far light shadows off: lamps far from you stop casting shadows (you can't see those shadows anyway).", "Shadow distance and max lights: lower = more FPS.", "Only your screen changes, so it works in any lobby.", "Graphics mods (like REPO Fidelity on Ultra) can eat the FPS back - set them lower." };

	public override string Status => "FPS: " + Mathf.RoundToInt(_fps);

	protected override void Setup()
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Expected O, but got Unknown
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Expected O, but got Unknown
		I = this;
		CutAtFog = base.Config.Bind<bool>(Id, "CutAtFog", true, "Don't draw what the fog hides.");
		FarShadowsOff = base.Config.Bind<bool>(Id, "FarLightShadowsOff", true, "Lights far from you don't cast shadows.");
		LightShadowRange = base.Config.Bind<float>(Id, "LightShadowRange", 14f, new ConfigDescription("Lights further than this (m) cast no shadows.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 40f), Array.Empty<object>()));
		ShadowDistance = base.Config.Bind<float>(Id, "ShadowDistance", 25f, new ConfigDescription("How far shadows are drawn (m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 80f), Array.Empty<object>()));
		PixelLights = base.Config.Bind<int>(Id, "PixelLights", 4, new ConfigDescription("Max per-pixel lights per object.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
	}

	public override void BuildSettings(YuSettings s)
	{
		s.Toggle("Cut the view at the fog", CutAtFog);
		s.Toggle("No shadows from far lights", FarShadowsOff);
		s.Slider("Light shadows up to", () => LightShadowRange.Value, delegate(float v)
		{
			LightShadowRange.Value = v;
		}, 5f, 40f, 1f, (float v) => v.ToString("0") + " m");
		s.Slider("Shadow distance", () => ShadowDistance.Value, delegate(float v)
		{
			ShadowDistance.Value = v;
		}, 10f, 80f, 5f, (float v) => v.ToString("0") + " m");
		s.Slider("Max lights per object", () => PixelLights.Value, delegate(float v)
		{
			PixelLights.Value = Mathf.RoundToInt(v);
		}, 1f, 8f, 1f, (float v) => Mathf.RoundToInt(v).ToString());
	}

	protected override void OnToggled(bool on)
	{
		if (!on)
		{
			RestoreAll();
		}
	}

	private static void RestoreAll()
	{
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_cam != (Object)null && _origFar > 0f)
		{
			_cam.farClipPlane = _origFar;
		}
		_cam = null;
		_origFar = -1f;
		if (_origShadowDist > 0f)
		{
			QualitySettings.shadowDistance = _origShadowDist;
		}
		if (_origPixel >= 0)
		{
			QualitySettings.pixelLightCount = _origPixel;
		}
		_origShadowDist = -1f;
		_origPixel = -1;
		foreach (KeyValuePair<Light, LightShadows> item in _shadowOff)
		{
			if ((Object)(object)item.Key != (Object)null)
			{
				item.Key.shadows = item.Value;
			}
		}
		_shadowOff.Clear();
	}

	internal static void Tick()
	{
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Invalid comparison between Unknown and I4
		//IL_01f7: 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_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Invalid comparison between Unknown and I4
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: 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_0298: Unknown result type (might be due to invalid IL or missing references)
		float unscaledDeltaTime = Time.unscaledDeltaTime;
		if (unscaledDeltaTime > 0f)
		{
			_fps = Mathf.Lerp(_fps, 1f / unscaledDeltaTime, 0.05f);
		}
		if (I == null || !I.Enabled.Value)
		{
			return;
		}
		Camera main = Camera.main;
		if ((Object)(object)main != (Object)(object)_cam)
		{
			if ((Object)(object)_cam != (Object)null && _origFar > 0f)
			{
				_cam.farClipPlane = _origFar;
			}
			_cam = main;
			_origFar = (((Object)(object)main != (Object)null) ? main.farClipPlane : (-1f));
		}
		if ((Object)(object)main != (Object)null)
		{
			float num = _origFar;
			if (I.CutAtFog.Value && RenderSettings.fog)
			{
				num = Mathf.Clamp((((int)RenderSettings.fogMode == 1) ? RenderSettings.fogEndDistance : (3f / Mathf.Max(0.001f, RenderSettings.fogDensity))) + 8f, 20f, _origFar);
			}
			if (FreeCamModule.Overriding)
			{
				num = _origFar;
			}
			if (!Mathf.Approximately(main.farClipPlane, num))
			{
				main.farClipPlane = num;
			}
		}
		if (_origShadowDist < 0f)
		{
			_origShadowDist = QualitySettings.shadowDistance;
		}
		if (_origPixel < 0)
		{
			_origPixel = QualitySettings.pixelLightCount;
		}
		float num2 = Mathf.Min(I.ShadowDistance.Value, _origShadowDist);
		if (!Mathf.Approximately(QualitySettings.shadowDistance, num2))
		{
			QualitySettings.shadowDistance = num2;
		}
		int num3 = Mathf.Min(I.PixelLights.Value, Mathf.Max(1, _origPixel));
		if (QualitySettings.pixelLightCount != num3)
		{
			QualitySettings.pixelLightCount = num3;
		}
		float unscaledTime = Time.unscaledTime;
		if (unscaledTime >= _nextScan)
		{
			_nextScan = unscaledTime + 2f;
			_lights = Object.FindObjectsByType<Light>((FindObjectsSortMode)0);
		}
		if (unscaledTime < _nextLights || (Object)(object)main == (Object)null)
		{
			return;
		}
		_nextLights = unscaledTime + 0.4f;
		Vector3 position = ((Component)main).transform.position;
		float value = I.LightShadowRange.Value;
		Light[] lights = _lights;
		foreach (Light val in lights)
		{
			if ((Object)(object)val == (Object)null || (int)val.type == 1)
			{
				continue;
			}
			if (I.FarShadowsOff.Value)
			{
				Vector3 val2 = ((Component)val).transform.position - position;
				if (((Vector3)(ref val2)).sqrMagnitude > value * value)
				{
					if ((int)val.shadows != 0 && !_shadowOff.ContainsKey(val))
					{
						_shadowOff[val] = val.shadows;
						val.shadows = (LightShadows)0;
					}
					continue;
				}
			}
			if (_shadowOff.TryGetValue(val, out var value2))
			{
				val.shadows = value2;
				_shadowOff.Remove(val);
			}
		}
	}
}
public class FreeCamModule : YuModule
{
	[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
	internal static class BodyPatch
	{
		[HarmonyPostfix]
		private static void Postfix(PlayerController __instance)
		{
			if (Body && Active && (Object)(object)__instance == (Object)(object)PlayerController.instance)
			{
				try
				{
					MoveBody();
				}
				catch
				{
				}
			}
		}
	}

	internal static FreeCamModule I;

	internal static ConfigEntry<KeyCode> ToggleKey;

	internal static ConfigEntry<float> Speed;

	internal static ConfigEntry<float> Sensitivity;

	internal static ConfigEntry<float> Smoothing;

	internal static ConfigEntry<bool> Flashlight;

	internal static ConfigEntry<float> FlashlightPower;

	internal static ConfigEntry<KeyCode> BodyKey;

	internal static ConfigEntry<bool> VoiceAtCamera;

	internal static bool Body;

	private static Vector3 _bodyOffset;

	private static bool _madeKinematic;

	internal static bool Active;

	internal static bool External;

	internal static Vector3 ExtPos;

	internal static Quaternion ExtRot = Quaternion.identity;

	private static Vector3 _pos;

	private static Vector3 _vel;

	private static float _yaw;

	private static float _pitch;

	private static float _yawT;

	private static float _pitchT;

	private static Light _light;

	private static Camera _cam;

	private static Vector3 _savedPos;

	private static Quaternion _savedRot;

	private static bool _swapped;

	private static Coroutine _restorer;

	private static readonly List<InputKey> Allowed = new List<InputKey>
	{
		(InputKey)6,
		(InputKey)18,
		(InputKey)7,
		(InputKey)13,
		(InputKey)9,
		(InputKey)25,
		(InputKey)32,
		(InputKey)8
	};

	private static readonly FieldRef<PlayerAvatar, bool> _tumbling = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isTumbling");

	public override string Id => "FreeCam";

	public override string Title => "Free Cam";

	public override bool HostOnly => false;

	protected override bool EnabledByDefault => false;

	public override string Description => "Press the key (F) to fly a free camera around the map, alive or dead. Press it again to go back. WASD move, Space/E up, Ctrl/Q down, Shift fast, scroll = speed.";

	public override string Summary => "Fly around the map with a free camera.";

	public override string[] Details => new string[7] { "Press F (alive or dead) to start flying, press F again to go back to your body / spectating.", "WASD = move, Space/E = up, Ctrl/Q = down, Shift = fast, mouse wheel = speed.", "Your character stays where it is while you fly.", "Has its own flashlight (can be turned off below).", "While flying press G to take your BODY with you (others see you fly, walls don't stop you). G again = drop the body where you are.", "Body flying works in any lobby: your position is sent by your own game.", "Voice from camera (setting): your voice moves with the camera; friends with YuMods hear it there." };

	internal static bool Overriding
	{
		get
		{
			if (!Active)
			{
				return External;
			}
			return true;
		}
	}

	private static Vector3 PosNow
	{
		get
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (!External)
			{
				return _pos;
			}
			return ExtPos;
		}
	}

	private static Quaternion RotNow
	{
		get
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (!External)
			{
				return Quaternion.Euler(_pitch, _yaw, 0f);
			}
			return ExtRot;
		}
	}

	public override string Status
	{
		get
		{
			//IL_0020: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			if (!base.Enabled.Value)
			{
				return null;
			}
			if (!Active)
			{
				return "Ready - press " + ((object)ToggleKey.Value/*cast due to .constrained prefix*/).ToString() + " in game";
			}
			if (!Body)
			{
				return "<color=#5dff7a>FLYING</color> - " + ((object)BodyKey.Value/*cast due to .constrained prefix*/).ToString() + " = take body, " + ((object)ToggleKey.Value/*cast due to .constrained prefix*/).ToString() + " = back";
			}
			return "<color=#ffb347>FLYING WITH BODY</color> - " + ((object)BodyKey.Value/*cast due to .constrained prefix*/).ToString() + " = drop body";
		}
	}

	protected override void Setup()
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Expected O, but got Unknown
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Expected O, but got Unknown
		I = this;
		ToggleKey = base.Config.Bind<KeyCode>(Id, "ToggleKey", (KeyCode)102, "Key that turns the free camera on/off (while the module is enabled).");
		Speed = base.Config.Bind<float>(Id, "Speed", 8f, new ConfigDescription("Fly speed (m/s). Shift = x3.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 40f), Array.Empty<object>()));
		Sensitivity = base.Config.Bind<float>(Id, "MouseSensitivity", 1f, new ConfigDescription("Mouse look multiplier on top of your in-game sensitivity (1 = same as the game).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 3f), Array.Empty<object>()));
		Smoothing = base.Config.Bind<float>(Id, "Smoothing", 0.5f, new ConfigDescription("How smooth the camera moves and turns (0 = instant, 1 = very smooth).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		Flashlight = base.Config.Bind<bool>(Id, "Flashlight", true, "Give the free camera its own flashlight.");
		FlashlightPower = base.Config.Bind<float>(Id, "FlashlightPower", 1f, new ConfigDescription("Flashlight brightness.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 3f), Array.Empty<object>()));
		BodyKey = base.Config.Bind<KeyCode>(Id, "BodyKey", (KeyCode)103, "While flying: take your body with you / drop it.");
		VoiceAtCamera = base.Config.Bind<bool>(Id, "VoiceAtCamera", true, "While flying, your voice comes from the camera (on) or stays at your body (off).");
		Application.onBeforeRender += new UnityAction(BeforeRender);
		Plugin.Harmony.PatchAll(typeof(BodyPatch));
	}

	protected override void OnToggled(bool on)
	{
		if (!on)
		{
			Stop();
		}
	}

	public override void BuildSettings(YuSettings s)
	{
		s.Slider("Speed", () => Speed.Value, delegate(float v)
		{
			Speed.Value = v;
		}, 1f, 40f, 1f, (float v) => v.ToString("0") + " m/s");
		s.Slider("Mouse sensitivity (x game)", () => Sensitivity.Value, delegate(float v)
		{
			Sensitivity.Value = v;
		}, 0.2f, 3f, 0.1f, (float v) => v.ToString("0.0") + "x");
		s.Slider("Smoothness", () => Smoothing.Value, delegate(float v)
		{
			Smoothing.Value = v;
		}, 0f, 1f, 0.05f, (float v) => Mathf.RoundToInt(v * 100f) + "%");
		s.Toggle("Flashlight while flying", Flashlight);
		s.Toggle("Voice from camera (off = from your body)", VoiceAtCamera);
		s.Note(() => (!VoiceAtCamera.Value) ? "Your voice stays at your character, wherever the camera flies." : "Your voice moves with the camera. Friends with YuMods hear you there; players without it still hear you from your body.", 14f);
		s.Slider("Flashlight brightness", () => FlashlightPower.Value, delegate(float v)
		{
			FlashlightPower.Value = v;
		}, 0.2f, 3f, 0.1f, (float v) => v.ToString("0.0") + "x");
		s.Note(() => "Body key: " + ((object)BodyKey.Value/*cast due to .constrained prefix*/).ToString() + " (while flying) - fly around with your character.", 14f);
		s.Note(() => "Key: " + ((object)ToggleKey.Value/*cast due to .constrained prefix*/).ToString() + " (change in yu.yumods.cfg). WASD move, Space/E up, Ctrl/Q down, Shift fast, wheel = speed.", 14f);
	}

	private static bool InLevel()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Invalid comparison between Unknown and I4
		try
		{
			return (Object)(object)GameDirector.instance != (Object)null && (int)GameDirector.instance.currentState >= 2 && !SemiFunc.MenuLevel();
		}
		catch
		{
			return false;
		}
	}

	internal static void Tick(YuMenu host, bool menuOpen)
	{
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: 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_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0400: Unknown result type (might be due to invalid IL or missing references)
		//IL_0405: Unknown result type (might be due to invalid IL or missing references)
		//IL_040a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_0415: Unknown result type (might be due to invalid IL or missing references)
		//IL_041a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_0431: Unknown result type (might be due to invalid IL or missing references)
		//IL_0310: 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_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: 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_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		if (I == null || !I.Enabled.Value)
		{
			if (Active)
			{
				Stop();
			}
			return;
		}
		if (Active && (!InLevel() || (Object)(object)Camera.main == (Object)null))
		{
			Stop();
			return;
		}
		bool flag = false;
		try
		{
			flag = !SemiFunc.NoTextInputsActive();
		}
		catch
		{
		}
		if (!menuOpen && !flag && YuMenu.KeyPressed(ToggleKey.Value) && InLevel())
		{
			if (Active)
			{
				Stop();
			}
			else
			{
				Start();
			}
		}
		if (!Active)
		{
			try
			{
				FreeCamVoice.Apply(active: false, Vector3.zero);
				return;
			}
			catch
			{
				return;
			}
		}
		if (!menuOpen && !flag && YuMenu.KeyPressed(BodyKey.Value))
		{
			SetBody(!Body);
		}
		try
		{
			InputManager.instance.DisableMovement(0.2f);
			InputManager.instance.DisableAiming(0.2f);
			InputManager.instance.DisableControlsExcept(0.2f, Allowed);
		}
		catch
		{
		}
		float unscaledDeltaTime = Time.unscaledDeltaTime;
		float value = Smoothing.Value;
		float num = ((value <= 0.001f) ? 1f : (1f - Mathf.Exp((0f - unscaledDeltaTime) * Mathf.Lerp(40f, 4f, value))));
		Keyboard current = Keyboard.current;
		Mouse current2 = Mouse.current;
		Vector3 val = Vector3.zero;
		float num2 = Speed.Value;
		if (!menuOpen && !flag)
		{
			if (current2 != null)
			{
				float num3 = 50f;
				bool flag2 = false;
				try
				{
					num3 = G.AimSensitivity(GameplayManager.instance);
					flag2 = G.AimInvert(GameplayManager.instance);
				}
				catch
				{
				}
				float num4 = Mathf.Lerp(0.2f, 4f, num3 / 100f);
				Vector2 val2 = ((InputControl<Vector2>)(object)((Pointer)current2).delta).ReadValue() * 0.05f * num4 * Sensitivity.Value;
				if (flag2)
				{
					val2.y = 0f - val2.y;
				}
				_yawT += val2.x;
				_pitchT = Mathf.Clamp(_pitchT - val2.y, -89f, 89f);
				float y = ((InputControl<Vector2>)(object)current2.scroll).ReadValue().y;
				if (Mathf.Abs(y) > 0.01f)
				{
					Speed.Value = Mathf.Clamp(Speed.Value * ((y > 0f) ? 1.15f : 0.86956525f), 1f, 40f);
				}
			}
			if (current != null)
			{
				Quaternion val3 = Quaternion.Euler(_pitchT, _yawT, 0f);
				if (((ButtonControl)current.wKey).isPressed)
				{
					val += val3 * Vector3.forward;
				}
				if (((ButtonControl)current.sKey).isPressed)
				{
					val -= val3 * Vector3.forward;
				}
				if (((ButtonControl)current.dKey).isPressed)
				{
					val += val3 * Vector3.right;
				}
				if (((ButtonControl)current.aKey).isPressed)
				{
					val -= val3 * Vector3.right;
				}
				if (((ButtonControl)current.spaceKey).isPressed || ((ButtonControl)current.eKey).isPressed)
				{
					val += Vector3.up;
				}
				if (((ButtonControl)current.leftCtrlKey).isPressed || ((ButtonControl)current.qKey).isPressed)
				{
					val -= Vector3.up;
				}
				if (((ButtonControl)current.leftShiftKey).isPressed)
				{
					num2 *= 3f;
				}
			}
		}
		_yaw = Mathf.LerpAngle(_yaw, _yawT, num);
		_pitch = Mathf.Lerp(_pitch, _pitchT, num);
		_vel = Vector3.Lerp(_vel, ((Vector3)(ref val)).normalized * num2, (value <= 0.001f) ? 1f : (1f - Mathf.Exp((0f - unscaledDeltaTime) * Mathf.Lerp(30f, 5f, value))));
		_pos += _vel * unscaledDeltaTime;
		if (Body)
		{
			MoveBody();
		}
		UpdateLight();
		try
		{
			FreeCamVoice.Apply(active: true, _pos);
		}
		catch
		{
		}
	}

	private static void UpdateLight()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		if (!Flashlight.Value)
		{
			if ((Object)(object)_light != (Object)null && ((Component)_light).gameObject.activeSelf)
			{
				((Component)_light).gameObject.SetActive(false);
			}
			return;
		}
		if ((Object)(object)_light == (Object)null)
		{
			GameObject val = new GameObject("YuMods.FreeCamLight");
			Object.DontDestroyOnLoad((Object)val);
			_light = val.AddComponent<Light>();
			_light.type = (LightType)0;
			_light.spotAngle = 70f;
			_light.innerSpotAngle = 35f;
			_light.range = 30f;
			_light.color = new Color(1f, 0.96f, 0.88f);
			_light.shadows = (LightShadows)2;
		}
		if (!((Component)_light).gameObject.activeSelf)
		{
			((Component)_light).gameObject.SetActive(true);
		}
		_light.intensity = 2.5f * FlashlightPower.Value;
		((Component)_light).transform.SetPositionAndRotation(_pos, Quaternion.Euler(_pitch, _yaw, 0f));
	}

	internal static Vector3 WorldToCanvas(Vector3 world)
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: 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_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if ((Object)(object)main == (Object)null)
		{
			return SemiFunc.UIWorldToCanvasPosition(world);
		}
		Transform transform = ((Component)main).transform;
		Vector3 position = transform.position;
		Quaternion rotation = transform.rotation;
		transform.SetPositionAndRotation(PosNow, RotNow);
		try
		{
			return SemiFunc.UIWorldToCanvasPosition(world);
		}
		finally
		{
			transform.SetPositionAndRotation(position, rotation);
		}
	}

	private static void Start()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: 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_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: 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_0069: 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)
		Camera main = Camera.main;
		if (!((Object)(object)main == (Object)null))
		{
			_pos = ((Component)main).transform.position;
			Vector3 eulerAngles = ((Component)main).transform.eulerAngles;
			_yaw = (_yawT = eulerAngles.y);
			_pitch = (_pitchT = ((eulerAngles.x > 180f) ? (eulerAngles.x - 360f) : eulerAngles.x));
			_vel = Vector3.zero;
			Active = true;
			Plugin.Log.LogInfo((object)"Free cam ON");
		}
	}

	private static void SetBody(bool on)
	{
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unkno