Decompiled source of Hide and PEAK v1.0.2

hide_and_peak.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using HideAndSeekMod;
using Hide_and_PEAK;
using Hide_and_PEAK.Configuration;
using Hide_and_PEAK.Patches;
using Hide_and_PEAK.UI;
using Hide_and_PEAK.Voice;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("hide_and_peak")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+54cc65cacdf6da33bb3418a35fdd865a4d0fee51")]
[assembly: AssemblyProduct("hide_and_peak")]
[assembly: AssemblyTitle("hide_and_peak")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace HideAndSeekMod
{
	public class HideAndSeekManager : MonoBehaviourPunCallbacks
	{
		public static HideAndSeekManager Instance;

		private readonly HashSet<int> _processingCaught = new HashSet<int>();

		private bool _gameEndSequenceActive = false;

		private Coroutine _endGameCoroutine;

		public PhotonView View;

		public float HiderGracePeriod = Plugin.ConfigurationHandler.ConfigHiderGracePeriod.Value;

		public bool IsGameActive = false;

		public bool IsHider
		{
			get
			{
				object value;
				return ((Dictionary<object, object>)(object)PhotonNetwork.LocalPlayer.CustomProperties).TryGetValue((object)"Team", out value) && (Team)value == Team.Hider;
			}
		}

		public bool IsSeeker
		{
			get
			{
				object value;
				return ((Dictionary<object, object>)(object)PhotonNetwork.LocalPlayer.CustomProperties).TryGetValue((object)"Team", out value) && (Team)value == Team.Seeker;
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				View = ((Component)((Component)this).transform).GetComponent<PhotonView>();
				if ((Object)(object)View == (Object)null)
				{
					Plugin.Log.LogError((object)"No PhotonView attached!");
				}
				Plugin.Log.LogInfo((object)$"PhotonView ID: {View.ViewID}, IsMine: {View.IsMine}, Owner: {View.Owner}");
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Plugin.Log.LogWarning((object)"[HideAndSeekManager] Instance already exists, destroying old one.");
				Object.Destroy((Object)(object)Instance);
				Instance = this;
			}
		}

		private void Start()
		{
			CheckIfInGame();
		}

		private void CheckIfInGame()
		{
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Checking if in game...");
			if (((Dictionary<object, object>)(object)PhotonNetwork.MasterClient.CustomProperties).TryGetValue((object)"IsInGame", out object value) && (bool)value)
			{
				Plugin.Log.LogInfo((object)"[HideAndSeekManager] Found game: Starting game...");
				RejoinGame();
			}
		}

		[PunRPC]
		public void RPC_StartGame()
		{
			StartGame();
		}

		[PunRPC]
		public void RPC_RequestCurrentTimeString(int requesterActorNumber)
		{
			if (!((Object)(object)PlayerStats.Instance == (Object)null))
			{
				float currentTime = PlayerStats.Instance._currentTime;
				Player val = PhotonNetwork.CurrentRoom.Players[requesterActorNumber];
				if (val != null)
				{
					View.RPC("RPC_ReceiveCurrentTimeString", val, new object[1] { currentTime });
					Plugin.Log.LogInfo((object)("[RPC_RequestCurrentTimeString] Sent _currentTimeString to " + val.NickName));
				}
			}
		}

		[PunRPC]
		public void RPC_ReceiveCurrentTimeString(float currentTime)
		{
			if ((Object)(object)PlayerStats.Instance != (Object)null)
			{
				PlayerStats.Instance.SetCurrentTimeFromHost(currentTime);
				Plugin.Log.LogInfo((object)$"[RPC_ReceiveCurrentTimeString] Updated _currentTime: {currentTime}");
			}
		}

		public void RejoinGame()
		{
			((Dictionary<object, object>)(object)PhotonNetwork.LocalPlayer.CustomProperties).TryGetValue((object)"Team", out object value);
			Team team = (Team)value;
			((Component)this).gameObject.AddComponent<HideAndSeekPlayer>();
			Plugin.Log.LogInfo((object)"InitiatingUI");
			DeathLog.InitiateDeathLog();
			IsGameActive = true;
			View.RPC("RPC_RequestCurrentTimeString", PhotonNetwork.MasterClient, new object[1] { PhotonNetwork.LocalPlayer.ActorNumber });
			Plugin.Log.LogInfo((object)"[RequestCurrentTimeString] Requested _currentTimeString from host");
		}

		public void StartGame()
		{
			((Dictionary<object, object>)(object)PhotonNetwork.LocalPlayer.CustomProperties).TryGetValue((object)"Team", out object value);
			Team team = (Team)value;
			((Component)this).gameObject.AddComponent<HideAndSeekPlayer>();
			Plugin.Log.LogInfo((object)"InitiatingUI");
			DeathLog.InitiateDeathLog();
			PlayerStats.InitiatePlayerStats();
			IsGameActive = true;
			if (IsHost())
			{
				View.RPC("RPC_SetHiderGracePeriod", (RpcTarget)1, new object[1] { HiderGracePeriod });
				Plugin.Log.LogInfo((object)$"[HideAndSeekManager] Broadcasting HiderGracePeriod ({HiderGracePeriod}) to clients");
				View.RPC("RPC_SetSoundIntervals", (RpcTarget)1, new object[2]
				{
					SoundPlayer.Instance?.nextSoundTime ?? ((float)Plugin.ConfigurationHandler.ConfigTauntStartTime.Value),
					SoundPlayer.Instance?.soundInterval ?? ((float)Plugin.ConfigurationHandler.ConfigTauntIntervalTime.Value)
				});
				Plugin.Log.LogInfo((object)"[HideAndSeekManager] Broadcasting SoundPlayer intervals to clients");
			}
			if ((Object)(object)SoundPlayer.Instance != (Object)null)
			{
				SoundPlayer.Instance.nextSoundTime = PlayerStats.Instance._currentTime + (float)Plugin.ConfigurationHandler.ConfigTauntStartTime.Value;
			}
		}

		[PunRPC]
		public void RPC_SetSoundIntervals(float nextSound, float interval)
		{
			if ((Object)(object)SoundPlayer.Instance != (Object)null)
			{
				SoundPlayer.Instance.nextSoundTime = nextSound;
				SoundPlayer.Instance.soundInterval = interval;
				Plugin.Log.LogInfo((object)$"[HideAndSeekManager] Sound intervals synced from host: nextSound={nextSound}, interval={interval}");
			}
		}

		[PunRPC]
		public void RPC_SetHiderGracePeriod(float gracePeriod)
		{
			HiderGracePeriod = gracePeriod;
			Plugin.Log.LogInfo((object)$"[HideAndSeekManager] HiderGracePeriod set to {gracePeriod} by host.");
		}

		[PunRPC]
		public void RPC_SetFrozenState(int viewId, bool isFrozen, float frozenHeight, float frozenStamina)
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			PhotonView val = PhotonView.Find(viewId);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)$"[FreezeSync] Could not find PhotonView for {viewId}");
				return;
			}
			Character component = ((Component)val).GetComponent<Character>();
			if ((Object)(object)component == (Object)null)
			{
				Plugin.Log.LogWarning((object)$"[FreezeSync] No Character component on PhotonView {viewId}");
				return;
			}
			if (!isFrozen)
			{
				Plugin.Log.LogInfo((object)("[FreezeSync] Unfreezing " + component.characterName));
				return;
			}
			Bodypart bodypart = component.GetBodypart((BodypartType)2);
			if ((Object)(object)((bodypart != null) ? bodypart.Rig : null) != (Object)null)
			{
				Rigidbody rig = bodypart.Rig;
				Vector3 position = bodypart.Rig.position;
				position.y = frozenHeight;
				rig.position = position;
				bodypart.Rig.linearVelocity = Vector3.zero;
				bodypart.Rig.angularVelocity = Vector3.zero;
			}
			component.data.currentStamina = frozenStamina;
			component.input.movementInput = Vector2.zero;
			component.input.jumpIsPressed = false;
			component.input.crouchIsPressed = false;
			Plugin.Log.LogInfo((object)$"[FreezeSync] Applied freeze to {component.characterName}, height={frozenHeight}");
		}

		public void SyncFreezeState(Character character, bool isFrozen, float frozenHeight, float frozenStamina)
		{
			if (!((Object)(object)character?.refs?.view == (Object)null))
			{
				View.RPC("RPC_SetFrozenState", (RpcTarget)1, new object[4]
				{
					character.refs.view.ViewID,
					isFrozen,
					frozenHeight,
					frozenStamina
				});
			}
		}

		[PunRPC]
		public void RPC_RequestCatch(int seekerViewId, int hiderViewId)
		{
			if (IsHost())
			{
				Character val = Character.AllCharacters.Find((Character c) => c.refs.view.ViewID == seekerViewId);
				Character val2 = Character.AllCharacters.Find((Character c) => c.refs.view.ViewID == hiderViewId);
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
				{
					Plugin.Log.LogInfo((object)("[HideAndSeekPlayer] Host processing catch: " + val.characterName + " -> " + val2.characterName));
					CatchHider(val, val2);
				}
			}
		}

		public void CatchHider(Character seekerCharacter, Character hiderCharacter)
		{
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_0180: Expected O, but got Unknown
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			//IL_01c3: Expected O, but got Unknown
			if (!IsHost())
			{
				return;
			}
			if (PlayerStats.Instance._currentTime < HiderGracePeriod)
			{
				Plugin.Log.LogInfo((object)"[HideAndSeekPlayer] Catch ignored, hider grace period.");
				return;
			}
			Player controller = hiderCharacter.view.Controller;
			Player controller2 = seekerCharacter.view.Controller;
			((Dictionary<object, object>)(object)controller.CustomProperties).TryGetValue((object)"Team", out object value);
			((Dictionary<object, object>)(object)controller2.CustomProperties).TryGetValue((object)"Team", out object value2);
			if ((Team)value != 0 || (Team)value2 != Team.Seeker)
			{
				return;
			}
			int viewID = hiderCharacter.refs.view.ViewID;
			if (!_processingCaught.Contains(viewID))
			{
				_processingCaught.Add(viewID);
				Plugin.Log.LogInfo((object)"Team swap 1");
				View.RPC("RPC_AddDeath", (RpcTarget)0, new object[2]
				{
					seekerCharacter.refs.view.ViewID,
					hiderCharacter.refs.view.ViewID
				});
				Plugin.Log.LogInfo((object)"Team swap 2");
				Hashtable val = new Hashtable();
				((Dictionary<object, object>)val).Add((object)"Team", (object)Team.Seeker);
				((Dictionary<object, object>)val).Add((object)"OriginalRole", (object)Team.Hider);
				((Dictionary<object, object>)val).Add((object)"Caught_Time", (object)PlayerStats.Instance._currentTimeString);
				Hashtable val2 = val;
				controller.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
				((Dictionary<object, object>)(object)controller2.CustomProperties).TryGetValue((object)"Catches", out object value3);
				int num = (int)value3 + 1;
				Hashtable val3 = new Hashtable();
				((Dictionary<object, object>)val3).Add((object)"Catches", (object)num);
				Hashtable val4 = val3;
				controller2.SetCustomProperties(val4, (Hashtable)null, (WebFlags)null);
				Plugin.Log.LogInfo((object)$"{controller2.NickName} now has {num} catches.");
				((MonoBehaviour)this).StartCoroutine(ClearProcessingAfterDelay(viewID, 1f));
				if (IsHost())
				{
					((MonoBehaviour)this).StartCoroutine(CheckGameEndAfterDelay(0.5f));
				}
			}
		}

		private IEnumerator ClearProcessingAfterDelay(int viewId, float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			_processingCaught.Remove(viewId);
		}

		private IEnumerator CheckGameEndAfterDelay(float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			CheckForGameEnd();
		}

		private void CheckForGameEnd()
		{
			if (!IsHost() || !IsGameActive || _gameEndSequenceActive)
			{
				return;
			}
			int num = 0;
			int num2 = 0;
			Player[] playerList = PhotonNetwork.PlayerList;
			foreach (Player val in playerList)
			{
				if (((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"OriginalRole", out object value) && (Team)value == Team.Hider)
				{
					num++;
					if (((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"Team", out object value2) && (Team)value2 == Team.Hider)
					{
						num2++;
					}
				}
			}
			Plugin.Log.LogInfo((object)$"[GameEnd Check] Original Hiders: {num}, Remaining: {num2}");
			if (num > 0 && num2 == 0)
			{
				Plugin.Log.LogInfo((object)"[GameEnd] All hiders caught! Ending game...");
				_gameEndSequenceActive = true;
				View.RPC("RPC_ShowEndGameScoreboard", (RpcTarget)0, Array.Empty<object>());
			}
		}

		private void SaveCurrentMatch()
		{
			MatchResult matchResult = new MatchResult
			{
				Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
				Duration = (((Object)(object)PlayerStats.Instance != (Object)null) ? PlayerStats.Instance._currentTime : 0f)
			};
			Player[] playerList = PhotonNetwork.PlayerList;
			foreach (Player val in playerList)
			{
				matchResult.PlayerResults.Add(new PlayerResult
				{
					PlayerName = val.NickName,
					Team = ((!((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"Team", out object value)) ? Team.Seeker : ((Team)value)),
					OriginalRole = ((!((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"OriginalRole", out object value2)) ? Team.Seeker : ((Team)value2)),
					CaughtTime = (((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"Caught_Time", out object value3) ? value3.ToString() : ""),
					Catches = (((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"Catches", out object value4) ? ((int)value4) : 0)
				});
			}
			MatchHistoryManager.SaveMatch(matchResult);
		}

		[PunRPC]
		public void RPC_ShowEndGameScoreboard()
		{
			Plugin.Log.LogInfo((object)"[GameEnd] Received RPC: ShowEndGameScoreboard");
			ShowEndGameScoreboard();
		}

		private void ShowEndGameScoreboard()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_006a: Expected O, but got Unknown
			if ((Object)(object)ScoreBoardUI.Instance != (Object)null)
			{
				ScoreBoardUI.Instance.isGameOverMode = true;
				ScoreBoardUI.Instance.gameOverCountdown = 30f;
				ScoreBoardUI.Instance.SetScoreBoardUI(visible: true);
				ScoreBoardUI.Instance.IsOpenMode = true;
				Plugin.Log.LogInfo((object)"[GameEnd] Scoreboard opened");
				Hashtable val = new Hashtable();
				((Dictionary<object, object>)val).Add((object)"IsInGame", (object)false);
				Hashtable val2 = val;
				PhotonNetwork.LocalPlayer.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
			}
			SaveCurrentMatch();
			if (_endGameCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_endGameCoroutine);
			}
			_endGameCoroutine = ((MonoBehaviour)this).StartCoroutine(EndGameTimer());
		}

		private IEnumerator EndGameTimer()
		{
			Plugin.Log.LogInfo((object)"[GameEnd] Starting 30-second countdown...");
			float elapsed = 0f;
			float duration = 30f;
			while (elapsed < duration)
			{
				if ((Object)(object)ScoreBoardUI.Instance != (Object)null)
				{
					ScoreBoardUI.Instance.gameOverCountdown = duration - elapsed;
				}
				elapsed += Time.deltaTime;
				yield return null;
			}
			if (elapsed >= duration)
			{
				Plugin.Log.LogInfo((object)"[GameEnd] 30 seconds elapsed, restarting game");
				ScoreBoardUI.Instance.IsOpenMode = false;
			}
			if ((Object)(object)ScoreBoardUI.Instance != (Object)null && ScoreBoardUI.Instance.showUI)
			{
				ScoreBoardUI.Instance.isGameOverMode = false;
				ScoreBoardUI.Instance.gameOverCountdown = 0f;
				ScoreBoardUI.Instance.SetScoreBoardUI(visible: false);
			}
			if (IsHost())
			{
				RestartGameForAll();
				_gameEndSequenceActive = false;
			}
			_endGameCoroutine = null;
		}

		[PunRPC]
		public void RPC_AddDeath(int seekerViewId, int hiderViewId)
		{
			PhotonView val = PhotonView.Find(seekerViewId);
			PhotonView val2 = PhotonView.Find(hiderViewId);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				Plugin.Log.LogError((object)$"[DeathLog] Could not resolve PhotonViews! seeker={seekerViewId}, hider={hiderViewId}");
				return;
			}
			if ((Object)(object)DeathLog.Instance == (Object)null)
			{
				DeathLog.InitiateDeathLog();
			}
			DeathLog.Instance?.AddDeath(val, val2);
		}

		private void Update()
		{
			if (!PhotonNetwork.InRoom)
			{
				return;
			}
			if (IsHost() && Plugin.ConfigurationHandler.TeamSelectionUIAction.WasPressedThisFrame())
			{
				View.RPC("RPC_SetTeamSelectionUI", (RpcTarget)0, new object[1] { !TeamSelectionUI.Instance.showUI });
			}
			if (Plugin.ConfigurationHandler.ScoreBoardAction.IsPressed())
			{
				if (!ScoreBoardUI.Instance.showUI)
				{
					ScoreBoardUI.Instance.SetScoreBoardUI(visible: true);
				}
				else if (ScoreBoardUI.Instance.IsOpenMode)
				{
					ScoreBoardUI.Instance.IsOpenMode = false;
					ScoreBoardUI.Instance.SetScoreBoardUI(visible: false);
				}
			}
			else if (!ScoreBoardUI.Instance.IsOpenMode && ScoreBoardUI.Instance.showUI)
			{
				ScoreBoardUI.Instance.SetScoreBoardUI(visible: false);
			}
		}

		[PunRPC]
		public void RPC_SetTeamSelectionUI(bool visible)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			Plugin.Log.LogInfo((object)$"Received RPC: SetTeamSelectionUI -> {visible}");
			if ((Object)(object)TeamSelectionUI.Instance == (Object)null)
			{
				Plugin.Log.LogInfo((object)"TeamSelectionUI.Instance was null. Creating UI GameObject on demand.");
				GameObject val = new GameObject("Team Selection UI");
				val.AddComponent<TeamSelectionUI>();
			}
			TeamSelectionUI.Instance.SetTeamSelectionUI(visible);
		}

		[PunRPC]
		public void RPC_TestDeath()
		{
			try
			{
				if ((Object)(object)DeathLog.Instance == (Object)null)
				{
					DeathLog.InitiateDeathLog();
				}
				Character localCharacter = Character.localCharacter;
				PhotonView localPV = ((!((Object)(object)localCharacter != (Object)null)) ? null : localCharacter.refs?.view);
				if ((Object)(object)localPV == (Object)null)
				{
					Plugin.Log.LogError((object)"[DeathLog Test] Local PhotonView not found.");
					return;
				}
				PhotonView hider = (from c in Character.AllCharacters
					where (Object)(object)c != (Object)null && (Object)(object)c.refs?.view != (Object)null && c.refs.view.ViewID != localPV.ViewID
					select c.refs.view).FirstOrDefault() ?? localPV;
				DeathLog.Instance?.AddDeath(localPV, hider);
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"[DeathLog Test] Exception: {arg}");
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		public bool IsHost()
		{
			return PhotonNetwork.IsMasterClient;
		}

		public void DestroyGame()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00b6: Expected O, but got Unknown
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Destroying game state...");
			IsGameActive = false;
			_processingCaught.Clear();
			HideAndSeekPlayer component = ((Component)this).gameObject.GetComponent<HideAndSeekPlayer>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
				Plugin.Log.LogInfo((object)"[HideAndSeekManager] Removed HideAndSeekPlayer component");
			}
			if (PhotonNetwork.LocalPlayer != null)
			{
				Hashtable val = new Hashtable();
				((Dictionary<object, object>)val).Add((object)"Team", (object)null);
				((Dictionary<object, object>)val).Add((object)"Ready", (object)false);
				((Dictionary<object, object>)val).Add((object)"OriginalRole", (object)null);
				((Dictionary<object, object>)val).Add((object)"Caught_Time", (object)"");
				((Dictionary<object, object>)val).Add((object)"Catches", (object)0);
				Hashtable val2 = val;
				PhotonNetwork.LocalPlayer.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
				Plugin.Log.LogInfo((object)"[HideAndSeekManager] Reset local player properties");
			}
			if ((Object)(object)PlayerStats.Instance != (Object)null)
			{
				PlayerStats.Instance.ResetStats();
				Plugin.Log.LogInfo((object)"[HideAndSeekManager] Reset PlayerStats");
			}
			if ((Object)(object)DeathLog.Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)DeathLog.Instance).gameObject);
				DeathLog.Instance = null;
				Plugin.Log.LogInfo((object)"[HideAndSeekManager] Cleared DeathLog");
			}
			if ((Object)(object)TeamSelectionUI.Instance != (Object)null && TeamSelectionUI.Instance.showUI)
			{
				TeamSelectionUI.Instance.SetTeamSelectionUI(visible: false);
				Plugin.Log.LogInfo((object)"[HideAndSeekManager] Closed TeamSelectionUI");
			}
			if ((Object)(object)ScoreBoardUI.Instance != (Object)null && ScoreBoardUI.Instance.showUI)
			{
				ScoreBoardUI.Instance.SetScoreBoardUI(visible: false);
				Plugin.Log.LogInfo((object)"[HideAndSeekManager] Closed ScoreBoardUI");
			}
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Game destroyed successfully");
		}

		public void InitializeNewGame()
		{
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Initializing new game...");
			try
			{
				Plugin.ConfigurationHandler?.PushNameColorToPhoton();
			}
			catch
			{
			}
			if ((Object)(object)TeamSelectionUI.Instance != (Object)null)
			{
				TeamSelectionUI.Instance.SetTeamSelectionUI(visible: true);
				Plugin.Log.LogInfo((object)"[HideAndSeekManager] Opened TeamSelectionUI for new game");
			}
			else
			{
				Plugin.Log.LogWarning((object)"[HideAndSeekManager] TeamSelectionUI.Instance is null, cannot open");
			}
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] New game initialized");
		}

		public void RestartGame()
		{
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Restarting game...");
			DestroyGame();
			InitializeNewGame();
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Game restarted successfully");
		}

		[PunRPC]
		public void RPC_DestroyGame()
		{
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Received RPC: DestroyGame");
			DestroyGame();
		}

		[PunRPC]
		public void RPC_InitializeNewGame()
		{
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Received RPC: InitializeNewGame");
			InitializeNewGame();
		}

		[PunRPC]
		public void RPC_RestartGame()
		{
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Received RPC: RestartGame");
			RestartGame();
		}

		public void DestroyGameForAll()
		{
			if (!IsHost())
			{
				Plugin.Log.LogWarning((object)"[HideAndSeekManager] Only host can destroy game for all");
				return;
			}
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Broadcasting destroy to all clients");
			View.RPC("RPC_DestroyGame", (RpcTarget)0, Array.Empty<object>());
		}

		public void InitializeNewGameForAll()
		{
			if (!IsHost())
			{
				Plugin.Log.LogWarning((object)"[HideAndSeekManager] Only host can initialize new game for all");
				return;
			}
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Broadcasting new game initialization to all clients");
			View.RPC("RPC_InitializeNewGame", (RpcTarget)0, Array.Empty<object>());
		}

		public void RestartGameForAll()
		{
			if (!IsHost())
			{
				Plugin.Log.LogWarning((object)"[HideAndSeekManager] Only host can restart game for all");
				return;
			}
			Plugin.Log.LogInfo((object)"[HideAndSeekManager] Broadcasting game restart to all clients");
			View.RPC("RPC_RestartGame", (RpcTarget)0, Array.Empty<object>());
		}
	}
}
namespace Hide_and_PEAK
{
	public class HideAndSeekPlayer : MonoBehaviour
	{
		private Vector3 _lastPosition = Vector3.zero;

		private Camera MainCamera = Camera.main;

		public bool IsHider
		{
			get
			{
				object value;
				return ((Dictionary<object, object>)(object)PhotonNetwork.LocalPlayer.CustomProperties).TryGetValue((object)"Team", out value) && (Team)value == Team.Hider;
			}
		}

		public bool IsSeeker
		{
			get
			{
				object value;
				return ((Dictionary<object, object>)(object)PhotonNetwork.LocalPlayer.CustomProperties).TryGetValue((object)"Team", out value) && (Team)value == Team.Seeker;
			}
		}

		private void Update()
		{
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			//IL_0189: Expected O, but got Unknown
			if (!((Object)(object)Character.localCharacter == (Object)null) && Character.localCharacter.refs != null && HideAndSeekManager.Instance.IsGameActive)
			{
				Character.localCharacter.refs.afflictions.hungerPerSecond = 0f;
				if (IsSeeker)
				{
					Character.localCharacter.infiniteStam = true;
				}
				if (IsSeeker && (Object)(object)Character.localCharacter.input != (Object)null && Character.localCharacter.input.useSecondaryIsPressed)
				{
					TryRaycastCatch(2f);
				}
				else if (IsSeeker && (Object)(object)Character.localCharacter.input != (Object)null && !Character.localCharacter.input.useSecondaryIsPressed)
				{
					TryRaycastCatch(0.8f);
				}
				if (Character.localCharacter.data.dead || Character.localCharacter.refs.customization.isDead)
				{
					Plugin.Log.LogInfo((object)"[HideAndSeekPlayer] Hider is dead, reviving them and switching to seeker");
					Team team = (IsHider ? Team.Seeker : Team.Hider);
					Hashtable val = new Hashtable();
					((Dictionary<object, object>)val).Add((object)"Team", (object)Team.Seeker);
					((Dictionary<object, object>)val).Add((object)"OriginalRole", (object)team);
					((Dictionary<object, object>)val).Add((object)"Caught_Time", (object)PlayerStats.Instance._currentTimeString);
					((Dictionary<object, object>)val).Add((object)"Catches", (object)0);
					Hashtable val2 = val;
					PhotonNetwork.LocalPlayer.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
					DeathLog.Instance.AddWorldDeath(Character.localCharacter.view);
					Plugin.Log.LogInfo((object)"[HideAndSeekPlayer] Switched local player to seeker");
				}
			}
		}

		private void TryRaycastCatch(float distance)
		{
			//IL_0078: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)MainCamera == (Object)null)
			{
				MainCamera = Camera.main;
				if ((Object)(object)MainCamera == (Object)null)
				{
					Plugin.Log.LogError((object)"[HideAndSeekPlayer] No main camera found for raycast.");
					return;
				}
			}
			if (!Object.op_Implicit((Object)(object)HideAndSeekManager.Instance) || !HideAndSeekManager.Instance.IsGameActive)
			{
				return;
			}
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)MainCamera).transform.position, ((Component)MainCamera).transform.forward);
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(val, ref val2, distance))
			{
				return;
			}
			Character componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Character>();
			if (!((Object)(object)componentInParent == (Object)null) && (!((Object)(object)Character.localCharacter != (Object)null) || !((Object)(object)componentInParent == (Object)(object)Character.localCharacter)))
			{
				Plugin.Log.LogInfo((object)("[HideAndSeekPlayer] UseSecondary hit: " + componentInParent.characterName));
				if ((Object)(object)HideAndSeekManager.Instance == (Object)null)
				{
					Plugin.Log.LogError((object)"[HideAndSeekPlayer] HideAndSeekManager is null! Cannot catch hider.");
					return;
				}
				int viewID = Character.localCharacter.refs.view.ViewID;
				int viewID2 = componentInParent.refs.view.ViewID;
				HideAndSeekManager.Instance.View.RPC("RPC_RequestCatch", (RpcTarget)2, new object[2] { viewID, viewID2 });
			}
		}
	}
	public static class MatchHistoryManager
	{
		[Serializable]
		private class MatchListWrapper
		{
			public List<MatchResult> Matches;
		}

		private static readonly string savePath = Path.Combine(Application.persistentDataPath, "match_history.json");

		private static List<MatchResult> _matches = new List<MatchResult>();

		public static List<MatchResult> Matches
		{
			get
			{
				if (_matches == null)
				{
					LoadMatches();
				}
				return _matches;
			}
		}

		public static void SaveMatch(MatchResult match)
		{
			_matches.Add(match);
			string contents = JsonUtility.ToJson((object)new MatchListWrapper
			{
				Matches = _matches
			}, true);
			File.WriteAllText(savePath, contents);
			Debug.Log((object)("[MatchHistory] Saved match to " + savePath));
		}

		private static void LoadMatches()
		{
			if (File.Exists(savePath))
			{
				string text = File.ReadAllText(savePath);
				MatchListWrapper matchListWrapper = JsonUtility.FromJson<MatchListWrapper>(text);
				_matches = matchListWrapper.Matches ?? new List<MatchResult>();
			}
			else
			{
				_matches = new List<MatchResult>();
			}
		}
	}
	[Serializable]
	public class MatchResult
	{
		public string Date;

		public float Duration;

		public List<PlayerResult> PlayerResults = new List<PlayerResult>();
	}
	[Serializable]
	public class PlayerResult
	{
		public string PlayerName;

		public Team Team;

		public Team OriginalRole;

		public string CaughtTime;

		public int Catches;
	}
	[BepInPlugin("hide_and_peak", "hide_and_peak", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static ConfigurationHandler ConfigurationHandler;

		private ModConfigurationUI _ui;

		private SoundPlayer _soundPlayer;

		public bool _isInitialised = false;

		private bool _pushedNameColor = false;

		private GameObject _teamSelectionUI;

		private GameObject _scoreBoardUI;

		private HideAndSeekManager _manager;

		private RichPresenceService _richPresenceService = null;

		public static Plugin Instance;

		private RichPresenceState lastState = (RichPresenceState)0;

		public const string Id = "hide_and_peak";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "hide_and_peak";

		public static string Version => "1.0.0";

		private void Awake()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " v" + Version + " loaded!"));
			_harmony = new Harmony("hide_and_peak");
			_harmony.PatchAll(typeof(BodypartOnCollisionEnterPatch));
			_harmony.PatchAll(typeof(VoiceObscuranceFilterPatch));
			_harmony.PatchAll(typeof(CharacterMovementUpdatePatch));
			_harmony.PatchAll(typeof(RunManagerStartRunPatch));
			_harmony.PatchAll(typeof(CharacterDeathPosPatch));
			ConfigurationHandler = new ConfigurationHandler();
			GameObject val = new GameObject("HideAndPEAKConfigUI");
			Object.DontDestroyOnLoad((Object)(object)val);
			_ui = val.AddComponent<ModConfigurationUI>();
			_ui.Init(new List<Option>
			{
				Option.InputAction("Menu Key", ConfigurationHandler.ConfigMenuKey),
				Option.InputAction("Freeze Key", ConfigurationHandler.ConfigFreezeKey),
				Option.InputAction("Team Selection UI Key", ConfigurationHandler.ConfigTeamSelectionUIKey),
				Option.InputAction("Score Board Key", ConfigurationHandler.ConfigScoreBoardKey),
				Option.Int("Taunt Start Time (seconds)", ConfigurationHandler.ConfigTauntStartTime, 1, 900, 10),
				Option.Int("Taunt Interval Time (seconds)", ConfigurationHandler.ConfigTauntIntervalTime, 1, 600, 10),
				Option.Int("Hider Grace Period (seconds)", ConfigurationHandler.ConfigHiderGracePeriod, 1, 60),
				Option.Bool("Taunts Enabled", ConfigurationHandler.ConfigTauntsEnabled),
				Option.Bool("Seeker Voice", ConfigurationHandler.ConfigSeekerVoice),
				Option.Colour("Name Colour", ConfigurationHandler.NameColourR, ConfigurationHandler.NameColourG, ConfigurationHandler.NameColourB)
			});
		}

		private void Update()
		{
			//IL_0019: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Invalid comparison between Unknown and I4
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			_richPresenceService = GameHandler.GetService<RichPresenceService>();
			RichPresenceService richPresenceService = _richPresenceService;
			RichPresenceState val = (RichPresenceState)((richPresenceService != null) ? ((int)richPresenceService.m_currentState) : 0);
			if (_richPresenceService != null && lastState != val)
			{
				Log.LogInfo((object)$"[Plugin] Rich presence state changed from {lastState} to {_richPresenceService.m_currentState}");
				RichPresenceState currentState = _richPresenceService.m_currentState;
				RichPresenceState val2 = currentState;
				if ((int)val2 != 0)
				{
					if ((int)val2 == 1 && _isInitialised)
					{
						Log.LogInfo((object)"[Plugin] tearing down mod");
						TeardownMod();
					}
				}
				else if (_isInitialised)
				{
					Log.LogInfo((object)"[Plugin] tearing down mod");
					TeardownMod();
				}
				lastState = _richPresenceService.m_currentState;
			}
			if (ConfigurationHandler.MenuAction.WasPerformedThisFrame())
			{
				ModConfigurationUI.Instance.ToggleMenu();
			}
			if (Input.GetKeyDown((KeyCode)107) && (Object)(object)_soundPlayer != (Object)null)
			{
				_soundPlayer.PlayRandomSound();
			}
			if (!_pushedNameColor && PhotonNetwork.InRoom)
			{
				try
				{
					ConfigurationHandler?.PushNameColorToPhoton();
				}
				catch
				{
				}
				_pushedNameColor = true;
			}
		}

		public void InitialiseMod()
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			if (_isInitialised || (Object)(object)Character.localCharacter == (Object)null)
			{
				return;
			}
			Character.localCharacter.refs.afflictions.hungerPerSecond = 0f;
			Log.LogInfo((object)"[Plugin] Initialising Hide and PEAK mod...");
			Character val = Character.localCharacter;
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (object.Equals(allCharacter.player.view.Controller, PhotonNetwork.MasterClient))
				{
					Log.LogInfo((object)"[Plugin] Found the host character");
					val = allCharacter;
				}
			}
			ConfigurationHandler.PushNameColorToPhoton();
			_teamSelectionUI = new GameObject("Team Selection UI");
			_teamSelectionUI.AddComponent<TeamSelectionUI>();
			Object.DontDestroyOnLoad((Object)(object)_teamSelectionUI);
			_scoreBoardUI = new GameObject("Scoreboard UI");
			_scoreBoardUI.AddComponent<ScoreBoardUI>();
			Object.DontDestroyOnLoad((Object)(object)_scoreBoardUI);
			_manager = ((Component)val).gameObject.AddComponent<HideAndSeekManager>();
			_soundPlayer = ((Component)val).gameObject.AddComponent<SoundPlayer>();
			PlayerStats.InitiatePlayerStats();
			_isInitialised = true;
			Log.LogInfo((object)"[Plugin] Initialisation complete");
		}

		public void TeardownMod()
		{
			if (_isInitialised)
			{
				Log.LogInfo((object)"[Plugin] Tearing down Hide and PEAK mod...");
				if ((Object)(object)_manager != (Object)null)
				{
					Object.Destroy((Object)(object)_manager);
					_manager = null;
				}
				if ((Object)(object)_soundPlayer != (Object)null)
				{
					Object.Destroy((Object)(object)_soundPlayer);
					_soundPlayer = null;
				}
				if ((Object)(object)_teamSelectionUI != (Object)null)
				{
					Object.Destroy((Object)(object)_teamSelectionUI);
				}
				if ((Object)(object)_scoreBoardUI != (Object)null)
				{
					Object.Destroy((Object)(object)_scoreBoardUI);
				}
				_teamSelectionUI = null;
				_scoreBoardUI = null;
				if ((Object)(object)PlayerStats.Instance != (Object)null)
				{
					PlayerStats.Instance.ResetStats();
				}
				_pushedNameColor = false;
				_isInitialised = false;
				Log.LogInfo((object)"[Plugin] Teardown complete, ready to initialise again");
			}
		}

		private void OnDestroy()
		{
			TeardownMod();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		public static bool IsHost()
		{
			return PhotonNetwork.IsMasterClient;
		}
	}
	public enum Team
	{
		Hider,
		Seeker
	}
}
namespace Hide_and_PEAK.Voice
{
	public class SoundPlayer : MonoBehaviour
	{
		private List<AudioClip> loadedClips = new List<AudioClip>();

		private Dictionary<string, AudioClip> clipLookup = new Dictionary<string, AudioClip>();

		private bool isLoaded = false;

		public static SoundPlayer Instance;

		public float nextSoundTime;

		public float soundInterval = Plugin.ConfigurationHandler.ConfigTauntIntervalTime.Value;

		private void Start()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				((MonoBehaviour)this).StartCoroutine(LoadSounds());
			}
			else
			{
				Plugin.Log.LogWarning((object)"[SoundPlayer] Instance already exists, destroying old one.");
				Object.Destroy((Object)(object)Instance);
				Instance = this;
			}
		}

		private void Update()
		{
			if (isLoaded && !((Object)(object)PlayerStats.Instance == (Object)null) && HideAndSeekManager.Instance.IsGameActive && HideAndSeekManager.Instance.IsHost())
			{
				float currentTime = PlayerStats.Instance._currentTime;
				if (currentTime >= nextSoundTime)
				{
					PlayRandomSound();
					nextSoundTime += soundInterval;
					Plugin.Log.LogInfo((object)$"[SoundPlayer] Host triggered sound at {currentTime:F2}s, next at {nextSoundTime:F2}s");
				}
			}
		}

		private IEnumerator LoadSounds()
		{
			string soundsFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sounds");
			if (!Directory.Exists(soundsFolder))
			{
				Plugin.Log.LogWarning((object)("[SoundPlayer] Sounds folder not found: " + soundsFolder));
				yield break;
			}
			string[] files = Directory.GetFiles(soundsFolder, "*.wav");
			if (files.Length == 0)
			{
				Plugin.Log.LogWarning((object)("[SoundPlayer] No WAV files found in: " + soundsFolder));
				yield break;
			}
			Plugin.Log.LogInfo((object)$"[SoundPlayer] Loading {files.Length} sound files...");
			string[] array = files;
			foreach (string file in array)
			{
				UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip("file:///" + file, (AudioType)20);
				try
				{
					yield return www.SendWebRequest();
					if ((int)www.result != 1)
					{
						Plugin.Log.LogError((object)("[SoundPlayer] Failed to load " + Path.GetFileName(file) + ": " + www.error));
						continue;
					}
					AudioClip clip = DownloadHandlerAudioClip.GetContent(www);
					((Object)clip).name = Path.GetFileNameWithoutExtension(file);
					loadedClips.Add(clip);
					clipLookup[((Object)clip).name] = clip;
					Plugin.Log.LogInfo((object)("[SoundPlayer] Loaded: " + ((Object)clip).name));
				}
				finally
				{
					((IDisposable)www)?.Dispose();
				}
			}
			isLoaded = true;
			float startTime = Plugin.ConfigurationHandler.ConfigTauntStartTime.Value;
			float currentTime = (((Object)(object)PlayerStats.Instance != (Object)null) ? PlayerStats.Instance._currentTime : 0f);
			nextSoundTime = currentTime + startTime;
			Plugin.Log.LogInfo((object)$"[SoundPlayer] Finished loading {loadedClips.Count} sounds. First sound at {nextSoundTime:F2}s");
		}

		public void PlayRandomSound()
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			if (!isLoaded || loadedClips.Count == 0)
			{
				Plugin.Log.LogWarning((object)"[SoundPlayer] No sounds loaded yet!");
			}
			else
			{
				if (!HideAndSeekManager.Instance.IsHost() || !Plugin.ConfigurationHandler.ConfigTauntsEnabled.Value)
				{
					return;
				}
				foreach (Character allCharacter in Character.AllCharacters)
				{
					if (((Dictionary<object, object>)(object)allCharacter.view.Controller.CustomProperties).TryGetValue((object)"Team", out object value) && (Team)value == Team.Hider)
					{
						AudioClip val = loadedClips[Random.Range(0, loadedClips.Count)];
						Vector3 cameraPos = allCharacter.GetCameraPos(0f);
						HideAndSeekManager.Instance.View.RPC("RPC_PlaySound", (RpcTarget)0, new object[2]
						{
							((Object)val).name,
							cameraPos
						});
						Plugin.Log.LogInfo((object)$"[SoundPlayer] Host broadcasting sound: {((Object)val).name} at {cameraPos}");
					}
				}
			}
		}

		[PunRPC]
		public void RPC_PlaySound(string clipName, Vector3 pos)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (!clipLookup.TryGetValue(clipName, out AudioClip value))
			{
				Plugin.Log.LogWarning((object)("[SoundPlayer] Clip not found on client: " + clipName));
				return;
			}
			SFX_Instance val = ScriptableObject.CreateInstance<SFX_Instance>();
			val.clips = (AudioClip[])(object)new AudioClip[1] { value };
			val.settings = new SFX_Settings
			{
				volume = 1f,
				pitch = 1f,
				pitch_Variation = 0.2f,
				cooldown = 0.1f,
				spatialBlend = 1f,
				volume_Variation = 0.4f,
				dopplerLevel = 0f,
				range = 450f
			};
			val.Play(pos);
			Plugin.Log.LogInfo((object)$"[SoundPlayer] Playing clip via RPC: {clipName} at {pos}");
		}
	}
}
namespace Hide_and_PEAK.UI
{
	public class DeathLog : MonoBehaviour
	{
		private TMP_Text _text;

		public static DeathLog Instance;

		private readonly List<(string message, float expires)> _deaths = new List<(string, float)>();

		private void Start()
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				_text = ((Component)this).GetComponent<TMP_Text>();
				if ((Object)(object)_text == (Object)null)
				{
					TextMeshProUGUI component = ((Component)this).GetComponent<TextMeshProUGUI>();
					if (!((Object)(object)component != (Object)null))
					{
						Plugin.Log.LogError((object)"[DeathLog] No TMP_Text/TextMeshProUGUI found on object!");
						((Behaviour)this).enabled = false;
						return;
					}
					_text = (TMP_Text)(object)component;
				}
				_text.autoSizeTextContainer = true;
				_text.textWrappingMode = (TextWrappingModes)0;
				_text.alignment = (TextAlignmentOptions)260;
				((Graphic)_text).color = Color.white;
				_text.fontSize = 26f;
				_text.outlineColor = Color32.op_Implicit(Color.black);
				_text.outlineWidth = 0.06f;
				_text.lineSpacing = -30f;
				_text.text = "";
			}
			else
			{
				Plugin.Log.LogWarning((object)"[DeathLog] Instance already exists, destroying old one.");
				Object.Destroy((Object)(object)Instance);
				Instance = this;
			}
		}

		private void Update()
		{
			if ((Object)(object)_text == (Object)null)
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			for (int num = _deaths.Count - 1; num >= 0; num--)
			{
				(string message, float expires) tuple = _deaths[num];
				string item = tuple.message;
				float item2 = tuple.expires;
				float num2 = item2 - Time.time;
				if (num2 <= 0f)
				{
					_deaths.RemoveAt(num);
				}
				else
				{
					float num3 = Mathf.Clamp01(num2 / 5f);
					string value = item.Replace("{alpha}", Mathf.RoundToInt(num3 * 255f).ToString("X2"));
					stringBuilder.Append(value).Append('\n');
				}
			}
			_text.text = stringBuilder.ToString();
		}

		public void AddDeath(PhotonView seeker, PhotonView hider)
		{
			Plugin.Log.LogInfo((object)"[DeathLog] Adding death");
			string text = "FF5555";
			string text2 = "55AAFF";
			if (seeker.Owner != null && ((Dictionary<object, object>)(object)seeker.Owner.CustomProperties).TryGetValue((object)"NameColor", out object value))
			{
				text = (string)value;
			}
			if (hider.Owner != null && ((Dictionary<object, object>)(object)hider.Owner.CustomProperties).TryGetValue((object)"NameColor", out object value2))
			{
				text2 = (string)value2;
			}
			string text3 = "<color=#" + text + "{alpha}>" + seeker.Owner.NickName + "</color>";
			string text4 = "<color=#" + text2 + "{alpha}>" + hider.Owner.NickName + "</color>";
			string text5 = "<color=#FFFFFF{alpha}> found </color>";
			string item = text3 + text5 + text4;
			float item2 = Time.time + 5f;
			_deaths.Add((item, item2));
			Plugin.Log.LogInfo((object)"[DeathLog] Death added");
		}

		public void AddWorldDeath(PhotonView hider)
		{
			Plugin.Log.LogInfo((object)"[DeathLog] Adding death");
			string text = "FFFFFF";
			string text2 = "55AAFF";
			if (hider.Owner != null && ((Dictionary<object, object>)(object)hider.Owner.CustomProperties).TryGetValue((object)"NameColor", out object value))
			{
				text2 = (string)value;
			}
			string text3 = "<color=#" + text + "{alpha}>Death</color>";
			string text4 = "<color=#" + text2 + "{alpha}>" + hider.Owner.NickName + "</color>";
			string text5 = "<color=#FFFFFF{alpha}> found </color>";
			string item = text3 + text5 + text4;
			float item2 = Time.time + 5f;
			_deaths.Add((item, item2));
			Plugin.Log.LogInfo((object)"[DeathLog] Death added");
		}

		public static void InitiateDeathLog()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0090: 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_00b6: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				AscentUI val = Object.FindAnyObjectByType<AscentUI>();
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Log.LogError((object)"[DeathLog] Could not find AscentUI parent to attach!");
					return;
				}
				GameObject val2 = new GameObject("DeathLog UI", new Type[3]
				{
					typeof(RectTransform),
					typeof(CanvasRenderer),
					typeof(TextMeshProUGUI)
				});
				RectTransform component = val2.GetComponent<RectTransform>();
				((Transform)component).SetParent(((Component)val).transform.parent, false);
				((Transform)component).localScale = Vector3.one;
				Vector2 val3 = default(Vector2);
				((Vector2)(ref val3))..ctor(1f, 1f);
				component.anchorMax = val3;
				component.anchorMin = val3;
				component.pivot = new Vector2(1f, 1f);
				component.anchoredPosition = new Vector2(-16f, -16f);
				component.sizeDelta = new Vector2(600f, 200f);
				TMP_Text component2 = ((Component)val).GetComponent<TMP_Text>();
				if ((Object)(object)component2 != (Object)null && (Object)(object)component2.font != (Object)null)
				{
					TextMeshProUGUI component3 = val2.GetComponent<TextMeshProUGUI>();
					if ((Object)(object)component3 != (Object)null)
					{
						((TMP_Text)component3).font = component2.font;
						Plugin.Log.LogInfo((object)("[DeathLog] Copied font from AscentUI: " + ((Object)component2.font).name));
					}
				}
				else
				{
					Plugin.Log.LogWarning((object)"[DeathLog] Could not find font on AscentUI, using default");
				}
				val2.AddComponent<DeathLog>();
				((Transform)component).SetAsLastSibling();
			}
			else
			{
				Object.Destroy((Object)(object)((Component)Instance).gameObject);
				Instance = null;
				InitiateDeathLog();
			}
		}
	}
	public class PlayerStats : MonoBehaviour
	{
		private TMP_Text _text;

		private float _deathTime = 0f;

		public float _currentTime = 0f;

		public float _startTime = 0f;

		public static PlayerStats Instance;

		public string _currentTimeString = "";

		private string FormatTime(float totalSeconds)
		{
			int num = Mathf.FloorToInt(totalSeconds);
			return $"{num / 3600}:{num % 3600 / 60:00}:{num % 60:00}";
		}

		private void Start()
		{
			//IL_00ac: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				_text = ((Component)this).GetComponent<TMP_Text>();
				if ((Object)(object)_text == (Object)null)
				{
					Plugin.Log.LogError((object)"[PlayerStats] No TMP_Text found on object!");
					((Behaviour)this).enabled = false;
					return;
				}
				_text.autoSizeTextContainer = true;
				_text.textWrappingMode = (TextWrappingModes)0;
				_text.alignment = (TextAlignmentOptions)258;
				((Graphic)_text).color = Color.white;
				_text.fontSize = 34f;
				_text.outlineColor = Color32.op_Implicit(Color.black);
				_text.outlineWidth = 0.06f;
				_text.lineSpacing = -30f;
				ResetTimer();
			}
			else
			{
				Plugin.Log.LogWarning((object)"[PlayerStats] Instance already exists, destroying old one.");
				Object.Destroy((Object)(object)Instance);
				Instance = this;
			}
		}

		public void ResetStats()
		{
			ResetTimer();
		}

		private void ResetTimer()
		{
			_startTime = Time.time;
		}

		public void SetCurrentTimeFromHost(float currentTimeFromHost)
		{
			_startTime = Time.time - currentTimeFromHost;
			_currentTime = currentTimeFromHost;
			_currentTimeString = FormatTime(_currentTime);
			Plugin.Log.LogInfo((object)("[PlayerStats] Synced _currentTime from host: " + _currentTimeString));
		}

		private void Update()
		{
			if (!((Object)(object)_text == (Object)null) && !((Object)(object)Character.localCharacter == (Object)null))
			{
				CharacterStats stats = Character.localCharacter.refs.stats;
				_currentTime = Time.time - _startTime;
				_currentTimeString = FormatTime(_currentTime);
				if (HideAndSeekManager.Instance.IsGameActive)
				{
					_text.text = $"{_currentTimeString}\n{stats.heightInMeters}m";
				}
				else
				{
					_text.text = $"{stats.heightInMeters}m";
				}
			}
		}

		public static void InitiatePlayerStats()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				AscentUI val = Object.FindAnyObjectByType<AscentUI>();
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Log.LogError((object)"[Plugin] Could not find AscentUI to clone!");
					return;
				}
				Transform obj = Object.Instantiate<Transform>(((Component)val).transform, ((Component)val).transform.parent);
				RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null);
				((Object)val2).name = "Player Stats UI";
				Object.Destroy((Object)(object)((Component)val2).GetComponent<AscentUI>());
				((Component)val2).gameObject.AddComponent<PlayerStats>();
				Vector2 val3 = default(Vector2);
				((Vector2)(ref val3))..ctor(0.5f, 1f);
				val2.anchorMax = val3;
				val2.anchorMin = val3;
				val2.pivot = new Vector2(0.5f, 1f);
				val2.anchoredPosition = Vector2.zero;
			}
			else
			{
				Instance.ResetStats();
			}
		}
	}
	public class ScoreBoardUI : MenuWindow
	{
		public bool showUI = false;

		public bool isGameOverMode = false;

		public float gameOverCountdown = 0f;

		private int _currentMatchIndex = -1;

		private GUIStyle panelStyle;

		private GUIStyle headerStyle;

		private GUIStyle teamHeaderStyle;

		private GUIStyle playerStyle;

		private GUIStyle buttonStyle;

		private bool stylesCreated = false;

		public bool IsOpenMode = false;

		private Vector2 scrollPos;

		private string elapsedTime = "00:00";

		public static ScoreBoardUI Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
				((MenuWindow)this).StartClosed();
				Plugin.Log.LogInfo((object)"[ScoreBoardUI] Awake: Scoreboard UI initialized.");
			}
			else
			{
				Plugin.Log.LogWarning((object)"[ScoreBoardUI] Instance already exists, destroying old one.");
				Object.Destroy((Object)(object)Instance);
				Instance = this;
			}
		}

		private void OnGUI()
		{
			if (showUI)
			{
				if (!stylesCreated)
				{
					CreateGUIStyles();
					stylesCreated = true;
				}
				UpdateElapsedTime();
				DrawScoreBoard();
			}
		}

		public void SetScoreBoardUI(bool visible)
		{
			showUI = visible;
			if (visible)
			{
				((MenuWindow)this).Open();
			}
			else
			{
				((MenuWindow)this).Close();
			}
		}

		public void UpdateElapsedTime()
		{
			if ((Object)(object)PlayerStats.Instance != (Object)null)
			{
				elapsedTime = PlayerStats.Instance._currentTimeString;
			}
		}

		private void CreateGUIStyles()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_007e: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_0117: 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)
			//IL_0124: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			Font font = Resources.Load<Font>("Fonts/NotoSans-Regular");
			GUIStyle val = new GUIStyle(GUI.skin.box)
			{
				font = font
			};
			val.normal.background = MakeTex(4, 4, new Color(0.12f, 0.12f, 0.12f, 0.85f));
			val.border = new RectOffset(12, 12, 12, 12);
			val.padding = new RectOffset(15, 15, 15, 15);
			panelStyle = val;
			GUIStyle val2 = new GUIStyle(GUI.skin.label)
			{
				font = font,
				fontSize = 28,
				fontStyle = (FontStyle)1
			};
			val2.normal.textColor = Color.white;
			val2.alignment = (TextAnchor)4;
			headerStyle = val2;
			GUIStyle val3 = new GUIStyle(GUI.skin.label)
			{
				font = font,
				fontSize = 18,
				fontStyle = (FontStyle)1
			};
			val3.normal.textColor = Color.white;
			val3.alignment = (TextAnchor)3;
			teamHeaderStyle = val3;
			GUIStyle val4 = new GUIStyle(GUI.skin.label)
			{
				font = font,
				fontSize = 16,
				fontStyle = (FontStyle)1
			};
			val4.normal.textColor = new Color(0.9f, 0.9f, 0.9f);
			val4.alignment = (TextAnchor)3;
			val4.richText = true;
			playerStyle = val4;
			GUIStyle val5 = new GUIStyle(GUI.skin.label)
			{
				font = font,
				fontSize = 16,
				alignment = (TextAnchor)4
			};
			val5.normal.textColor = Color.white;
			val5.hover.textColor = Color.white;
			buttonStyle = val5;
		}

		private Texture2D MakeTex(int width, int height, Color col)
		{
			//IL_0010: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private void DrawScoreBoard()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)Screen.width * 0.75f;
			float num2 = (float)Screen.height * 0.8f;
			float num3 = (float)Screen.width / 2f - num / 2f;
			float num4 = (float)Screen.height * 0.1f;
			GUILayout.BeginArea(new Rect(num3, num4, num, num2), panelStyle);
			float num5 = num2 * 0.12f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(0f, 0f, num, num5 * 0.6f);
			string text;
			if (_currentMatchIndex >= 0 && _currentMatchIndex < MatchHistoryManager.Matches.Count)
			{
				MatchResult matchResult = MatchHistoryManager.Matches[_currentMatchIndex];
				text = "Match: " + matchResult.Date + " | Duration: " + FormatTime(matchResult.Duration);
			}
			else
			{
				text = (isGameOverMode ? "GAME OVER!" : "Hide & Seek Scoreboard");
			}
			GUI.Label(val, text, headerStyle);
			string text2 = (isGameOverMode ? $"Restarting: {Mathf.CeilToInt(gameOverCountdown)}s" : ((_currentMatchIndex >= 0) ? "" : ("Time: " + elapsedTime)));
			Vector2 val2 = headerStyle.CalcSize(new GUIContent(text2));
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(num - val2.x - 10f, 0f, val2.x, num5 * 0.6f);
			GUI.Label(val3, text2, headerStyle);
			GUILayout.Space(num5 * 0.65f);
			scrollPos = GUILayout.BeginScrollView(scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			float rowHeight = num2 * 0.05f;
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (DrawFlatButton("< Previous", new Color(0.25f, 0.5f, 1f)))
			{
				ShowPreviousMatch();
			}
			GUILayout.FlexibleSpace();
			if (DrawFlatButton("Next >", new Color(1f, 0.55f, 0.2f)))
			{
				ShowNextMatch();
			}
			GUILayout.EndHorizontal();
			if (_currentMatchIndex >= 0 && _currentMatchIndex < MatchHistoryManager.Matches.Count)
			{
				DrawMatch(MatchHistoryManager.Matches[_currentMatchIndex], rowHeight);
			}
			else
			{
				DrawLiveGame(rowHeight);
			}
			GUILayout.EndScrollView();
			GUILayout.EndArea();
		}

		private bool DrawFlatButton(string text, Color baseColor)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = buttonStyle.CalcSize(new GUIContent(text));
			Rect rect = GUILayoutUtility.GetRect(val.x + 20f, val.y + 8f);
			Color val2 = baseColor;
			if (((Rect)(ref rect)).Contains(Event.current.mousePosition))
			{
				val2 *= 1.2f;
			}
			GUI.DrawTexture(rect, (Texture)(object)MakeTex((int)((Rect)(ref rect)).width, (int)((Rect)(ref rect)).height, val2));
			GUI.Label(rect, text, buttonStyle);
			return GUI.Button(rect, GUIContent.none, GUIStyle.none);
		}

		private void DrawMatch(MatchResult match, float rowHeight)
		{
			DrawTeamHeaderFromHistory(match.PlayerResults, Team.Hider);
			foreach (PlayerResult playerResult in match.PlayerResults)
			{
				if (playerResult.Team == Team.Hider)
				{
					DrawPlayerRowFromHistory(playerResult, rowHeight);
				}
			}
			DrawTeamHeaderFromHistory(match.PlayerResults, Team.Seeker);
			foreach (PlayerResult playerResult2 in match.PlayerResults)
			{
				if (playerResult2.Team == Team.Seeker)
				{
					DrawPlayerRowFromHistory(playerResult2, rowHeight);
				}
			}
		}

		private void DrawTeamHeaderFromHistory(List<PlayerResult> players, Team team)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			int num2 = 0;
			foreach (PlayerResult player in players)
			{
				if (player.Team == team)
				{
					num++;
				}
				if (team == Team.Hider && player.OriginalRole == Team.Hider && player.Team != 0)
				{
					num2++;
				}
			}
			string text = ((team == Team.Hider) ? $"Hiders ({num}) | Former Hiders: {num2}" : $"Seekers ({num})");
			Color col = ((team == Team.Hider) ? new Color(0.25f, 0.5f, 1f, 0.3f) : new Color(1f, 0.55f, 0.2f, 0.3f));
			Rect rect = GUILayoutUtility.GetRect(new GUIContent(text), teamHeaderStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(30f)
			});
			GUI.DrawTexture(rect, (Texture)(object)MakeTex(1, 1, col));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 16f, ((Rect)(ref rect)).height), text, teamHeaderStyle);
		}

		private void DrawLiveGame(float rowHeight)
		{
			DrawTeamHeader(Team.Hider);
			Player[] playerList = PhotonNetwork.PlayerList;
			foreach (Player val in playerList)
			{
				if (((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"Team", out object value) && (Team)value == Team.Hider)
				{
					DrawPlayerRow(val, Team.Hider, rowHeight);
				}
			}
			DrawTeamHeader(Team.Seeker);
			Player[] playerList2 = PhotonNetwork.PlayerList;
			foreach (Player val2 in playerList2)
			{
				if (((Dictionary<object, object>)(object)val2.CustomProperties).TryGetValue((object)"Team", out object value2) && (Team)value2 == Team.Seeker)
				{
					DrawPlayerRow(val2, Team.Seeker, rowHeight);
				}
			}
		}

		private void ShowPreviousMatch()
		{
			if (MatchHistoryManager.Matches.Count != 0)
			{
				if (_currentMatchIndex == -1)
				{
					_currentMatchIndex = MatchHistoryManager.Matches.Count;
				}
				_currentMatchIndex = Mathf.Max(0, _currentMatchIndex - 1);
			}
		}

		private void ShowNextMatch()
		{
			if (_currentMatchIndex != -1)
			{
				_currentMatchIndex++;
				if (_currentMatchIndex >= MatchHistoryManager.Matches.Count)
				{
					_currentMatchIndex = -1;
				}
			}
		}

		private void DrawPlayerRowFromHistory(PlayerResult player, float rowHeight)
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			string text = "<color=#FFFFFF>" + player.PlayerName + "</color>";
			string text2 = text;
			if (player.OriginalRole != player.Team)
			{
				text2 += $" | Original: {player.OriginalRole}";
			}
			if (!string.IsNullOrEmpty(player.CaughtTime))
			{
				text2 = text2 + " | Caught: " + player.CaughtTime;
			}
			if (player.Team == Team.Seeker)
			{
				text2 += $" | Catches: {player.Catches}";
			}
			Color col = default(Color);
			((Color)(ref col))..ctor(0.25f, 0.25f, 0.3f, 0.5f);
			Rect rect = GUILayoutUtility.GetRect(new GUIContent(text2), playerStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(rowHeight)
			});
			GUI.DrawTexture(rect, (Texture)(object)MakeTex(1, 1, col));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 16f, ((Rect)(ref rect)).height), text2, playerStyle);
		}

		private void DrawTeamHeader(Team team)
		{
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			int num2 = 0;
			Player[] playerList = PhotonNetwork.PlayerList;
			foreach (Player val in playerList)
			{
				if (((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"Team", out object value) && (Team)value == team)
				{
					num++;
				}
				if (team == Team.Hider && ((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"OriginalRole", out object value2) && (Team)value2 == Team.Hider && ((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"Team", out object value3) && (Team)value3 != 0)
				{
					num2++;
				}
			}
			string text = ((team == Team.Hider) ? $"Hiders ({num}) | Former Hiders: {num2}" : $"Seekers ({num})");
			Color col = ((team == Team.Hider) ? new Color(0.25f, 0.5f, 1f, 0.3f) : new Color(1f, 0.55f, 0.2f, 0.3f));
			Rect rect = GUILayoutUtility.GetRect(new GUIContent(text), teamHeaderStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(30f)
			});
			GUI.DrawTexture(rect, (Texture)(object)MakeTex(1, 1, col));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 16f, ((Rect)(ref rect)).height), text, teamHeaderStyle);
		}

		private void DrawPlayerRow(Player player, Team team, float rowHeight)
		{
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: 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)
			Team team2 = team;
			if (((Dictionary<object, object>)(object)player.CustomProperties).TryGetValue((object)"OriginalRole", out object value))
			{
				team2 = (Team)value;
			}
			object value2;
			string text = (((Dictionary<object, object>)(object)player.CustomProperties).TryGetValue((object)"Caught_Time", out value2) ? ((string)value2) : "");
			object value3;
			int num = (((Dictionary<object, object>)(object)player.CustomProperties).TryGetValue((object)"Catches", out value3) ? ((int)value3) : 0);
			string text2 = "FFFFFF";
			if (((Dictionary<object, object>)(object)player.CustomProperties).TryGetValue((object)"NameColor", out object value4) && value4 is string text3 && text3.Length >= 6)
			{
				text2 = text3.Substring(0, 6);
			}
			string text4 = "<color=#" + text2 + ">" + player.NickName + "</color>";
			string text5 = text4 + (player.IsLocal ? " (You)" : "");
			if (team2 != team)
			{
				text5 += $" | Original: {team2}";
			}
			if (!string.IsNullOrEmpty(text))
			{
				text5 = text5 + " | Caught: " + text;
			}
			if (team == Team.Seeker)
			{
				text5 += $" | Catches: {num}";
			}
			Color col = default(Color);
			((Color)(ref col))..ctor(0.25f, 0.25f, 0.3f, 0.5f);
			Rect rect = GUILayoutUtility.GetRect(new GUIContent(text5), playerStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(rowHeight)
			});
			GUI.DrawTexture(rect, (Texture)(object)MakeTex(1, 1, col));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 16f, ((Rect)(ref rect)).height), text5, playerStyle);
		}

		private string FormatTime(float seconds)
		{
			int num = Mathf.FloorToInt(seconds / 60f);
			int num2 = Mathf.FloorToInt(seconds % 60f);
			return $"{num:00}:{num2:00}";
		}
	}
	public class TeamSelectionUI : MenuWindow
	{
		public bool showUI = false;

		private bool isReady = false;

		private GUIStyle panelStyle;

		private GUIStyle buttonStyle;

		private GUIStyle readyButtonStyle;

		private GUIStyle labelStyle;

		private GUIStyle titleStyle;

		private bool stylesCreated = false;

		private Vector2 hidersScrollPos;

		private Vector2 seekersScrollPos;

		private readonly float buttonHeight = 50f;

		private readonly float buttonWidthFactor = 0.65f;

		private readonly float buttonBottomPadding = 25f;

		public static TeamSelectionUI Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
				((MenuWindow)this).StartClosed();
				Plugin.Log.LogInfo((object)"[TeamSelectionUI] Awake: Team UI initialized.");
			}
			else
			{
				Plugin.Log.LogWarning((object)"[TeamSelectionUI] Instance already exists, destroying old one.");
				Object.Destroy((Object)(object)Instance);
				Instance = this;
			}
		}

		private void Update()
		{
			if (PhotonNetwork.InRoom && showUI)
			{
				CheckForReady();
			}
		}

		public void SetTeamSelectionUI(bool visible)
		{
			showUI = visible;
			if (visible)
			{
				((MenuWindow)this).Open();
			}
			else
			{
				((MenuWindow)this).Close();
			}
		}

		private void OnGUI()
		{
			if (showUI)
			{
				if (!stylesCreated)
				{
					CreateGUIStyles();
					stylesCreated = true;
				}
				DrawTeamUI();
			}
		}

		private void CreateGUIStyles()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_007e: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00b0: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00cf: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_0136: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: 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_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			Font font = Resources.Load<Font>("Fonts/NotoSans-Regular");
			GUIStyle val = new GUIStyle(GUI.skin.box)
			{
				font = font
			};
			val.normal.background = MakeTex(4, 4, new Color(0.12f, 0.12f, 0.12f, 0.85f));
			val.border = new RectOffset(12, 12, 12, 12);
			val.padding = new RectOffset(15, 15, 15, 15);
			panelStyle = val;
			GUIStyle val2 = new GUIStyle(GUI.skin.button)
			{
				font = font
			};
			val2.normal.textColor = Color.white;
			val2.fontSize = 18;
			val2.alignment = (TextAnchor)4;
			val2.padding = new RectOffset(12, 12, 8, 8);
			buttonStyle = val2;
			readyButtonStyle = new GUIStyle(buttonStyle);
			GUIStyle val3 = new GUIStyle(GUI.skin.label)
			{
				font = font
			};
			val3.normal.textColor = new Color(0.9f, 0.9f, 0.9f);
			val3.fontSize = 16;
			val3.alignment = (TextAnchor)3;
			val3.richText = true;
			labelStyle = val3;
			GUIStyle val4 = new GUIStyle(GUI.skin.label)
			{
				font = font
			};
			val4.normal.textColor = Color.white;
			val4.fontSize = 28;
			val4.alignment = (TextAnchor)4;
			val4.fontStyle = (FontStyle)1;
			titleStyle = val4;
		}

		private Texture2D MakeTex(int width, int height, Color col)
		{
			//IL_0010: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private void CheckForReady()
		{
			if (!isReady || (Object)(object)HideAndSeekManager.Instance == (Object)null || HideAndSeekManager.Instance.IsGameActive)
			{
				return;
			}
			int num = PhotonNetwork.PlayerList.Length;
			int num2 = 0;
			Player[] playerList = PhotonNetwork.PlayerList;
			foreach (Player val in playerList)
			{
				if (((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"Ready", out object value) && (bool)value)
				{
					num2++;
				}
			}
			if (num2 >= num)
			{
				if (PhotonNetwork.IsMasterClient)
				{
					HideAndSeekManager.Instance.View.RPC("RPC_StartGame", (RpcTarget)0, Array.Empty<object>());
					HideAndSeekManager.Instance.View.RPC("RPC_SetTeamSelectionUI", (RpcTarget)0, new object[1] { false });
				}
				SetReady(ready: false);
			}
		}

		private void DrawTeamUI()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Expected O, but got Unknown
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: 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)
			float num = (float)Screen.width / 2f;
			float num2 = Screen.height;
			GUI.color = new Color(0f, 1f, 1f, 0.9f);
			GUI.DrawTexture(new Rect(num - 2f, 0f, 4f, num2), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.white;
			float num3 = num2 - buttonHeight - 120f;
			float num4 = num * buttonWidthFactor;
			float num5 = 10f;
			float num6 = num2 - buttonHeight - buttonBottomPadding;
			GUILayout.BeginArea(new Rect(0f, 0f, num, num2), panelStyle);
			GUILayout.Label("HIDERS", titleStyle, Array.Empty<GUILayoutOption>());
			hidersScrollPos = GUILayout.BeginScrollView(hidersScrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num3) });
			DrawPlayerList(Team.Hider);
			GUILayout.EndScrollView();
			if (GUI.Button(new Rect((num - num4) / 2f, num6, num4, buttonHeight), "Join Hiders", MakeColoredButton(new Color(0.25f, 0.5f, 1f))))
			{
				SetTeam(Team.Hider);
			}
			GUILayout.EndArea();
			GUILayout.BeginArea(new Rect(num, 0f, num, num2), panelStyle);
			GUILayout.Label("SEEKERS", titleStyle, Array.Empty<GUILayoutOption>());
			seekersScrollPos = GUILayout.BeginScrollView(seekersScrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num3) });
			DrawPlayerList(Team.Seeker);
			GUILayout.EndScrollView();
			if (GUI.Button(new Rect((num - num4) / 2f, num6, num4, buttonHeight), "Join Seekers", MakeColoredButton(new Color(1f, 0.55f, 0.2f))))
			{
				SetTeam(Team.Seeker);
			}
			GUILayout.EndArea();
			GUIContent val = new GUIContent(isReady ? "✓ Ready" : "X Not Ready");
			Vector2 val2 = readyButtonStyle.CalcSize(val);
			float num7 = val2.x + num5 * 2f;
			readyButtonStyle.normal.background = MakeTex(4, 4, isReady ? new Color(0.1f, 0.6f, 0.1f, 0.95f) : new Color(0.7f, 0.15f, 0.15f, 0.95f));
			readyButtonStyle.hover.background = MakeTex(4, 4, isReady ? new Color(0.2f, 0.8f, 0.2f, 0.95f) : new Color(0.9f, 0.25f, 0.25f, 0.95f));
			if (GUI.Button(new Rect((float)Screen.width / 2f - num7 / 2f, num6, num7, buttonHeight), val, readyButtonStyle))
			{
				isReady = !isReady;
				SetReady(isReady);
			}
		}

		private void DrawPlayerList(Team team)
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			Player[] playerList = PhotonNetwork.PlayerList;
			Color col = default(Color);
			foreach (Player val in playerList)
			{
				if (((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"Team", out object value) && (Team)value == team)
				{
					object value2;
					bool flag = ((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"Ready", out value2) && (bool)value2;
					string text = "FFFFFF";
					if (((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"NameColor", out object value3) && value3 is string text2 && text2.Length >= 6)
					{
						text = text2.Substring(0, 6);
					}
					string text3 = "<color=#" + text + ">" + val.NickName + "</color>";
					string text4 = text3 + (val.IsLocal ? " (You)" : "");
					GUIStyle val2 = new GUIStyle(labelStyle)
					{
						fontStyle = (FontStyle)(val.IsLocal ? 1 : 0)
					};
					Rect rect = GUILayoutUtility.GetRect(new GUIContent(text4), val2, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.ExpandWidth(true),
						GUILayout.Height(28f)
					});
					((Color)(ref col))..ctor(0.25f, 0.25f, 0.3f, 0.5f);
					GUI.DrawTexture(rect, (Texture)(object)MakeTex(1, 1, col));
					GUI.Label(new Rect(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 30f, ((Rect)(ref rect)).height), text4, val2);
					string text5 = (flag ? "✓" : "X");
					GUI.Label(new Rect(((Rect)(ref rect)).xMax - 22f, ((Rect)(ref rect)).y, 20f, ((Rect)(ref rect)).height), text5, val2);
				}
			}
		}

		private GUIStyle MakeColoredButton(Color baseColor)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0016: 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_0031: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(buttonStyle);
			val.normal.background = MakeTex(4, 4, baseColor);
			val.hover.background = MakeTex(4, 4, baseColor * 1.2f);
			val.active.background = MakeTex(4, 4, baseColor * 0.8f);
			return val;
		}

		private void SetTeam(Team team)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0060: Expected O, but got Unknown
			Hashtable val = new Hashtable();
			((Dictionary<object, object>)val).Add((object)"Team", (object)team);
			((Dictionary<object, object>)val).Add((object)"OriginalRole", (object)team);
			((Dictionary<object, object>)val).Add((object)"Caught_Time", (object)"");
			((Dictionary<object, object>)val).Add((object)"Catches", (object)0);
			((Dictionary<object, object>)val).Add((object)"IsInGame", (object)true);
			Hashtable val2 = val;
			PhotonNetwork.LocalPlayer.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
			SetReady(ready: false);
			Plugin.Log.LogInfo((object)$"[TeamSelectionUI] You joined {team} team.");
		}

		private void SetReady(bool ready)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0020: Expected O, but got Unknown
			isReady = ready;
			Hashtable val = new Hashtable();
			((Dictionary<object, object>)val).Add((object)"Ready", (object)ready);
			Hashtable val2 = val;
			PhotonNetwork.LocalPlayer.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
			Plugin.Log.LogInfo((object)("[TeamSelectionUI] You are " + (ready ? "ready" : "not ready") + "."));
		}
	}
}
namespace Hide_and_PEAK.Patches
{
	public class BodypartOnCollisionEnterPatch
	{
		private static string _lastTouched = "";

		[HarmonyPatch(typeof(Bodypart), "OnCollisionEnter")]
		[HarmonyPostfix]
		private static void Postfix(Bodypart __instance, Collision collision)
		{
			if (!PhotonNetwork.IsMasterClient || (Object)(object)HideAndSeekManager.Instance == (Object)null || !HideAndSeekManager.Instance.IsGameActive)
			{
				return;
			}
			((Dictionary<object, object>)(object)__instance.character.view.Controller.CustomProperties).TryGetValue((object)"Team", out object value);
			if ((Team)value == Team.Hider || !__instance.character.input.useSecondaryIsPressed)
			{
				return;
			}
			Transform val = ((Component)collision.collider).transform;
			while ((Object)(object)val != (Object)null)
			{
				if (((Object)val).name.StartsWith("Character"))
				{
					Character component = ((Component)val).GetComponent<Character>();
					if (!component.characterName.Equals(Character.localCharacter.characterName))
					{
						Plugin.Log.LogInfo((object)$"Player: {component.characterName} touched by {__instance.character.characterName} of team {(Team)value}");
						((Dictionary<object, object>)(object)component.view.Controller.CustomProperties).TryGetValue((object)"Team", out value);
						Plugin.Log.LogInfo((object)$"Player: {component.characterName}'s team: {(Team)value}");
						if ((Team)value == Team.Hider && !component.characterName.Equals(_lastTouched))
						{
							_lastTouched = component.characterName;
							HideAndSeekManager.Instance.CatchHider(__instance.character, component);
						}
					}
					break;
				}
				val = val.parent;
			}
		}
	}
	public class CharacterDeathPosPatch
	{
		[HarmonyPatch(typeof(Character), "DeathPos")]
		[HarmonyPrefix]
		private static bool Prefix(Character __instance, ref Vector3 __result)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log.LogInfo((object)"RunManager: Death pos Patch!");
			((Dictionary<object, object>)(object)__instance.view.Controller.CustomProperties).TryGetValue((object)"Team", out object value);
			if ((Team)value == Team.Hider)
			{
				__result = __instance.Center + Vector3.up;
				Plugin.Log.LogInfo((object)$"RunManager: Death pos Patch! Hider death position set to {__result}");
				return false;
			}
			return true;
		}
	}
	public class CharacterMovementUpdatePatch
	{
		private static bool _isFrozen;

		private static float _frozenHeight;

		private static float _frozenStamina;

		[HarmonyPatch(typeof(CharacterMovement), "Update")]
		[HarmonyPostfix]
		private static void Postfix(CharacterMovement __instance)
		{
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter == (Object)null || !__instance.character.IsLocal || (Object)(object)localCharacter.refs?.ragdoll == (Object)null)
			{
				return;
			}
			if (Plugin.ConfigurationHandler.FreezeAction != null && Plugin.ConfigurationHandler.FreezeAction.WasPerformedThisFrame())
			{
				_isFrozen = !_isFrozen;
				if (_isFrozen)
				{
					_frozenHeight = localCharacter.GetBodypart((BodypartType)2).Rig.position.y;
					_frozenStamina = localCharacter.data.currentStamina;
				}
				Plugin.Log.LogInfo((object)$"[CharacterFreezePatch] Freeze toggled: {_isFrozen}");
				HideAndSeekManager instance = HideAndSeekManager.Instance;
				if (instance != null)
				{
					instance.View.RPC("RPC_SetFrozenState", (RpcTarget)0, new object[4]
					{
						localCharacter.refs.view.ViewID,
						_isFrozen,
						_frozenHeight,
						_frozenStamina
					});
				}
			}
			if (!_isFrozen)
			{
				return;
			}
			localCharacter.data.currentStamina = _frozenStamina;
			localCharacter.input.movementInput = Vector2.zero;
			localCharacter.input.jumpIsPressed = false;
			localCharacter.input.crouchIsPressed = false;
			Rigidbody rig = localCharacter.GetBodypart((BodypartType)2).Rig;
			Vector3 position = localCharacter.GetBodypart((BodypartType)2).Rig.position;
			position.y = _frozenHeight;
			rig.position = position;
			foreach (Bodypart part