Decompiled source of NineKingsPvP v0.2.0

BepInEx/plugins/NineKingsPvP/NineKingsPvP.dll

Decompiled 24 minutes ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Cards;
using Core;
using Core.Entities;
using Core.Kingdoms;
using Core.UI;
using Difficulty;
using Gameplay;
using GameplayInterface;
using HarmonyLib;
using I2.Loc;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using KingSelectionUI;
using MainMenuUI;
using Microsoft.CodeAnalysis;
using MultiplayerSystems;
using Newtonsoft.Json;
using StalemateSystem;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
using UnityEngine.UI;
using _9_Kings_Mod.Gameplay;
using _9_Kings_Mod.Networking;
using _9_Kings_Mod.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("NineKingsPvP")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7272facf17a3181eccf920ac8b7575e85531c7c1")]
[assembly: AssemblyProduct("NineKingsPvP")]
[assembly: AssemblyTitle("NineKingsPvP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 _9_Kings_Mod
{
	[BepInPlugin("com.bubba1650.ninekings.pvp", "Nine Kings 1v1 PvP", "0.2.0")]
	public class Plugin : BasePlugin
	{
		internal static ManualLogSource Log;

		private Harmony _harmony;

		public override void Load()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(41, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("=========================================");
			}
			log.LogInfo(val);
			ManualLogSource log2 = Log;
			val = new BepInExInfoLogInterpolatedStringHandler(13, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Nine Kings 1v1 PvP");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.2.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log2.LogInfo(val);
			ManualLogSource log3 = Log;
			val = new BepInExInfoLogInterpolatedStringHandler(41, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("=========================================");
			}
			log3.LogInfo(val);
			_harmony = new Harmony("com.bubba1650.ninekings.pvp");
			_harmony.PatchAll();
			((BasePlugin)this).AddComponent<PvPDebugOverlay>();
			Log.LogInfo((object)"Harmony patches and PvPDebugOverlay initialized successfully.");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.bubba1650.ninekings.pvp";

		public const string PLUGIN_NAME = "Nine Kings 1v1 PvP";

		public const string PLUGIN_VERSION = "0.2.0";
	}
}
namespace _9_Kings_Mod.UI
{
	public class PvPDebugOverlay : MonoBehaviour
	{
		private PvPUiTheme _theme;

		private Canvas _canvas;

		private PvPLobbyPanel _lobbyPanel;

		private PvPHudView _hudView;

		private PvPMatchOverModal _matchOverModal;

		private bool _visible;

		private bool _wasMatchActive;

		private bool _matchOverModalDismissed;

		private bool _uiBuilt;

		private bool _uiBuildFailed;

		public PvPDebugOverlay(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Awake()
		{
			SteamPvPManager.Instance.Initialize();
			PvPMatchController.Instance.Initialize();
			ManualLogSource log = Plugin.Log;
			if (log != null)
			{
				log.LogInfo((object)"PvPDebugOverlay active (Native Main Menu + In-Match uGUI). Press F9 to toggle in-match overlay.");
			}
		}

		private void Update()
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			SteamPvPManager.Instance.Update();
			PvPMatchController.Instance.Update();
			try
			{
				Keyboard current = Keyboard.current;
				if (current != null && current.f9Key != null && ((ButtonControl)current.f9Key).wasPressedThisFrame)
				{
					_visible = !_visible;
				}
			}
			catch
			{
			}
			if (!_uiBuilt && !_uiBuildFailed)
			{
				TryBuildNativeUI();
			}
			if (!_uiBuilt || !((Object)(object)_canvas != (Object)null))
			{
				return;
			}
			try
			{
				_theme.TickFontResolution();
				PvPNativeMainMenu.Instance.Update();
				PvPMatchController instance = PvPMatchController.Instance;
				bool isMatchActive = instance.IsMatchActive;
				if (isMatchActive != _wasMatchActive)
				{
					_wasMatchActive = isMatchActive;
					_visible = false;
				}
				_hudView.Refresh(instance, ref _matchOverModalDismissed);
				_matchOverModal.Refresh(instance, _matchOverModalDismissed);
				_lobbyPanel.Refresh(_visible);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PvPDebugOverlay] uGUI Refresh error: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					log.LogError(val);
				}
			}
		}

		private void TryBuildNativeUI()
		{
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			try
			{
				_theme = new PvPUiTheme();
				_theme.EnsureResources();
				PvPNativeMainMenu.Instance.SetTheme(_theme);
				_canvas = PvPUiFactory.CreateRootCanvas("NineKingsPvP_UICanvas");
				Transform transform = ((Component)_canvas).transform;
				_hudView = new PvPHudView(transform, _theme, delegate
				{
					_matchOverModalDismissed = false;
				}, delegate
				{
					_visible = !_visible;
				});
				_lobbyPanel = new PvPLobbyPanel(transform, _theme, delegate
				{
					_visible = !_visible;
				});
				_matchOverModal = new PvPMatchOverModal(transform, _theme, delegate
				{
					_matchOverModalDismissed = true;
				});
				_lobbyPanel.Refresh(visible: false);
				_uiBuilt = true;
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogInfo((object)"[PvPUI] Native uGUI Canvas + In-Match views initialized (hidden until match starts).");
				}
			}
			catch (Exception ex)
			{
				_uiBuildFailed = true;
				ManualLogSource log2 = Plugin.Log;
				if (log2 != null)
				{
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(44, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PvPUI] Failed to build native uGUI Canvas: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					log2.LogError(val);
				}
			}
		}

		private void OnApplicationQuit()
		{
			SteamPvPManager.Instance.LeaveLobby();
		}
	}
	internal sealed class PvPHudView
	{
		private readonly PvPUiTheme _theme;

		private PvPPanelFrame _bannerFrame;

		private TextMeshProUGUI _bannerText;

		private PvPButton _forceStartBtn;

		private PvPButton _reopenModalBtn;

		private PvPButton _menuToggleBtn;

		private PvPPanelFrame _toastFrame;

		private TextMeshProUGUI _toastTitle;

		private TextMeshProUGUI _toastSubtitle;

		private readonly Action _onReopenMatchOverModal;

		private readonly Action _onToggleInMatchDrawer;

		public PvPHudView(Transform canvasRoot, PvPUiTheme theme, Action onReopenMatchOverModal, Action onToggleInMatchDrawer)
		{
			_theme = theme;
			_onReopenMatchOverModal = onReopenMatchOverModal;
			_onToggleInMatchDrawer = onToggleInMatchDrawer;
			BuildBanner(canvasRoot);
			BuildToast(canvasRoot);
		}

		private void BuildBanner(Transform canvasRoot)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			PvPUiPalette palette = _theme.Palette;
			_bannerFrame = PvPUiFactory.CreateFramedPanel(canvasRoot, "PvPHudBanner", _theme.PanelFillSprite, _theme.PanelFrameSprite, palette.HeaderBg, palette.PanelBorder);
			RectTransform rect = _bannerFrame.Rect;
			rect.anchorMin = new Vector2(0f, 1f);
			rect.anchorMax = new Vector2(0f, 1f);
			rect.pivot = new Vector2(0f, 1f);
			rect.anchoredPosition = new Vector2(248f, -14f);
			rect.sizeDelta = new Vector2(380f, 38f);
			HorizontalLayoutGroup obj = _bannerFrame.Root.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(12, 8, 4, 4);
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			_bannerText = PvPUiFactory.CreateText(_bannerFrame.Root.transform, _theme, "BannerText", "", 15f, palette.TextPrimary, (TextAlignmentOptions)4097, bold: true);
			((Component)_bannerText).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
			_forceStartBtn = PvPUiFactory.CreateButton(_bannerFrame.Root.transform, _theme, "ForceStartBtn", "Force Start", PvPButtonVariant.Danger, delegate
			{
				PvPMatchController.Instance.ForceStartBattleNow();
			}, 13f, 28f, 98f, flexibleWidth: false);
			_reopenModalBtn = PvPUiFactory.CreateButton(_bannerFrame.Root.transform, _theme, "ReopenResultsBtn", "Results", PvPButtonVariant.Gold, delegate
			{
				_onReopenMatchOverModal?.Invoke();
			}, 13f, 28f, 82f, flexibleWidth: false);
			_menuToggleBtn = PvPUiFactory.CreateButton(_bannerFrame.Root.transform, _theme, "MenuToggleBtn", "F9", PvPButtonVariant.Secondary, delegate
			{
				_onToggleInMatchDrawer?.Invoke();
			}, 12f, 28f, 40f, flexibleWidth: false);
			_bannerFrame.Root.SetActive(false);
		}

		private void BuildToast(Transform canvasRoot)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			PvPUiPalette palette = _theme.Palette;
			_toastFrame = PvPUiFactory.CreateFramedPanel(canvasRoot, "PvPClashToast", _theme.PanelFillSprite, _theme.PanelFrameSprite, palette.InfoFill, palette.InfoBorder, blockRaycasts: false);
			RectTransform rect = _toastFrame.Rect;
			rect.anchorMin = new Vector2(0.5f, 1f);
			rect.anchorMax = new Vector2(0.5f, 1f);
			rect.pivot = new Vector2(0.5f, 1f);
			rect.anchoredPosition = new Vector2(0f, -104f);
			rect.sizeDelta = new Vector2(620f, 66f);
			VerticalLayoutGroup obj = _toastFrame.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(18, 18, 9, 9);
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 4f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)4;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			_toastTitle = PvPUiFactory.CreateText(_toastFrame.Root.transform, _theme, "ToastTitle", "", 22f, palette.TextPrimary, (TextAlignmentOptions)514, bold: true);
			_toastSubtitle = PvPUiFactory.CreateText(_toastFrame.Root.transform, _theme, "ToastSubtitle", "", 16f, palette.TextSecondary, (TextAlignmentOptions)514);
			_toastFrame.Root.SetActive(false);
		}

		public void Refresh(PvPMatchController match, ref bool matchOverModalDismissed)
		{
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: 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_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			bool flag = match.IsMatchActive && !string.IsNullOrEmpty(match.StatusBanner);
			if (_bannerFrame.Root.activeSelf != flag)
			{
				_bannerFrame.Root.SetActive(flag);
			}
			if (!flag)
			{
				if (_toastFrame.Root.activeSelf)
				{
					_toastFrame.Root.SetActive(false);
				}
				return;
			}
			PvPUiPalette palette = _theme.Palette;
			bool flag2 = match.IsMatchActive && match.TurnPhase == PvPTurnPhase.ClashWaitingForOpponent;
			bool flag3 = match.IsMatchActive && (match.TurnPhase == PvPTurnPhase.ClashInBattle || match.TurnPhase == PvPTurnPhase.ClashReadyToStart);
			bool flag4 = match.IsMatchActive && match.TurnPhase == PvPTurnPhase.MatchOver;
			if (!flag4)
			{
				matchOverModalDismissed = false;
			}
			bool visible = flag4 & matchOverModalDismissed;
			Color fill;
			Color border;
			if (flag4)
			{
				if (match.MatchOutcome == PvPMatchOutcome.Victory)
				{
					fill = palette.SuccessFill;
					border = palette.SuccessBorder;
				}
				else if (match.MatchOutcome == PvPMatchOutcome.Defeat)
				{
					fill = palette.DangerFill;
					border = palette.DangerBorder;
				}
				else
				{
					fill = palette.WarningFill;
					border = palette.WarningBorder;
				}
			}
			else if (flag2)
			{
				fill = palette.WarningFill;
				border = palette.WarningBorder;
			}
			else if (flag3)
			{
				fill = palette.DangerFill;
				border = palette.GoldAccent;
			}
			else
			{
				fill = palette.HeaderBg;
				border = palette.PanelBorder;
			}
			_bannerFrame.SetColors(fill, border);
			((Graphic)_bannerText).color = palette.TextPrimary;
			PvPUiFactory.SetTextIfChanged(_bannerText, match.StatusBanner);
			_forceStartBtn.SetVisible(flag2);
			_reopenModalBtn.SetVisible(visible);
			_menuToggleBtn.SetVisible(!flag4);
			float num = (flag2 ? 430f : 380f);
			if (Mathf.Abs(_bannerFrame.Rect.sizeDelta.x - num) > 1f)
			{
				_bannerFrame.Rect.sizeDelta = new Vector2(num, 38f);
			}
			((TMP_Text)_bannerText).alignment = (TextAlignmentOptions)4097;
			bool flag5 = match.HasActiveClashToast && !flag4;
			if (_toastFrame.Root.activeSelf != flag5)
			{
				_toastFrame.Root.SetActive(flag5);
			}
			if (flag5)
			{
				Color fill2;
				Color border2;
				switch (match.ClashToastTone)
				{
				case 1:
					fill2 = palette.SuccessFill;
					border2 = palette.SuccessBorder;
					break;
				case -1:
					fill2 = palette.DangerFill;
					border2 = palette.DangerBorder;
					break;
				case 2:
					fill2 = palette.WarningFill;
					border2 = palette.WarningBorder;
					break;
				default:
					fill2 = palette.InfoFill;
					border2 = palette.InfoBorder;
					break;
				}
				_toastFrame.SetColors(fill2, border2);
				((Graphic)_toastTitle).color = palette.TextPrimary;
				((Graphic)_toastSubtitle).color = palette.TextSecondary;
				PvPUiFactory.SetTextIfChanged(_toastTitle, match.ClashToastTitle);
				bool flag6 = !string.IsNullOrEmpty(match.ClashToastSubtitle);
				if (((Component)_toastSubtitle).gameObject.activeSelf != flag6)
				{
					((Component)_toastSubtitle).gameObject.SetActive(flag6);
				}
				if (flag6)
				{
					PvPUiFactory.SetTextIfChanged(_toastSubtitle, match.ClashToastSubtitle);
				}
			}
		}
	}
	internal sealed class PvPLobbyPanel
	{
		private const int MaxLogLines = 6;

		private readonly PvPUiTheme _theme;

		private PvPPanelFrame _panelFrame;

		private TextMeshProUGUI _matchupText;

		private PvPBadge _pingBadge;

		private TextMeshProUGUI _rulesSummaryText;

		private PvPButton _clashSpeedBtn;

		private PvPButton _leaveBtn;

		private PvPButton _advToggleBtn;

		private PvPPanelFrame _advCard;

		private GameObject _p2pTestRow;

		private TextMeshProUGUI _logText;

		private bool _advancedExpanded;

		private int _lastLogCount = -1;

		private string _lastLogTail;

		private bool _lastVisible = true;

		public PvPLobbyPanel(Transform canvasRoot, PvPUiTheme theme, Action onToggleVisible)
		{
			_theme = theme;
			BuildQuickDrawer(canvasRoot, onToggleVisible);
		}

		private void BuildQuickDrawer(Transform canvasRoot, Action onToggleVisible)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Expected O, but got Unknown
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Expected O, but got Unknown
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Expected O, but got Unknown
			//IL_0571: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Expected O, but got Unknown
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			PvPUiPalette palette = _theme.Palette;
			_panelFrame = PvPUiFactory.CreateFramedPanel(canvasRoot, "PvPInMatchPanel", _theme.PanelFillSprite, _theme.PanelFrameSprite, palette.PanelBg, palette.PanelBorder);
			RectTransform rect = _panelFrame.Rect;
			rect.anchorMin = new Vector2(0f, 1f);
			rect.anchorMax = new Vector2(0f, 1f);
			rect.pivot = new Vector2(0f, 1f);
			rect.anchoredPosition = new Vector2(248f, -58f);
			rect.sizeDelta = new Vector2(380f, 0f);
			VerticalLayoutGroup obj = _panelFrame.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(5, 5, 5, 10);
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			ContentSizeFitter obj2 = _panelFrame.Root.AddComponent<ContentSizeFitter>();
			obj2.horizontalFit = (FitMode)0;
			obj2.verticalFit = (FitMode)2;
			Image val = PvPUiFactory.CreateSolidRect(_panelFrame.Root.transform, "HeaderBar", palette.HeaderBg);
			LayoutElement obj3 = ((Component)val).gameObject.AddComponent<LayoutElement>();
			obj3.minHeight = 40f;
			obj3.preferredHeight = 40f;
			HorizontalLayoutGroup obj4 = ((Component)val).gameObject.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj4).padding = new RectOffset(12, 8, 5, 5);
			((HorizontalOrVerticalLayoutGroup)obj4).spacing = 6f;
			((LayoutGroup)obj4).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false;
			((Component)PvPUiFactory.CreateText(((Component)val).transform, _theme, "Title", "1v1 PvP", 18f, palette.TextGold, (TextAlignmentOptions)4097, bold: true)).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
			_pingBadge = PvPUiFactory.CreateBadge(((Component)val).transform, _theme, "PingBadge", "... ms", 12f, 22f, 56f);
			PvPUiFactory.CreateButton(((Component)val).transform, _theme, "HideBtn", "Hide [F9]", PvPButtonVariant.Secondary, onToggleVisible, 12f, 26f, 74f, flexibleWidth: false);
			VerticalLayoutGroup val2 = PvPUiFactory.CreateVerticalStack(_panelFrame.Root.transform, "Body", 8f, new RectOffset(10, 10, 2, 2), (TextAnchor)0);
			PvPPanelFrame pvPPanelFrame = PvPUiFactory.CreateFramedPanel(((Component)val2).transform, "MatchCard", _theme.CardFillSprite, _theme.CardFrameSprite, palette.CardBg, palette.CardBorder, blockRaycasts: false);
			VerticalLayoutGroup obj5 = pvPPanelFrame.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj5).padding = new RectOffset(10, 10, 8, 10);
			((HorizontalOrVerticalLayoutGroup)obj5).spacing = 6f;
			((HorizontalOrVerticalLayoutGroup)obj5).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj5).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandHeight = false;
			_matchupText = PvPUiFactory.CreateText(pvPPanelFrame.Root.transform, _theme, "Matchup", "Not connected", 15f, palette.TextPrimary, (TextAlignmentOptions)4097, bold: true);
			_rulesSummaryText = PvPUiFactory.CreateText(pvPPanelFrame.Root.transform, _theme, "RulesSummary", "", 13f, palette.TextSecondary, (TextAlignmentOptions)4097, bold: false, wrap: true);
			_clashSpeedBtn = PvPUiFactory.CreateButton(pvPPanelFrame.Root.transform, _theme, "ClashSpeedBtn", "Clash Speed: Auto 1x", PvPButtonVariant.Primary, delegate
			{
				PvPMatchController.Instance.CycleClashAutoSpeedMode();
			}, 14f, 32f);
			_leaveBtn = PvPUiFactory.CreateButton(pvPPanelFrame.Root.transform, _theme, "LeaveLobbyBtn", "Leave Lobby", PvPButtonVariant.Danger, delegate
			{
				SteamPvPManager.Instance.LeaveLobby();
			}, 13f, 28f);
			_advToggleBtn = PvPUiFactory.CreateButton(((Component)val2).transform, _theme, "AdvToggleBtn", "> Advanced", PvPButtonVariant.Ghost, delegate
			{
				_advancedExpanded = !_advancedExpanded;
				_advCard.Root.SetActive(_advancedExpanded);
				_advToggleBtn.SetText(_advancedExpanded ? "v Advanced" : "> Advanced");
			}, 12f, 24f);
			_advCard = PvPUiFactory.CreateFramedPanel(((Component)val2).transform, "AdvCard", _theme.CardFillSprite, _theme.CardFrameSprite, palette.CardBg, palette.CardBorder, blockRaycasts: false);
			VerticalLayoutGroup obj6 = _advCard.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj6).padding = new RectOffset(8, 8, 6, 8);
			((HorizontalOrVerticalLayoutGroup)obj6).spacing = 6f;
			((HorizontalOrVerticalLayoutGroup)obj6).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj6).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj6).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj6).childForceExpandHeight = false;
			HorizontalLayoutGroup val3 = PvPUiFactory.CreateHorizontalRow(_advCard.Root.transform, "Tests", 6f, null, (TextAnchor)3);
			_p2pTestRow = ((Component)val3).gameObject;
			PvPUiFactory.CreateButton(((Component)val3).transform, _theme, "PingBtn", "Ping Opponent", PvPButtonVariant.Secondary, delegate
			{
				SteamPvPManager.Instance.SendPing();
			}, 12f, 24f);
			PvPPanelFrame pvPPanelFrame2 = PvPUiFactory.CreateFramedPanel(_advCard.Root.transform, "LogInset", _theme.CardFillSprite, _theme.BadgeFrameSprite, palette.InsetBg, palette.Divider, blockRaycasts: false);
			VerticalLayoutGroup obj7 = pvPPanelFrame2.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj7).padding = new RectOffset(6, 6, 4, 4);
			((HorizontalOrVerticalLayoutGroup)obj7).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj7).childControlHeight = true;
			pvPPanelFrame2.Root.AddComponent<LayoutElement>().minHeight = 90f;
			_logText = PvPUiFactory.CreateText(pvPPanelFrame2.Root.transform, _theme, "LogText", "No events yet.", 12f, palette.TextSecondary, (TextAlignmentOptions)257, bold: false, wrap: true, addShadow: false);
			_advCard.Root.SetActive(false);
		}

		public void Refresh(bool visible)
		{
			//IL_007b: 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_0087: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			if (_lastVisible != visible)
			{
				_lastVisible = visible;
				_panelFrame.Root.SetActive(visible);
			}
			if (!visible)
			{
				return;
			}
			SteamPvPManager instance = SteamPvPManager.Instance;
			PvPMatchController instance2 = PvPMatchController.Instance;
			IPvPTransport active = PvPTransportHost.Active;
			PvPUiPalette palette = _theme.Palette;
			bool flag = active.State == PvPConnectionState.Connected;
			_pingBadge.SetVisible(flag);
			if (flag)
			{
				int lastPingMs = active.LastPingMs;
				if (lastPingMs < 0)
				{
					_pingBadge.Set("... ms", palette.InsetBg, palette.CardBorder, palette.TextMuted);
				}
				else if (lastPingMs < 90)
				{
					_pingBadge.Set($"{lastPingMs} ms", palette.SuccessFill, palette.SuccessBorder, palette.TextPrimary);
				}
				else if (lastPingMs < 180)
				{
					_pingBadge.Set($"{lastPingMs} ms", palette.WarningFill, palette.WarningBorder, palette.TextPrimary);
				}
				else
				{
					_pingBadge.Set($"{lastPingMs} ms", palette.DangerFill, palette.DangerBorder, palette.TextPrimary);
				}
			}
			string text = ((flag && !string.IsNullOrEmpty(active.OpponentName)) ? active.OpponentName : null);
			PvPUiFactory.SetTextIfChanged(_matchupText, (text != null) ? ("vs " + text) : "Not in a 1v1 lobby");
			string value = ((instance2.Rules.Mode == PvPGameMode.EveryYearDuel) ? "Every Year" : $"Every {instance2.Rules.EffectiveClashInterval}y");
			string value2 = ((instance2.Rules.TieBreaker == PvPTieBreakerMode.DrawOnDoubleWin) ? "Draw" : "Faster Wins");
			PvPUiFactory.SetTextIfChanged(_rulesSummaryText, $"Clash: {value}  |  {instance2.GetSyncedDifficultyDisplayName()}  |  {value2}");
			ClashAutoSpeedMode clashAutoSpeedMode = instance2.ClashAutoSpeedMode;
			_clashSpeedBtn.SetText("Clash Speed: " + clashAutoSpeedMode switch
			{
				ClashAutoSpeedMode.Normal1x => "Auto 1x", 
				ClashAutoSpeedMode.Fast2x => "Auto 2x", 
				_ => "Manual", 
			});
			_leaveBtn.SetVisible(instance.CurrentLobbyId != 0);
			if (!_advancedExpanded)
			{
				return;
			}
			bool flag2 = instance.State == PvPConnectionState.Connected;
			if (_p2pTestRow.activeSelf != flag2)
			{
				_p2pTestRow.SetActive(flag2);
			}
			IReadOnlyList<string> recentLogs = instance.RecentLogs;
			string text2 = ((recentLogs.Count > 0) ? recentLogs[recentLogs.Count - 1] : string.Empty);
			if (recentLogs.Count == _lastLogCount && !(text2 != _lastLogTail))
			{
				return;
			}
			_lastLogCount = recentLogs.Count;
			_lastLogTail = text2;
			if (recentLogs.Count == 0)
			{
				PvPUiFactory.SetTextIfChanged(_logText, "No events yet.");
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			int num = Math.Max(0, recentLogs.Count - 6);
			for (int i = num; i < recentLogs.Count; i++)
			{
				if (i > num)
				{
					stringBuilder.Append('\n');
				}
				stringBuilder.Append(PvPUiTheme.SanitizeText(recentLogs[i]));
			}
			PvPUiFactory.SetTextIfChanged(_logText, stringBuilder.ToString());
		}
	}
	internal sealed class PvPMatchOverModal
	{
		private const int MaxHistoryRows = 10;

		private readonly PvPUiTheme _theme;

		private readonly Action _onDismiss;

		private GameObject _root;

		private Image _scrim;

		private PvPPanelFrame _modalFrame;

		private Image _headerBg;

		private TextMeshProUGUI _headlineText;

		private TextMeshProUGUI _reasonText;

		private PvPPanelFrame _scoreCard;

		private TextMeshProUGUI _scoreText;

		private PvPPanelFrame _rematchBanner;

		private TextMeshProUGUI _rematchBannerText;

		private TextMeshProUGUI _historyHeaderText;

		private PvPPanelFrame _historyInset;

		private TextMeshProUGUI _emptyHistoryText;

		private readonly List<TextMeshProUGUI> _historyRowTexts = new List<TextMeshProUGUI>();

		private PvPButton _rematchBtn;

		private PvPButton _mainMenuBtn;

		private PvPButton _hideBtn;

		private int _lastHistoryCount = -1;

		public PvPMatchOverModal(Transform canvasRoot, PvPUiTheme theme, Action onDismiss)
		{
			_theme = theme;
			_onDismiss = onDismiss;
			BuildModal(canvasRoot);
		}

		private void BuildModal(Transform canvasRoot)
		{
			//IL_0014: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Expected O, but got Unknown
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Expected O, but got Unknown
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Expected O, but got Unknown
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Expected O, but got Unknown
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			PvPUiPalette palette = _theme.Palette;
			_scrim = PvPUiFactory.CreateSolidRect(canvasRoot, "PvPMatchOverModal", palette.ScrimBg, blockRaycasts: true);
			_root = ((Component)_scrim).gameObject;
			PvPUiFactory.StretchFull(((Graphic)_scrim).rectTransform);
			_modalFrame = PvPUiFactory.CreateFramedPanel(_root.transform, "ModalCard", _theme.PanelFillSprite, _theme.PanelFrameSprite, palette.PanelBg, palette.PanelBorder);
			RectTransform rect = _modalFrame.Rect;
			rect.anchorMin = new Vector2(0.5f, 0.5f);
			rect.anchorMax = new Vector2(0.5f, 0.5f);
			rect.pivot = new Vector2(0.5f, 0.5f);
			rect.anchoredPosition = Vector2.zero;
			rect.sizeDelta = new Vector2(580f, 0f);
			VerticalLayoutGroup obj = _modalFrame.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(5, 5, 5, 16);
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 12f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			ContentSizeFitter obj2 = _modalFrame.Root.AddComponent<ContentSizeFitter>();
			obj2.horizontalFit = (FitMode)0;
			obj2.verticalFit = (FitMode)2;
			_headerBg = PvPUiFactory.CreateSolidRect(_modalFrame.Root.transform, "HeaderBar", palette.HeaderBg);
			LayoutElement obj3 = ((Component)_headerBg).gameObject.AddComponent<LayoutElement>();
			obj3.minHeight = 60f;
			obj3.preferredHeight = 60f;
			_headlineText = PvPUiFactory.CreateText(((Component)_headerBg).transform, _theme, "Headline", "1v1 VICTORY!", 28f, palette.TextPrimary, (TextAlignmentOptions)514, bold: true);
			PvPUiFactory.StretchFull(((TMP_Text)_headlineText).rectTransform, 16f, 16f);
			VerticalLayoutGroup val = PvPUiFactory.CreateVerticalStack(_modalFrame.Root.transform, "Body", 10f, new RectOffset(18, 18, 2, 2), (TextAnchor)0);
			_reasonText = PvPUiFactory.CreateText(((Component)val).transform, _theme, "ReasonText", "", 18f, palette.TextSecondary, (TextAlignmentOptions)514, bold: false, wrap: true);
			_scoreCard = PvPUiFactory.CreateFramedPanel(((Component)val).transform, "ScoreCard", _theme.CardFillSprite, _theme.CardFrameSprite, palette.CardBg, palette.CardBorder, blockRaycasts: false);
			HorizontalLayoutGroup obj4 = _scoreCard.Root.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj4).padding = new RectOffset(14, 14, 10, 10);
			((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true;
			_scoreText = PvPUiFactory.CreateText(_scoreCard.Root.transform, _theme, "ScoreText", "Final Hearts: You 5 - 0 Opponent", 19f, palette.TextGold, (TextAlignmentOptions)514, bold: true);
			_rematchBanner = PvPUiFactory.CreateFramedPanel(((Component)val).transform, "RematchBanner", _theme.BadgeFillSprite, _theme.BadgeFrameSprite, palette.SuccessFill, palette.SuccessBorder, blockRaycasts: false);
			HorizontalLayoutGroup obj5 = _rematchBanner.Root.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj5).padding = new RectOffset(12, 12, 7, 7);
			((HorizontalOrVerticalLayoutGroup)obj5).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj5).childControlHeight = true;
			_rematchBannerText = PvPUiFactory.CreateText(_rematchBanner.Root.transform, _theme, "RematchText", "Opponent is ready for a Rematch!", 16f, palette.TextPrimary, (TextAlignmentOptions)514, bold: true);
			_rematchBanner.Root.SetActive(false);
			_historyHeaderText = PvPUiFactory.CreateText(((Component)val).transform, _theme, "HistoryHeader", "CLASH HISTORY", 15f, palette.TextGold, (TextAlignmentOptions)4097, bold: true);
			_historyInset = PvPUiFactory.CreateFramedPanel(((Component)val).transform, "HistoryInset", _theme.CardFillSprite, _theme.BadgeFrameSprite, palette.InsetBg, palette.CardBorder, blockRaycasts: false);
			VerticalLayoutGroup obj6 = _historyInset.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj6).padding = new RectOffset(12, 12, 10, 10);
			((HorizontalOrVerticalLayoutGroup)obj6).spacing = 4f;
			((LayoutGroup)obj6).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)obj6).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj6).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj6).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj6).childForceExpandHeight = false;
			_historyInset.Root.AddComponent<LayoutElement>().minHeight = 140f;
			_emptyHistoryText = PvPUiFactory.CreateText(_historyInset.Root.transform, _theme, "EmptyHistory", "No clashes completed before match ended.", 15f, palette.TextMuted, (TextAlignmentOptions)4097, bold: false, wrap: false, addShadow: false);
			for (int i = 0; i < 10; i++)
			{
				TextMeshProUGUI val2 = PvPUiFactory.CreateText(_historyInset.Root.transform, _theme, $"HistoryRow_{i}", "", 15f, palette.TextPrimary, (TextAlignmentOptions)4097, bold: false, wrap: false, addShadow: false);
				((Component)val2).gameObject.SetActive(false);
				_historyRowTexts.Add(val2);
			}
			HorizontalLayoutGroup val3 = PvPUiFactory.CreateHorizontalRow(((Component)val).transform, "PrimaryActions", 10f, null, (TextAnchor)3);
			_rematchBtn = PvPUiFactory.CreateButton(((Component)val3).transform, _theme, "RematchBtn", "Rematch", PvPButtonVariant.Gold, delegate
			{
				PvPMatchController.Instance.RequestRematchAndGoToKingSelection();
			}, 17f, 42f);
			_mainMenuBtn = PvPUiFactory.CreateButton(((Component)val3).transform, _theme, "MainMenuBtn", "Main Menu", PvPButtonVariant.Secondary, delegate
			{
				PvPMatchController.Instance.ReturnToMainMenuFromMatchOver();
			}, 17f, 42f);
			_hideBtn = PvPUiFactory.CreateButton(((Component)val).transform, _theme, "HideModalBtn", "Inspect Board", PvPButtonVariant.Ghost, delegate
			{
				_onDismiss?.Invoke();
			}, 14f, 32f);
			_root.SetActive(false);
		}

		public void Refresh(PvPMatchController match, bool dismissed)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			bool flag = match.IsMatchActive && match.TurnPhase == PvPTurnPhase.MatchOver && !dismissed;
			if (_root.activeSelf != flag)
			{
				_root.SetActive(flag);
				if (flag)
				{
					_lastHistoryCount = -1;
				}
			}
			if (!flag)
			{
				return;
			}
			PvPUiPalette palette = _theme.Palette;
			Color border;
			Color color;
			string text;
			switch (match.MatchOutcome)
			{
			case PvPMatchOutcome.Victory:
				border = palette.SuccessBorder;
				color = palette.SuccessFill;
				text = "1v1 VICTORY!";
				break;
			case PvPMatchOutcome.Defeat:
				border = palette.DangerBorder;
				color = palette.DangerFill;
				text = "1v1 DEFEAT";
				break;
			default:
				border = palette.WarningBorder;
				color = palette.WarningFill;
				text = "1v1 MATCH DRAW";
				break;
			}
			_modalFrame.SetColors(palette.PanelBg, border);
			((Graphic)_headerBg).color = color;
			PvPUiFactory.SetTextIfChanged(_headlineText, text);
			bool flag2 = !string.IsNullOrEmpty(match.MatchOverReason);
			if (((Component)_reasonText).gameObject.activeSelf != flag2)
			{
				((Component)_reasonText).gameObject.SetActive(flag2);
			}
			if (flag2)
			{
				PvPUiFactory.SetTextIfChanged(_reasonText, match.MatchOverReason);
			}
			string text2 = ((!string.IsNullOrEmpty(PvPTransportHost.Active?.OpponentName)) ? PvPTransportHost.Active.OpponentName : "Opponent");
			PvPUiFactory.SetTextIfChanged(_scoreText, $"You {match.LocalHearts}  -  {match.OpponentHearts} {text2}   |   {match.ClashesCompleted} Clashes   |   Year {match.CurrentWaveNumber}");
			bool opponentWantsRematch = match.OpponentWantsRematch;
			if (_rematchBanner.Root.activeSelf != opponentWantsRematch)
			{
				_rematchBanner.Root.SetActive(opponentWantsRematch);
			}
			if (opponentWantsRematch)
			{
				PvPUiFactory.SetTextIfChanged(_rematchBannerText, text2 + " is ready for a Rematch!");
			}
			IReadOnlyList<ClashHistoryEntry> clashHistory = match.ClashHistory;
			if (clashHistory.Count == _lastHistoryCount)
			{
				return;
			}
			_lastHistoryCount = clashHistory.Count;
			bool flag3 = clashHistory.Count == 0;
			((Component)_emptyHistoryText).gameObject.SetActive(flag3);
			int num = Math.Max(0, clashHistory.Count - 10);
			int num2 = clashHistory.Count - num;
			for (int i = 0; i < 10; i++)
			{
				TextMeshProUGUI val = _historyRowTexts[i];
				bool flag4 = !flag3 && i < num2;
				((Component)val).gameObject.SetActive(flag4);
				if (flag4)
				{
					ClashHistoryEntry clashHistoryEntry = clashHistory[num + i];
					string value = (clashHistoryEntry.LocalWon ? "Defended" : "Fell");
					string value2 = (clashHistoryEntry.OpponentWon ? "Defended" : "Fell");
					string text3 = $"Y{clashHistoryEntry.Wave}: {clashHistoryEntry.Summary}  [{value} vs {value2}]  ->  {clashHistoryEntry.LocalHeartsAfter}-{clashHistoryEntry.OpponentHeartsAfter}";
					PvPUiFactory.SetTextIfChanged(val, text3);
					string text4 = (clashHistoryEntry.Summary ?? string.Empty).ToUpperInvariant();
					if (text4.Contains("WON") || (clashHistoryEntry.LocalWon && !clashHistoryEntry.OpponentWon))
					{
						((Graphic)val).color = palette.SuccessBorder;
					}
					else if (text4.Contains("LOST") || (!clashHistoryEntry.LocalWon && clashHistoryEntry.OpponentWon))
					{
						((Graphic)val).color = palette.DangerBorder;
					}
					else
					{
						((Graphic)val).color = palette.WarningBorder;
					}
				}
			}
		}
	}
	internal sealed class PvPNativeMainMenu
	{
		private sealed class FriendRow
		{
			public GameObject Root;

			public TextMeshProUGUI NameText;

			public ulong LobbyId;
		}

		private const int MaxFriendRows = 4;

		private const int MaxLogLines = 6;

		private PvPUiTheme _theme;

		private MainMenuUI_Main _mainMenu;

		private GameObject _menuBtnGo;

		private GameObject _screenRoot;

		private bool _isOpen;

		private AudioClip _nativeClickSfx;

		private AudioClip _nativeStartSfx;

		private PvPBadge _stateBadge;

		private PvPBadge _pingBadge;

		private TextMeshProUGUI _matchupText;

		private PvPPanelFrame _rejectBanner;

		private TextMeshProUGUI _rejectBannerText;

		private GameObject _lobbyCodeRow;

		private TextMeshProUGUI _lobbyCodeText;

		private PvPButton _copyCodeBtn;

		private GameObject _noLobbyGroup;

		private GameObject _friendsListRoot;

		private readonly List<FriendRow> _friendRows = new List<FriendRow>();

		private TextMeshProUGUI _clipboardErrorText;

		private float _clipboardErrorUntil;

		private GameObject _inLobbyGroup;

		private PvPBadge _heartsBadge;

		private PvPBadge _roleBadge;

		private GameObject _hostSettingsGrid;

		private PvPButton _formatBtn;

		private PvPButton _diffBtn;

		private PvPButton _tieBtn;

		private PvPButton _seedBtn;

		private PvPButton _newSeedBtn;

		private GameObject _guestSettingsBox;

		private TextMeshProUGUI _guestSettingsText;

		private PvPButton _clashSpeedBtn;

		private PvPButton _advToggleBtn;

		private PvPPanelFrame _advCard;

		private GameObject _p2pTestRow;

		private PvPButton _pvpActiveToggleBtn;

		private TextMeshProUGUI _logText;

		private TextMeshProUGUI _footerHintText;

		private PvPButton _startMatchBtn;

		private bool _advancedExpanded;

		private float _copiedUntilTime;

		private int _lastLogCount = -1;

		private string _lastLogTail;

		public static PvPNativeMainMenu Instance { get; } = new PvPNativeMainMenu();

		public bool IsOpen
		{
			get
			{
				if (_isOpen && (Object)(object)_screenRoot != (Object)null)
				{
					return _screenRoot.activeInHierarchy;
				}
				return false;
			}
		}

		public void SetTheme(PvPUiTheme theme)
		{
			_theme = theme;
		}

		public void AttachToMainMenu(MainMenuUI_Main mainMenu)
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			if ((Object)(object)mainMenu == (Object)null || ((Object)(object)_mainMenu != (Object)null && ((Il2CppObjectBase)_mainMenu).Pointer == ((Il2CppObjectBase)mainMenu).Pointer && (Object)(object)_menuBtnGo != (Object)null && (Object)(object)_screenRoot != (Object)null))
			{
				return;
			}
			try
			{
				if (_theme == null)
				{
					_theme = new PvPUiTheme();
				}
				_theme.EnsureResources();
				_mainMenu = mainMenu;
				_isOpen = false;
				_nativeClickSfx = mainMenu.m_ButtonClickSFX;
				_nativeStartSfx = mainMenu.m_PlayButtonSFX;
				InjectRootMenuButton(mainMenu);
				BuildNativePvPScreen(mainMenu);
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogInfo((object)"[PvPUI] Injected native '1v1 PvP' button & screen into Root Main Menu.");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				if (log2 != null)
				{
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(60, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PvPUI] Failed to attach native Root Main Menu integration: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					log2.LogError(val);
				}
			}
		}

		private void InjectRootMenuButton(MainMenuUI_Main mainMenu)
		{
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Invalid comparison between Unknown and I4
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Invalid comparison between Unknown and I4
			MainMenuPanel mainMenuPanel = mainMenu._mainMenuPanel;
			if (mainMenuPanel == null || (Object)(object)mainMenuPanel.optionsBtn == (Object)null || (Object)(object)mainMenuPanel.startBtn == (Object)null)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)"[PvPUI] MainMenuPanel buttons unavailable; skipping Root Menu button injection.");
				}
				return;
			}
			Transform parent = ((Component)mainMenuPanel.optionsBtn).transform.parent;
			if ((Object)(object)parent == (Object)null)
			{
				return;
			}
			Transform val = parent.Find("PvP1v1MenuButton");
			if ((Object)(object)val != (Object)null)
			{
				_menuBtnGo = ((Component)val).gameObject;
				return;
			}
			_menuBtnGo = Object.Instantiate<GameObject>(((Component)mainMenuPanel.optionsBtn).gameObject, parent, false);
			((Object)_menuBtnGo).name = "PvP1v1MenuButton";
			int siblingIndex = ((Component)mainMenuPanel.startBtn).transform.GetSiblingIndex();
			_menuBtnGo.transform.SetSiblingIndex(siblingIndex + 1);
			StripLocalization(_menuBtnGo);
			Il2CppArrayBase<TMP_Text> componentsInChildren = _menuBtnGo.GetComponentsInChildren<TMP_Text>(true);
			if (componentsInChildren != null)
			{
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					if ((Object)(object)componentsInChildren[i] != (Object)null)
					{
						componentsInChildren[i].text = "1v1 PvP";
					}
				}
			}
			Button component = _menuBtnGo.GetComponent<Button>();
			if ((Object)(object)component != (Object)null)
			{
				component.onClick = new ButtonClickedEvent();
				((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					PlayClickSfx();
					OpenScreen();
				}));
				try
				{
					Navigation navigation = ((Selectable)mainMenuPanel.startBtn).navigation;
					Navigation navigation2 = ((Selectable)mainMenuPanel.optionsBtn).navigation;
					Navigation navigation3 = ((Selectable)component).navigation;
					if ((int)navigation.mode == 4)
					{
						navigation.m_SelectOnDown = (Selectable)(object)component;
						((Selectable)mainMenuPanel.startBtn).navigation = navigation;
						navigation3.mode = (Mode)4;
						navigation3.m_SelectOnUp = (Selectable)(object)mainMenuPanel.startBtn;
						navigation3.m_SelectOnDown = (Selectable)(object)mainMenuPanel.optionsBtn;
						((Selectable)component).navigation = navigation3;
						if ((int)navigation2.mode == 4)
						{
							navigation2.m_SelectOnUp = (Selectable)(object)component;
							((Selectable)mainMenuPanel.optionsBtn).navigation = navigation2;
						}
					}
				}
				catch
				{
				}
			}
			_menuBtnGo.SetActive(true);
		}

		private void BuildNativePvPScreen(MainMenuUI_Main mainMenu)
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Expected O, but got Unknown
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Expected O, but got Unknown
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Expected O, but got Unknown
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			_friendRows.Clear();
			_lastLogCount = -1;
			_lastLogTail = null;
			_advancedExpanded = false;
			Transform val = (((Object)(object)((Component)mainMenu).transform.parent != (Object)null) ? ((Component)mainMenu).transform.parent : ((Component)mainMenu).transform);
			Transform val2 = val.Find("NineKingsPvP_NativeMenuScreen");
			if ((Object)(object)val2 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
			Color color = default(Color);
			((Color)(ref color))..ctor(0.05f, 0.04f, 0.08f, 0.8f);
			try
			{
				MainMenuUI_Options val3 = ((UIController<MainMenuUI>)(object)((UISubController<MainMenuUI>)(object)mainMenu).Controller)?.GetSubController<MainMenuUI_Options>();
				if ((Object)(object)val3 != (Object)null && (Object)(object)val3._background != (Object)null && ((Graphic)val3._background).color.a > 0.2f)
				{
					color = ((Graphic)val3._background).color;
				}
			}
			catch
			{
			}
			PvPUiPalette palette = _theme.Palette;
			Image val4 = PvPUiFactory.CreateSolidRect(val, "NineKingsPvP_NativeMenuScreen", color, blockRaycasts: true);
			_screenRoot = ((Component)val4).gameObject;
			PvPUiFactory.StretchFull(((Graphic)val4).rectTransform);
			_screenRoot.transform.SetAsLastSibling();
			PvPPanelFrame pvPPanelFrame = PvPUiFactory.CreateFramedPanel(_screenRoot.transform, "PvPWindow", _theme.PanelFillSprite, _theme.PanelFrameSprite, palette.PanelBg, palette.PanelBorder);
			RectTransform rect = pvPPanelFrame.Rect;
			rect.anchorMin = new Vector2(0.5f, 0.5f);
			rect.anchorMax = new Vector2(0.5f, 0.5f);
			rect.pivot = new Vector2(0.5f, 0.5f);
			rect.anchoredPosition = Vector2.zero;
			rect.sizeDelta = new Vector2(660f, 0f);
			VerticalLayoutGroup obj2 = pvPPanelFrame.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(5, 5, 5, 5);
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 0f;
			((LayoutGroup)obj2).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			ContentSizeFitter obj3 = pvPPanelFrame.Root.AddComponent<ContentSizeFitter>();
			obj3.horizontalFit = (FitMode)0;
			obj3.verticalFit = (FitMode)2;
			Image val5 = PvPUiFactory.CreateSolidRect(pvPPanelFrame.Root.transform, "HeaderBar", palette.HeaderBg);
			LayoutElement obj4 = ((Component)val5).gameObject.AddComponent<LayoutElement>();
			obj4.minHeight = 56f;
			obj4.preferredHeight = 56f;
			HorizontalLayoutGroup obj5 = ((Component)val5).gameObject.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj5).padding = new RectOffset(18, 16, 8, 8);
			((HorizontalOrVerticalLayoutGroup)obj5).spacing = 8f;
			((LayoutGroup)obj5).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)obj5).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj5).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandHeight = false;
			((Component)PvPUiFactory.CreateText(((Component)val5).transform, _theme, "Title", "1v1 PvP  v0.2.0", 24f, palette.TextGold, (TextAlignmentOptions)4097, bold: true)).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
			_pingBadge = PvPUiFactory.CreateBadge(((Component)val5).transform, _theme, "PingBadge", "... ms", 13f, 26f, 64f);
			_stateBadge = PvPUiFactory.CreateBadge(((Component)val5).transform, _theme, "StateBadge", "READY", 13f, 26f, 92f);
			VerticalLayoutGroup val6 = PvPUiFactory.CreateVerticalStack(pvPPanelFrame.Root.transform, "Body", 10f, new RectOffset(16, 16, 12, 12), (TextAnchor)0);
			BuildLobbyCard(((Component)val6).transform);
			BuildSettingsCard(((Component)val6).transform);
			BuildAdvancedDrawer(((Component)val6).transform);
			Image val7 = PvPUiFactory.CreateSolidRect(pvPPanelFrame.Root.transform, "FooterBar", palette.HeaderBg);
			LayoutElement obj6 = ((Component)val7).gameObject.AddComponent<LayoutElement>();
			obj6.minHeight = 60f;
			obj6.preferredHeight = 60f;
			HorizontalLayoutGroup obj7 = ((Component)val7).gameObject.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj7).padding = new RectOffset(16, 16, 10, 10);
			((HorizontalOrVerticalLayoutGroup)obj7).spacing = 10f;
			((LayoutGroup)obj7).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)obj7).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj7).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj7).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj7).childForceExpandHeight = false;
			PvPUiFactory.CreateButton(((Component)val7).transform, _theme, "BackBtn", "Back", PvPButtonVariant.Secondary, delegate
			{
				PlayClickSfx();
				CloseScreen();
			}, 17f, 40f, 112f, flexibleWidth: false);
			_footerHintText = PvPUiFactory.CreateText(((Component)val7).transform, _theme, "FooterHint", "Host or join a friend to play.", 14f, palette.TextSecondary, (TextAlignmentOptions)514);
			((Component)_footerHintText).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
			_startMatchBtn = PvPUiFactory.CreateButton(((Component)val7).transform, _theme, "StartMatchBtn", "Start 1v1", PvPButtonVariant.Ghost, OnStartMatchClicked, 18f, 40f, 186f, flexibleWidth: false);
			_screenRoot.SetActive(false);
		}

		private void BuildLobbyCard(Transform parent)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_0152: 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_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			PvPUiPalette palette = _theme.Palette;
			PvPPanelFrame pvPPanelFrame = PvPUiFactory.CreateFramedPanel(parent, "LobbyCard", _theme.CardFillSprite, _theme.CardFrameSprite, palette.CardBg, palette.CardBorder, blockRaycasts: false);
			VerticalLayoutGroup obj = pvPPanelFrame.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(14, 14, 10, 12);
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			_matchupText = PvPUiFactory.CreateText(pvPPanelFrame.Root.transform, _theme, "MatchupText", "Waiting for Steam...", 17f, palette.TextPrimary, (TextAlignmentOptions)4097, bold: true);
			_rejectBanner = PvPUiFactory.CreateFramedPanel(pvPPanelFrame.Root.transform, "VersionRejectBanner", _theme.BadgeFillSprite, _theme.BadgeFrameSprite, palette.DangerFill, palette.DangerBorder, blockRaycasts: false);
			HorizontalLayoutGroup obj2 = _rejectBanner.Root.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(10, 10, 6, 6);
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true;
			_rejectBannerText = PvPUiFactory.CreateText(_rejectBanner.Root.transform, _theme, "RejectText", "", 14f, palette.TextPrimary, (TextAlignmentOptions)4097, bold: true, wrap: true);
			_rejectBanner.Root.SetActive(false);
			HorizontalLayoutGroup val = PvPUiFactory.CreateHorizontalRow(pvPPanelFrame.Root.transform, "LobbyCodeRow", 8f, null, (TextAnchor)3, forceExpandWidth: false);
			_lobbyCodeRow = ((Component)val).gameObject;
			_lobbyCodeText = PvPUiFactory.CreateText(((Component)val).transform, _theme, "CodeText", "Lobby ID: ...", 14f, palette.TextSecondary, (TextAlignmentOptions)4097);
			((Component)_lobbyCodeText).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
			_copyCodeBtn = PvPUiFactory.CreateButton(((Component)val).transform, _theme, "CopyBtn", "Copy ID", PvPButtonVariant.Secondary, delegate
			{
				PlayClickSfx();
				ulong currentLobbyId = SteamPvPManager.Instance.CurrentLobbyId;
				if (currentLobbyId != 0L)
				{
					GUIUtility.systemCopyBuffer = currentLobbyId.ToString();
					_copiedUntilTime = Time.unscaledTime + 1.8f;
				}
			}, 14f, 28f, 96f, flexibleWidth: false);
			VerticalLayoutGroup val2 = PvPUiFactory.CreateVerticalStack(pvPPanelFrame.Root.transform, "NoLobbyGroup", 6f, null, (TextAnchor)0);
			_noLobbyGroup = ((Component)val2).gameObject;
			HorizontalLayoutGroup obj3 = PvPUiFactory.CreateHorizontalRow(((Component)val2).transform, "ActionRow", 8f, null, (TextAnchor)3);
			PvPUiFactory.CreateButton(((Component)obj3).transform, _theme, "HostBtn", "Host Lobby", PvPButtonVariant.Gold, delegate
			{
				PlayClickSfx();
				SteamPvPManager.Instance.HostLobby();
			}, 16f);
			PvPUiFactory.CreateButton(((Component)obj3).transform, _theme, "JoinIdBtn", "Join by ID", PvPButtonVariant.Primary, delegate
			{
				PlayClickSfx();
				OnJoinClipboard();
			}, 16f);
			PvPUiFactory.CreateButton(((Component)obj3).transform, _theme, "FindFriendsBtn", "Find Friends", PvPButtonVariant.Secondary, delegate
			{
				PlayClickSfx();
				SteamPvPManager.Instance.RefreshFriendLobbies();
			}, 16f);
			_clipboardErrorText = PvPUiFactory.CreateText(((Component)val2).transform, _theme, "ClipboardHint", "Copy a friend's Lobby ID first, then click Join by ID.", 13f, palette.WarningBorder, (TextAlignmentOptions)4097, bold: false, wrap: false, addShadow: false);
			((Component)_clipboardErrorText).gameObject.SetActive(false);
			VerticalLayoutGroup val3 = PvPUiFactory.CreateVerticalStack(((Component)val2).transform, "FriendsList", 5f, null, (TextAnchor)0);
			_friendsListRoot = ((Component)val3).gameObject;
			for (int num = 0; num < 4; num++)
			{
				HorizontalLayoutGroup val4 = PvPUiFactory.CreateHorizontalRow(((Component)val3).transform, $"Friend_{num}", 8f, null, (TextAnchor)3, forceExpandWidth: false);
				TextMeshProUGUI val5 = PvPUiFactory.CreateText(((Component)val4).transform, _theme, "Name", "", 15f, palette.TextSecondary, (TextAlignmentOptions)4097);
				((Component)val5).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
				int captured = num;
				PvPUiFactory.CreateButton(((Component)val4).transform, _theme, "JoinBtn", "Join", PvPButtonVariant.Success, delegate
				{
					PlayClickSfx();
					if (captured >= 0 && captured < _friendRows.Count && _friendRows[captured].LobbyId != 0L)
					{
						SteamPvPManager.Instance.JoinLobby(_friendRows[captured].LobbyId);
					}
				}, 14f, 28f, 82f, flexibleWidth: false);
				((Component)val4).gameObject.SetActive(false);
				_friendRows.Add(new FriendRow
				{
					Root = ((Component)val4).gameObject,
					NameText = val5
				});
			}
			HorizontalLayoutGroup val6 = PvPUiFactory.CreateHorizontalRow(pvPPanelFrame.Root.transform, "InLobbyGroup", 8f, null, (TextAnchor)3);
			_inLobbyGroup = ((Component)val6).gameObject;
			PvPUiFactory.CreateButton(((Component)val6).transform, _theme, "InviteBtn", "Invite Friend", PvPButtonVariant.Gold, delegate
			{
				PlayClickSfx();
				SteamPvPManager.Instance.OpenInviteOverlay();
			}, 16f);
			PvPUiFactory.CreateButton(((Component)val6).transform, _theme, "LeaveBtn", "Leave Lobby", PvPButtonVariant.Danger, delegate
			{
				PlayClickSfx();
				SteamPvPManager.Instance.LeaveLobby();
			}, 16f);
		}

		private void BuildSettingsCard(Transform parent)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Expected O, but got Unknown
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			PvPUiPalette palette = _theme.Palette;
			PvPPanelFrame pvPPanelFrame = PvPUiFactory.CreateFramedPanel(parent, "SettingsCard", _theme.CardFillSprite, _theme.CardFrameSprite, palette.CardBg, palette.CardBorder, blockRaycasts: false);
			VerticalLayoutGroup obj = pvPPanelFrame.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(14, 14, 10, 12);
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			HorizontalLayoutGroup val = PvPUiFactory.CreateHorizontalRow(pvPPanelFrame.Root.transform, "SettingsHdr", 6f, null, (TextAnchor)3, forceExpandWidth: false);
			((Component)PvPUiFactory.CreateText(((Component)val).transform, _theme, "Title", "MATCH SETTINGS", 15f, palette.TextGold, (TextAlignmentOptions)4097, bold: true)).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
			_heartsBadge = PvPUiFactory.CreateBadge(((Component)val).transform, _theme, "HeartsBadge", "5 Hearts", 12f, 22f);
			_roleBadge = PvPUiFactory.CreateBadge(((Component)val).transform, _theme, "RoleBadge", "HOST", 12f, 22f, 58f);
			VerticalLayoutGroup val2 = PvPUiFactory.CreateVerticalStack(pvPPanelFrame.Root.transform, "HostSettingsGrid", 7f, null, (TextAnchor)0);
			_hostSettingsGrid = ((Component)val2).gameObject;
			HorizontalLayoutGroup val3 = PvPUiFactory.CreateHorizontalRow(((Component)val2).transform, "Row1", 8f, null, (TextAnchor)3);
			_formatBtn = PvPUiFactory.CreateButton(((Component)val3).transform, _theme, "FormatBtn", "Clash: Every 3 Years", PvPButtonVariant.Primary, delegate
			{
				PlayClickSfx();
				PvPMatchController.Instance.CycleGameMode();
			}, 15f, 34f);
			_diffBtn = PvPUiFactory.CreateButton(((Component)val3).transform, _theme, "DiffBtn", "Difficulty: Knight", PvPButtonVariant.Primary, delegate
			{
				PlayClickSfx();
				PvPMatchController.Instance.CyclePvEDifficulty();
			}, 15f, 34f);
			HorizontalLayoutGroup val4 = PvPUiFactory.CreateHorizontalRow(((Component)val2).transform, "Row2", 8f, null, (TextAnchor)3);
			_tieBtn = PvPUiFactory.CreateButton(((Component)val4).transform, _theme, "TieBtn", "Tiebreaker: Draw", PvPButtonVariant.Secondary, delegate
			{
				PlayClickSfx();
				PvPMatchController.Instance.ToggleTieBreaker();
			}, 15f, 34f);
			_seedBtn = PvPUiFactory.CreateButton(((Component)val4).transform, _theme, "SeedBtn", "Shop Seed: Random", PvPButtonVariant.Secondary, delegate
			{
				PlayClickSfx();
				PvPMatchController.Instance.ToggleSharedSeed();
			}, 15f, 34f);
			_newSeedBtn = PvPUiFactory.CreateButton(((Component)val4).transform, _theme, "NewSeedBtn", "New", PvPButtonVariant.Secondary, delegate
			{
				PlayClickSfx();
				PvPMatchController.Instance.RerollSharedSeed();
			}, 14f, 34f, 64f, flexibleWidth: false);
			PvPPanelFrame pvPPanelFrame2 = PvPUiFactory.CreateFramedPanel(pvPPanelFrame.Root.transform, "GuestSummary", _theme.CardFillSprite, _theme.BadgeFrameSprite, palette.InsetBg, palette.Divider, blockRaycasts: false);
			_guestSettingsBox = pvPPanelFrame2.Root;
			VerticalLayoutGroup obj2 = pvPPanelFrame2.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(10, 10, 8, 8);
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true;
			_guestSettingsText = PvPUiFactory.CreateText(pvPPanelFrame2.Root.transform, _theme, "SummaryText", "", 15f, palette.TextSecondary, (TextAlignmentOptions)514, bold: false, wrap: true, addShadow: false);
			_clashSpeedBtn = PvPUiFactory.CreateButton(pvPPanelFrame.Root.transform, _theme, "ClashSpeedBtn", "Clash Speed: Auto 1x", PvPButtonVariant.Ghost, delegate
			{
				PlayClickSfx();
				PvPMatchController.Instance.CycleClashAutoSpeedMode();
			}, 14f, 30f);
		}

		private void BuildAdvancedDrawer(Transform parent)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			PvPUiPalette palette = _theme.Palette;
			_advToggleBtn = PvPUiFactory.CreateButton(parent, _theme, "AdvToggleBtn", "> Advanced", PvPButtonVariant.Ghost, delegate
			{
				PlayClickSfx();
				_advancedExpanded = !_advancedExpanded;
				_advCard.Root.SetActive(_advancedExpanded);
				_advToggleBtn.SetText(_advancedExpanded ? "v Advanced" : "> Advanced");
			}, 13f, 26f);
			_advCard = PvPUiFactory.CreateFramedPanel(parent, "AdvancedCard", _theme.CardFillSprite, _theme.CardFrameSprite, palette.CardBg, palette.CardBorder, blockRaycasts: false);
			VerticalLayoutGroup obj = _advCard.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(12, 12, 8, 10);
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 6f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			HorizontalLayoutGroup val = PvPUiFactory.CreateHorizontalRow(_advCard.Root.transform, "TopAdvRow", 6f, null, (TextAnchor)3);
			_pvpActiveToggleBtn = PvPUiFactory.CreateButton(((Component)val).transform, _theme, "PvPActiveBtn", "1v1 Enabled: ON", PvPButtonVariant.Success, delegate
			{
				PlayClickSfx();
				PvPMatchController instance = PvPMatchController.Instance;
				instance.SetPvPModeArmed(!instance.IsPvPModeArmed);
			}, 13f, 28f);
			HorizontalLayoutGroup val2 = PvPUiFactory.CreateHorizontalRow(_advCard.Root.transform, "P2PTests", 6f, null, (TextAnchor)3);
			_p2pTestRow = ((Component)val2).gameObject;
			PvPUiFactory.CreateButton(((Component)val2).transform, _theme, "PingBtn", "Ping Opponent", PvPButtonVariant.Secondary, delegate
			{
				PlayClickSfx();
				SteamPvPManager.Instance.SendPing();
			}, 13f, 28f);
			PvPPanelFrame pvPPanelFrame = PvPUiFactory.CreateFramedPanel(_advCard.Root.transform, "LogInset", _theme.CardFillSprite, _theme.BadgeFrameSprite, palette.InsetBg, palette.Divider, blockRaycasts: false);
			VerticalLayoutGroup obj2 = pvPPanelFrame.Root.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(8, 8, 6, 6);
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true;
			pvPPanelFrame.Root.AddComponent<LayoutElement>().minHeight = 96f;
			_logText = PvPUiFactory.CreateText(pvPPanelFrame.Root.transform, _theme, "LogText", "No events yet.", 13f, palette.TextSecondary, (TextAlignmentOptions)257, bold: false, wrap: true, addShadow: false);
			_advCard.Root.SetActive(false);
		}

		public void OpenScreen()
		{
			if ((Object)(object)_screenRoot == (Object)null)
			{
				return;
			}
			try
			{
				MainMenuUI_Main mainMenu = _mainMenu;
				if (mainMenu != null)
				{
					MainMenuPanel mainMenuPanel = mainMenu._mainMenuPanel;
					if (mainMenuPanel != null)
					{
						mainMenuPanel.HidePanel();
					}
				}
			}
			catch
			{
			}
			_isOpen = true;
			_screenRoot.SetActive(true);
			_screenRoot.transform.SetAsLastSibling();
			Refresh();
		}

		public void CloseScreen()
		{
			_isOpen = false;
			if ((Object)(object)_screenRoot != (Object)null)
			{
				_screenRoot.SetActive(false);
			}
			try
			{
				MainMenuUI_Main mainMenu = _mainMenu;
				if (mainMenu != null)
				{
					MainMenuPanel mainMenuPanel = mainMenu._mainMenuPanel;
					if (mainMenuPanel != null)
					{
						mainMenuPanel.ShowPanel();
					}
				}
			}
			catch
			{
			}
		}

		public void Update()
		{
			if (!_isOpen || (Object)(object)_screenRoot == (Object)null || !_screenRoot.activeInHierarchy)
			{
				return;
			}
			try
			{
				Keyboard current = Keyboard.current;
				if (current != null && current.escapeKey != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame)
				{
					PlayClickSfx();
					CloseScreen();
					return;
				}
			}
			catch
			{
			}
			Refresh();
		}

		private void Refresh()
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: 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_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_screenRoot == (Object)null || !_screenRoot.activeSelf)
			{
				return;
			}
			SteamPvPManager instance = SteamPvPManager.Instance;
			PvPMatchController instance2 = PvPMatchController.Instance;
			IPvPTransport active = PvPTransportHost.Active;
			PvPUiPalette palette = _theme.Palette;
			bool flag = active.State == PvPConnectionState.Connected;
			bool flag2 = PvPTransportHost.IsOverridden || instance.IsVersionVerified;
			bool flag3 = instance.CurrentLobbyId != 0;
			switch (instance.State)
			{
			case PvPConnectionState.Connected:
				if (instance.IsVersionVerified)
				{
					_stateBadge.Set("CONNECTED", palette.SuccessFill, palette.SuccessBorder, palette.TextPrimary);
				}
				else
				{
					_stateBadge.Set("VERIFYING", palette.WarningFill, palette.WarningBorder, palette.TextPrimary);
				}
				break;
			case PvPConnectionState.CreatingLobby:
			case PvPConnectionState.JoiningLobby:
				_stateBadge.Set("JOINING...", palette.WarningFill, palette.WarningBorder, palette.TextPrimary);
				break;
			case PvPConnectionState.InLobbyWaitingForOpponent:
				_stateBadge.Set("IN LOBBY", palette.WarningFill, palette.WarningBorder, palette.TextPrimary);
				break;
			default:
				if (flag)
				{
					_stateBadge.Set("CONNECTED", palette.InfoFill, palette.InfoBorder, palette.TextPrimary);
				}
				else
				{
					_stateBadge.Set("READY", palette.InsetBg, palette.CardBorder, palette.TextMuted);
				}
				break;
			}
			_pingBadge.SetVisible(flag);
			if (flag)
			{
				int lastPingMs = active.LastPingMs;
				if (lastPingMs < 0)
				{
					_pingBadge.Set("... ms", palette.InsetBg, palette.CardBorder, palette.TextMuted);
				}
				else if (lastPingMs < 90)
				{
					_pingBadge.Set($"{lastPingMs} ms", palette.SuccessFill, palette.SuccessBorder, palette.TextPrimary);
				}
				else if (lastPingMs < 180)
				{
					_pingBadge.Set($"{lastPingMs} ms", palette.WarningFill, palette.WarningBorder, palette.TextPrimary);
				}
				else
				{
					_pingBadge.Set($"{lastPingMs} ms", palette.DangerFill, palette.DangerBorder, palette.TextPrimary);
				}
			}
			string text = ((instance.LocalSteamId != 0L) ? instance.LocalName : "You");
			string text2 = ((flag && !string.IsNullOrEmpty(active.OpponentName)) ? (text + "   vs   " + active.OpponentName) : ((instance.LocalSteamId != 0L) ? ("Player: " + text) : "Connecting to Steam..."));
			PvPUiFactory.SetTextIfChanged(_matchupText, text2);
			bool flag4 = !string.IsNullOrEmpty(instance.LastRejectReason);
			if (_rejectBanner.Root.activeSelf != flag4)
			{
				_rejectBanner.Root.SetActive(flag4);
			}
			if (flag4)
			{
				PvPUiFactory.SetTextIfChanged(_rejectBannerText, instance.LastRejectReason);
			}
			if (_lobbyCodeRow.activeSelf != flag3)
			{
				_lobbyCodeRow.SetActive(flag3);
			}
			if (flag3)
			{
				PvPUiFactory.SetTextIfChanged(_lobbyCodeText, $"Lobby ID: {instance.CurrentLobbyId}");
				_copyCodeBtn.SetText((Time.unscaledTime < _copiedUntilTime) ? "Copied!" : "Copy ID");
			}
			if (_noLobbyGroup.activeSelf != !flag3)
			{
				_noLobbyGroup.SetActive(!flag3);
			}
			if (_inLobbyGroup.activeSelf != flag3)
			{
				_inLobbyGroup.SetActive(flag3);
			}
			if (!flag3)
			{
				bool flag5 = Time.unscaledTime < _clipboardErrorUntil;
				if (((Component)_clipboardErrorText).gameObject.activeSelf != flag5)
				{
					((Component)_clipboardErrorText).gameObject.SetActive(flag5);
				}
				IReadOnlyList<FriendLobbyInfo> friendLobbies = instance.FriendLobbies;
				int num = Math.Min(friendLobbies.Count, 4);
				if (_friendsListRoot.activeSelf != num > 0)
				{
					_friendsListRoot.SetActive(num > 0);
				}
				for (int i = 0; i < _friendRows.Count; i++)
				{
					FriendRow friendRow = _friendRows[i];
					if ((Object)(object)friendRow.Root == (Object)null)
					{
						continue;
					}
					bool flag6 = i < num;
					if (friendRow.Root.activeSelf != flag6)
					{
						friendRow.Root.SetActive(flag6);
					}
					if (flag6)
					{
						FriendLobbyInfo friendLobbyInfo = friendLobbies[i];
						friendRow.LobbyId = friendLobbyInfo.LobbyId;
						string text3 = friendLobbyInfo.FriendName;
						if (!string.IsNullOrEmpty(friendLobbyInfo.ModVersion) && friendLobbyInfo.ModVersion != "0.2.0")
						{
							text3 = friendLobbyInfo.FriendName + "  (v" + friendLobbyInfo.ModVersion + " - mismatch)";
						}
						PvPUiFactory.SetTextIfChanged(friendRow.NameText, text3);
					}
				}
			}
			bool flag7 = (flag ? active.IsHost : (!flag3 || instance.IsHost));
			_heartsBadge.Set($"{instance2.Rules.StartingHearts} Hearts", palette.DangerFill, palette.DangerBorder, palette.TextPrimary);
			_roleBadge.Set(flag7 ? "HOST" : "GUEST", flag7 ? palette.BtnGoldFill : palette.InfoFill, flag7 ? palette.BtnGoldBorder : palette.InfoBorder, palette.TextPrimary);
			if (_hostSettingsGrid.activeSelf != flag7)
			{
				_hostSettingsGrid.SetActive(flag7);
			}
			if (_guestSettingsBox.activeSelf != !flag7)
			{
				_guestSettingsBox.SetActive(!flag7);
			}
			string text4 = ((instance2.Rules.Mode == PvPGameMode.EveryYearDuel) ? "Every Year" : $"Every {instance2.Rules.EffectiveClashInterval} Years");
			string syncedDifficultyDisplayName = instance2.GetSyncedDifficultyDisplayName();
			string text5 = ((instance2.Rules.TieBreaker == PvPTieBreakerMode.DrawOnDoubleWin) ? "Draw" : "Faster Wins");
			string text6 = (instance2.Rules.UseSharedSeed ? $"Shared ({instance2.SharedSeed % 10000:D4})" : "Random");
			if (flag7)
			{
				_formatBtn.SetText("Clash: " + text4);
				_diffBtn.SetText("Difficulty: " + syncedDifficultyDisplayName);
				_tieBtn.SetText("Tiebreaker: " + text5);
				_seedBtn.SetText("Shop Seed: " + text6);
				_newSeedBtn.SetVisible(instance2.Rules.UseSharedSeed);
			}
			else
			{
				PvPUiFactory.SetTextIfChanged(_guestSettingsText, $"Clash: {text4}  |  Difficulty: {syncedDifficultyDisplayName}\nTiebreaker: {text5}  |  Shop Seed: {text6}");
			}
			ClashAutoSpeedMode clashAutoSpeedMode = instance2.ClashAutoSpeedMode;
			_clashSpeedBtn.SetText("Clash Speed: " + clashAutoSpeedMode switch
			{
				ClashAutoSpeedMode.Normal1x => "Auto 1x", 
				ClashAutoSpeedMode.Fast2x => "Auto 2x", 
				_ => "Manual", 
			});
			bool flag8 = flag && flag2;
			if ((Object)(object)_startMatchBtn.Button != (Object)null)
			{
				((Selectable)_startMatchBtn.Button).interactable = flag8;
			}
			if (flag8)
			{
				_startMatchBtn.SetText("Start 1v1");
				if (_startMatchBtn.Variant != PvPButtonVariant.Success)
				{
					_startMatchBtn.ApplyVariant(_theme, PvPButtonVariant.Success);
				}
				PvPUiFactory.SetTextIfChanged(_footerHintText, "Ready! Pick your King to begin.");
			}
			else if (flag && !flag2)
			{
				_startMatchBtn.SetText("Verifying...");
				if (_startMatchBtn.Variant != PvPButtonVariant.Ghost)
				{
					_startMatchBtn.ApplyVariant(_theme, PvPButtonVariant.Ghost);
				}
				PvPUiFactory.SetTextIfChanged(_footerHintText, "Verifying mod version with opponent...");
			}
			else if (flag3)
			{
				_startMatchBtn.SetText("Waiting...");
				if (_startMatchBtn.Variant != PvPButtonVariant.Ghost)
				{
					_startMatchBtn.ApplyVariant(_theme, PvPButtonVariant.Ghost);
				}
				PvPUiFactory.SetTextIfChanged(_footerHintText, "Invite a friend or share your Lobby ID.");
			}
			else
			{
				_startMatchBtn.SetText("Start 1v1");
				if (_startMatchBtn.Variant != PvPButtonVariant.Ghost)
				{
					_startMatchBtn.ApplyVariant(_theme, PvPButtonVariant.Ghost);
				}
				PvPUiFactory.SetTextIfChanged(_footerHintText, "Host or join a friend to play.");
			}
			if (!_advancedExpanded)
			{
				return;
			}
			_pvpActiveToggleBtn.SetVisible(flag7);
			if (flag7)
			{
				_pvpActiveToggleBtn.SetText(instance2.IsPvPModeArmed ? "1v1 Enabled: ON" : "1v1 Enabled: OFF");
				PvPButtonVariant pvPButtonVariant = (instance2.IsPvPModeArmed ? PvPButtonVariant.Success : PvPButtonVariant.Danger);
				if (_pvpActiveToggleBtn.Variant != pvPButtonVariant)
				{
					_pvpActiveToggleBtn.ApplyVariant(_theme, pvPButtonVariant);
				}
			}
			bool flag9 = instance.State == PvPConnectionState.Connected;
			if (_p2pTestRow.activeSelf != flag9)
			{
				_p2pTestRow.SetActive(flag9);
			}
			IReadOnlyList<string> recentLogs = instance.RecentLogs;
			string text7 = ((recentLogs.Count > 0) ? recentLogs[recentLogs.Count - 1] : string.Empty);
			if (recentLogs.Count == _lastLogCount && !(text7 != _lastLogTail))
			{
				return;
			}
			_lastLogCount = recentLogs.Count;
			_lastLogTail = text7;
			if (recentLogs.Count == 0)
			{
				PvPUiFactory.SetTextIfChanged(_logText, "No events yet.");
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			int num2 = Math.Max(0, recentLogs.Count - 6);
			for (int j = num2; j < recentLogs.Count; j++)
			{
				if (j > num2)
				{
					stringBuilder.Append('\n');
				}
				stringBuilder.Append(PvPUiTheme.SanitizeText(recentLogs[j]));
			}
			PvPUiFactory.SetTextIfChanged(_logText, stringBuilder.ToString());
		}

		private void OnStartMatchClicked()
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			PvPMatchController instance = PvPMatchController.Instance;
			if (PvPTransportHost.Active.State != PvPConnectionState.Connected || (!PvPTransportHost.IsOverridden && !SteamPvPManager.Instance.IsVersionVerified))
			{
				return;
			}
			if (!instance.IsPvPModeArmed && PvPTransportHost.Active.IsHost)
			{
				instance.SetPvPModeArmed(armed: true);
			}
			PlayStartSfx();
			_isOpen = false;
			if ((Object)(object)_screenRoot != (Object)null)
			{
				_screenRoot.SetActive(false);
			}
			try
			{
				if ((Object)(object)_mainMenu != (Object)null)
				{
					ManualLogSource log = Plugin.Log;
					if (log != null)
					{
						log.LogInfo((object)"[PvPUI] Launching directly into King Selection from Native 1v1 PvP Screen...");
					}
					_mainMenu.OnStartBtn();
					return;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				if (log2 != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(70, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PvPUI] Direct OnStartBtn transition failed (");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); showing MainMenuPanel.");
					}
					log2.LogWarning(val);
				}
			}
			CloseScreen();
		}

		private void OnJoinClipboard()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			string text = (GUIUtility.systemCopyBuffer ?? string.Empty).Trim();
			if (ulong.TryParse(text, out var result) && result != 0L)
			{
				_clipboardErrorUntil = 0f;
				SteamPvPManager.Instance.JoinLobby(result);
				return;
			}
			_clipboardErrorUntil = Time.unscaledTime + 3.5f;
			ManualLogSource log = Plugin.Log;
			if (log != null)
			{
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(53, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PvP] Clipboard does not contain a valid Lobby ID: '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
				}
				log.LogWarning(val);
			}
		}

		private static void StripLocalization(GameObject go)
		{
			try
			{
				Il2CppArrayBase<Localize> componentsInChildren = go.GetComponentsInChildren<Localize>(true);
				if (componentsInChildren == null)
				{
					return;
				}
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					if ((Object)(object)componentsInChildren[i] != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
					}
				}
			}
			catch
			{
			}
		}

		private void PlayClickSfx()
		{
			try
			{
				if ((Object)(object)_nativeClickSfx != (Object)null)
				{
					Audio.Play(Audio.UI(_nativeClickSfx));
				}
			}
			catch
			{
			}
		}

		private void PlayStartSfx()
		{
			try
			{
				if ((Object)(object)_nativeStartSfx != (Object)null)
				{
					Audio.Play(Audio.UI(_nativeStartSfx));
				}
				else
				{
					PlayClickSfx();
				}
			}
			catch
			{
			}
		}
	}
	internal sealed class PvPPanelFrame
	{
		public GameObject Root { get; }

		public RectTransform Rect { get; }

		public Image FillImage { get; }

		public Image BorderImage { get; }

		public PvPPanelFrame(GameObject root, RectTransform rect, Image fillImage, Image borderImage)
		{
			Root = root;
			Rect = rect;
			FillImage = fillImage;
			BorderImage = borderImage;
		}

		public void SetColors(Color fill, Color border)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)FillImage != (Object)null)
			{
				((Graphic)FillImage).color = fill;
			}
			if ((Object)(object)BorderImage != (Object)null)
			{
				((Graphic)BorderImage).color = border;
			}
		}
	}
	internal sealed class PvPButton
	{
		private string _lastText;

		public GameObject Root { get; }

		public RectTransform Rect { get; }

		public Button Button { get; }

		public Image FillImage { get; }

		public Image BorderImage { get; }

		public TextMeshProUGUI Label { get; }

		public LayoutElement Layout { get; }

		public PvPButtonVariant Variant { get; private set; }

		public PvPButton(GameObject root, RectTransform rect, Button button, Image fillImage, Image borderImage, TextMeshProUGUI label, LayoutElement layout, PvPButtonVariant variant)
		{
			Root = root;
			Rect = rect;
			Button = button;
			FillImage = fillImage;
			BorderImage = borderImage;
			Label = label;
			Layout = layout;
			Variant = variant;
		}

		public void SetText(string text)
		{
			string text2 = PvPUiTheme.SanitizeText(text);
			if (!(_lastText == text2))
			{
				_lastText = text2;
				if ((Object)(object)Label != (Object)null)
				{
					((TMP_Text)Label).text = text2;
				}
			}
		}

		public void SetVisible(bool visible)
		{
			if ((Object)(object)Root != (Object)null && Root.activeSelf != visible)
			{
				Root.SetActive(visible);
			}
		}

		public void ApplyVariant(PvPUiTheme theme, PvPButtonVariant variant)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)