BepInEx/plugins/LCF/LCF.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Authentication;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCF.Game;
using LCF.Net;
using LCF.UI;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.UI;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using WebSocketSharp;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LCF")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Lethal Company 1v1 Single Day Clear (SDC) league")]
[assembly: AssemblyFileVersion("0.2.7.0")]
[assembly: AssemblyInformationalVersion("0.2.7+f414752b46b84fcfe5c62fb175001b3218107740")]
[assembly: AssemblyProduct("LCF")]
[assembly: AssemblyTitle("LCF")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 LCF
{
	public class Core : MonoBehaviour
	{
		public static Core I;

		public readonly LcfClient Net = new LcfClient();

		public readonly RoomChatJournal RoomChat = new RoomChatJournal();

		public MatchSession Match;

		public Ui Ui;

		public GameDirector Director;

		public SpectateJoin Joiner;

		public CorpseCamera CorpseView;

		private string _rankedOffer;

		private Coroutine _rankedHandoff;

		private string _quitPartyMatchId;

		private string _partyMatchRoomCode;

		private bool _warnedNoSteam;

		private static bool _initialModNoticeChecked;

		public bool RankedQueued { get; private set; }

		public bool RankedSwitching { get; private set; }

		public void QuitPartyGame(MatchSession m)
		{
			if (m != null && Match == m)
			{
				_quitPartyMatchId = m.MatchId;
				Match = null;
				Joiner.StopForRanked();
				Ui.PartyResult.Pending = null;
				Ui.PartyResult.PendingTeamPalette = null;
				Ui.CloseAll();
				if (m.IsSpectator && !m.Decided)
				{
					Net.Send(new
					{
						t = "party_unwatch"
					});
				}
				else if (!m.Eliminated && !m.Decided && m.Phase != MatchPhase.Finished)
				{
					Net.Send(new
					{
						t = "forfeit"
					});
				}
			}
		}

		public void RequestPartyWatch()
		{
			if (Match == null && !GameDirector.InGame && !RankedSwitching)
			{
				_quitPartyMatchId = null;
				Net.Send(new
				{
					t = "party_watch"
				});
			}
		}

		public void SetRankedQueued()
		{
			RankedQueued = true;
			_rankedOffer = null;
			if (_rankedHandoff == null)
			{
				RankedSwitching = false;
			}
		}

		public void CancelRanked()
		{
			Net.Send(new
			{
				t = "cancel_ranked"
			});
			RankedQueued = false;
			_rankedOffer = null;
			if (_rankedHandoff == null)
			{
				RankedSwitching = false;
			}
		}

		private IEnumerator SwitchToRanked()
		{
			string oldMatchId = Match?.MatchId;
			string oldRoomCode = Ui.Room.State?.Code;
			Ui.DismissNotice();
			Joiner.StopForRanked();
			Match = null;
			Ui.Room.Clear();
			Ui.PartyResult.Pending = null;
			Ui.PartyResult.PendingTeamPalette = null;
			Ui.DailyResult.Hide();
			Ui.Augments.Reset();
			Director.LeaveForRanked();
			float until = Time.realtimeSinceStartup + 80f;
			while (!Director.ReadyForRanked && Time.realtimeSinceStartup < until)
			{
				yield return null;
			}
			yield return null;
			_rankedHandoff = null;
			Net.Send(new
			{
				t = "ranked_activity_left",
				match_id = oldMatchId,
				room_code = oldRoomCode
			});
			if (!Director.ReadyForRanked)
			{
				CancelRanked();
				Ui.Toast("Could not leave the current game. Ranked search cancelled.", UiKit.Bad);
			}
			else if (RankedQueued && _rankedOffer != null)
			{
				Net.Send(new
				{
					t = "ranked_switch_ready",
					offer_id = _rankedOffer
				});
			}
			else
			{
				RankedSwitching = false;
			}
		}

		private void Awake()
		{
			I = this;
			Ui = ((Component)this).gameObject.AddComponent<Ui>();
			Director = ((Component)this).gameObject.AddComponent<GameDirector>();
			Joiner = ((Component)this).gameObject.AddComponent<SpectateJoin>();
			CorpseView = ((Component)this).gameObject.AddComponent<CorpseCamera>();
			((Component)this).gameObject.AddComponent<MenuMusic>();
			Net.OnMessage += Route;
			Net.OnAuthenticated += delegate
			{
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				Ui.OnProfileChanged();
				bool flag = !_initialModNoticeChecked;
				_initialModNoticeChecked = true;
				if (!Net.IntegrityOk && Net.IntegrityIssues.Length != 0)
				{
					if (flag)
					{
						Ui.Notice(ModNotice(Net.IntegrityIssues));
					}
				}
				else if (Net.LastError != null)
				{
					Ui.Toast(Net.LastError, UiKit.Bad);
				}
				if (Ui.Room != null && Ui.Room.InRoom)
				{
					bool num = Ui.IsCurrent(((Component)Ui.Room.Root).gameObject);
					Ui.Room.Clear();
					if (num && Match == null)
					{
						Ui.ShowLobby();
					}
				}
				MatchSession match = Match;
				Proto.SetTeamPalette((match != null && match.IsParty) ? Match.TeamPalette : null);
			};
			Net.OnDisconnected += delegate
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				RoomChat.Leave();
				RankedQueued = false;
				_rankedOffer = null;
				if (_rankedHandoff == null)
				{
					RankedSwitching = false;
				}
				Ui.Toast("Disconnected from LCF server. Reconnecting...", UiKit.Bad);
			};
		}

		private void Update()
		{
			EnsureIdentity();
			Net.Tick();
			SoloMicrophone.Tick();
			Ui ui = Ui;
			PlayerActivity.Tick(ui != null && ui.Augments?.Visible == true);
			if (PlayerActivity.ConsumeWarning())
			{
				SoundFx.EventAlarm();
			}
			if (PlayerActivity.ConsumeExpired())
			{
				Director.OnAfkTimeout();
			}
		}

		private void OnApplicationQuit()
		{
			SoloMicrophone.Reset();
			PlayerActivity.Reset();
			if (Match != null && Match.InGame && Match.Phase != MatchPhase.Over)
			{
				Net.Send(new
				{
					t = "forfeit"
				});
			}
			Net.Close();
		}

		private void EnsureIdentity()
		{
			//IL_0035: 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)
			if (Net.HasIdentity || (Object)(object)GameNetworkManager.Instance == (Object)null)
			{
				return;
			}
			try
			{
				if (!GameNetworkManager.Instance.disableSteam && SteamClient.IsValid)
				{
					Net.SetIdentity(SteamClient.SteamId.Value.ToString(), SteamClient.Name);
					return;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Steam identity unavailable: " + ex.Message));
			}
			if (GameNetworkManager.Instance.disableSteam && !_warnedNoSteam)
			{
				_warnedNoSteam = true;
				Net.SetUnavailable("Steam is required for LCF (LAN mode is not supported).");
			}
		}

		public void StartLayout()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!RankedSwitching)
			{
				if (Match != null)
				{
					Ui.Toast("Leave your current game first.", UiKit.Bad);
					return;
				}
				Match = new MatchSession
				{
					MatchId = "layout",
					Kind = "layout",
					IsLayout = true,
					Me = Net.Me,
					Phase = MatchPhase.Loading,
					Settings = new GameSettings
					{
						Seed = Random.Range(1, 100000000),
						Moon = "Experimentation",
						Weather = "mild",
						Banned = new List<string> { "cruiser" }
					}
				};
				Ui.ShowLoading(Match);
				Director.BeginMatch(Match);
			}
		}

		private static bool GameShowsChatOf(string steamId)
		{
			StartOfRound instance = StartOfRound.Instance;
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if ((Object)(object)instance == (Object)null || (Object)(object)val == (Object)null || val.isPlayerDead || GameDirector.SpectatorClient || !ulong.TryParse(steamId, out var result))
			{
				return false;
			}
			PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if ((Object)(object)val2 != (Object)null && val2.playerSteamId == result && val2.isPlayerControlled)
				{
					return !val2.isPlayerDead;
				}
			}
			return false;
		}

		private static bool RoomOnlyLine(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return true;
			}
			string[] array = new string[8] { "joined the room", "left the room", "was kicked", "was banned from the room", "is the host now", "is spectating now", "is a player again", "Room settings updated" };
			foreach (string value in array)
			{
				if (text.Contains(value))
				{
					return true;
				}
			}
			return false;
		}

		private static void ApplyTeams(MatchSession match, JObject m)
		{
			ApplyTeamPalette(match, m);
			MatchSession matchSession = match;
			JToken obj = m["teams"];
			matchSession.Teams = ((obj != null) ? obj.ToObject<List<TeamInfo>>() : null) ?? new List<TeamInfo>();
			match.TeamMode = match.Teams.Count > 0;
			match.MyTeam = match.Teams.Find((TeamInfo t) => t.Members.Contains(match.Me?.SteamId ?? ""));
			match.TeamRespawn = (bool?)m["team_respawn"] == true;
			match.ScoreMode = ((string)m["score_mode"]) ?? "ship_cruiser";
			match.RespawnsLeft = (match.TeamRespawn ? ((int?)m["respawn_pool"]).GetValueOrDefault() : 0);
		}

		private static void ApplyTeamPalette(MatchSession match, JObject m)
		{
			JToken obj = m["team_palette"];
			match.TeamPalette = ((obj != null) ? obj.ToObject<List<TeamDefinition>>() : null) ?? Proto.DefaultTeamPalette();
			Proto.SetTeamPalette(match.TeamPalette);
		}

		private void OnPartyDeath(JObject m)
		{
			//IL_0081: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			if (Match != null && Match.IsParty)
			{
				string text = (string)m["steam_id"];
				string text2 = ((string)m["name"]) ?? "?";
				int? t = (int?)m["team"];
				bool valueOrDefault = (bool?)m["out"] == true;
				Color color = (t.HasValue ? UiKit.Hex(Proto.TeamColorHex(t)) : UiKit.Bad);
				string text3;
				if (t.HasValue)
				{
					int valueOrDefault2 = ((int?)m["respawns_left"]).GetValueOrDefault();
					text3 = "Team " + Proto.TeamName(t) + "  -  " + (valueOrDefault ? "no respawn left" : $"respawning  ({valueOrDefault2} left)");
				}
				else
				{
					int valueOrDefault3 = ((int?)m["deaths"]).GetValueOrDefault();
					int num = ((int?)m["lives"]) ?? Match.Lives;
					text3 = (valueOrDefault ? $"Out  ({valueOrDefault3}/{num})" : $"Deaths {valueOrDefault3}/{num}");
				}
				if (!(text == Net.Me?.SteamId))
				{
					string text4 = (t.HasValue ? Proto.TeamColorHex(t) : "#ff4d4d");
					string cause = (string)m["cause"];
					string text5 = Proto.DeathLabel(cause);
					Ui.Alert(text2.ToUpperInvariant() + " DIED" + Proto.DeathSuffix(cause), text3, color);
					Director.ShowSystemChat("<color=" + text4 + ">" + text2 + " died" + ((text5 == null) ? "" : (" (" + text5 + ")")) + " - " + text3 + "</color>");
				}
			}
		}

		private static string ModNotice(string[] issues)
		{
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			foreach (string issue in issues)
			{
				if (issue.StartsWith("other mods loaded:"))
				{
					list.AddRange(Rest("other mods loaded:").Split(','));
				}
				else if (issue.StartsWith("foreign code patches"))
				{
					Match match = Regex.Match(issue, "\\) by ([^:]+):");
					if (match.Success)
					{
						list.AddRange(match.Groups[1].Value.Split(','));
						continue;
					}
					foreach (Match item in Regex.Matches(issue, " by ([^;]+)"))
					{
						list.Add(item.Groups[1].Value);
					}
				}
				else
				{
					list2.Add(issue);
				}
				string Rest(string prefix)
				{
					return issue.Substring(prefix.Length);
				}
			}
			List<string> list3 = new List<string>();
			foreach (string item2 in list)
			{
				string text = item2.Trim().TrimEnd('.', ' ');
				if (text.Length != 0 && !(text == "..."))
				{
					if (text.StartsWith("harmony-auto-"))
					{
						text = "unknown mod (unnamed Harmony patch)";
					}
					if (!list3.Contains(text))
					{
						list3.Add(text);
					}
				}
			}
			StringBuilder stringBuilder = new StringBuilder("RANKED AND MOD-LOCKED ROOMS ARE UNAVAILABLE\n");
			if (list3.Count > 0)
			{
				stringBuilder.Append("\n<color=#c25604>NOT APPROVED:</color>\n");
				foreach (string item3 in list3)
				{
					stringBuilder.Append("<color=#fdac0d>- ").Append(item3).Append("</color>\n");
				}
			}
			foreach (string item4 in list2)
			{
				stringBuilder.Append("\n<color=#c25604>- ").Append(item4).Append("</color>");
			}
			stringBuilder.Append("\n\nDaily runs remain playable but cannot enter the leaderboard.\nRemove these mods and restart the game for ranked, or play in rooms without the mod lock.");
			return stringBuilder.ToString();
		}

		private void Route(string t, JObject m)
		{
			//IL_084d: Unknown result type (might be due to invalid IL or missing references)
			//IL_2e82: Unknown result type (might be due to invalid IL or missing references)
			//IL_25fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_2601: Invalid comparison between Unknown and I4
			//IL_1c8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_2c3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f43: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f49: Invalid comparison between Unknown and I4
			//IL_2b01: Unknown result type (might be due to invalid IL or missing references)
			//IL_274f: Unknown result type (might be due to invalid IL or missing references)
			//IL_2755: Invalid comparison between Unknown and I4
			//IL_1e5e: Unknown result type (might be due to invalid IL or missing references)
			//IL_2a28: Unknown result type (might be due to invalid IL or missing references)
			//IL_2a8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_2a83: Unknown result type (might be due to invalid IL or missing references)
			//IL_2c95: Unknown result type (might be due to invalid IL or missing references)
			//IL_2c9c: Invalid comparison between Unknown and I4
			//IL_1de0: Unknown result type (might be due to invalid IL or missing references)
			//IL_1f71: Unknown result type (might be due to invalid IL or missing references)
			//IL_290b: Unknown result type (might be due to invalid IL or missing references)
			//IL_2b92: Unknown result type (might be due to invalid IL or missing references)
			//IL_2b8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_20dc: Unknown result type (might be due to invalid IL or missing references)
			switch (t)
			{
			case "party_setup":
			case "party_start":
			case "party_watch":
			case "party_result":
				if (_quitPartyMatchId != null && (string)m["match_id"] == _quitPartyMatchId)
				{
					return;
				}
				break;
			}
			if (RankedSwitching && t != "ranked_offer" && t != "queued" && t != "ranked_queue_left" && t != "match_found" && t != "server_notice" && t != "server_shutdown" && t != "error" && t != "welcome" && t != "pong")
			{
				return;
			}
			if (t == null)
			{
				return;
			}
			switch (t.Length)
			{
			case 12:
				switch (t[2])
				{
				case 'n':
					if (!(t == "ranked_offer"))
					{
						break;
					}
					if (!RankedQueued)
					{
						Net.Send(new
						{
							t = "cancel_ranked"
						});
						break;
					}
					RankedQueued = true;
					RankedSwitching = true;
					_rankedOffer = (string)m["offer_id"];
					if (_rankedHandoff == null)
					{
						_rankedHandoff = ((MonoBehaviour)this).StartCoroutine(SwitchToRanked());
					}
					break;
				case 'i':
					if (t == "daily_result")
					{
						if (Match != null && Match.IsDaily)
						{
							Match.Phase = MatchPhase.Over;
							Director.OnMatchOver();
						}
						Ui.DailyResult.Show(m);
					}
					break;
				case 'r':
					if (!(t == "party_scores"))
					{
						if (!(t == "party_result"))
						{
							break;
						}
						PartyResultScreen partyResult = Ui.PartyResult;
						JToken obj30 = m["team_palette"];
						partyResult.PendingTeamPalette = ((obj30 != null) ? obj30.ToObject<List<TeamDefinition>>() : null) ?? Proto.DefaultTeamPalette();
						Proto.SetTeamPalette(Ui.PartyResult.PendingTeamPalette);
						JToken obj31 = m["standings"];
						List<Standing> list5 = ((obj31 != null) ? obj31.ToObject<List<Standing>>() : null) ?? new List<Standing>();
						Ui.PartyResult.Pending = list5;
						if (Match != null && Match.IsParty && Match.MatchId == (string)m["match_id"])
						{
							Match.Standings = list5;
							Match.Phase = MatchPhase.Over;
							Director.OnMatchOver();
							if (GameDirector.InGame)
							{
								Director.LeaveToMenu();
								break;
							}
							Match = null;
							Ui.ShowRoom();
						}
					}
					else if (Match != null && Match.IsParty)
					{
						MatchSession match4 = Match;
						JToken obj32 = m["players"];
						match4.Scores = ((obj32 != null) ? obj32.ToObject<List<PartyPlayerState>>() : null) ?? Match.Scores;
					}
					break;
				case 'o':
					if (t == "room_created")
					{
						Ui ui = Ui;
						string code = (string)m["code"];
						string kind = (string)m["kind"];
						JToken obj29 = m["options"];
						ui.ShowWaiting(code, kind, (obj29 != null) ? obj29.ToObject<RoomOptions>() : null);
					}
					break;
				case 'e':
					if (t == "event_rolled")
					{
						SetupScreen setup4 = Ui.Setup;
						bool triggered = (bool)m["triggered"];
						JToken obj25 = m["event"];
						object ev;
						if (obj25 == null || (int)obj25.Type != 10)
						{
							JToken obj26 = m["event"];
							ev = ((obj26 != null) ? obj26.ToObject<GameEvent>() : null);
						}
						else
						{
							ev = null;
						}
						JToken obj27 = m["pool"];
						string[] pool = ((obj27 != null) ? obj27.ToObject<string[]>() : null) ?? new string[0];
						bool valueOrDefault4 = (bool?)m["fixed"] == true;
						JToken obj28 = m["extra"];
						setup4.EventRolled(triggered, (GameEvent)ev, pool, valueOrDefault4, ((obj28 != null) ? obj28.ToObject<List<GameEvent>>() : null) ?? new List<GameEvent>());
					}
					break;
				case 't':
					if (t == "match_result")
					{
						MatchResult matchResult = ((JToken)m).ToObject<MatchResult>();
						string text9 = (string)m["note"];
						if (!string.IsNullOrEmpty(text9))
						{
							Ui.Toast(text9, UiKit.Blue);
						}
						if (matchResult.Profile != null)
						{
							Net.Me = matchResult.Profile;
						}
						if (Match == null)
						{
							Ui.Toast((matchResult.Result == "win") ? "Your last match: WIN" : ((matchResult.Result == "draw") ? "Your last match: DRAW" : ("Your last match: LOSS (" + matchResult.Reason + ")")), (matchResult.Result == "win") ? UiKit.Gold : UiKit.Bad);
							Ui.OnProfileChanged();
							break;
						}
						Match.Result = matchResult;
						Match.Phase = MatchPhase.Over;
						Director.OnMatchOver();
						Ui.ShowResult(Match);
					}
					break;
				}
				break;
			case 17:
				switch (t[0])
				{
				case 'r':
					if (t == "ranked_queue_left")
					{
						RankedQueued = false;
						_rankedOffer = null;
						if (_rankedHandoff == null)
						{
							RankedSwitching = false;
						}
					}
					break;
				case 'm':
					if (t == "moon_choice_phase" && Match != null)
					{
						SetupScreen setup3 = Ui.Setup;
						JToken obj24 = m["pool"];
						setup3.MoonChoicePhase(((obj24 != null) ? obj24.ToObject<string[]>() : null) ?? new string[0], (float)(((long?)m["timeout_ms"]) ?? 20000) / 1000f);
					}
					break;
				case 'o':
					if (t == "opponent_finished" && Match != null)
					{
						Match.OppFinished = true;
						Match.OppScore = (long)m["score"];
						Ui.Alert(Match.Opponent?.Name + " LEFT THE MOON", "Final: " + UiKit.Money(Match.OppScore), UiKit.Gold);
					}
					break;
				}
				break;
			case 5:
				switch (t[0])
				{
				case 'e':
					if (t == "error")
					{
						Ui.Toast((string)m["message"], UiKit.Bad);
					}
					break;
				case 'r':
					if (t == "rooms")
					{
						LobbyScreen lobby2 = Ui.Lobby;
						JToken obj23 = m["rooms"];
						lobby2.SetRooms(((obj23 != null) ? obj23.ToObject<RoomInfo[]>() : null) ?? new RoomInfo[0]);
					}
					break;
				}
				break;
			case 11:
				switch (t[6])
				{
				case 's':
					switch (t)
					{
					case "lobby_stats":
						Ui.Lobby.SetStats(((int?)m["searching"]).GetValueOrDefault(), ((int?)m["playing"]).GetValueOrDefault(), ((int?)m["rooms"]).GetValueOrDefault(), ((int?)m["online"]).GetValueOrDefault());
						Ui.Lobby.SetQuickStats(((int?)m["quick_members"]) ?? (-1), ((int?)m["quick_playing"]).GetValueOrDefault());
						break;
					case "party_state":
					{
						PartyState partyState = ((JToken)m).ToObject<PartyState>();
						Ui.Room.SetState(partyState);
						if (Match != null && Match.IsParty && Match.Phase != MatchPhase.Over && partyState.InGame && !string.IsNullOrEmpty(_partyMatchRoomCode) && partyState.Code == _partyMatchRoomCode)
						{
							List<Profile> list3 = new List<Profile>();
							foreach (PartyMember member in partyState.Members)
							{
								Profile profile2 = member?.Profile;
								if (string.IsNullOrEmpty(profile2?.SteamId))
								{
									continue;
								}
								int num2 = Match.PartyPlayers.FindIndex((Profile p) => p?.SteamId == profile2.SteamId);
								if (num2 >= 0)
								{
									Match.PartyPlayers[num2] = profile2;
									if (Match.Me?.SteamId == profile2.SteamId)
									{
										Match.Me = profile2;
									}
									if (Match.Opponent?.SteamId == profile2.SteamId)
									{
										Match.Opponent = profile2;
									}
									list3.Add(profile2);
								}
							}
							foreach (Profile item in list3)
							{
								Ui.RefreshOpenProfile(item);
							}
						}
						if (Match == null && !Ui.ResultOpen)
						{
							Ui.ShowRoom();
						}
						break;
					}
					case "party_setup":
					{
						JToken obj18 = m["players"];
						List<Profile> list4 = ((obj18 != null) ? obj18.ToObject<List<Profile>>() : null) ?? new List<Profile>();
						bool valueOrDefault3 = (bool?)m["spectator"] == true;
						if (valueOrDefault3 || list4.Exists((Profile p) => p.SteamId == Net.Me?.SteamId))
						{
							_partyMatchRoomCode = Ui.Room.State?.Code;
							MatchSession obj19 = new MatchSession
							{
								MatchId = (string)m["match_id"],
								Kind = (((string)m["kind"]) ?? "custom"),
								IsParty = true,
								IsSpectator = valueOrDefault3,
								Me = (list4.Find((Profile p) => p.SteamId == Net.Me?.SteamId) ?? Net.Me),
								PartyPlayers = list4,
								Lives = (((int?)m["lives"]) ?? 3),
								BanCount = (((int?)m["ban_count"]) ?? 1),
								Phase = MatchPhase.Setup
							};
							JToken obj20 = m["captains"];
							obj19.Captains = ((obj20 != null) ? obj20.ToObject<List<string>>() : null) ?? new List<string>();
							Match = obj19;
							Match.TeamMode = Match.Captains.Count > 0;
							ApplyTeamPalette(Match, m);
							MatchSession match3 = Match;
							JToken obj21 = m["teams"];
							match3.Teams = ((obj21 != null) ? obj21.ToObject<List<TeamInfo>>() : null) ?? new List<TeamInfo>();
							Match.MyTeam = Match.Teams.Find((TeamInfo teamInfo) => teamInfo.Members.Contains(Match.Me?.SteamId ?? ""));
							Match.VersusMs = ((int?)m["versus_ms"]).GetValueOrDefault();
							if (Match.VersusMs > 0 && Match.TwoSides)
							{
								Match.Phase = MatchPhase.Found;
								Ui.ShowVersus(Match, (float)Match.VersusMs / 1000f);
							}
							else if (valueOrDefault3)
							{
								Ui.Setup.WaitForSetup();
							}
						}
						break;
					}
					case "party_start":
					{
						if (Match != null && Match.IsParty && !Match.IsSpectator && Match.MatchId == (string)m["match_id"])
						{
							MatchSession match2 = Match;
							JToken obj14 = m["settings"];
							match2.Settings = ((obj14 != null) ? obj14.ToObject<GameSettings>() : null);
							Match.Lives = ((int?)m["lives"]) ?? Match.Lives;
							Match.Phase = MatchPhase.Loading;
							ApplyTeams(Match, m);
							MatchSession starting2 = Match;
							Ui.Setup.CloseThen(delegate
							{
								if (Match == starting2 && !RankedSwitching)
								{
									Ui.ShowLoading(starting2);
									if (starting2.IsCaptain)
									{
										Director.BeginMatch(starting2);
									}
									else
									{
										Ui.SetLoadingStatus("Waiting for your captain to open the ship...");
									}
								}
							});
							break;
						}
						JToken obj15 = m["players"];
						List<Profile> list2 = ((obj15 != null) ? obj15.ToObject<List<Profile>>() : null) ?? new List<Profile>();
						if (list2.Exists((Profile p) => p.SteamId == Net.Me?.SteamId))
						{
							_partyMatchRoomCode = Ui.Room.State?.Code;
							MatchSession obj16 = new MatchSession
							{
								MatchId = (string)m["match_id"],
								Kind = (((string)m["kind"]) ?? "custom"),
								IsParty = true,
								Me = (list2.Find((Profile p) => p.SteamId == Net.Me?.SteamId) ?? Net.Me),
								PartyPlayers = list2,
								Lives = (((int?)m["lives"]) ?? 3)
							};
							JToken obj17 = m["settings"];
							obj16.Settings = ((obj17 != null) ? obj17.ToObject<GameSettings>() : null);
							obj16.Phase = MatchPhase.Loading;
							Match = obj16;
							ApplyTeams(Match, m);
							Ui.ShowLoading(Match);
							Director.BeginMatch(Match);
						}
						break;
					}
					}
					break;
				case 'd':
					if (t == "party_death")
					{
						OnPartyDeath(m);
					}
					break;
				case 'w':
				{
					if (!(t == "party_watch"))
					{
						break;
					}
					bool flag3 = Match != null && Match.IsParty && Match.IsSpectator && Match.MatchId == (string)m["match_id"] && (Match.Phase == MatchPhase.Setup || Match.Phase == MatchPhase.Found);
					if ((Match != null && !flag3) || GameDirector.InGame)
					{
						break;
					}
					JToken obj10 = m["players"];
					List<Profile> partyPlayers = ((obj10 != null) ? obj10.ToObject<List<Profile>>() : null) ?? new List<Profile>();
					_partyMatchRoomCode = Ui.Room.State?.Code;
					MatchSession obj11 = new MatchSession
					{
						MatchId = (string)m["match_id"],
						Kind = (((string)m["kind"]) ?? "custom"),
						IsParty = true,
						IsSpectator = true,
						Me = Net.Me,
						PartyPlayers = partyPlayers,
						Lives = (((int?)m["lives"]) ?? 3)
					};
					JToken obj12 = m["settings"];
					obj11.Settings = ((obj12 != null) ? obj12.ToObject<GameSettings>() : null);
					obj11.ScoreMode = ((string)m["score_mode"]) ?? "ship_cruiser";
					obj11.Phase = MatchPhase.Loading;
					Match = obj11;
					ApplyTeamPalette(Match, m);
					MatchSession match = Match;
					JToken obj13 = m["teams"];
					match.Teams = ((obj13 != null) ? obj13.ToObject<List<TeamInfo>>() : null) ?? new List<TeamInfo>();
					Match.TeamMode = Match.Teams.Count > 0;
					MatchSession watching = Match;
					Ui.Setup.CloseThen(delegate
					{
						if (Match == watching && !RankedSwitching)
						{
							Ui.ShowLoading(watching);
							Joiner.Begin(watching);
						}
					});
					break;
				}
				case 'b':
					if (t == "leaderboard")
					{
						LobbyScreen lobby = Ui.Lobby;
						JToken obj22 = m["entries"];
						lobby.SetLeaderboard(((obj22 != null) ? obj22.ToObject<LeaderboardEntry[]>() : null) ?? new LeaderboardEntry[0], ((int?)m["total"]).GetValueOrDefault());
					}
					break;
				case 'f':
					if (t == "match_found")
					{
						if ((string)m["kind"] == "ranked")
						{
							bool rankedQueued = (RankedSwitching = false);
							RankedQueued = rankedQueued;
							_rankedOffer = null;
						}
						if (GameDirector.InGame)
						{
							Director.LeaveForSpectate();
						}
						MatchSession obj7 = new MatchSession
						{
							MatchId = (string)m["match_id"],
							Kind = (string)m["kind"]
						};
						JToken obj8 = m["you"];
						obj7.Me = ((obj8 != null) ? obj8.ToObject<Profile>() : null);
						JToken obj9 = m["opponent"];
						obj7.Opponent = ((obj9 != null) ? obj9.ToObject<Profile>() : null);
						obj7.Phase = MatchPhase.Found;
						Match = obj7;
						Ui.ShowVersus(Match, (float)(((long?)m["delay_ms"]) ?? 3500) / 1000f);
					}
					break;
				case 'o':
					if (t == "moon_rolled" && Match != null)
					{
						Match.Phase = MatchPhase.Setup;
						SetupScreen setup2 = Ui.Setup;
						string moon = (string)m["moon"];
						JToken obj6 = m["pool"];
						setup2.MoonRolled(moon, (obj6 != null) ? obj6.ToObject<string[]>() : null, (int)m["rerolls_left"], (bool)m["can_vote"], (float)(((long?)m["vote_timeout_ms"]) ?? 20000) / 1000f, (bool?)m["fixed"] == true);
					}
					break;
				}
				break;
			case 14:
				switch (t[9])
				{
				case 'o':
				{
					if (!(t == "player_profile"))
					{
						break;
					}
					JToken obj = m["profile"];
					Profile profile = ((obj != null) ? obj.ToObject<Profile>() : null);
					if (profile == null)
					{
						break;
					}
					if (!string.IsNullOrEmpty(profile.SteamId) && profile.SteamId == Net.Me?.SteamId)
					{
						Net.Me = profile;
						Ui.OnProfileChanged();
					}
					if ((bool?)m["updated"] == true)
					{
						if (Match != null)
						{
							if (Match.Me?.SteamId == profile.SteamId)
							{
								Match.Me = profile;
							}
							if (Match.Opponent?.SteamId == profile.SteamId)
							{
								Match.Opponent = profile;
							}
							for (int i = 0; i < Match.PartyPlayers.Count; i++)
							{
								if (Match.PartyPlayers[i]?.SteamId == profile.SteamId)
								{
									Match.PartyPlayers[i] = profile;
								}
							}
						}
						Ui.RefreshOpenProfile(profile);
					}
					else
					{
						Ui.Lobby.ShowProfile(profile);
					}
					break;
				}
				case 'i':
					if (t == "augment_picked" && Match != null && !Match.IsSpectator && Match.Settings?.Mode == "augment" && Match.MatchId == (string)m["match_id"])
					{
						AugmentPicked augmentPicked = ((JToken)m).ToObject<AugmentPicked>();
						Match.SelectedAugments = new List<string>(augmentPicked.Selected);
						AugmentRules.SetSelected(Match.SelectedAugments);
						Ui.Augments?.Picked(augmentPicked);
					}
					break;
				case 'c':
					if (t == "party_watchers")
					{
						SpectateJoin joiner = Joiner;
						string matchId = (string)m["match_id"];
						JToken obj2 = m["watchers"];
						joiner.SetWatchers(matchId, (obj2 != null) ? obj2.ToObject<List<string>>() : null);
					}
					break;
				case 't':
					if (t == "rematch_status")
					{
						Ui.Result.SetRematch((bool?)m["you"] == true, (bool?)m["opponent"] == true, (bool?)m["available"] == true);
					}
					break;
				case 'd':
					if (t == "opponent_death" && Match != null)
					{
						Match.OppDeaths = (int)m["deaths"];
						string text3 = Proto.DeathLabel((string)m["cause"]);
						bool flag = Match.OppDeaths >= Match.Lives;
						Ui.Alert(Match.Opponent?.Name + " DIED" + Proto.DeathSuffix((string)m["cause"]), (!flag) ? $"Deaths {Match.OppDeaths}/{Match.Lives}" : (Match.Eliminated ? "Both out of lives" : "OUT OF LIVES  -  leave the moon alive to win"), UiKit.Bad);
						Director.ShowSystemChat(string.Format("<color=#ff4d4d>{0} died{1} ({2}/{3})</color>", Match.Opponent?.Name, (text3 == null) ? "" : (" (" + text3 + ")"), Match.OppDeaths, Match.Lives));
					}
					break;
				case 's':
					if (t == "opponent_score" && Match != null)
					{
						Match.OppScore = (long)m["value"];
					}
					break;
				}
				break;
			case 10:
				switch (t[6])
				{
				case 'i':
					if (!(t == "daily_info"))
					{
						if (t == "moon_final")
						{
							Ui.Setup.MoonFinal((string)m["moon"]);
						}
					}
					else
					{
						Ui.Lobby.Daily?.Set(m);
					}
					break;
				case 'p':
				{
					if (!(t == "daily_pace") || Match == null || !Match.IsDaily)
					{
						break;
					}
					JToken obj4 = m["entries"];
					JArray val = (JArray)(object)((obj4 is JArray) ? obj4 : null);
					if (val == null)
					{
						break;
					}
					List<DailyPace.Entry> list = new List<DailyPace.Entry>();
					foreach (JToken item2 in val)
					{
						list.Add(new DailyPace.Entry
						{
							SteamId = (string)item2[(object)"steam_id"],
							Name = (string)item2[(object)"name"],
							Score = ((long?)item2[(object)"score"]).GetValueOrDefault()
						});
					}
					Match.DailyPace.Apply((string)m["match_id"], (string)m["day"], (bool?)m["first"] == true, list);
					break;
				}
				case 'c':
				{
					if (!(t == "party_chat"))
					{
						break;
					}
					string text5 = (string)m["name"];
					string text6 = (string)m["text"];
					bool valueOrDefault2 = (bool?)m["system"] == true;
					if (valueOrDefault2 && text6 == "Room settings updated")
					{
						break;
					}
					JToken obj5 = m["prefix"];
					string text7 = UiKit.PrefixSpace((obj5 != null && (int)obj5.Type == 1) ? m["prefix"].ToObject<NamePrefix>() : null);
					RoomChatHud.Ensure(HUDManager.Instance);
					string sender = (string)m["steam_id"];
					int? team = (int?)m["team"];
					bool spectator = (Ui.Room.State?.Members.Find((PartyMember x) => x.Profile?.SteamId == sender))?.Spectator ?? (Match != null && Match.IsParty && sender != null && Match.PartyProfile(sender) == null);
					RoomChat.Add(sender, text5, text6, valueOrDefault2, text7, team, sender == Net.Me?.SteamId, spectator, !valueOrDefault2 || !RoomOnlyLine(text6));
					Ui.Room.SyncChat();
					Ui.Setup.SyncRoomChat();
					Ui.PartyResult.SyncRoomChat();
					if (Match == null || !Match.IsParty || !GameDirector.InGame)
					{
						break;
					}
					string text8 = (string)m["steam_id"];
					int? team2 = (int?)m["team"];
					if (valueOrDefault2)
					{
						if (!RoomOnlyLine(text6))
						{
							Director.ShowSystemChat("<color=#ffd34d>" + text6 + "</color>");
						}
					}
					else if (!(text8 == Net.Me?.SteamId) && (text8 != null || !(text5 == Net.Me?.Name)) && (!Match.TeamMode || Match.MyTeam == null || !Match.MyTeam.Members.Contains(text8 ?? "") || !GameShowsChatOf(text8)))
					{
						Director.ShowOpponentChat(text7 + SpectatorChat.Name(text5, text8, team2), text6);
					}
					break;
				}
				case 'e':
					if (t == "team_death" && Match != null && Match.TeamMode)
					{
						Match.RespawnsLeft = ((int?)m["respawns_left"]) ?? Match.RespawnsLeft;
						Director.OnTeamDeath((string)m["steam_id"], (string)m["name"], (bool?)m["revive"] == true);
					}
					break;
				case 'l':
					if (t == "party_left")
					{
						Ui.Room.Clear();
						Ui.PartyResult.Pending = null;
						Ui.PartyResult.PendingTeamPalette = null;
						string text4 = (string)m["reason"];
						if (!string.IsNullOrEmpty(text4))
						{
							Ui.Toast(text4, UiKit.Bad);
						}
						if (Match == null)
						{
							Ui.ShowLobby();
						}
					}
					break;
				case 'a':
					if (t == "ban_status")
					{
						SetupScreen setup = Ui.Setup;
						bool opponentPicked = (bool)m["opponent_picked"];
						int? picked = (int?)m["picked"];
						int? total = (int?)m["total"];
						JToken obj3 = m["picks"];
						setup.BanStatus(opponentPicked, picked, total, (obj3 != null) ? obj3.ToObject<List<PlayerPick>>() : null);
					}
					break;
				case 't':
				{
					if (!(t == "game_start"))
					{
						break;
					}
					if (Match == null || Match.IsSpectator)
					{
						break;
					}
					Match.Settings = m["settings"].ToObject<GameSettings>();
					if (Match.Settings != null && Match.Settings.Lives > 0)
					{
						Match.Lives = Match.Settings.Lives;
					}
					Match.Phase = MatchPhase.Loading;
					MatchSession starting = Match;
					Ui.Setup.CloseThen(delegate
					{
						if (Match == starting && !RankedSwitching)
						{
							Ui.ShowLoading(starting);
							Director.BeginMatch(starting);
						}
					});
					break;
				}
				}
				break;
			case 15:
				switch (t[0])
				{
				case 'j':
					if (t == "join_team_lobby" && Match != null && !Match.IsSpectator && Match.TeamMode && !Match.IsCaptain)
					{
						Director.JoinTeamGame((string)m["lobby_id"], (string)m["captain"]);
					}
					break;
				case 's':
					if (t == "server_shutdown")
					{
						RankedQueued = false;
						_rankedOffer = null;
						string text2 = ((string)m["message"]) ?? "The LCF server is shutting down.";
						bool inGame = GameDirector.InGame;
						Match = null;
						if (inGame)
						{
							Director.AbortToMenu(text2);
							break;
						}
						Ui.Toast(text2, UiKit.Bad);
						Ui.ShowLobby();
					}
					break;
				case 'm':
					if (t == "match_cancelled")
					{
						string text = (string)m["reason"];
						if (Match != null && GameDirector.InGame)
						{
							Match = null;
							Director.AbortToMenu("Match cancelled: " + text);
						}
						else
						{
							Match = null;
							Ui.ShowLobby();
							Ui.Toast("Match cancelled: " + text, UiKit.Bad);
						}
					}
					break;
				}
				break;
			case 13:
				switch (t[2])
				{
				case 'g':
					if (t == "augment_offer" && Match != null && !Match.IsSpectator && Match.Settings?.Mode == "augment")
					{
						Ui.Augments?.Offer(((JToken)m).ToObject<AugmentOffer>());
					}
					break;
				case 'r':
					if (t == "server_notice")
					{
						string text13 = ((string)m["message"]) ?? "";
						long? num4 = (long?)m["shutdown_in"];
						string title = (num4.HasValue ? $"SERVER RESTART IN {Math.Max(1L, (num4.Value + 59) / 60)} MIN" : "SERVER NOTICE");
						Ui.Alert(title, text13, UiKit.Gold);
						if (GameDirector.InGame)
						{
							Director.ShowSystemChat("<color=#ffd34d>[LCF] " + text13 + "</color>");
						}
					}
					break;
				case 'e':
					if (t == "seed_rerolled" && Match != null && !Match.IsParty)
					{
						MatchSession match5 = Match;
						JToken obj47 = m["settings"];
						match5.Settings = ((obj47 != null) ? obj47.ToObject<GameSettings>() : null) ?? Match.Settings;
						Match.SeedRerollsLeft = ((int?)m["rerolls_left"]) ?? (Match.SeedRerollsLeft - 1);
						Match.MySeedVoteUntil = (Match.OppSeedVoteUntil = 0f);
						Match.MyDeaths = (Match.OppDeaths = 0);
						Match.MyScore = (Match.OppScore = 0L);
						Match.OppFinished = false;
						Match.Eliminated = false;
						Match.Hurt = false;
						Match.Phase = MatchPhase.Loading;
						Ui.Alert("NEW SEED", "Both voted: restarting on " + Match.Settings?.Moon + " with a new map...", UiKit.Gold);
						Director.RestartWithNewSeed();
					}
					break;
				case 'n':
					if (t == "bans_revealed")
					{
						SetupScreen setup9 = Ui.Setup;
						string yours = (string)m["your_ban"];
						string theirs = (string)m["opponent_ban"];
						JToken obj43 = m["banned"];
						string[] banned = ((obj43 != null) ? obj43.ToObject<string[]>() : null) ?? new string[0];
						JToken obj44 = m["tally"];
						List<ToolVotes> tally = ((obj44 != null) ? obj44.ToObject<List<ToolVotes>>() : null);
						JToken obj45 = m["tie"];
						string[] tie2 = ((obj45 != null) ? obj45.ToObject<string[]>() : null);
						JToken obj46 = m["picks"];
						setup9.BansRevealed(yours, theirs, banned, tally, tie2, (obj46 != null) ? obj46.ToObject<List<PlayerPick>>() : null);
					}
					break;
				case 'p':
					if (t == "opponent_chat")
					{
						JToken obj42 = m["prefix"];
						string text11 = UiKit.PrefixSpace((obj42 != null && (int)obj42.Type == 1) ? m["prefix"].ToObject<NamePrefix>() : null);
						string text12 = (((string)m["name"]) ?? "").Replace("<", "").Replace(">", "");
						if (!Ui.Setup.AddChat(text12, (string)m["text"], mine: false, text11) && !Ui.Result.AddChat(text12, (string)m["text"], text11))
						{
							Director.ShowOpponentChat(text11 + "<color=#ff3b1f>" + text12 + "</color>", (string)m["text"]);
						}
					}
					break;
				}
				break;
			case 19:
				switch (t[0])
				{
				case 'p':
					if (t == "party_update_result")
					{
						Ui.Room.SettingsApplied((string)m["request_id"]);
					}
					break;
				case 'o':
					if (t == "opponent_connection" && Match != null)
					{
						Match.OppConnected = (bool)m["connected"];
						Ui.Toast(Match.OppConnected ? "Opponent reconnected." : "Opponent disconnected (90s to come back).", Match.OppConnected ? UiKit.Good : UiKit.Bad);
					}
					break;
				}
				break;
			case 6:
				switch (t[0])
				{
				case 'q':
					if (t == "queued")
					{
						if ((string)m["kind"] == "ranked")
						{
							SetRankedQueued();
						}
						else
						{
							Ui.ShowWaiting(null, "quick");
						}
					}
					break;
				case 'r':
					if (!(t == "resume"))
					{
						break;
					}
					if (Match != null && Match.IsDaily && Match.MatchId == (string)m["match_id"])
					{
						JToken obj41 = m["daily_first"];
						if (obj41 != null && (int)obj41.Type == 9)
						{
							Match.DailyPace.Start(Match.MatchId, (string)m["daily_day"], (bool?)m["daily_first"]);
						}
					}
					if (Match != null && Match.MatchId == (string)m["match_id"] && Match.Eliminated)
					{
						Match.OppDeaths = (int)m["opponent_deaths"];
						Match.OppScore = (long)m["opponent_score"];
					}
					else if (Match != null && Match.MatchId == (string)m["match_id"] && GameDirector.HostedMatch)
					{
						Match.MyDeaths = (int)m["your_deaths"];
						Match.OppDeaths = (int)m["opponent_deaths"];
						Match.OppScore = (long)m["opponent_score"];
						if ((bool)m["started"])
						{
							Director.OnResumed();
						}
						else
						{
							Net.Send(new
							{
								t = "ready",
								integrity = Integrity.Snapshot(),
								baseline = Watchdog.BaselineObject
							});
						}
					}
					else
					{
						Net.Send(new
						{
							t = "forfeit"
						});
					}
					break;
				}
				break;
			case 16:
				switch (t[0])
				{
				case 's':
					if (t == "seed_reroll_vote" && Match != null && !Match.IsParty)
					{
						float num3 = (float)(((long?)m["timeout_ms"]) ?? 60000) / 1000f;
						string text10 = ((string)m["name"]) ?? "Opponent";
						if ((bool?)m["mine"] == true)
						{
							Match.MySeedVoteUntil = Time.realtimeSinceStartup + num3;
							Director.ShowSystemChat($"<color=#ffd34d>Seed reroll vote sent. Waiting for {text10} ({num3:0}s).</color>");
						}
						else
						{
							Match.OppSeedVoteUntil = Time.realtimeSinceStartup + num3;
							Ui.Alert(text10.ToUpperInvariant() + " WANTS A NEW SEED", $"ESC  >  vote within {num3:0}s to restart on a new map (same moon, bans and events)", UiKit.Gold);
							Director.ShowSystemChat($"<color=#ffd34d>{text10} wants to reroll the seed. Press ESC and vote within {num3:0}s.</color>");
						}
					}
					break;
				case 'm':
					if (t == "moon_vote_status")
					{
						SetupScreen setup8 = Ui.Setup;
						bool? you = (bool?)m["you"];
						bool opponentVoted = (bool)m["opponent_voted"];
						int? voted = (int?)m["voted"];
						int? total2 = (int?)m["total"];
						JToken obj40 = m["votes"];
						setup8.MoonVoteStatus(you, opponentVoted, voted, total2, (obj40 != null) ? obj40.ToObject<List<PlayerVote>>() : null);
					}
					break;
				}
				break;
			case 18:
				switch (t[12])
				{
				case 's':
					if (t == "moon_choice_status" && Match != null)
					{
						SetupScreen setup7 = Ui.Setup;
						JToken obj39 = m["votes"];
						setup7.MoonChoiceStatus((obj39 != null) ? obj39.ToObject<List<PlayerMoonChoice>>() : null);
					}
					break;
				case 'r':
					if (t == "moon_choice_result" && Match != null)
					{
						SetupScreen setup6 = Ui.Setup;
						string moon2 = (string)m["moon"];
						JToken obj37 = m["tie"];
						string[] tie = ((obj37 != null) ? obj37.ToObject<string[]>() : null) ?? new string[0];
						JToken obj38 = m["votes"];
						setup6.MoonChoiceResult(moon2, tie, (obj38 != null) ? obj38.ToObject<List<PlayerMoonChoice>>() : null);
					}
					break;
				}
				break;
			case 9:
				switch (t[0])
				{
				case 'b':
					if (t == "ban_phase")
					{
						SetupScreen setup5 = Ui.Setup;
						JToken obj36 = m["tools"];
						setup5.BanPhase(((obj36 != null) ? obj36.ToObject<string[]>() : null) ?? Proto.Tools, (float)(((long?)m["timeout_ms"]) ?? 30000) / 1000f, (bool?)m["secret_vote"] == true);
					}
					break;
				case 'd':
					if (t == "death_ack" && Match != null)
					{
						Match.MyDeaths = (int)m["deaths"];
						if ((bool)m["eliminated"])
						{
							Director.OnEliminated();
						}
					}
					break;
				case 'm':
					if (t == "my_badges")
					{
						JToken obj33 = m["worn"];
						long?[] worn = ((obj33 != null) ? obj33.ToObject<long?[]>() : null) ?? new long?[2];
						if (Net.Me != null)
						{
							Net.Me.Worn = worn;
							Profile me = Net.Me;
							JToken obj34 = m["prefix"];
							me.Prefix = ((obj34 != null) ? obj34.ToObject<NamePrefix>() : null);
							Ui.OnProfileChanged();
						}
						LobbyScreen lobby3 = Ui.Lobby;
						JToken obj35 = m["badges"];
						lobby3.SetMyBadges(((obj35 != null) ? obj35.ToObject<List<BadgeRef>>() : null) ?? new List<BadgeRef>(), worn);
					}
					break;
				}
				break;
			case 8:
				if (t == "daily_go")
				{
					Match = new MatchSession
					{
						MatchId = (string)m["match_id"],
						Kind = "daily",
						Me = Net.Me,
						Lives = (((int?)m["lives"]) ?? 3),
						Phase = MatchPhase.Loading
					};
					Match.DailyPace.Start(Match.MatchId, (string)m["day"], (bool?)m["first"]);
				}
				break;
			case 4:
				if (t == "left" && Match == null)
				{
					Ui.ShowLobby();
				}
				break;
			case 2:
				if (t == "go")
				{
					Director.OnGo();
				}
				break;
			case 7:
				if (t == "welcome")
				{
					Ui.OnProfileChanged();
					long? num = (long?)m["shutdown_in"];
					if (num.HasValue)
					{
						long valueOrDefault = num.GetValueOrDefault();
						Ui.Alert($"SERVER RESTART IN {Math.Max(1L, (valueOrDefault + 59) / 60)} MIN", "Running games go on; no new games can start.", UiKit.Gold);
					}
					RemoteIcons.Refresh();
				}
				break;
			case 3:
				break;
			}
		}
	}
	[BepInPlugin("asta.lcf", "LCF", "0.2.7")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "asta.lcf";

		public const string Name = "LCF";

		public const string Version = "0.2.7";

		public const float RespawnDelay = 4f;

		public const int RespawnHealth = 20;

		internal static Plugin Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<string> ServerUrl;

		internal static ConfigEntry<bool> DevMode;

		internal static ConfigEntry<bool> StreamerMode;

		internal static ConfigEntry<string> Language;

		private static Assembly _wsAssembly;

		private void Awake()
		{
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			AppDomain.CurrentDomain.AssemblyResolve += ResolveEmbedded;
			ServerUrl = ((BaseUnityPlugin)this).Config.Bind<string>("Server", "Url", "wss://lcf.asta.rs/ws", "WebSocket URL of the LCF backend (lcf-be).");
			if (ServerUrl.Value == "ws://f.asta.rs:2897/ws")
			{
				ServerUrl.Value = "wss://lcf.asta.rs/ws";
			}
			DevMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Dev", "Enabled", false, "Developer mode: adds 'SOLO TEST' to Create room (play alone vs a server bot, unrated, not recorded).");
			StreamerMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Privacy", "StreamerMode", false, "Hide room codes as ???? on screen. Clicking a room code still copies the real code.");
			Language = ((BaseUnityPlugin)this).Config.Bind<string>("Interface", "Language", "en", "LCF interface language: en, ko, ru, fr or ja. Change it at the lower right of the main menu.");
			Localization.Initialize(Path.Combine(Path.GetDirectoryName(typeof(Plugin).Assembly.Location) ?? "", "assets", "i18n"), Language.Value, delegate(string selected)
			{
				Language.Value = selected;
			}, delegate(string message)
			{
				Log.LogWarning((object)message);
			});
			Language.SettingChanged += delegate
			{
				Localization.SetLanguage(Language.Value);
			};
			Boot();
			Log.LogInfo((object)("LCF 0.2.7 loaded. Server: " + ServerUrl.Value));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void Boot()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			PatchAll(new Harmony("asta.lcf"));
			GameObject val = new GameObject("LCF.Core")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<Core>();
		}

		private static void PatchAll(Harmony harmony)
		{
			int num = 0;
			int num2 = 0;
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(Plugin).Assembly);
			foreach (Type type in typesFromAssembly)
			{
				try
				{
					if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Length != 0)
					{
						harmony.CreateClassProcessor(type).Patch();
						num++;
					}
				}
				catch (Exception ex)
				{
					num2++;
					Log.LogWarning((object)("LCF: patch " + type.Name + " skipped on this game version: " + (ex.InnerException ?? ex).Message));
				}
			}
			Log.LogInfo((object)$"LCF: {num} patches applied, {num2} skipped (Lethal Company v{Compat.GameVersion})");
		}

		private static Assembly ResolveEmbedded(object sender, ResolveEventArgs args)
		{
			if (!args.Name.StartsWith("websocket-sharp", StringComparison.OrdinalIgnoreCase))
			{
				return null;
			}
			if (_wsAssembly != null)
			{
				return _wsAssembly;
			}
			using (Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream("LCF.websocket-sharp.dll"))
			{
				if (stream == null)
				{
					return null;
				}
				using MemoryStream memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				_wsAssembly = Assembly.Load(memoryStream.ToArray());
			}
			return _wsAssembly;
		}
	}
	internal static class BuildInfo
	{
		public const string Version = "0.2.7";
	}
}
namespace LCF.UI
{
	public sealed class AugmentScreen
	{
		private sealed class Card
		{
			public RectTransform Root;

			public RectTransform Hit;

			public CanvasGroup Group;

			public Image Face;

			public Button Button;

			public Vector2 Home;

			public float Angle;

			public string Id;
		}

		private readonly Ui _ui;

		private readonly RectTransform _root;

		private readonly RectTransform _fan;

		private readonly RectTransform _tray;

		private readonly CanvasGroup _group;

		private readonly CanvasGroup _trayGroup;

		private readonly Image _dim;

		private readonly TextMeshProUGUI _name;

		private readonly TextMeshProUGUI _description;

		private readonly TextMeshProUGUI _step;

		private readonly TextMeshProUGUI _hint;

		private readonly List<Card> _cards = new List<Card>();

		private readonly Dictionary<string, Sprite> _icons = new Dictionary<string, Sprite>();

		private AugmentOffer _offer;

		private AugmentOffer _pending;

		private string _matchId;

		private List<string> _selected = new List<string>();

		private List<string> _traySelection;

		private string _trayMatchId;

		private readonly List<Image> _trayBackgrounds = new List<Image>();

		private float _trayShownAt;

		private int _traySeenCount;

		private bool _trayWasInspecting;

		private float _trayInspectBlend;

		private float _trayInspectFrom;

		private float _trayInspectAt;

		private float _trayIdleAlpha = 1f;

		private float _trayRevealFrom = 1f;

		private float _until;

		private float _showAt;

		private bool _busy;

		private bool _submitted;

		private bool _inputHeld;

		private int _hover = -1;

		private Coroutine _animation;

		private PlayerControllerB _inputPlayer;

		private bool _oldLook;

		private bool _oldMove;

		private bool _oldTyping;

		private bool _oldCursor;

		private CursorLockMode _oldLock;

		public bool Visible => ((Component)_root).gameObject.activeSelf;

		private bool CanInspectTray
		{
			get
			{
				if (((Component)_tray).gameObject.activeSelf && !Visible)
				{
					GameNetworkManager instance = GameNetworkManager.Instance;
					if (instance == null)
					{
						return false;
					}
					return instance.localPlayerController?.quickMenuManager?.isMenuOpen == true;
				}
				return false;
			}
		}

		public AugmentScreen(RectTransform root, Ui ui)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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_028b: Unknown result type (might be due to invalid IL or missing references)
			_root = root;
			_ui = ui;
			_group = ((Component)(object)root).Group();
			_dim = UiKit.Box((Transform)(object)root, new Color(0f, 0f, 0f, 0.58f), "Dim");
			((Graphic)_dim).rectTransform.Fill();
			_step = UiKit.Label((Transform)(object)root, "AUGMENT", 22f, UiKit.Gold, (TextAlignmentOptions)514);
			((TMP_Text)_step).characterSpacing = 5f;
			((TMP_Text)_step).rectTransform.At(0.5f, 0.5f, 0f, 365f, 1100f, 35f);
			_name = UiKit.Label((Transform)(object)root, "Choose an augment", 54f, UiKit.Hex("#fff1db"), (TextAlignmentOptions)514);
			((TMP_Text)_name).fontStyle = (FontStyles)1;
			((TMP_Text)_name).rectTransform.At(0.5f, 0.5f, 0f, 295f, 1300f, 76f);
			_description = UiKit.Label((Transform)(object)root, "Hover a card for its full effect.", 25f, UiKit.Hex("#f1c6a3"), (TextAlignmentOptions)514);
			((TMP_Text)_description).rectTransform.At(0.5f, 0.5f, 0f, 202f, 1100f, 100f);
			_fan = UiKit.Rect("Cards", (Transform)(object)root).Fill();
			_tray = UiKit.Rect("ChosenAugments", ((Transform)root).parent).At(1f, 0f, -32f, 28f, 660f, 80f);
			_trayGroup = ((Component)(object)_tray).Group();
			_trayGroup.blocksRaycasts = (_trayGroup.interactable = false);
			((Component)_tray).gameObject.SetActive(false);
			_hint = UiKit.Label((Transform)(object)root, "CLICK A CARD OR PRESS 1 / 2 / 3  ·  THE GAME CONTINUES", 17f, UiKit.Hex("#e8b76d"), (TextAlignmentOptions)514);
			((TMP_Text)_hint).rectTransform.At(0.5f, 1f, 0f, -38f, 1300f, 30f);
			((Component)_root).gameObject.SetActive(false);
		}

		public void Offer(AugmentOffer offer)
		{
			MatchSession matchSession = Core.I?.Match;
			if (offer == null || matchSession == null || matchSession.IsSpectator || matchSession.MatchId != offer.MatchId)
			{
				return;
			}
			List<string> choices = offer.Choices;
			if (choices != null && choices.Count == 3)
			{
				if (_matchId != offer.MatchId)
				{
					Reset();
					_matchId = offer.MatchId;
				}
				if (offer.Round >= _selected.Count && (_offer == null || offer.Round > _offer.Round))
				{
					_pending = offer;
					AugmentRules.BeginSelectionProtection(offer.MatchId, (float)Math.Max(0L, offer.TimeoutMs) / 1000f);
					_until = Time.realtimeSinceStartup + (float)Math.Max(0L, offer.TimeoutMs) / 1000f;
					_showAt = Time.realtimeSinceStartup + (float)Math.Max(0L, offer.ShowInMs) / 1000f;
				}
			}
		}

		private void ShowPending()
		{
			_offer = _pending;
			_pending = null;
			_submitted = false;
			_hover = -1;
			UiKit.Clear((Transform)(object)_fan);
			_cards.Clear();
			AugmentRules.OnSelectionShown(_offer.MatchId, Math.Max(0f, _until - Time.realtimeSinceStartup));
			((Component)_root).gameObject.SetActive(true);
			CanvasGroup trayGroup = _trayGroup;
			bool blocksRaycasts = (_trayGroup.interactable = false);
			trayGroup.blocksRaycasts = blocksRaycasts;
			((Transform)_root).SetAsLastSibling();
			_group.alpha = 1f;
			CanvasGroup obj = _group;
			blocksRaycasts = (_group.interactable = true);
			obj.blocksRaycasts = blocksRaycasts;
			HoldInput();
			((TMP_Text)_name).text = "Choose an augment";
			((TMP_Text)_description).text = "Hover a card for its full effect.\nYour choice applies immediately.";
			((TMP_Text)_hint).text = "CLICK A CARD OR PRESS 1 / 2 / 3  ·  THE GAME CONTINUES";
			RefreshTray(Core.I?.Match);
			for (int i = 0; i < 3; i++)
			{
				BuildCard(i, _offer.Choices[i]);
			}
			SoundFx.Reveal();
			_animation = ((MonoBehaviour)_ui).StartCoroutine(Deal());
		}

		private void BuildCard(int index, string id)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Expected O, but got Unknown
			AugmentEntry augmentEntry = AugmentCatalog.Find(id);
			Image val = UiKit.Box((Transform)(object)_fan, UiKit.Hex("#590001"), "Augment_" + id, raycast: false);
			RectTransform val2 = ((Graphic)val).rectTransform.At(0.5f, 0.5f, (index - 1) * 295, (index == 1) ? (-220) : (-265), 330f, 430f);
			val2.pivot = new Vector2(0.5f, 0.5f);
			UiKit.Frame(val2, UiKit.Hex("#d7a52b"), 3f);
			((TMP_Text)UiKit.Label((Transform)(object)val2, (index + 1).ToString(), 17f, UiKit.Hex("#d7a52b"), (TextAlignmentOptions)514)).rectTransform.At(0f, 1f, 20f, -14f, 24f, 24f);
			Image val3 = UiKit.Box((Transform)(object)val2, Color.white, "Icon", raycast: false);
			val3.sprite = LoadIcon(augmentEntry?.Icon);
			val3.preserveAspect = true;
			if ((Object)(object)val3.sprite == (Object)null)
			{
				((Graphic)val3).color = Color.clear;
			}
			((Graphic)val3).rectTransform.At(0.5f, 1f, 0f, -54f, 156f, 156f);
			TextMeshProUGUI obj = UiKit.Label((Transform)(object)val2, augmentEntry?.Name ?? id, 29f, UiKit.Gold, (TextAlignmentOptions)514);
			((TMP_Text)obj).fontStyle = (FontStyles)1;
			((TMP_Text)obj).rectTransform.At(0.5f, 1f, 0f, -226f, 286f, 68f);
			TextMeshProUGUI obj2 = UiKit.Label((Transform)(object)val2, augmentEntry?.Description ?? "", 21f, UiKit.Hex("#f1c6a3"), (TextAlignmentOptions)514);
			((TMP_Text)obj2).rectTransform.At(0.5f, 0f, 0f, 52f, 280f, 62f);
			((TMP_Text)obj2).overflowMode = (TextOverflowModes)1;
			((TMP_Text)obj2).maxVisibleLines = 2;
			RectTransform val4 = ((Graphic)UiKit.Box((Transform)(object)_fan, Color.clear, "Hit_" + id)).rectTransform.At(0.5f, 0.5f, val2.anchoredPosition.x, val2.anchoredPosition.y + 70f, 360f, 570f);
			Button val5 = ((Component)val4).gameObject.AddComponent<Button>();
			((Selectable)val5).transition = (Transition)0;
			Card item = new Card
			{
				Root = val2,
				Face = val,
				Group = ((Component)(object)val2).Group(),
				Button = val5,
				Hit = val4,
				Home = val2.anchoredPosition,
				Angle = (1 - index) * 13,
				Id = id
			};
			((UnityEvent)val5.onClick).AddListener((UnityAction)delegate
			{
				Pick(index);
			});
			((Component)val4).gameObject.AddComponent<AugmentCardFocus>().Init(delegate
			{
				Hover(index);
			}, delegate
			{
				Unhover(index);
			});
			_cards.Add(item);
		}

		private static string ResolveIconPath(string directory, string relative)
		{
			if (string.IsNullOrEmpty(directory) || string.IsNullOrEmpty(relative) || Path.IsPathRooted(relative))
			{
				return null;
			}
			if (!relative.StartsWith("scraps/", StringComparison.OrdinalIgnoreCase) && !relative.StartsWith("scraps\\", StringComparison.OrdinalIgnoreCase))
			{
				return null;
			}
			string text = relative.Substring(7);
			if (text != Path.GetFileName(text) || !text.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
			{
				return null;
			}
			string fullPath = Path.GetFullPath(Path.Combine(directory, "assets", "scraps"));
			string fullPath2 = Path.GetFullPath(Path.Combine(fullPath, text));
			if (!fullPath2.StartsWith(fullPath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) || !File.Exists(fullPath2))
			{
				return null;
			}
			return fullPath2;
		}

		private Sprite LoadIcon(string relative)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(relative))
			{
				return null;
			}
			if (_icons.TryGetValue(relative, out var value))
			{
				return value;
			}
			Texture2D val = null;
			try
			{
				string directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location);
				string text = ResolveIconPath(directoryName, relative);
				if (text == null)
				{
					Plugin.Log.LogWarning((object)("Augment icon missing: " + relative + " (plugin: " + directoryName + ")"));
					return null;
				}
				byte[] array = File.ReadAllBytes(text);
				val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (!ImageConversion.LoadImage(val, array))
				{
					Object.Destroy((Object)(object)val);
					return null;
				}
				Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.one * 0.5f, 100f);
				_icons[relative] = val2;
				return val2;
			}
			catch (Exception ex)
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
				Plugin.Log.LogWarning((object)("Augment icon " + relative + ": " + ex.Message));
				return null;
			}
		}

		private IEnumerator Deal()
		{
			_busy = true;
			foreach (Card card2 in _cards)
			{
				((Selectable)card2.Button).interactable = false;
				card2.Group.alpha = 0f;
			}
			yield return Tween.Run(0.65f, delegate(float k)
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: 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_0067: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
				for (int i = 0; i < _cards.Count; i++)
				{
					float num = Mathf.Clamp01((k - (float)i * 0.1f) / 0.8f);
					Card card = _cards[i];
					card.Group.alpha = num;
					card.Root.anchoredPosition = Vector2.LerpUnclamped(new Vector2(0f, -720f), card.Home, Ease.OutCubic(num));
					((Transform)card.Root).localScale = Vector3.one * Mathf.Lerp(0.72f, 1f, Ease.OutCubic(num));
					((Transform)card.Root).localEulerAngles = new Vector3(0f, 0f, Mathf.Lerp(0f, card.Angle, num));
				}
			});
			foreach (Card card3 in _cards)
			{
				((Selectable)card3.Button).interactable = true;
			}
			_busy = false;
			_animation = null;
		}

		private void Hover(int index)
		{
			if (!_busy && !_submitted && index >= 0 && index < _cards.Count)
			{
				if (_hover != index)
				{
					SoundFx.Hover();
				}
				_hover = index;
				AugmentEntry augmentEntry = AugmentCatalog.Find(_cards[index].Id);
				((TMP_Text)_name).text = augmentEntry?.Name ?? _cards[index].Id;
				((TMP_Text)_description).text = augmentEntry?.Description ?? "";
				((Transform)_cards[index].Root).SetAsLastSibling();
				((Transform)_cards[index].Hit).SetAsLastSibling();
			}
		}

		private void Unhover(int index)
		{
			if (_hover == index && !_submitted && !_busy)
			{
				_hover = -1;
				((TMP_Text)_name).text = "Choose an augment";
				((TMP_Text)_description).text = "Hover a card for its full effect.\nYour choice applies immediately.";
			}
		}

		private void Pick(int index)
		{
			if (_busy || _submitted || _offer == null || index < 0 || index >= _cards.Count)
			{
				return;
			}
			_submitted = true;
			_hover = index;
			foreach (Card card in _cards)
			{
				((Selectable)card.Button).interactable = false;
			}
			((TMP_Text)_hint).text = "CONFIRMING YOUR CHOICE...";
			Core.I.Net.Send(new
			{
				t = "augment_pick",
				match_id = _offer.MatchId,
				round = _offer.Round,
				id = _cards[index].Id
			});
		}

		public void Picked(AugmentPicked picked)
		{
			if (picked == null || picked.MatchId != Core.I?.Match?.MatchId)
			{
				return;
			}
			if (_matchId != picked.MatchId)
			{
				Reset();
				_matchId = picked.MatchId;
			}
			List<string> list = new List<string>(picked.Selected ?? new List<string>());
			if (list.Count > _selected.Count)
			{
				SoundFx.AugmentPicked();
			}
			_selected = list;
			if (_pending != null && _pending.Round <= picked.Round)
			{
				_pending = null;
			}
			if (!Visible || _offer == null || _offer.Round != picked.Round)
			{
				if (_animation != null)
				{
					((MonoBehaviour)_ui).StopCoroutine(_animation);
				}
				_animation = null;
				((Component)_root).gameObject.SetActive(false);
				ReleaseInput();
				_offer = null;
				_busy = (_submitted = false);
				if (_selected.Count >= 3)
				{
					_pending = null;
					AugmentRules.EndSelectionProtection();
				}
				return;
			}
			int num = _cards.FindIndex((Card c) => c.Id == picked.Id);
			if (num >= 0)
			{
				if (_animation != null)
				{
					((MonoBehaviour)_ui).StopCoroutine(_animation);
				}
				_busy = true;
				_submitted = true;
				_hover = num;
				_animation = ((MonoBehaviour)_ui).StartCoroutine(Collect(num));
			}
		}

		private IEnumerator Collect(int index)
		{
			Card card = _cards[index];
			((Transform)card.Root).SetAsLastSibling();
			foreach (Card card2 in _cards)
			{
				((Selectable)card2.Button).interactable = false;
			}
			((TMP_Text)_name).text = AugmentCatalog.Find(card.Id)?.Name ?? card.Id;
			((TMP_Text)_description).text = "";
			((TMP_Text)_hint).text = "";
			Vector2 start = card.Root.anchoredPosition;
			Vector3 scale = ((Transform)card.Root).localScale;
			yield return Tween.Run(0.24f, delegate(float t)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: 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_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: 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)
				card.Root.anchoredPosition = Vector2.LerpUnclamped(start, new Vector2(0f, -35f), Ease.OutCubic(t));
				((Transform)card.Root).localScale = Vector3.LerpUnclamped(scale, Vector3.one * 1.12f, Ease.OutBack(t));
				((Transform)card.Root).localEulerAngles = Vector3.zero;
				foreach (Card card3 in _cards)
				{
					if (card3 != card)
					{
						card3.Group.alpha = 1f - t;
						RectTransform root2 = card3.Root;
						root2.anchoredPosition += Vector2.down * Time.unscaledDeltaTime * 180f;
					}
				}
			});
			yield return Tween.Wait(0.14f);
			int num = Math.Max(0, _selected.Count - 1);
			RectTransform root = _root;
			RectTransform tray = _tray;
			Rect rect = _tray.rect;
			float num2 = 0f - ((Rect)(ref rect)).width + 43f + (float)(num * 220);
			rect = _tray.rect;
			Vector2 dest = Vector2.op_Implicit(((Transform)root).InverseTransformPoint(((Transform)tray).TransformPoint(new Vector3(num2, ((Rect)(ref rect)).height * 0.5f, 0f))));
			yield return Tween.Run(0.48f, delegate(float t)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: 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_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				float num3 = Ease.OutCubic(t);
				card.Root.anchoredPosition = Vector2.Lerp(new Vector2(0f, -35f), dest, num3) + Vector2.up * (Mathf.Sin(t * MathF.PI) * 95f);
				((Transform)card.Root).localScale = Vector3.one * Mathf.Lerp(1.12f, 0.14f, num3);
				card.Group.alpha = 1f - t * 0.8f;
			});
			card.Group.alpha = 0f;
			RefreshTray(Core.I?.Match);
			_busy = false;
			_animation = null;
			if (_pending != null)
			{
				ShowPending();
			}
			else if (_selected.Count >= 3)
			{
				_busy = true;
				yield return Tween.Wait(0.35f);
				yield return Tween.Run(0.22f, delegate(float t)
				{
					_group.alpha = 1f - t;
				});
				((Component)_root).gameObject.SetActive(false);
				ReleaseInput();
				AugmentRules.EndSelectionProtection();
				_busy = false;
			}
		}

		private void RefreshTray(MatchSession match)
		{
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			int num;
			if (GameDirector.InGame && match != null && !match.IsSpectator && match.Settings?.Mode == "augment")
			{
				List<string> selectedAugments = match.SelectedAugments;
				num = ((selectedAugments != null && selectedAugments.Count > 0) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			bool flag = (byte)num != 0;
			if (((Component)_tray).gameObject.activeSelf != flag)
			{
				((Component)_tray).gameObject.SetActive(flag);
			}
			CanvasGroup trayGroup = _trayGroup;
			bool blocksRaycasts = (_trayGroup.interactable = flag && CanInspectTray);
			trayGroup.blocksRaycasts = blocksRaycasts;
			if (!flag)
			{
				return;
			}
			if (_trayMatchId != match.MatchId || _traySelection != match.SelectedAugments || _traySeenCount != match.SelectedAugments.Count)
			{
				if (_trayMatchId != match.MatchId || match.SelectedAugments.Count > _traySeenCount)
				{
					_trayRevealFrom = ((_trayMatchId != match.MatchId) ? 1f : _trayIdleAlpha);
					_trayShownAt = Time.realtimeSinceStartup;
				}
				_trayMatchId = match.MatchId;
				_traySelection = match.SelectedAugments;
				_traySeenCount = match.SelectedAugments.Count;
				BuildTray(_traySelection);
			}
			bool canInspectTray = CanInspectTray;
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (canInspectTray != _trayWasInspecting)
			{
				_trayWasInspecting = canInspectTray;
				_trayInspectFrom = _trayInspectBlend;
				_trayInspectAt = realtimeSinceStartup;
			}
			_trayInspectBlend = Mathf.Lerp(_trayInspectFrom, canInspectTray ? 1f : 0f, Mathf.SmoothStep(0f, 1f, (realtimeSinceStartup - _trayInspectAt) / 0.25f));
			float num2 = realtimeSinceStartup - _trayShownAt;
			float num3 = Mathf.Lerp(_trayRevealFrom, 1f, Mathf.SmoothStep(0f, 1f, num2 / 0.25f));
			_trayIdleAlpha = Mathf.Lerp(num3, 0.55f, Mathf.SmoothStep(0f, 1f, num2 - 3f));
			_trayGroup.alpha = Mathf.Lerp(_trayIdleAlpha, 1f, _trayInspectBlend);
			foreach (Image trayBackground in _trayBackgrounds)
			{
				Color color = ((Graphic)trayBackground).color;
				color.a = _trayInspectBlend;
				((Graphic)trayBackground).color = color;
				((Behaviour)trayBackground).enabled = _trayInspectBlend > 0f;
			}
		}

		private void BuildTray(IList<string> selected)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			UiKit.Clear((Transform)(object)_tray);
			_trayBackgrounds.Clear();
			for (int i = 0; i < selected.Count && i < 3; i++)
			{
				AugmentEntry e = AugmentCatalog.Find(selected[i]);
				Image val = UiKit.Box((Transform)(object)_tray, new Color(0.16f, 0f, 0f, 1f), "Chosen_" + i);
				((Graphic)val).rectTransform.At(0f, 0.5f, i * 220, 0f, 208f, 76f);
				UiKit.Frame(((Graphic)val).rectTransform, UiKit.Hex("#8d621d"), 1f);
				Image[] componentsInChildren = ((Component)val).GetComponentsInChildren<Image>();
				foreach (Image val2 in componentsInChildren)
				{
					((Behaviour)val2).enabled = CanInspectTray;
					_trayBackgrounds.Add(val2);
				}
				HoverTip.Add((Graphic)(object)val, () => (e != null) ? ("<b>" + e.Name + "</b>\n" + e.Description) : "", () => CanInspectTray);
				Image val3 = UiKit.Box((Transform)(object)((Graphic)val).rectTransform, Color.white, "Icon", raycast: false);
				val3.sprite = LoadIcon(e?.Icon);
				val3.preserveAspect = true;
				if ((Object)(object)val3.sprite == (Object)null)
				{
					((Graphic)val3).color = Color.clear;
				}
				((Graphic)val3).rectTransform.At(0f, 0.5f, 16f, 0f, 54f, 54f);
				((TMP_Text)UiKit.Label((Transform)(object)((Graphic)val).rectTransform, e?.Name ?? selected[i], 17f, UiKit.Gold, (TextAlignmentOptions)4097)).rectTransform.At(0f, 0.5f, 80f, 0f, 118f, 56f);
			}
		}

		public void Tick()
		{
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: 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_01c7: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			MatchSession matchSession = Core.I?.Match;
			RefreshTray(matchSession);
			if (matchSession == null || matchSession.IsSpectator || matchSession.Decided || matchSession.Eliminated || matchSession.Phase == MatchPhase.Finished)
			{
				if (Visible || _pending != null || _offer != null)
				{
					ClearChoice();
				}
				return;
			}
			if (!_busy && _pending != null && Time.realtimeSinceStartup >= _showAt && matchSession.Phase == MatchPhase.Playing && (!Visible || _submitted))
			{
				ShowPending();
			}
			if (!Visible)
			{
				return;
			}
			((Transform)_root).SetAsLastSibling();
			if (((Component)_tray).gameObject.activeSelf)
			{
				((Transform)_tray).SetAsLastSibling();
			}
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			if ((Object)(object)_inputPlayer != (Object)null)
			{
				Compat.Set(_inputPlayer, "disableLookInput", true);
				Compat.Set(_inputPlayer, "disableMoveInput", true);
				Compat.Set(_inputPlayer, "isTypingChat", true);
			}
			int num = Mathf.Max(0, Mathf.CeilToInt(_until - Time.realtimeSinceStartup));
			((TMP_Text)_step).text = $"AUGMENT  {_offer.Round + 1} / 3     ·     {num}s";
			if (!_busy)
			{
				foreach (Card card in _cards)
				{
					bool flag = _cards.IndexOf(card) == _hover;
					Vector2 val = card.Home + (flag ? (Vector2.up * 110f) : Vector2.zero);
					float num2 = 1f - Mathf.Exp(-14f * Time.unscaledDeltaTime);
					card.Root.anchoredPosition = Vector2.Lerp(card.Root.anchoredPosition, val, num2);
					((Transform)card.Root).localScale = Vector3.Lerp(((Transform)card.Root).localScale, Vector3.one * (flag ? 1.08f : 1f), num2);
					((Transform)card.Root).localRotation = Quaternion.Slerp(((Transform)card.Root).localRotation, Quaternion.Euler(0f, 0f, flag ? 0f : card.Angle), num2);
					((Graphic)card.Face).color = (flag ? UiKit.Hex("#8e0101") : UiKit.Hex("#590001"));
				}
			}
			Keyboard current2 = Keyboard.current;
			if (current2 != null && !_busy && !_submitted)
			{
				if (((ButtonControl)current2.digit1Key).wasPressedThisFrame)
				{
					Pick(0);
				}
				else if (((ButtonControl)current2.digit2Key).wasPressedThisFrame)
				{
					Pick(1);
				}
				else if (((ButtonControl)current2.digit3Key).wasPressedThisFrame)
				{
					Pick(2);
				}
			}
		}

		private void HoldInput()
		{
			//IL_0021: 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)
			if (!_inputHeld)
			{
				_inputPlayer = GameNetworkManager.Instance?.localPlayerController;
				_oldLock = Cursor.lockState;
				_oldCursor = Cursor.visible;
				_oldLook = Compat.Get(_inputPlayer, "disableLookInput", fallback: false);
				_oldMove = Compat.Get(_inputPlayer, "disableMoveInput", fallback: false);
				_oldTyping = Compat.Get(_inputPlayer, "isTypingChat", fallback: false);
				_inputHeld = true;
			}
		}

		private void ReleaseInput()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			if (_inputHeld)
			{
				if ((Object)(object)_inputPlayer != (Object)null)
				{
					Compat.Set(_inputPlayer, "disableLookInput", _oldLook);
					Compat.Set(_inputPlayer, "disableMoveInput", _oldMove);
					Compat.Set(_inputPlayer, "isTypingChat", _oldTyping);
				}
				PlayerControllerB inputPlayer = _inputPlayer;
				if (inputPlayer == null || inputPlayer.quickMenuManager?.isMenuOpen != true)
				{
					Cursor.lockState = _oldLock;
					Cursor.visible = _oldCursor;
				}
				_inputHeld = false;
				_inputPlayer = null;
			}
		}

		public void Reset()
		{
			ClearChoice();
			((Component)_tray).gameObject.SetActive(false);
			_traySelection = null;
			_trayMatchId = null;
			_traySeenCount = 0;
			_trayShownAt = 0f;
			_trayWasInspecting = false;
			_trayInspectBlend = (_trayInspectFrom = (_trayInspectAt = 0f));
			_trayIdleAlpha = (_trayRevealFrom = 1f);
		}

		private void ClearChoice()
		{
			AugmentRules.EndSelectionProtection();
			if (_animation != null)
			{
				((MonoBehaviour)_ui).StopCoroutine(_animation);
			}
			_animation = null;
			ReleaseInput();
			((Component)_root).gameObject.SetActive(false);
			_offer = (_pending = null);
			_selected.Clear();
			_cards.Clear();
			_matchId = null;
			_busy = (_submitted = false);
		}
	}
	public sealed class AugmentCardFocus : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler
	{
		private Action _enter;

		private Action _exit;

		public void Init(Action enter, Action exit)
		{
			_enter = enter;
			_exit = exit;
		}

		public void OnPointerEnter(PointerEventData e)
		{
			_enter?.Invoke();
		}

		public void OnPointerExit(PointerEventData e)
		{
			_exit?.Invoke();
		}

		public void OnSelect(BaseEventData e)
		{
			_enter?.Invoke();
		}

		public void OnDeselect(BaseEventData e)
		{
			_exit?.Invoke();
		}
	}
	public static class ChatKey
	{
		public struct State
		{
			internal int Frames;

			internal int StartFrame;

			internal string Before;

			internal bool SelectAll;

			internal bool RestoreSelectAll;

			internal bool OwnsActivation;

			internal bool Canceled;
		}

		private static readonly FieldInfo PendingActivation = AccessTools.Field(typeof(TMP_InputField), "m_ShouldActivateNextUpdate");

		public static void Tick(TMP_InputField input, ref State state)
		{
			if (state.Canceled && state.StartFrame == Time.frameCount)
			{
				return;
			}
			if (!Available(input))
			{
				Cancel(input, ref state);
				return;
			}
			if (state.Frames > 0 && Time.frameCount - state.StartFrame > 3)
			{
				Cancel(input, ref state);
			}
			Keyboard current = Keyboard.current;
			bool flag = current != null && (((ButtonControl)current.slashKey).wasPressedThisFrame || ((ButtonControl)current.numpadDivideKey).wasPressedThisFrame);
			if (state.Frames > 0)
			{
				state.Frames--;
				if (flag && Time.frameCount != state.StartFrame)
				{
					state.Before = null;
				}
				string text = input.text ?? "";
				int num = state.Before?.Length ?? (-1);
				if (num >= 0 && text.Length > num && text.StartsWith(state.Before, StringComparison.Ordinal) && text[num] == '/')
				{
					int selectionStringAnchorPosition = input.selectionStringAnchorPosition;
					int selectionStringFocusPosition = input.selectionStringFocusPosition;
					input.text = text.Remove(num, 1);
					input.selectionStringAnchorPosition = ((selectionStringAnchorPosition > num) ? (selectionStringAnchorPosition - 1) : selectionStringAnchorPosition);
					input.selectionStringFocusPosition = ((selectionStringFocusPosition > num) ? (selectionStringFocusPosition - 1) : selectionStringFocusPosition);
					state.Before = null;
				}
				if (input.isFocused && state.RestoreSelectAll)
				{
					input.onFocusSelectAll = state.SelectAll;
					state.RestoreSelectAll = false;
					state.OwnsActivation = false;
				}
				else if (!input.isFocused && state.RestoreSelectAll && state.Frames > 0)
				{
					state.OwnsActivation |= Focus(input);
				}
				if (state.Frames == 0)
				{
					Cancel(input, ref state);
				}
			}
			else if (flag && !input.isFocused)
			{
				state = new State
				{
					Frames = 3,
					StartFrame = Time.frameCount,
					Before = (input.text ?? ""),
					SelectAll = input.onFocusSelectAll,
					RestoreSelectAll = true
				};
				input.onFocusSelectAll = false;
				input.stringPosition = input.text.Length;
				state.OwnsActivation = Focus(input);
			}
		}

		public static void Tick(TMP_InputField input, ref int stripFrames)
		{
			if (!Available(input))
			{
				stripFrames = 0;
				return;
			}
			if (stripFrames > 0)
			{
				stripFrames--;
				if (input.text == "/")
				{
					input.text = "";
				}
				if (!input.isFocused && stripFrames > 0)
				{
					Focus(input);
				}
			}
			Keyboard current = Keyboard.current;
			if (current != null && !input.isFocused && (((ButtonControl)current.slashKey).wasPressedThisFrame || ((ButtonControl)current.numpadDivideKey).wasPressedThisFrame))
			{
				Focus(input);
				stripFrames = 3;
			}
		}

		private static bool Available(TMP_InputField input)
		{
			if ((Object)(object)input == (Object)null || !((UIBehaviour)input).IsActive() || !((Selectable)input).IsInteractable() || input.readOnly || !string.IsNullOrEmpty(Input.compositionString))
			{
				return false;
			}
			EventSystem current = EventSystem.current;
			GameObject val = ((current != null) ? current.currentSelectedGameObject : null);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)((Component)input).gameObject))
			{
				if ((Object)(object)val.GetComponent<TMP_InputField>() == (Object)null)
				{
					return (Object)(object)val.GetComponent<InputField>() == (Object)null;
				}
				return false;
			}
			return true;
		}

		private static bool Focus(TMP_InputField input)
		{
			if ((Object)(object)EventSystem.current == (Object)null || !((Behaviour)EventSystem.current).isActiveAndEnabled)
			{
				return false;
			}
			((Selectable)input).Select();
			input.ActivateInputField();
			return true;
		}

		public static void Cancel(TMP_InputField input, ref State state)
		{
			if ((Object)(object)input != (Object)null && state.OwnsActivation && !input.isFocused)
			{
				PendingActivation?.SetValue(input, false);
			}
			if ((Object)(object)input != (Object)null && state.RestoreSelectAll)
			{
				input.onFocusSelectAll = state.SelectAll;
			}
			state = new State
			{
				StartFrame = Time.frameCount,
				Canceled = true
			};
		}
	}
	public class ChatPanel
	{
		public readonly RectTransform Root;

		private readonly TextMeshProUGUI _log;

		private readonly TMP_InputField _input;

		private readonly List<string> _lines = new List<string>();

		private readonly Action<string> _send;

		private readonly int _max;

		private ChatKey.State _strip;

		private RoomChatCursor _roomChatCursor;

		public bool Visible
		{
			get
			{
				if ((Object)(object)Root != (Object)null)
				{
					return ((Component)Root).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		public void SyncRoomChat()
		{
			Core.I.RoomChat.Replay(ref _roomChatCursor, delegate(RoomChatEntry line)
			{
				Add(line.System ? null : line.Name, line.Text, line.Mine, line.Prefix);
			}, delegate
			{
				_lines.Clear();
				((TMP_Text)_log).text = "";
			});
		}

		public ChatPanel(RectTransform parent, Action<string> send, string hint, float w = 430f, float h = 250f, int lines = 7)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			_send = send;
			_max = lines;
			Root = ((Graphic)UiKit.Box((Transform)(object)parent, new Color(0.08f, 0f, 0f, 0.92f), "Chat")).rectTransform.At(0f, 0f, 16f, 16f, w, h);
			UiKit.Frame(Root, UiKit.WindowEdge, 3f);
			_log = UiKit.Label((Transform)(object)Root, "<color=#b4500c><i>" + hint + "</i></color>", 19f, UiKit.Text, (TextAlignmentOptions)1025);
			((TMP_Text)_log).rectTransform.Fill(12f, 8f, 12f, 58f);
			((TMP_Text)_log).overflowMode = (TextOverflowModes)3;
			GradientText.On((TMP_Text)(object)_log);
			_input = UiKit.Input((Transform)(object)Root, "chat...  ( / )", 19f, 100);
			((Component)_input).GetComponent<RectTransform>().At(0.5f, 0f, 0f, 8f, w - 24f, 40f);
			((Graphic)((Component)_input).GetComponent<Image>()).color = UiKit.Panel2;
			((UnityEvent<string>)(object)_input.onSubmit).AddListener((UnityAction<string>)Submit);
		}

		private void Submit(string text)
		{
			text = (text ?? "").Trim();
			_input.text = "";
			_input.ActivateInputField();
			if (text.Length > 0)
			{
				_send(text);
			}
		}

		public void Add(string name, string text, bool mine = false, string prefix = null)
		{
			name = name?.Replace("<", "").Replace(">", "");
			text = (text ?? "").Replace("<", "").Replace(">", "");
			if (_lines.Count == 0)
			{
				((TMP_Text)_log).text = "";
			}
			_lines.Add((name == null) ? ("<color=#b4500c><i>" + text + "</i></color>") : (prefix + "<color=" + (mine ? "#fdac0d" : "#ffb27a") + ">" + name + "</color>  <color=#ffe3c4>" + text + "</color>"));
			while (_lines.Count > _max)
			{
				_lines.RemoveAt(0);
			}
			((TMP_Text)(object)_log).SetRawText(string.Join("\n", _lines));
		}

		public void Tick()
		{
			if (Visible)
			{
				((Transform)Root).SetAsLastSibling();
				ChatKey.Tick(_input, ref _strip);
			}
		}
	}
	public class CreditsView
	{
		private static readonly Color Cream = UiKit.Hex("#ffe3c4");

		private readonly RectTransform _root;

		private readonly ScrollRect _scroll;

		private readonly TextMeshProUGUI _devs;

		private readonly TextMeshProUGUI _testers;

		private readonly TextMeshProUGUI _vanilla;

		private bool _loading;

		private bool _loadedNames;

		private static string _vanillaText;

		public CreditsView(RectTransform root)
		{
			//IL_008a: 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_00b4: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			_root = root;
			RectTransform val = ((Graphic)UiKit.TermBox((Transform)(object)root, "CreditsPanel", raycast: true)).rectTransform.At(0f, 1f, 0f, -90f, 1500f, 930f);
			RectTransform val2 = UiKit.Rect("Viewport", (Transform)(object)val).Fill(48f, 20f, 40f, 20f);
			((Component)val2).gameObject.AddComponent<RectMask2D>();
			RectTransform val3 = UiKit.Rect("Content", (Transform)(object)val2);
			val3.anchorMin = new Vector2(0f, 1f);
			val3.anchorMax = new Vector2(1f, 1f);
			val3.pivot = new Vector2(0.5f, 1f);
			val3.sizeDelta = Vector2.zero;
			val3.anchoredPosition = Vector2.zero;
			((LayoutGroup)UiKit.VList(val3, 10f)).padding = new RectOffset(0, 24, 12, 40);
			((Component)val3).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			_scroll = ((Component)val).gameObject.AddComponent<ScrollRect>();
			_scroll.viewport = val2;
			_scroll.content = val3;
			_scroll.horizontal = false;
			_scroll.movementType = (MovementType)2;
			_scroll.scrollSensitivity = 40f;
			UiKit.VScrollbar(val, _scroll);
			Header(val3, "LETHAL COMPANY FIGHT", "THE PEOPLE BEHIND LCF");
			Section(val3, "DEVELOPER");
			_devs = Body(val3, "LOADING...");
			Section(val3, "BETA TESTER");
			_testers = Body(val3, "LOADING...");
			Section(val3, "LOGO DESIGNER");
			Body(val3, "Cuttlef1sh");
			Section(val3, "SCRAP ICON DESIGNER");
			Body(val3, "debbicar and honee");
			Gap(val3, 36f);
			Header(val3, "VANILLA CREDITS", "LETHAL COMPANY BY ZEEKERSS");
			_vanilla = Body(val3, "", 24f, UiKit.Text);
			((TMP_Text)_vanilla).alignment = (TextAlignmentOptions)257;
		}

		public void Enter()
		{
			_scroll.verticalNormalizedPosition = 1f;
			string text = FindVanillaCredits();
			if (string.IsNullOrWhiteSpace(text))
			{
				((TMP_Text)(object)_vanilla).SetLocalizedText("<color=#c25604>[ THE GAME'S CREDITS COULD NOT BE FOUND ]</color>");
			}
			else
			{
				((TMP_Text)(object)_vanilla).SetRawText(text);
			}
			if (!_loading && (Object)(object)Core.I?.Ui != (Object)null)
			{
				((MonoBehaviour)Core.I.Ui).StartCoroutine(Load());
			}
		}

		private IEnumerator Load()
		{
			_loading = true;
			try
			{
				JObject j = null;
				yield return RemoteIcons.GetJson("/api/credits", delegate(JObject r)
				{
					j = r;
				});
				if (j == null)
				{
					if (!_loadedNames)
					{
						((TMP_Text)(object)_devs).SetLocalizedText(Muted("[ OFFLINE ]"));
						((TMP_Text)(object)_testers).SetLocalizedText(Muted("[ OFFLINE ]"));
					}
				}
				else
				{
					TextMeshProUGUI devs = _devs;
					JToken obj = j["developers"];
					((TMP_Text)(object)devs).SetRawText(Names((JArray)(object)((obj is JArray) ? obj : null)));
					TextMeshProUGUI testers = _testers;
					JToken obj2 = j["beta_testers"];
					((TMP_Text)(object)testers).SetRawText(Names((JArray)(object)((obj2 is JArray) ? obj2 : null)));
					_loadedNames = true;
				}
			}
			finally
			{
				_loading = false;
			}
		}

		private static string Names(JArray a)
		{
			List<string> list = (from s in ((IEnumerable<JToken>)a)?.Select((JToken x) => (string)x)
				where !string.IsNullOrWhiteSpace(s)
				select s).ToList() ?? new List<string>();
			if (list.Count == 0)
			{
				return Muted("-");
			}
			return string.Join("\n", list.Select((string n) => "<noparse>" + n.Replace("</noparse>", "") + "</noparse>"));
		}

		private static string Muted(string s)
		{
			return "<color=#c25604>" + s + "</color>";
		}

		private string FindVanillaCredits()
		{
			if (!string.IsNullOrEmpty(_vanillaText))
			{
				return _vanillaText;
			}
			try
			{
				string text = "";
				HashSet<Transform> hashSet = new HashSet<Transform>();
				TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>(true);
				foreach (TextMeshProUGUI val in array)
				{
					if ((Object)(object)val == (Object)null || ((TMP_Text)val).transform.IsChildOf((Transform)(object)_root))
					{
						continue;
					}
					Transform val2 = null;
					Transform val3 = ((TMP_Text)val).transform;
					while ((Object)(object)val3 != (Object)null)
					{
						if (((Object)val3).name.IndexOf("credit", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							val2 = val3;
							break;
						}
						val3 = val3.parent;
					}
					if (!((Object)(object)val2 == (Object)null) && hashSet.Add(val2))
					{
						string text2 = Collect(val2);
						if (text2.Length > text.Length)
						{
							text = text2;
						}
					}
				}
				if (text.Length < 100)
				{
					array = Object.FindObjectsOfType<TextMeshProUGUI>(true);
					foreach (TextMeshProUGUI val4 in array)
					{
						if (!((Object)(object)val4 == (Object)null) && !((TMP_Text)val4).transform.IsChildOf((Transform)(object)_root))
						{
							string text3 = ((TMP_Text)val4).text ?? "";
							if (text3.Length > text.Length && text3.Length > 200 && text3.IndexOf("zeekerss", StringComparison.OrdinalIgnoreCase) >= 0)
							{
								text = text3.Trim();
							}
						}
					}
				}
				if (text.Length >= 40)
				{
					_vanillaText = text;
					Plugin.Log.LogInfo((object)$"LCF: vanilla credits found ({text.Length} chars)");
				}
				else
				{
					Plugin.Log.LogWarning((object)"LCF: vanilla credits text not found");
				}
				return (text.Length >= 40) ? text : null;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("LCF: reading the vanilla credits failed: " + ex.Message));
				return null;
			}
		}

		private static string Collect(Transform panel)
		{
			StringBuilder stringBuilder = new StringBuilder();
			TextMeshProUGUI[] componentsInChildren = ((Component)panel).GetComponentsInChildren<TextMeshProUGUI>(true);
			foreach (TextMeshProUGUI val in componentsInChildren)
			{
				if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponentInParent<Button>(true) != (Object)null)
				{
					continue;
				}
				string text = (((TMP_Text)val).text ?? "").Trim();
				if (text.Length != 0)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append("\n\n");
					}
					stringBuilder.Append(text);
				}
			}
			return stringBuilder.ToString();
		}

		private static void Header(RectTransform list, string title, string sub)
		{
			//IL_0023: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_0112: 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)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = UiKit.Rect("Header", (Transform)(object)list);
			((Component)(object)obj).Pref(96f);
			TextMeshProUGUI obj2 = UiKit.Label((Transform)(object)obj, title, 52f, UiKit.Orange, (TextAlignmentOptions)1025);
			((TMP_Text)obj2).rectTransform.At(0f, 1f, 0f, 0f, 1100f, 62f);
			((TMP_Text)obj2).fontStyle = (FontStyles)1;
			((TMP_Text)obj2).characterSpacing = 6f;
			((TMP_Text)obj2).enableWordWrapping = false;
			TextMeshProUGUI obj3 = UiKit.Label((Transform)(object)obj, sub, 20f, UiKit.Muted, (TextAlignmentOptions)4100);
			((TMP_Text)obj3).rectTransform.At(1f, 1f, 0f, -26f, 600f, 30f);
			((TMP_Text)obj3).characterSpacing = 4f;
			RectTransform rectTransform = ((Graphic)UiKit.Box((Transform)(object)obj, UiKit.TermLine, "Rule", raycast: false)).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 0f);
			rectTransform.anchorMax = new Vector2(1f, 0f);
			rectTransform.pivot = new Vector2(0.5f, 0f);
			rectTransform.sizeDelta = new Vector2(0f, 3f);
			rectTransform.anchoredPosition = new Vector2(0f, 14f);
		}

		private static void Section(RectTransform list, string title)
		{
			//IL_0001: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			Image obj = UiKit.Box((Transform)(object)list, UiKit.Item, "Section", raycast: false);
			((Component)(object)((Graphic)obj).rectTransform).Pref(52f);
			UiKit.Frame(((Graphic)obj).rectTransform, UiKit.TermLine);
			RectTransform rectTransform = ((Graphic)UiKit.Box((Transform)(object)((Graphic)obj).rectTransform, UiKit.Orange, "Edge", raycast: false)).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 0f);
			rectTransform.anchorMax = new Vector2(0f, 1f);
			rectTransform.pivot = new Vector2(0f, 0.5f);
			rectTransform.sizeDelta = new Vector2(4f, 0f);
			rectTransform.anchoredPosition = Vector2.zero;
			TextMeshProUGUI obj2 = UiKit.Label((Transform)(object)((Graphic)obj).rectTransform, "> " + title, 30f, UiKit.Orange, (TextAlignmentOptions)4097);
			((TMP_Text)obj2).rectTransform.Fill(20f, 0f, 20f);
			((TMP_Text)obj2).fontStyle = (FontStyles)1;
			((TMP_Text)obj2).characterSpacing = 6f;
			((TMP_Text)obj2).enableWordWrapping = false;
		}

		private static TextMeshProUGUI Body(RectTransform list, string text, float size = 32f, Color? color = null)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = UiKit.Label((Transform)(object)list, text, size, (Color)(((??)color) ?? Cream), (TextAlignmentOptions)257, "Body");
			((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
			((TMP_Text)obj).margin = new Vector4(26f, 4f, 0f, 10f);
			return obj;
		}

		private static void Gap(RectTransform list, float h)
		{
			((Component)(object)UiKit.Rect("Gap", (Transform)(object)list)).Pref(h);
		}
	}
	public class DailyResultPanel
	{
		private static readonly Color DimTxt = UiKit.Hex("#b4500c");

		private static readonly Color Light = UiKit.Hex("#ffe3c4");

		private readonly RectTransform _root;

		private readonly RectTransform _card;

		private readonly TextMeshProUGUI _score;

		private readonly TextMeshProUGUI