Decompiled source of StormSurvivors v0.8.0

plugins/StormSurvivors.dll

Decompiled 16 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using LaneClash.Config;
using LaneClash.Match;
using LaneClash.Net;
using LaneClash.Objectives;
using LaneClash.Systems;
using LaneClash.Teams;
using LaneClash.UI;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ConVar;
using RoR2.Navigation;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StormSurvivors")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.8.0.0")]
[assembly: AssemblyInformationalVersion("0.8.0")]
[assembly: AssemblyProduct("StormSurvivors")]
[assembly: AssemblyTitle("StormSurvivors")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.8.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 LaneClash
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("armarioxx.StormSurvivors", "StormSurvivors", "0.8.0")]
	public class LaneClashPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "armarioxx.StormSurvivors";

		public const string PluginName = "StormSurvivors";

		public const string PluginVersion = "0.8.0";

		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			LaneClashConfig.Init(((BaseUnityPlugin)this).Config);
			StructureFactory.Init();
			Decor.Init();
			MinionWaveSpawner.Init();
			GameModeRegistration.Init();
			LaneNet.Init();
			LaneClashMatch.Init();
			MatchStats.Init();
			StructureRegistry.Init();
			TeamAssignment.Init();
			TeamSwapRequests.Init();
			RespawnSystem.Init();
			NoHealHooks.Init();
			LaneLevels.Init();
			Recall.Init();
			Log.LogInfo((object)"StormSurvivors 0.8.0 cargado.");
		}

		private void Update()
		{
			LaneClashHud.Tick();
			ShopUi.Tick();
			LevelUi.Tick();
			TurretWarning.Tick();
			AllyCardFilter.Tick();
			LobbyTeamUi.Tick();
		}
	}
	internal static class TeleportUtil
	{
		internal static void Body(CharacterBody body, Vector3 footPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			TeleportHelper.TeleportBody(body, footPosition);
		}
	}
}
namespace LaneClash.UI
{
	internal static class AllyCardFilter
	{
		private static float _timer;

		internal static void Tick()
		{
			if (!LaneClashMatch.IsLaneClashRun)
			{
				return;
			}
			_timer -= Time.unscaledDeltaTime;
			if (_timer > 0f)
			{
				return;
			}
			_timer = 0.5f;
			AllyCardManager[] array = Object.FindObjectsOfType<AllyCardManager>();
			foreach (AllyCardManager val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeSelf)
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
		}
	}
	internal static class EnemyMarkerFilter
	{
		private static float _next;

		private static readonly List<PositionIndicator> Enemy = new List<PositionIndicator>();

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

		internal static void Tick()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			if (!LaneClashMatch.IsLaneClashRun)
			{
				Enemy.Clear();
				return;
			}
			if (Time.unscaledTime >= _next)
			{
				_next = Time.unscaledTime + 0.3f;
				Enemy.Clear();
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				CharacterMaster val = ((firstLocalUser != null) ? firstLocalUser.cachedMaster : null);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				TeamIndex teamIndex = val.teamIndex;
				PositionIndicator[] array = Object.FindObjectsOfType<PositionIndicator>();
				foreach (PositionIndicator val2 in array)
				{
					if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.targetTransform))
					{
						continue;
					}
					CharacterBody componentInParent = ((Component)val2.targetTransform).GetComponentInParent<CharacterBody>();
					if (!Object.op_Implicit((Object)(object)componentInParent) || !Object.op_Implicit((Object)(object)componentInParent.teamComponent))
					{
						continue;
					}
					TeamIndex teamIndex2 = componentInParent.teamComponent.teamIndex;
					if (teamIndex2 != teamIndex && TeamManager.IsTeamEnemy(teamIndex, teamIndex2))
					{
						Enemy.Add(val2);
						string name = ((Object)((Component)val2).gameObject).name;
						if (Logged.Add(name))
						{
							LaneClashPlugin.Log.LogInfo((object)("[marcador] oculto '" + name + "' sobre " + ((Object)componentInParent).name + " (padre: " + (Object.op_Implicit((Object)(object)val2.transform.parent) ? ((Object)val2.transform.parent).name : "-") + ")."));
						}
					}
				}
			}
			foreach (PositionIndicator item in Enemy)
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					((Behaviour)item).enabled = false;
					if (Object.op_Implicit((Object)(object)item.insideViewObject))
					{
						item.insideViewObject.SetActive(false);
					}
					if (Object.op_Implicit((Object)(object)item.outsideViewObject))
					{
						item.outsideViewObject.SetActive(false);
					}
					if (Object.op_Implicit((Object)(object)item.alwaysVisibleObject))
					{
						item.alwaysVisibleObject.SetActive(false);
					}
					item.transform.localScale = Vector3.zero;
				}
			}
		}
	}
	internal class LaneClashHud : MonoBehaviour
	{
		private struct Banner
		{
			public string Title;

			public string Sub;

			public Color Color;

			public float Duration;

			public bool Big;
		}

		private struct FeedEntry
		{
			public string Text;

			public float Expires;
		}

		private class Bar
		{
			public GameObject Root;

			public RectTransform Fill;

			public Image FillImage;

			public TextMeshProUGUI Label;

			public void Set(float fraction)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				Fill.anchorMax = new Vector2(Mathf.Clamp01(fraction), 1f);
			}
		}

		private static readonly Color CBlue = new Color(0.216f, 0.541f, 0.867f);

		private static readonly Color CRed = new Color(0.886f, 0.294f, 0.29f);

		private static readonly Color CBlueLight = new Color(0.522f, 0.718f, 0.922f);

		private static readonly Color CRedLight = new Color(0.941f, 0.584f, 0.584f);

		private static readonly Color CGold = new Color(0.98f, 0.78f, 0.459f);

		private static readonly Color CText = new Color(0.91f, 0.9f, 0.87f);

		private static readonly Color CMuted = new Color(0.71f, 0.7f, 0.66f);

		private static readonly Color CPanel = new Color(0.067f, 0.082f, 0.102f, 0.82f);

		private static readonly Color CBarBg = new Color(0.04f, 0.05f, 0.06f, 0.9f);

		private static readonly Color CBorder = new Color(0.46f, 0.37f, 0.22f, 1f);

		private const string HexBlue = "#85B7EB";

		private const string HexRed = "#F09595";

		private static LaneClashHud _instance;

		private static bool _failed;

		private static TMP_FontAsset _font;

		private static bool _fontLoaded;

		private static ScoreMessage _score;

		private static float _scoreTime;

		private static readonly Queue<Banner> Pending = new Queue<Banner>();

		private static readonly List<FeedEntry> Feed = new List<FeedEntry>();

		private Canvas _canvas;

		private GameObject _top;

		private TextMeshProUGUI _blueScore;

		private TextMeshProUGUI _redScore;

		private TextMeshProUGUI _clock;

		private TextMeshProUGUI _kda;

		private TextMeshProUGUI _nextWave;

		private Bar _blueNexus;

		private Bar _redNexus;

		private Bar _blueBoss;

		private Bar _redBoss;

		private TextMeshProUGUI _bannerTitle;

		private TextMeshProUGUI _bannerSub;

		private TextMeshProUGUI _respawn;

		private readonly List<GameObject> _feedRows = new List<GameObject>();

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

		private GameObject _table;

		private TextMeshProUGUI _tableBlue;

		private TextMeshProUGUI _tableRed;

		private Banner _current;

		private float _bannerStart = -1f;

		internal static void Tick()
		{
			if (_failed)
			{
				return;
			}
			try
			{
				bool isLaneClashRun = LaneClashMatch.IsLaneClashRun;
				if (isLaneClashRun && !Object.op_Implicit((Object)(object)_instance))
				{
					Create();
				}
				else if (!isLaneClashRun && Object.op_Implicit((Object)(object)_instance))
				{
					DestroyHud();
				}
			}
			catch (Exception e)
			{
				Fail(e);
			}
		}

		internal static void OnScore(ScoreMessage m)
		{
			_score = m;
			_scoreTime = Time.time;
		}

		internal static void OnAnnounce(AnnounceMessage m)
		{
			try
			{
				Compose(m);
			}
			catch (Exception ex)
			{
				LaneClashPlugin.Log.LogWarning((object)("[hud] anuncio no mostrado: " + ex.Message));
			}
		}

		private static void Fail(Exception e)
		{
			_failed = true;
			LaneClashPlugin.Log.LogError((object)$"[hud] error, se desactiva el HUD de LaneClash: {e}");
			if (Object.op_Implicit((Object)(object)_instance))
			{
				Object.Destroy((Object)(object)((Component)_instance).gameObject);
			}
			_instance = null;
		}

		private static void DestroyHud()
		{
			Object.Destroy((Object)(object)((Component)_instance).gameObject);
			_instance = null;
			_score = null;
			Pending.Clear();
			Feed.Clear();
		}

		private static void Create()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			LoadFont();
			GameObject val = new GameObject("LaneClashHUD");
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas val2 = val.AddComponent<Canvas>();
			val2.renderMode = (RenderMode)0;
			val2.sortingOrder = 5;
			CanvasScaler val3 = val.AddComponent<CanvasScaler>();
			val3.uiScaleMode = (ScaleMode)1;
			val3.referenceResolution = new Vector2(1920f, 1080f);
			val3.matchWidthOrHeight = 0.5f;
			_instance = val.AddComponent<LaneClashHud>();
			_instance._canvas = val2;
			_instance.Build();
		}

		internal static void EnsureFont()
		{
			LoadFont();
		}

		internal static void LocalAlert(string text)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Show(text, "", CRedLight, 1.6f);
		}

		private static void LoadFont()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!_fontLoaded)
			{
				_fontLoaded = true;
				try
				{
					_font = Addressables.LoadAssetAsync<TMP_FontAsset>((object)"RoR2/Base/Common/Fonts/Bombardier/tmpBombDropshadow.asset").WaitForCompletion();
				}
				catch (Exception ex)
				{
					LaneClashPlugin.Log.LogWarning((object)("[hud] fuente de RoR2 no disponible: " + ex.Message));
				}
				if (!Object.op_Implicit((Object)(object)_font))
				{
					_font = TMP_Settings.defaultFontAsset;
				}
			}
		}

		private static uint LocalId()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
			int result;
			if (!Object.op_Implicit((Object)(object)val))
			{
				result = 0;
			}
			else
			{
				NetworkInstanceId netId = ((NetworkBehaviour)val).netId;
				result = (int)((NetworkInstanceId)(ref netId)).Value;
			}
			return (uint)result;
		}

		internal static PlayerRow LocalRow(out float age)
		{
			age = ((_score != null) ? (Time.time - _scoreTime) : 0f);
			uint num = LocalId();
			if (_score != null)
			{
				foreach (PlayerRow player in _score.Players)
				{
					if (player.Id == num)
					{
						return player;
					}
				}
			}
			return null;
		}

		private static LaneTeam LocalTeam()
		{
			uint num = LocalId();
			if (_score != null)
			{
				foreach (PlayerRow player in _score.Players)
				{
					if (player.Id == num)
					{
						return (LaneTeam)player.Team;
					}
				}
			}
			return LaneTeam.Blue;
		}

		private static string TeamHex(LaneTeam t)
		{
			return (t == LaneTeam.Red) ? "#F09595" : "#85B7EB";
		}

		private static string Col(string text, LaneTeam t)
		{
			return "<color=" + TeamHex(t) + ">" + text + "</color>";
		}

		private static string TeamName(LaneTeam t)
		{
			return (t == LaneTeam.Red) ? "roja" : "azul";
		}

		private static void Show(string title, string sub, Color color, float duration = 2.6f, bool big = false)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (Pending.Count < 4 || big)
			{
				Pending.Enqueue(new Banner
				{
					Title = title,
					Sub = (sub ?? ""),
					Color = color,
					Duration = duration,
					Big = big
				});
			}
		}

		private static void AddFeed(string text)
		{
			Feed.Add(new FeedEntry
			{
				Text = text,
				Expires = Time.time + 7f
			});
			if (Feed.Count > 6)
			{
				Feed.RemoveAt(0);
			}
		}

		private static void Compose(AnnounceMessage m)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_00e6: 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_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0586: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			AnnounceKind kind = (AnnounceKind)m.Kind;
			LaneTeam actorTeam = (LaneTeam)m.ActorTeam;
			LaneTeam t = TeamAssignment.Other(actorTeam);
			LaneTeam laneTeam = LocalTeam();
			uint num = LocalId();
			bool flag = actorTeam == laneTeam;
			bool flag2 = num != 0 && m.ActorId == num;
			bool flag3 = num != 0 && m.TargetId == num;
			Color val = (flag ? CGold : CRedLight);
			string title2;
			Color color;
			switch (kind)
			{
			case AnnounceKind.Welcome:
				Show("¡Bienvenidos a Storm Survivors!", "Destruyan el nexo enemigo y derroten a su guardián", CText, 4f, big: true);
				break;
			case AnnounceKind.MinionsSoon:
				Show($"{m.Count} segundos para que aparezcan los minions", "", CText, 3f);
				break;
			case AnnounceKind.MinionsSpawned:
				Show("¡Los minions han aparecido!", "", CText, 3f);
				break;
			case AnnounceKind.FirstBlood:
				title2 = "¡Primera sangre!";
				color = val;
				goto IL_0194;
			case AnnounceKind.Kill:
				if (flag2)
				{
					title2 = "¡Has asesinado a un enemigo!";
					color = CGold;
				}
				else if (flag3)
				{
					title2 = "Has sido asesinado";
					color = CRedLight;
				}
				else if (flag)
				{
					title2 = "Un enemigo ha sido asesinado";
					color = CBlueLight;
				}
				else
				{
					title2 = "Un aliado ha sido asesinado";
					color = CRedLight;
				}
				goto IL_0194;
			case AnnounceKind.MultiKill:
			{
				string title = ((m.Count >= 5) ? "¡Pentakill!" : ((m.Count == 4) ? "¡Cuádruple asesinato!" : ((m.Count == 3) ? "¡Triple asesinato!" : "¡Doble asesinato!")));
				Show(title, Col(m.Actor, actorTeam), val, 2.8f, big: true);
				break;
			}
			case AnnounceKind.Spree:
			{
				string text2 = ((m.Count >= 8) ? "es legendario" : ((m.Count == 7) ? "es casi legendario" : ((m.Count == 6) ? "está dominando" : ((m.Count == 5) ? "es imparable" : ((m.Count == 4) ? "está arrasando" : "está en racha")))));
				Show("¡" + m.Actor + " " + text2 + "!", "", val);
				break;
			}
			case AnnounceKind.Shutdown:
				Show("¡Racha cortada!", Col(m.Actor, actorTeam) + " acabó con la racha de " + Col(m.Target, t), val);
				break;
			case AnnounceKind.Executed:
				Show(flag3 ? "Has sido ejecutado" : (m.Target + " ha sido ejecutado"), "", flag ? CBlueLight : CRedLight);
				AddFeed(Col(m.Target, t) + "  ha sido ejecutado");
				break;
			case AnnounceKind.Ace:
				if (flag)
				{
					Show("¡As!", "Eliminaron a todo el equipo enemigo", CGold, 3f, big: true);
				}
				else
				{
					Show("Tu equipo ha sido eliminado", "", CRedLight, 3f, big: true);
				}
				break;
			case AnnounceKind.TurretDestroyed:
			{
				string text3 = (string.IsNullOrEmpty(m.Actor) ? "Los minions" : m.Actor);
				Show(flag ? "Torreta enemiga destruida" : "Tu torreta ha sido destruida", string.IsNullOrEmpty(m.Actor) ? "" : ("por " + Col(m.Actor, actorTeam)), val, 3f);
				AddFeed(Col(text3, actorTeam) + "  destruyó una torreta " + TeamName(t));
				break;
			}
			case AnnounceKind.NexusDestroyed:
			{
				string text = (string.IsNullOrEmpty(m.Target) ? "su guardián" : m.Target);
				if (flag)
				{
					Show("¡Nexo enemigo destruido!", "Maten a " + text + " en su base para ganar. No se cura.", CGold, 5f, big: true);
				}
				else
				{
					Show("¡Tu nexo ha caído!", "Defiendan a " + text + ": si muere, pierden la partida", CRedLight, 5f, big: true);
				}
				AddFeed(Col(string.IsNullOrEmpty(m.Actor) ? "Los minions" : m.Actor, actorTeam) + "  destruyó el nexo " + TeamName(t));
				break;
			}
			case AnnounceKind.BossSlain:
				Pending.Clear();
				Show(flag ? "VICTORIA" : "DERROTA", string.IsNullOrEmpty(m.Actor) ? "" : (Col(m.Actor, actorTeam) + " derrotó al guardián"), flag ? CGold : CRedLight, 6f, big: true);
				break;
			case AnnounceKind.Protected:
				{
					if (flag3)
					{
						Show("Estructura protegida", (m.Count == 1) ? "Destruye antes todas las torretas de un carril" : "Destruye antes la torreta exterior", CMuted, 2f);
					}
					break;
				}
				IL_0194:
				Show(title2, Col(m.Actor, actorTeam) + " mató a " + Col(m.Target, t), color);
				AddFeed(Col(m.Actor, actorTeam) + "  mató a  " + Col(m.Target, t));
				break;
			}
		}

		private void Build()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00d8: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: 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_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_050c: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05db: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)this).transform;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 1f);
			Image val2 = MakePanel(transform, "Score", val, val, new Vector2(0f, -8f), new Vector2(380f, 40f), CPanel, outline: true);
			_top = ((Component)val2).gameObject;
			_blueScore = MakeText(((Component)val2).transform, "Blue", new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(12f, 0f), new Vector2(140f, 34f), 20f, (TextAlignmentOptions)513);
			_redScore = MakeText(((Component)val2).transform, "Red", new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-12f, 0f), new Vector2(140f, 34f), 20f, (TextAlignmentOptions)516);
			_clock = MakeText(((Component)val2).transform, "Clock", val, val, new Vector2(0f, -2f), new Vector2(100f, 24f), 20f, (TextAlignmentOptions)514);
			_kda = MakeText(((Component)val2).transform, "KDA", new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 2f), new Vector2(200f, 14f), 11f, (TextAlignmentOptions)514);
			((Graphic)_kda).color = CMuted;
			_blueNexus = MakeBar(_top.transform, "BlueNexus", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(0f, -4f), new Vector2(188f, 14f), CBlue);
			_redNexus = MakeBar(_top.transform, "RedNexus", new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, -4f), new Vector2(188f, 14f), CRed);
			_nextWave = MakeText(_top.transform, "NextWave", new Vector2(0.5f, 0f), val, new Vector2(0f, -21f), new Vector2(300f, 16f), 12f, (TextAlignmentOptions)514);
			((Graphic)_nextWave).color = CMuted;
			_blueBoss = MakeBar(transform, "BlueBoss", val, val, new Vector2(0f, -84f), new Vector2(380f, 14f), CBlue);
			_redBoss = MakeBar(transform, "RedBoss", val, val, new Vector2(0f, -101f), new Vector2(380f, 14f), CRed);
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(0.5f, 0.5f);
			_bannerTitle = MakeText(transform, "BannerTitle", val3, val3, new Vector2(0f, 250f), new Vector2(1600f, 90f), 54f, (TextAlignmentOptions)514);
			_bannerSub = MakeText(transform, "BannerSub", val3, val3, new Vector2(0f, 195f), new Vector2(1600f, 40f), 26f, (TextAlignmentOptions)514);
			_respawn = MakeText(transform, "Respawn", val3, val3, new Vector2(0f, -40f), new Vector2(900f, 60f), 40f, (TextAlignmentOptions)514);
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(1f, 1f);
			for (int i = 0; i < 6; i++)
			{
				Image val5 = MakePanel(transform, "Feed" + i, val4, val4, new Vector2(-20f, -130f - (float)i * 26f), new Vector2(340f, 22f), CPanel, outline: false);
				TextMeshProUGUI item = MakeText(((Component)val5).transform, "Text", new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-8f, 0f), new Vector2(324f, 20f), 14f, (TextAlignmentOptions)516);
				_feedRows.Add(((Component)val5).gameObject);
				_feedTexts.Add(item);
			}
			Image val6 = MakePanel(transform, "Table", val, val, new Vector2(0f, -120f), new Vector2(760f, 200f), CPanel, outline: true);
			_table = ((Component)val6).gameObject;
			_tableBlue = MakeText(((Component)val6).transform, "BlueRows", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(14f, -10f), new Vector2(360f, 180f), 16f, (TextAlignmentOptions)257);
			_tableRed = MakeText(((Component)val6).transform, "RedRows", new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-14f, -10f), new Vector2(360f, 180f), 16f, (TextAlignmentOptions)260);
			Refresh();
		}

		internal static Image MakePanel(Transform parent, string name, Vector2 anchor, Vector2 pivot, Vector2 pos, Vector2 size, Color color, bool outline)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0059: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform val2 = (RectTransform)val.transform;
			Vector2 anchorMin = (val2.anchorMax = anchor);
			val2.anchorMin = anchorMin;
			val2.pivot = pivot;
			val2.anchoredPosition = pos;
			val2.sizeDelta = size;
			Image val4 = val.AddComponent<Image>();
			((Graphic)val4).color = color;
			((Graphic)val4).raycastTarget = false;
			if (outline)
			{
				Outline val5 = val.AddComponent<Outline>();
				((Shadow)val5).effectColor = CBorder;
				((Shadow)val5).effectDistance = new Vector2(1f, -1f);
			}
			return val4;
		}

		internal static TextMeshProUGUI MakeText(Transform parent, string name, Vector2 anchor, Vector2 pivot, Vector2 pos, Vector2 size, float fontSize, TextAlignmentOptions align)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0059: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform val2 = (RectTransform)val.transform;
			Vector2 anchorMin = (val2.anchorMax = anchor);
			val2.anchorMin = anchorMin;
			val2.pivot = pivot;
			val2.anchoredPosition = pos;
			val2.sizeDelta = size;
			TextMeshProUGUI val4 = val.AddComponent<TextMeshProUGUI>();
			if (Object.op_Implicit((Object)(object)_font))
			{
				((TMP_Text)val4).font = _font;
			}
			((TMP_Text)val4).fontSize = fontSize;
			((TMP_Text)val4).alignment = align;
			((TMP_Text)val4).richText = true;
			((TMP_Text)val4).enableWordWrapping = false;
			((Graphic)val4).raycastTarget = false;
			((Graphic)val4).color = CText;
			((TMP_Text)val4).text = "";
			return val4;
		}

		private static Bar MakeBar(Transform parent, string name, Vector2 anchor, Vector2 pivot, Vector2 pos, Vector2 size, Color fill)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			Image val = MakePanel(parent, name, anchor, pivot, pos, size, CBarBg, outline: true);
			GameObject val2 = new GameObject("Fill", new Type[1] { typeof(RectTransform) });
			val2.transform.SetParent(((Component)val).transform, false);
			RectTransform val3 = (RectTransform)val2.transform;
			val3.anchorMin = Vector2.zero;
			val3.anchorMax = Vector2.one;
			val3.offsetMin = new Vector2(1f, 1f);
			val3.offsetMax = new Vector2(-1f, -1f);
			Image val4 = val2.AddComponent<Image>();
			((Graphic)val4).color = fill;
			((Graphic)val4).raycastTarget = false;
			TextMeshProUGUI label = MakeText(((Component)val).transform, "Label", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(size.x - 8f, size.y), Mathf.Min(15f, size.y * 0.72f), (TextAlignmentOptions)514);
			return new Bar
			{
				Root = ((Component)val).gameObject,
				Fill = val3,
				FillImage = val4,
				Label = label
			};
		}

		private void Update()
		{
			try
			{
				bool flag = _score != null && _score.Phase == 3;
				((Behaviour)_canvas).enabled = Time.timeScale > 0f && (!flag || !(_bannerStart < 0f) || Pending.Count != 0);
				Refresh();
			}
			catch (Exception e)
			{
				Fail(e);
			}
		}

		private void Refresh()
		{
			UpdateScore();
			UpdateBanner();
			UpdateFeed();
		}

		private static string Clock(float seconds)
		{
			int num = Mathf.Max(0, Mathf.FloorToInt(seconds));
			return $"{num / 60:00}:{num % 60:00}";
		}

		private void UpdateScore()
		{
			ScoreMessage score = _score;
			bool flag = score != null;
			_top.SetActive(flag);
			if (!flag)
			{
				_blueBoss.Root.SetActive(false);
				_redBoss.Root.SetActive(false);
				((TMP_Text)_respawn).text = "";
				_table.SetActive(false);
				return;
			}
			float num = Time.time - _scoreTime;
			bool flag2 = score.Phase == 3;
			((TMP_Text)_blueScore).text = string.Format("<color={0}>AZUL</color>  {1}", "#85B7EB", score.BlueKills);
			((TMP_Text)_redScore).text = string.Format("{0}  <color={1}>ROJO</color>", score.RedKills, "#F09595");
			((TMP_Text)_clock).text = Clock(score.Elapsed + (flag2 ? 0f : num));
			PlayerRow playerRow = null;
			uint num2 = LocalId();
			foreach (PlayerRow player in score.Players)
			{
				if (player.Id == num2)
				{
					playerRow = player;
					break;
				}
			}
			((TMP_Text)_kda).text = ((playerRow != null) ? $"{playerRow.Kills} / {playerRow.Deaths} / {playerRow.Assists}   ·   {playerRow.Minions} minions" : "");
			SetNexus(_blueNexus, score.BlueNexus, score.BlueTurrets, score.BlueTurretsTotal);
			SetNexus(_redNexus, score.RedNexus, score.RedTurrets, score.RedTurretsTotal);
			float num3 = score.NextWaveIn - num;
			((TMP_Text)_nextWave).text = ((!flag2 && num3 > 0.5f && score.Phase == 1) ? ("Minions en " + Clock(num3)) : "");
			SetBoss(_blueBoss, score.BlueBoss, score.BlueBossName, "azul");
			SetBoss(_redBoss, score.RedBoss, score.RedBossName, "rojo");
			float num4 = ((playerRow != null) ? (playerRow.RespawnIn - num) : 0f);
			((TMP_Text)_respawn).text = ((num4 > 0.05f && !flag2) ? $"Reapareces en {Mathf.CeilToInt(num4)}" : "");
			bool key = Input.GetKey((KeyCode)9);
			_table.SetActive(key);
			if (key)
			{
				FillTable(score, num2, num);
			}
		}

		private static void SetNexus(Bar bar, float frac, int turrets, int total)
		{
			if (frac < 0f)
			{
				bar.Set(0f);
				((TMP_Text)bar.Label).text = "NEXO DESTRUIDO";
			}
			else
			{
				bar.Set(frac);
				((TMP_Text)bar.Label).text = $"Nexo {Mathf.CeilToInt(frac * 100f)}%   ·   Torretas {turrets}/{total}";
			}
		}

		private static void SetBoss(Bar bar, float frac, string name, string team)
		{
			bool flag = frac >= 0f;
			bar.Root.SetActive(flag);
			if (flag)
			{
				bar.Set(frac);
				((TMP_Text)bar.Label).text = $"Guardián {team}: {name}  ·  {Mathf.CeilToInt(frac * 100f)}%  ·  no se cura";
			}
		}

		private void FillTable(ScoreMessage sc, uint localId, float since)
		{
			StringBuilder stringBuilder = new StringBuilder("<color=#85B7EB>EQUIPO AZUL</color>      K / M / A    Minions\n");
			StringBuilder stringBuilder2 = new StringBuilder("Minions    K / M / A      <color=#F09595>EQUIPO ROJO</color>\n");
			foreach (PlayerRow player in sc.Players)
			{
				string text = ((player.Id == localId) ? ("<color=#FAC775>" + player.Name + "</color>") : player.Name) + $" <color=#888780>Nv{player.Level}</color>";
				string text2 = (string.IsNullOrEmpty(player.Survivor) ? "" : (" <color=#888780>(" + player.Survivor + ")</color>"));
				float num = player.RespawnIn - since;
				string text3 = ((num > 0.05f) ? $" <color=#F09595>[{Mathf.CeilToInt(num)}]</color>" : "");
				if (player.Team == 2)
				{
					stringBuilder2.Append($"{player.Minions}    {player.Kills} / {player.Deaths} / {player.Assists}      {text3}{text}{text2}\n");
				}
				else
				{
					stringBuilder.Append($"{text}{text2}{text3}      {player.Kills} / {player.Deaths} / {player.Assists}    {player.Minions}\n");
				}
			}
			((TMP_Text)_tableBlue).text = stringBuilder.ToString();
			((TMP_Text)_tableRed).text = stringBuilder2.ToString();
		}

		private void UpdateBanner()
		{
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0132: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			float unscaledTime = Time.unscaledTime;
			if (_bannerStart < 0f || unscaledTime - _bannerStart > _current.Duration)
			{
				if (Pending.Count <= 0)
				{
					_bannerStart = -1f;
					((TMP_Text)_bannerTitle).text = "";
					((TMP_Text)_bannerSub).text = "";
					return;
				}
				_current = Pending.Dequeue();
				_bannerStart = unscaledTime;
				((TMP_Text)_bannerTitle).text = _current.Title;
				((TMP_Text)_bannerTitle).fontSize = (_current.Big ? 64f : 46f);
				((TMP_Text)_bannerSub).text = _current.Sub;
			}
			float num = unscaledTime - _bannerStart;
			float num2 = Mathf.Clamp01(num / 0.15f) * Mathf.Clamp01((_current.Duration - num) / 0.4f);
			Color color = _current.Color;
			((Graphic)_bannerTitle).color = new Color(color.r, color.g, color.b, num2);
			((Graphic)_bannerSub).color = new Color(CText.r, CText.g, CText.b, num2);
		}

		private void UpdateFeed()
		{
			float now = Time.time;
			Feed.RemoveAll((FeedEntry f) => f.Expires < now);
			for (int num = 0; num < _feedRows.Count; num++)
			{
				bool flag = num < Feed.Count;
				_feedRows[num].SetActive(flag);
				if (flag)
				{
					((TMP_Text)_feedTexts[num]).text = Feed[num].Text;
				}
			}
		}
	}
	internal class LevelUi : MonoBehaviour
	{
		private static readonly Color CFrameBg = new Color(0.055f, 0.057f, 0.075f, 0.93f);

		private static readonly Color CBorder = new Color(0.46f, 0.37f, 0.22f, 1f);

		private static readonly Color CCorner = new Color(0.9f, 0.72f, 0.38f, 1f);

		private static readonly Color CBox = new Color(1f, 1f, 1f, 0.05f);

		private static readonly Color CBoxOn = new Color(1f, 1f, 1f, 0.12f);

		private static readonly Color CBoxUp = new Color(0.98f, 0.78f, 0.46f, 0.4f);

		private static readonly Color CBarBg = new Color(0f, 0f, 0f, 0.55f);

		private static readonly Color CXp = new Color(0.55f, 0.75f, 1f, 0.95f);

		private static readonly Color CHp = new Color(0.36f, 0.78f, 0.22f, 0.98f);

		private static readonly Color CShield = new Color(0.3f, 0.52f, 0.95f, 0.98f);

		private static readonly Color CRecall = new Color(0.45f, 0.85f, 0.95f, 0.95f);

		private static readonly Color CMuted = new Color(0.6f, 0.58f, 0.52f);

		private static readonly Color CGold = new Color(0.98f, 0.82f, 0.5f);

		private static readonly Color CPurple = new Color(0.2f, 0.09f, 0.3f, 0.96f);

		private const float PanelW = 750f;

		private const float PanelH = 124f;

		private const int ItemCells = 8;

		private const float SlotSize = 56f;

		private const float SlotInner = 50f;

		private const float BarW = 248f;

		private static LevelUi _instance;

		private static bool _failed;

		private static readonly string[] SlotKeys = new string[4] { "M1", "M2", "SH", "R" };

		private static readonly KeyCode[] Keys;

		private GameObject _panel;

		private GameObject _recallRoot;

		private GameObject _statsBox;

		private TextMeshProUGUI _lvl;

		private TextMeshProUGUI _bannerText;

		private TextMeshProUGUI _statsL;

		private TextMeshProUGUI _statsR;

		private TextMeshProUGUI _hpText;

		private TextMeshProUGUI _shieldText;

		private TextMeshProUGUI _gold;

		private TextMeshProUGUI _recallText;

		private TextMeshProUGUI _deadText;

		private TextMeshProUGUI _recallKey;

		private TextMeshProUGUI _shopKey;

		private RectTransform _xpFill;

		private RectTransform _recallFill;

		private RectTransform _hpFill;

		private RectTransform _shieldFill;

		private RawImage _portrait;

		private readonly Image[] _slotBg = (Image[])(object)new Image[4];

		private readonly Image[] _slotIcon = (Image[])(object)new Image[4];

		private readonly RectTransform[] _slotCd = (RectTransform[])(object)new RectTransform[4];

		private readonly TextMeshProUGUI[] _slotCdText = (TextMeshProUGUI[])(object)new TextMeshProUGUI[4];

		private readonly TextMeshProUGUI[] _slotPlus = (TextMeshProUGUI[])(object)new TextMeshProUGUI[4];

		private readonly Image[][] _pips = new Image[4][];

		private readonly float[] _cdMax = new float[4];

		private readonly Image[] _itemIcon = (Image[])(object)new Image[8];

		private readonly TextMeshProUGUI[] _itemCount = (TextMeshProUGUI[])(object)new TextMeshProUGUI[8];

		private static readonly Dictionary<ItemIndex, Sprite> IconCache;

		private int _lastLevel;

		private float _lastPress;

		private bool _showStats = true;

		private float _nextHide;

		private static readonly Vector2 TL;

		private static Sprite _circle;

		private static readonly HashSet<int> Hidden;

		internal static void Tick()
		{
			if (_failed)
			{
				return;
			}
			try
			{
				bool isLaneClashRun = LaneClashMatch.IsLaneClashRun;
				if (isLaneClashRun && !Object.op_Implicit((Object)(object)_instance))
				{
					Create();
				}
				else if (!isLaneClashRun && Object.op_Implicit((Object)(object)_instance))
				{
					Object.Destroy((Object)(object)((Component)_instance).gameObject);
					_instance = null;
				}
			}
			catch (Exception arg)
			{
				_failed = true;
				LaneClashPlugin.Log.LogError((object)$"[hud] error, se desactiva el HUD del campeon: {arg}");
				if (Object.op_Implicit((Object)(object)_instance))
				{
					Object.Destroy((Object)(object)((Component)_instance).gameObject);
				}
				_instance = null;
			}
		}

		private static void Create()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			LaneClashHud.EnsureFont();
			GameObject val = new GameObject("LaneClashChampionHud");
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas val2 = val.AddComponent<Canvas>();
			val2.renderMode = (RenderMode)0;
			val2.sortingOrder = 6;
			CanvasScaler val3 = val.AddComponent<CanvasScaler>();
			val3.uiScaleMode = (ScaleMode)1;
			val3.referenceResolution = new Vector2(1920f, 1080f);
			val3.matchWidthOrHeight = 0.5f;
			_instance = val.AddComponent<LevelUi>();
			_instance.Build();
		}

		private static Image Box(Transform parent, string name, float x, float y, float w, float h, Color c)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			return LaneClashHud.MakePanel(parent, name, TL, TL, new Vector2(x, 0f - y), new Vector2(w, h), c, outline: false);
		}

		private static TextMeshProUGUI Label(Transform parent, string name, float x, float y, float w, float h, float size, TextAlignmentOptions a)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return LaneClashHud.MakeText(parent, name, TL, TL, new Vector2(x, 0f - y), new Vector2(w, h), size, a);
		}

		private static Image Frame(Transform parent, string name, float x, float y, float w, float h, Color bg, bool corners)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			Image val = Box(parent, name, x, y, w, h, bg);
			Box(((Component)val).transform, "T", 0f, 0f, w, 1.5f, CBorder);
			Box(((Component)val).transform, "B", 0f, h - 1.5f, w, 1.5f, CBorder);
			Box(((Component)val).transform, "L", 0f, 0f, 1.5f, h, CBorder);
			Box(((Component)val).transform, "R", w - 1.5f, 0f, 1.5f, h, CBorder);
			if (corners)
			{
				Box(((Component)val).transform, "c1", -1.5f, -1.5f, 6f, 6f, CCorner);
				Box(((Component)val).transform, "c2", w - 4.5f, -1.5f, 6f, 6f, CCorner);
				Box(((Component)val).transform, "c3", -1.5f, h - 4.5f, 6f, 6f, CCorner);
				Box(((Component)val).transform, "c4", w - 4.5f, h - 4.5f, 6f, 6f, CCorner);
			}
			return val;
		}

		private static Sprite Circle()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0114: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_circle))
			{
				return _circle;
			}
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[16384];
			float num = 64f;
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num2 = Mathf.Sqrt(((float)j + 0.5f - num) * ((float)j + 0.5f - num) + ((float)i + 0.5f - num) * ((float)i + 0.5f - num));
					array[i * 128 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Mathf.Clamp01(num - num2) * 255f));
				}
			}
			val.SetPixels32(array);
			val.Apply();
			_circle = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f);
			return _circle;
		}

		private static Image Disc(Transform parent, string name, float x, float y, float size, Color c)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Image val = Box(parent, name, x, y, size, size, c);
			val.sprite = Circle();
			return val;
		}

		private void Build()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Expected O, but got Unknown
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Expected O, but got Unknown
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e3: Expected O, but got Unknown
			//IL_0732: Unknown result type (might be due to invalid IL or missing references)
			//IL_0760: Unknown result type (might be due to invalid IL or missing references)
			//IL_076f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0779: Expected O, but got Unknown
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Expected O, but got Unknown
			//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0916: Unknown result type (might be due to invalid IL or missing references)
			//IL_0972: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_09de: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a21: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a70: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a84: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab7: Expected O, but got Unknown
			//IL_0ace: Unknown result type (might be due to invalid IL or missing references)
			//IL_0add: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afb: 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)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0f);
			Image val2 = LaneClashHud.MakePanel(((Component)this).transform, "Panel", val, val, new Vector2(0f, 6f), new Vector2(750f, 124f), new Color(0f, 0f, 0f, 0f), outline: false);
			_panel = ((Component)val2).gameObject;
			Transform transform = _panel.transform;
			Image val3 = Frame(transform, "Stats", 0f, 14f, 178f, 104f, CFrameBg, corners: true);
			_statsBox = ((Component)val3).gameObject;
			_statsL = Label(_statsBox.transform, "L", 10f, 7f, 80f, 92f, 14f, (TextAlignmentOptions)257);
			_statsR = Label(_statsBox.transform, "R", 94f, 7f, 80f, 92f, 14f, (TextAlignmentOptions)257);
			((TMP_Text)_statsL).lineSpacing = 8f;
			((TMP_Text)_statsR).lineSpacing = 8f;
			Image val4 = Disc(transform, "Ring", 188f, 12f, 98f, CCorner);
			Disc(((Component)val4).transform, "Back", 3f, 3f, 92f, new Color(0.04f, 0.04f, 0.05f, 1f));
			Image val5 = Disc(((Component)val4).transform, "Mask", 6f, 6f, 86f, Color.white);
			((Component)val5).gameObject.AddComponent<Mask>().showMaskGraphic = false;
			GameObject val6 = new GameObject("Portrait", new Type[1] { typeof(RectTransform) });
			val6.transform.SetParent(((Component)val5).transform, false);
			RectTransform val7 = (RectTransform)val6.transform;
			Vector2 anchorMin = (val7.anchorMax = TL);
			val7.anchorMin = anchorMin;
			val7.pivot = TL;
			val7.anchoredPosition = Vector2.zero;
			val7.sizeDelta = new Vector2(86f, 86f);
			_portrait = val6.AddComponent<RawImage>();
			((Graphic)_portrait).raycastTarget = false;
			((Behaviour)_portrait).enabled = false;
			_deadText = Label(((Component)val4).transform, "Dead", 0f, 38f, 98f, 20f, 12f, (TextAlignmentOptions)514);
			Image val8 = Disc(transform, "Badge", 184f, 80f, 32f, CCorner);
			Disc(((Component)val8).transform, "Back", 2f, 2f, 28f, new Color(0.04f, 0.04f, 0.06f, 1f));
			_lvl = Label(((Component)val8).transform, "Lvl", 0f, 6f, 32f, 20f, 17f, (TextAlignmentOptions)514);
			Image val9 = Frame(transform, "XpBg", 192f, 113f, 90f, 7f, CBarBg, corners: false);
			_xpFill = (RectTransform)((Component)Box(((Component)val9).transform, "XpFill", 1.5f, 1.5f, 0f, 4f, CXp)).transform;
			for (int i = 0; i < 4; i++)
			{
				float num = 300f + (float)i * 62f;
				_pips[i] = (Image[])(object)new Image[5];
				if (i > 0)
				{
					for (int j = 0; j < 5; j++)
					{
						_pips[i][j] = Box(transform, "Pip" + i + j, num + 3f + (float)j * 10.6f, 21f, 9f, 5f, CBarBg);
						((Behaviour)_pips[i][j]).enabled = false;
					}
				}
				Image val10 = Frame(transform, "Slot" + i, num, 32f, 56f, 56f, CFrameBg, corners: false);
				_slotBg[i] = Box(((Component)val10).transform, "Tint", 2f, 2f, 52f, 52f, CBox);
				Image val11 = Box(((Component)val10).transform, "Icon", 3f, 3f, 50f, 50f, Color.white);
				val11.preserveAspect = true;
				((Behaviour)val11).enabled = false;
				_slotIcon[i] = val11;
				Image val12 = Box(((Component)val10).transform, "Cd", 3f, 3f, 50f, 0f, new Color(0f, 0f, 0f, 0.72f));
				_slotCd[i] = (RectTransform)((Component)val12).transform;
				_slotCdText[i] = Label(((Component)val10).transform, "CdText", 0f, 16f, 56f, 26f, 21f, (TextAlignmentOptions)514);
				Image val13 = Frame(((Component)val10).transform, "KeyBg", 2f, 39f, 24f, 15f, new Color(0f, 0f, 0f, 0.85f), corners: false);
				TextMeshProUGUI val14 = Label(((Component)val13).transform, "Key", 0f, 0f, 24f, 15f, 11f, (TextAlignmentOptions)514);
				((Graphic)val14).color = CGold;
				((TMP_Text)val14).text = SlotKeys[i];
				_slotPlus[i] = Label(((Component)val10).transform, "Plus", 36f, 0f, 18f, 20f, 20f, (TextAlignmentOptions)514);
				((Graphic)_slotPlus[i]).color = CGold;
			}
			Image val15 = Frame(transform, "HpBg", 300f, 96f, 248f, 15f, CBarBg, corners: false);
			_hpFill = (RectTransform)((Component)Box(((Component)val15).transform, "HpFill", 1.5f, 1.5f, 0f, 12f, CHp)).transform;
			_hpText = Label(((Component)val15).transform, "HpText", 0f, -1f, 248f, 16f, 12f, (TextAlignmentOptions)514);
			Image val16 = Frame(transform, "ShBg", 300f, 112f, 248f, 8f, CBarBg, corners: false);
			_shieldFill = (RectTransform)((Component)Box(((Component)val16).transform, "ShFill", 1.5f, 1.5f, 0f, 5f, CShield)).transform;
			_shieldText = Label(((Component)val16).transform, "ShText", 0f, -4f, 248f, 14f, 9f, (TextAlignmentOptions)514);
			for (int k = 0; k < 8; k++)
			{
				float x = 568f + (float)(k % 4) * 33f;
				float y = 32f + (float)(k / 4) * 33f;
				Image val17 = Frame(transform, "Item" + k, x, y, 31f, 31f, CFrameBg, corners: false);
				Image val18 = Box(((Component)val17).transform, "Icon", 2f, 2f, 27f, 27f, Color.white);
				val18.preserveAspect = true;
				((Behaviour)val18).enabled = false;
				_itemIcon[k] = val18;
				_itemCount[k] = Label(((Component)val17).transform, "Count", 0f, 17f, 30f, 12f, 10f, (TextAlignmentOptions)516);
			}
			Image val19 = Frame(transform, "RecallSlot", 706f, 32f, 40f, 40f, CFrameBg, corners: true);
			_recallKey = Label(((Component)val19).transform, "T", 0f, 4f, 40f, 34f, 20f, (TextAlignmentOptions)514);
			Image val20 = Frame(transform, "ShopSlot", 706f, 76f, 40f, 40f, CFrameBg, corners: true);
			_shopKey = Label(((Component)val20).transform, "T", 0f, 4f, 40f, 34f, 20f, (TextAlignmentOptions)514);
			Frame(transform, "GoldBox", 568f, 99f, 130f, 21f, CPurple, corners: false);
			_gold = Label(transform, "Gold", 572f, 100f, 122f, 20f, 15f, (TextAlignmentOptions)516);
			((Graphic)_gold).color = CGold;
			_bannerText = LaneClashHud.MakeText(transform, "Banner", new Vector2(0.5f, 1f), new Vector2(0.5f, 0f), new Vector2(40f, 4f), new Vector2(520f, 26f), 20f, (TextAlignmentOptions)514);
			Image val21 = LaneClashHud.MakePanel(((Component)this).transform, "Recall", val, val, new Vector2(0f, 190f), new Vector2(300f, 14f), CBarBg, outline: true);
			_recallRoot = ((Component)val21).gameObject;
			Image val22 = LaneClashHud.MakePanel(((Component)val21).transform, "RecallFill", new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), Vector2.zero, new Vector2(0f, 14f), CRecall, outline: false);
			_recallFill = (RectTransform)((Component)val22).transform;
			_recallText = LaneClashHud.MakeText(((Component)val21).transform, "RecallText", new Vector2(0.5f, 1f), new Vector2(0.5f, 0f), new Vector2(0f, 3f), new Vector2(380f, 24f), 16f, (TextAlignmentOptions)514);
			_recallRoot.SetActive(false);
			_panel.SetActive(false);
		}

		private static bool Typing()
		{
			EventSystem current = EventSystem.current;
			GameObject val = (Object.op_Implicit((Object)(object)current) ? current.currentSelectedGameObject : null);
			return Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.GetComponent<TMP_InputField>());
		}

		private static CharacterBody LocalBody()
		{
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			return (firstLocalUser != null) ? firstLocalUser.cachedBody : null;
		}

		private static CharacterMaster LocalMaster()
		{
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			return (firstLocalUser != null) ? firstLocalUser.cachedMaster : null;
		}

		private void Update()
		{
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			if (!LaneClashMatch.IsLaneClashRun)
			{
				return;
			}
			if (LaneClashConfig.HideVanillaHud.Value && Time.unscaledTime >= _nextHide)
			{
				_nextHide = Time.unscaledTime + 1.5f;
				try
				{
					HideVanillaHud();
				}
				catch (Exception ex)
				{
					LaneClashPlugin.Log.LogWarning((object)("[hud] no se pudo ocultar el HUD original: " + ex.Message));
					_nextHide = float.MaxValue;
				}
			}
			float age;
			PlayerRow playerRow = LaneClashHud.LocalRow(out age);
			if (playerRow == null)
			{
				_panel.SetActive(false);
				_recallRoot.SetActive(false);
				return;
			}
			CharacterBody val = LocalBody();
			int[] array = new int[4] { 0, playerRow.Rank1, playerRow.Rank2, playerRow.Rank3 };
			if (!Typing() && !ShopUi.IsOpen)
			{
				for (int i = 1; i <= 3; i++)
				{
					if (Input.GetKeyDown(Keys[i]) && Time.unscaledTime - _lastPress > 0.25f && LaneLevels.CanRank(playerRow.Level, playerRow.Points, array, i))
					{
						_lastPress = Time.unscaledTime;
						Submit("lc_habilidad " + i);
					}
				}
				if (Input.GetKeyDown(LaneClashConfig.RecallKey.Value))
				{
					Submit("lc_recall");
				}
				if (Input.GetKeyDown(LaneClashConfig.StatsKey.Value))
				{
					_showStats = !_showStats;
				}
			}
			if (Object.op_Implicit((Object)(object)val) && val.hasEffectiveAuthority && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
			{
				LaneLevels.ExtraRecharge(val, array[1], array[2], array[3], Time.deltaTime);
			}
			if (_lastLevel > 0 && playerRow.Level > _lastLevel && Object.op_Implicit((Object)(object)val))
			{
				Util.PlaySound("Play_UI_levelUp", ((Component)val).gameObject);
			}
			_lastLevel = playerRow.Level;
			_panel.SetActive(true);
			DrawLeft(val, playerRow);
			DrawSkills(val, playerRow, array);
			DrawBars(val);
			DrawItems(LocalMaster());
			DrawRecall(playerRow, age);
		}

		private static void Submit(string cmd)
		{
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser != null && !((Object)(object)firstLocalUser.currentNetworkUser == (Object)null))
			{
				Console.instance.SubmitCmd(firstLocalUser.currentNetworkUser, cmd, false);
			}
		}

		private void DrawLeft(CharacterBody body, PlayerRow row)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)_lvl).text = row.Level.ToString();
			_xpFill.sizeDelta = new Vector2(87f * Mathf.Clamp01(row.XpFrac), 4f);
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.portraitIcon))
			{
				_portrait.texture = body.portraitIcon;
				((Behaviour)_portrait).enabled = true;
			}
			_statsBox.SetActive(_showStats);
			if (_showStats && Object.op_Implicit((Object)(object)body))
			{
				((TMP_Text)_statsL).text = $"<color=#F0903D>DÑ</color> {body.damage:0}\n<color=#F0D060>VA</color> {body.attackSpeed:0.00}\n<color=#EE5555>CR</color> {body.crit:0}%\n<color=#A9BDD0>AR</color> {body.armor:0}";
				((TMP_Text)_statsR).text = $"<color=#7FD97F>VM</color> {body.moveSpeed:0.0}\n<color=#F08FB0>RG</color> {body.regen:0.0}\n<color=#70C050>HP</color> {body.maxHealth:0}\n<color=#8FC0FF>NV</color> {row.Level}";
			}
			((TMP_Text)_deadText).text = ((Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive) ? "" : "<color=#F09595>Reapareciendo</color>");
			((TMP_Text)_recallKey).text = "<color=#FAD580>" + ShopUi.KeyName(LaneClashConfig.RecallKey.Value) + "</color>\n<size=45%><color=#9a9a92>RECALL</color></size>";
			((TMP_Text)_shopKey).text = "<color=#FAD580>" + ShopUi.KeyName(LaneClashConfig.ShopKey.Value) + "</color>\n<size=45%><color=#9a9a92>TIENDA</color></size>";
			((TMP_Text)_bannerText).text = ((row.Points > 0) ? $"<color=#FAD580>¡SUBES DE NIVEL! +{row.Points}</color>  <size=65%><color=#c8c8c0>1 · 2 · 3</color></size>" : "");
		}

		private void DrawSkills(CharacterBody body, PlayerRow row, int[] ranks)
		{
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: 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_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			SkillLocator val = (Object.op_Implicit((Object)(object)body) ? body.skillLocator : null);
			for (int i = 0; i < 4; i++)
			{
				GenericSkill val2 = null;
				if (Object.op_Implicit((Object)(object)val))
				{
					val2 = (GenericSkill)(i switch
					{
						2 => val.utility, 
						1 => val.secondary, 
						0 => val.primary, 
						_ => val.special, 
					});
				}
				Sprite val3 = ((Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.skillDef)) ? val2.skillDef.icon : null);
				_slotIcon[i].sprite = val3;
				((Behaviour)_slotIcon[i]).enabled = (Object)(object)val3 != (Object)null;
				bool flag = i > 0 && ranks[i] <= 0;
				bool flag2 = i > 0 && LaneLevels.CanRank(row.Level, row.Points, ranks, i);
				int num = ((i > 0) ? LaneLevels.MaxRank(i) : 0);
				float num2 = (Object.op_Implicit((Object)(object)val2) ? val2.cooldownRemaining : 0f);
				if (num2 <= 0.01f)
				{
					_cdMax[i] = 0f;
				}
				else
				{
					_cdMax[i] = Mathf.Max(_cdMax[i], num2);
				}
				bool flag3 = num2 > 0.05f && Object.op_Implicit((Object)(object)val2) && val2.stock <= 0;
				float num3 = ((flag3 && _cdMax[i] > 0f) ? Mathf.Clamp01(num2 / _cdMax[i]) : 0f);
				_slotCd[i].sizeDelta = new Vector2(50f, 50f * num3);
				string text = ((!flag3) ? "" : ((num2 >= 10f) ? Mathf.CeilToInt(num2).ToString() : num2.ToString("0.0")));
				if (Object.op_Implicit((Object)(object)val2) && val2.maxStock > 1 && !flag3)
				{
					text = $"<size=60%>x{val2.stock}</size>";
				}
				if (flag && !flag2)
				{
					text = $"<size=55%><color=#9a9a92>nv {LaneLevels.LevelNeeded(i, 1)}</color></size>";
				}
				((TMP_Text)_slotCdText[i]).text = text;
				((Graphic)_slotIcon[i]).color = (Color)(flag ? new Color(0.35f, 0.35f, 0.35f, 1f) : Color.white);
				((Graphic)_slotBg[i]).color = (flag2 ? CBoxUp : (flag ? CBox : CBoxOn));
				((TMP_Text)_slotPlus[i]).text = (flag2 ? "+" : "");
				if (i != 0)
				{
					for (int j = 0; j < 5; j++)
					{
						Image val4 = _pips[i][j];
						((Behaviour)val4).enabled = j < num;
						((Graphic)val4).color = (Color)((j < ranks[i]) ? CGold : new Color(0.28f, 0.28f, 0.3f, 0.95f));
					}
				}
			}
		}

		private void DrawBars(CharacterBody body)
		{
			//IL_006c: 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)
			HealthComponent val = (Object.op_Implicit((Object)(object)body) ? body.healthComponent : null);
			float num = (Object.op_Implicit((Object)(object)val) ? Mathf.Max(0f, val.health) : 0f);
			float num2 = (Object.op_Implicit((Object)(object)val) ? Mathf.Max(1f, val.fullHealth) : 1f);
			_hpFill.sizeDelta = new Vector2(245f * Mathf.Clamp01(num / num2), 12f);
			((TMP_Text)_hpText).text = (Object.op_Implicit((Object)(object)val) ? $"{Mathf.CeilToInt(num)} / {Mathf.CeilToInt(num2)}" : "");
			float num3 = (Object.op_Implicit((Object)(object)val) ? Mathf.Max(0f, val.shield) : 0f);
			float num4 = (Object.op_Implicit((Object)(object)val) ? val.fullShield : 0f);
			_shieldFill.sizeDelta = new Vector2(245f * ((num4 > 0.5f) ? Mathf.Clamp01(num3 / num4) : 0f), 5f);
			((TMP_Text)_shieldText).text = ((num4 > 0.5f) ? $"{Mathf.CeilToInt(num3)}" : "");
		}

		private void DrawItems(CharacterMaster master)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Invalid comparison between Unknown and I4
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			if (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.inventory))
			{
				List<ItemIndex> itemAcquisitionOrder = master.inventory.itemAcquisitionOrder;
				int num2 = itemAcquisitionOrder.Count - 1;
				while (num2 >= 0 && num < 8)
				{
					ItemDef itemDef = ItemCatalog.GetItemDef(itemAcquisitionOrder[num2]);
					if (!((Object)(object)itemDef == (Object)null) && !itemDef.hidden && (int)itemDef.tier != 5)
					{
						int itemCountPermanent = master.inventory.GetItemCountPermanent(itemDef);
						if (itemCountPermanent > 0)
						{
							Sprite val = IconOf(itemDef, itemAcquisitionOrder[num2]);
							_itemIcon[num].sprite = val;
							((Behaviour)_itemIcon[num]).enabled = (Object)(object)val != (Object)null;
							((TMP_Text)_itemCount[num]).text = ((itemCountPermanent > 1) ? ("x" + itemCountPermanent) : "");
							num++;
						}
					}
					num2--;
				}
			}
			for (int i = num; i < 8; i++)
			{
				((Behaviour)_itemIcon[i]).enabled = false;
				((TMP_Text)_itemCount[i]).text = "";
			}
			((TMP_Text)_gold).text = (Object.op_Implicit((Object)(object)master) ? master.money : 0u).ToString("N0") + " <size=65%>oro</size>";
		}

		private static Sprite IconOf(ItemDef def, ItemIndex idx)
		{
			//IL_0006: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if (IconCache.TryGetValue(idx, out var value))
			{
				return value;
			}
			value = def.pickupIconSprite;
			try
			{
				if (!Object.op_Implicit((Object)(object)value))
				{
					MethodInfo method = typeof(ItemDef).GetMethod("GetIcon", Type.EmptyTypes);
					if (method != null)
					{
						object? obj = method.Invoke(def, null);
						value = (Sprite)((obj is Sprite) ? obj : null);
					}
				}
				if (!Object.op_Implicit((Object)(object)value))
				{
					FieldInfo field = typeof(ItemDef).GetField("pickupIconSpriteReference");
					AssetReference val = (AssetReference)((field != null) ? /*isinst with value type is only supported in some contexts*/: null);
					if (val != null && val.RuntimeKeyIsValid())
					{
						value = Addressables.LoadAssetAsync<Sprite>(val.RuntimeKey).WaitForCompletion();
					}
				}
			}
			catch (Exception)
			{
			}
			IconCache[idx] = value;
			return value;
		}

		private void DrawRecall(PlayerRow row, float age)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			bool flag = row.RecallLeft >= 0f && row.RecallTotal > 0f;
			_recallRoot.SetActive(flag);
			if (flag)
			{
				float num = Mathf.Max(0f, row.RecallLeft - age);
				_recallFill.sizeDelta = new Vector2(300f * Mathf.Clamp01(1f - num / row.RecallTotal), 14f);
				((TMP_Text)_recallText).text = $"Volviendo a la base · {num:0.0} s  <size=70%><color=#8c8c85>(no te muevas)</color></size>";
			}
		}

		private static void HideVanillaHud()
		{
			HUD[] array = Object.FindObjectsOfType<HUD>();
			foreach (HUD val in array)
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				List<Component> list = new List<Component>();
				string[] array2 = new string[7] { "healthBar", "expBar", "levelText", "moneyText", "itemInventoryDisplay", "sprintIcon", "keyItemIcon" };
				foreach (string name in array2)
				{
					AddField(val, name, list);
				}
				string[] array3 = new string[2] { "skillIcons", "equipmentIcons" };
				foreach (string name2 in array3)
				{
					AddField(val, name2, list);
				}
				foreach (Component item in list)
				{
					if (!Object.op_Implicit((Object)(object)item))
					{
						continue;
					}
					Fade(item.gameObject);
					Transform parent = item.transform.parent;
					for (int l = 0; l < 3; l++)
					{
						if (!Object.op_Implicit((Object)(object)parent))
						{
							break;
						}
						if (!((Object)(object)((Component)parent).gameObject != (Object)(object)val.mainUIPanel))
						{
							break;
						}
						if (!((Object)(object)((Component)parent).gameObject != (Object)(object)val.mainContainer))
						{
							break;
						}
						bool flag = true;
						for (int m = 0; m < parent.childCount && flag; m++)
						{
							GameObject gameObject = ((Component)parent.GetChild(m)).gameObject;
							if (gameObject.activeSelf && !Hidden.Contains(((Object)gameObject).GetInstanceID()))
							{
								flag = false;
							}
						}
						if (!flag)
						{
							break;
						}
						Fade(((Component)parent).gameObject);
						parent = parent.parent;
					}
				}
			}
		}

		private static void AddField(HUD hud, string name, List<Component> into)
		{
			FieldInfo field = typeof(HUD).GetField(name);
			if (field == null)
			{
				return;
			}
			object value = field.GetValue(hud);
			Component val = (Component)((value is Component) ? value : null);
			if (val != null)
			{
				into.Add(val);
			}
			else
			{
				if (!(value is Component[] array))
				{
					return;
				}
				Component[] array2 = array;
				foreach (Component val2 in array2)
				{
					if (Object.op_Implicit((Object)(object)val2))
					{
						into.Add(val2);
					}
				}
			}
		}

		private static void Fade(GameObject go)
		{
			if (Object.op_Implicit((Object)(object)go))
			{
				CanvasGroup val = go.GetComponent<CanvasGroup>();
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = go.AddComponent<CanvasGroup>();
				}
				val.alpha = 0f;
				val.blocksRaycasts = false;
				val.interactable = false;
				Hidden.Add(((Object)go).GetInstanceID());
			}
		}

		static LevelUi()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0055: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00cd: 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_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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: 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)
			KeyCode[] array = new KeyCode[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Keys = (KeyCode[])(object)array;
			IconCache = new Dictionary<ItemIndex, Sprite>();
			TL = new Vector2(0f, 1f);
			Hidden = new HashSet<int>();
		}
	}
	internal static class LobbyTab
	{
		private const string HeaderName = "LaneClashTeam";

		private static GameObject _root;

		private static float _nextTry;

		private static float _searchingSince = -1f;

		private static bool _loggedFail;

		internal static string Picked = "automatico";

		private static TextMeshProUGUI _status;

		private static TextMeshProUGUI _bots;

		internal static bool Integrated => Object.op_Implicit((Object)(object)_root);

		internal static bool GaveUp => !Object.op_Implicit((Object)(object)_root) && _searchingSince > 0f && Time.unscaledTime - _searchingSince > 4f;

		internal static void Reset()
		{
			_root = null;
			_searchingSince = -1f;
		}

		internal static void Tick()
		{
			if (Object.op_Implicit((Object)(object)_root))
			{
				return;
			}
			if (_searchingSince < 0f)
			{
				_searchingSince = Time.unscaledTime;
			}
			if (Time.unscaledTime < _nextTry)
			{
				return;
			}
			_nextTry = Time.unscaledTime + 0.5f;
			try
			{
				TryIntegrate();
			}
			catch (Exception arg)
			{
				if (!_loggedFail)
				{
					_loggedFail = true;
					LaneClashPlugin.Log.LogWarning((object)$"[lobby] no se pudo crear la pestaña Equipo: {arg}");
				}
				_searchingSince = 1f;
			}
		}

		private static void TryIntegrate()
		{
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Expected O, but got Unknown
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Expected O, but got Unknown
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Expected O, but got Unknown
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Expected O, but got Unknown
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			CharacterSelectController val = Object.FindObjectOfType<CharacterSelectController>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			object? obj = typeof(CharacterSelectController).GetField("loadoutHeaderButton")?.GetValue(val);
			GameObject val2 = (GameObject)((obj is GameObject) ? obj : null);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				return;
			}
			Type typeFromHandle = typeof(HGHeaderNavigationController);
			FieldInfo field = typeFromHandle.GetField("headers");
			Type nestedType = typeFromHandle.GetNestedType("Header");
			if (field == null || nestedType == null)
			{
				return;
			}
			FieldInfo field2 = nestedType.GetField("headerButton");
			FieldInfo field3 = nestedType.GetField("headerName");
			FieldInfo field4 = nestedType.GetField("tmpHeaderText");
			FieldInfo field5 = nestedType.GetField("headerRoot");
			HGHeaderNavigationController[] array = Object.FindObjectsOfType<HGHeaderNavigationController>();
			foreach (HGHeaderNavigationController nav in array)
			{
				if (!(field.GetValue(nav) is IEnumerable enumerable))
				{
					continue;
				}
				object obj2 = null;
				foreach (object item in enumerable)
				{
					object? value = field2.GetValue(item);
					MPButton val3 = (MPButton)((value is MPButton) ? value : null);
					if (field3.GetValue(item) as string == "LaneClashTeam")
					{
						return;
					}
					if (Object.op_Implicit((Object)(object)val3) && ((Object)(object)((Component)val3).gameObject == (Object)(object)val2 || ((Component)val3).transform.IsChildOf(val2.transform) || val2.transform.IsChildOf(((Component)val3).transform)))
					{
						obj2 = item;
					}
				}
				if (obj2 == null)
				{
					continue;
				}
				object? value2 = field2.GetValue(obj2);
				MPButton val4 = (MPButton)((value2 is MPButton) ? value2 : null);
				object? value3 = field5.GetValue(obj2);
				GameObject val5 = (GameObject)((value3 is GameObject) ? value3 : null);
				if (Object.op_Implicit((Object)(object)val4) && Object.op_Implicit((Object)(object)val5))
				{
					GameObject val6 = Object.Instantiate<GameObject>(((Component)val4).gameObject, ((Component)val4).transform.parent);
					((Object)val6).name = "LC_TeamHeaderButton";
					val6.transform.SetSiblingIndex(((Component)val4).transform.GetSiblingIndex() + 1);
					MPButton component = val6.GetComponent<MPButton>();
					((Button)component).onClick = new ButtonClickedEvent();
					MethodInfo choose = typeFromHandle.GetMethod("ChooseHeader", new Type[1] { typeof(string) });
					((UnityEvent)((Button)component).onClick).AddListener((UnityAction)delegate
					{
						choose?.Invoke(nav, new object[1] { "LaneClashTeam" });
					});
					TextMeshProUGUI value4 = Relabel(val6, "Equipo");
					_root = new GameObject("LC_TeamRoot", new Type[1] { typeof(RectTransform) });
					_root.transform.SetParent(val5.transform.parent, false);
					RectTransform val7 = (RectTransform)val5.transform;
					RectTransform val8 = (RectTransform)_root.transform;
					val8.anchorMin = val7.anchorMin;
					val8.anchorMax = val7.anchorMax;
					val8.pivot = val7.pivot;
					val8.anchoredPosition = val7.anchoredPosition;
					val8.sizeDelta = val7.sizeDelta;
					((Transform)val8).SetSiblingIndex(val5.transform.GetSiblingIndex() + 1);
					BuildContent(_root.transform, ((Component)val4).gameObject);
					_root.SetActive(false);
					object obj3 = Activator.CreateInstance(nestedType);
					field2.SetValue(obj3, component);
					field3.SetValue(obj3, "LaneClashTeam");
					field4?.SetValue(obj3, value4);
					field5.SetValue(obj3, _root);
					nestedType.GetField("AreConsolePlatformsSupported")?.SetValue(obj3, true);
					if (field.GetValue(nav) is IList { IsFixedSize: false } list)
					{
						list.Add(obj3);
					}
					else if (field.GetValue(nav) is Array array2)
					{
						Array array3 = Array.CreateInstance(nestedType, array2.Length + 1);
						Array.Copy(array2, array3, array2.Length);
						array3.SetValue(obj3, array2.Length);
						field.SetValue(nav, array3);
					}
					LaneClashPlugin.Log.LogInfo((object)"[lobby] pestaña Equipo agregada junto a Pertrecho.");
					break;
				}
			}
		}

		private static TextMeshProUGUI Relabel(GameObject go, string text)
		{
			LanguageTextMeshController[] componentsInChildren = go.GetComponentsInChildren<LanguageTextMeshController>(true);
			foreach (LanguageTextMeshController val in componentsInChildren)
			{
				Object.DestroyImmediate((Object)(object)val);
			}
			TextMeshProUGUI componentInChildren = go.GetComponentInChildren<TextMeshProUGUI>(true);
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				((TMP_Text)componentInChildren).text = text;
			}
			return componentInChildren;
		}

		private static void NativeButton(Transform parent, GameObject template, string label, Vector2 pos, float width, Color stripe, Action onClick)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0048: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00da: 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_0113: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(template, parent);
			((Object)val).name = "LC_Btn_" + label;
			RectTransform val2 = (RectTransform)val.transform;
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(0f, 1f);
			val2.anchorMax = val3;
			val2.anchorMin = val3;
			val2.pivot = new Vector2(0f, 1f);
			val2.anchoredPosition = pos;
			val2.sizeDelta = new Vector2(width, 52f);
			LayoutElement component = val.GetComponent<LayoutElement>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.ignoreLayout = true;
			}
			MPButton component2 = val.GetComponent<MPButton>();
			((Button)component2).onClick = new ButtonClickedEvent();
			((UnityEvent)((Button)component2).onClick).AddListener((UnityAction)delegate
			{
				onClick();
			});
			Relabel(val, label);
			if (stripe.a > 0f)
			{
				Image val4 = LaneClashHud.MakePanel(val.transform, "Stripe", new Vector2(0f, 0f), new Vector2(0f, 0f), Vector2.zero, new Vector2(width, 5f), stripe, outline: false);
				((Graphic)val4).raycastTarget = false;
			}
		}

		private static void BuildContent(Transform root, GameObject template)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_013b: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: 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)
			LaneClashHud.EnsureFont();
			TextMeshProUGUI val = LaneClashHud.MakeText(root, "Title", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(12f, -10f), new Vector2(500f, 34f), 26f, (TextAlignmentOptions)513);
			((TMP_Text)val).text = "Elige tu equipo";
			NativeButton(root, template, "Azul", new Vector2(12f, -50f), 160f, new Color(0.216f, 0.541f, 0.867f), delegate
			{
				Pick("azul");
			});
			NativeButton(root, template, "Rojo", new Vector2(184f, -50f), 160f, new Color(0.886f, 0.294f, 0.29f), delegate
			{
				Pick("rojo");
			});
			TextMeshProUGUI val2 = LaneClashHud.MakeText(root, "BotsTitle", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(12f, -124f), new Vector2(500f, 30f), 22f, (TextAlignmentOptions)513);
			((TMP_Text)val2).text = "Jugadores por equipo (los huecos se llenan con bots)";
			NativeButton(root, template, "−", new Vector2(12f, -160f), 64f, Color.clear, delegate
			{
				Bots(-1);
			});
			_bots = LaneClashHud.MakeText(root, "Bots", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(84f, -160f), new Vector2(80f, 52f), 34f, (TextAlignmentOptions)514);
			NativeButton(root, template, "+", new Vector2(172f, -160f), 64f, Color.clear, delegate
			{
				Bots(1);
			});
			_status = LaneClashHud.MakeText(root, "Status", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(12f, -228f), new Vector2(520f, 70f), 18f, (TextAlignmentOptions)257);
			((TMP_Text)_status).enableWordWrapping = true;
			Refresh();
		}

		internal static void Send(string cmd)
		{
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser != null && Object.op_Implicit((Object)(object)firstLocalUser.currentNetworkUser))
			{
				Console.instance.SubmitCmd(firstLocalUser.currentNetworkUser, cmd, false);
			}
		}

		internal static void Pick(string team)
		{
			Picked = team;
			Send("lc_equipo " + team);
			Refresh();
		}

		internal static void Bots(int delta)
		{
			int value = Mathf.Clamp(LaneClashConfig.BotTeamSize.Value + delta, 0, 5);
			LaneClashConfig.BotTeamSize.Value = value;
			Send("lc_bots " + value);
			Refresh();
		}

		private static void Refresh()
		{
			int value = LaneClashConfig.BotTeamSize.Value;
			if (Object.op_Implicit((Object)(object)_bots))
			{
				((TMP_Text)_bots).text = value.ToString();
			}
			if (Object.op_Implicit((Object)(object)_status))
			{
				((TMP_Text)_status).text = "Tu equipo: <b>" + Picked + "</b>\n" + ((value > 0) ? $"Equipos de {value}: los huecos los ocupan bots con nombre (ej. Nova-bot)." : "Sin bots.");
			}
		}
	}
	internal class LobbyTeamUi : MonoBehaviour
	{
		private static LobbyTeamUi _instance;

		private static bool _failed;

		private TextMeshProUGUI _status;

		private TextMeshProUGUI _botsLabel;

		private string _picked = "automatico";

		private GameObject _panel;

		private TextMeshProUGUI _tabLabel;

		private static bool _dumped;

		internal static void Tick()
		{
			if (_failed)
			{
				return;
			}
			try
			{
				bool flag = InLaneClashLobby();
				if (flag)
				{
					LobbyTab.Tick();
				}
				else
				{
					LobbyTab.Reset();
				}
				bool flag2 = flag && !LobbyTab.Integrated && LobbyTab.GaveUp;
				if (flag2 && !Object.op_Implicit((Object)(object)_instance))
				{
					Create();
				}
				else if (!flag2 && Object.op_Implicit((Object)(object)_instance))
				{
					Object.Destroy((Object)(object)((Component)_instance).gameObject);
					_instance = null;
				}
			}
			catch (Exception ex)
			{
				_failed = true;
				LaneClashPlugin.Log.LogWarning((object)("[lobby] panel de equipos desactivado: " + ex.Message));
				if (Object.op_Implicit((Object)(object)_instance))
				{
					Object.Destroy((Object)(object)((Component)_instance).gameObject);
				}
				_instance = null;
			}
		}

		private static bool InLaneClashLobby()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			PreGameController instance = PreGameController.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return false;
			}
			return GameModeCatalog.GetGameModeName(instance.gameModeIndex) == "LaneClashRun";
		}

		private static void Create()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			LaneClashHud.EnsureFont();
			GameObject val = new GameObject("LaneClashLobby");
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas val2 = val.AddComponent<Canvas>();
			val2.renderMode = (RenderMode)0;
			val2.sortingOrder = 20;
			CanvasScaler val3 = val.AddComponent<CanvasScaler>();
			val3.uiScaleMode = (ScaleMode)1;
			val3.referenceResolution = new Vector2(1920f, 1080f);
			val3.matchWidthOrHeight = 0.5f;
			val.AddComponent<GraphicRaycaster>();
			_instance = val.AddComponent<LobbyTeamUi>();
			_instance.Build();
		}

		private void Build()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00a7: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_0114: 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_012e: Unknown result type (might be due to invalid IL or missi