Decompiled source of PartyHUD v0.3.1

plugins/StonewardsPartyHUD.dll

Decompiled 20 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;
using UnityEngine.UIElements;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StonewardsPartyHUD")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+10a7bf2e2ce552d3209229e4dfdc4a93cf44f2e5")]
[assembly: AssemblyProduct("StonewardsPartyHUD")]
[assembly: AssemblyTitle("StonewardsPartyHUD")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 StonewardsPartyHUD
{
	[BepInPlugin("community.stonewards.partyhud", "Stonewards Party HUD", "0.3.1")]
	public sealed class PartyHudPlugin : BaseUnityPlugin
	{
		private enum PanelAnchor
		{
			TopLeft,
			BottomLeft
		}

		private sealed class PlayerEntry
		{
			public string Name;

			public string ClassName;

			public string Badge;

			public Sprite ClassIcon;

			public Color Accent;

			public float Health;

			public float MaxHealth;

			public bool HasStats;

			public bool IsDead;

			public bool ShowHostPing;

			public bool IsLocalHost;

			public bool HasPing;

			public int PingMs;

			public CompanionEntry Companion;
		}

		private sealed class OutlineEntry
		{
			public GameObject VisualRoot;

			public QuickOutline Component;

			public Renderer[] Renderers;

			public float NextMaterialCheck;
		}

		private sealed class CompanionEntry
		{
			public float Health;

			public float MaxHealth;

			public bool IsKnockedOut;
		}

		private sealed class PlayerBuildEntry
		{
			public FirstPersonController Player;

			public string Name;

			public bool HasRunData;

			public readonly List<BuildRingEntry> Rings = new List<BuildRingEntry>();
		}

		private sealed class BuildRingEntry
		{
			public string ID;

			public string Name;

			public Rarity Rarity;

			public Sprite Icon;

			public int Picks;
		}

		public const string PluginGuid = "community.stonewards.partyhud";

		public const string PluginName = "Stonewards Party HUD";

		public const string PluginVersion = "0.3.1";

		private const float RefreshSeconds = 0.2f;

		private const float PanelWidth = 278f;

		private const float HeaderHeight = 49f;

		private const float RowHeight = 67f;

		private const float CompanionRowHeight = 38f;

		private const float WallRowHeight = 66f;

		private const float FooterPadding = 8f;

		private const float BuildWindowWidth = 348f;

		private const float BuildWindowHeight = 434f;

		private const float BuildRingRowHeight = 42f;

		private const int BuildRingsPerPage = 6;

		private const float BottomHudSafeZone = 132f;

		private const float NativeRosterHeaderSafeZone = 130f;

		private const float NativeRosterPlayerRowSafeZone = 42f;

		private const float ReferenceScreenWidth = 1920f;

		private const float ReferenceScreenHeight = 1080f;

		private const float PanelSizeBoost = 0.95f;

		private static readonly Color PanelFrame = new Color(0.72f, 0.64f, 0.48f);

		private static readonly Color PanelBackground = new Color(0.07450981f, 0.09019608f, 0.1254902f, 0.97f);

		private static readonly Color PanelHeader = new Color(0.29803923f, 0.18039216f, 16f / 85f);

		private static readonly Color PanelDivider = new Color(0.71f, 0.63f, 0.48f, 0.38f);

		private static readonly Color SlotBackground = new Color(0.25f, 0.32f, 0.38f);

		private static readonly Color BarTrack = new Color(0.16f, 0.18f, 0.2f, 1f);

		private readonly List<PlayerEntry> _players = new List<PlayerEntry>(4);

		private readonly Dictionary<FirstPersonController, OutlineEntry> _teamOutlines = new Dictionary<FirstPersonController, OutlineEntry>();

		private readonly List<FirstPersonController> _expiredOutlines = new List<FirstPersonController>();

		private readonly List<PlayerBuildEntry> _buildPlayers = new List<PlayerBuildEntry>();

		private bool _showBuilds;

		private float _nextBuildRefresh;

		private int _buildPlayerIndex;

		private int _buildPage;

		private static readonly FieldInfo InventoryRootField = typeof(InventoryScreen).GetField("inventoryScreen", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly FieldInfo LoadingScreenInstanceField = typeof(LoadingScreen).GetField("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo LoadingScreenElementField = typeof(LoadingScreen).GetField("_loadingScreenElement", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly FieldInfo CharacterVisualsParentField = typeof(FirstPersonController).GetField("characterVisualsParent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo OutlineMaskMaterialField = typeof(QuickOutline).GetField("outlineMaskMaterial", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly FieldInfo OutlineFillMaterialField = typeof(QuickOutline).GetField("outlineFillMaterial", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly PropertyInfo HostConnectionRttProperty = typeof(NetworkConnectionToClient).GetProperty("rtt", BindingFlags.Instance | BindingFlags.Public);

		private static readonly FieldInfo HostConnectionRttField = typeof(NetworkConnectionToClient).GetField("rtt", BindingFlags.Instance | BindingFlags.Public);

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<float> _scale;

		private ConfigEntry<float> _readabilityScale;

		private ConfigEntry<bool> _autoScaleToResolution;

		private ConfigEntry<bool> _showCompanionHealth;

		private ConfigEntry<bool> _showWallHealth;

		private ConfigEntry<bool> _showHostPing;

		private ConfigEntry<bool> _enableBuildInspector;

		private ConfigEntry<bool> _showTeammateOutlines;

		private ConfigEntry<bool> _showPlayerNames;

		private ConfigEntry<float> _playerNameVerticalOffset;

		private ConfigEntry<bool> _outlinesThroughWalls;

		private ConfigEntry<float> _outlineWidth;

		private ConfigEntry<int> _leftOffset;

		private ConfigEntry<int> _topOffset;

		private ConfigEntry<bool> _avoidNativeRoster;

		private ConfigEntry<int> _bottomOffset;

		private ConfigEntry<PanelAnchor> _anchor;

		private float _nextRefresh;

		private float _nextWallRefresh;

		private bool _hasWall;

		private float _wallHealth;

		private float _wallMaxHealth;

		private int _wallSections;

		private bool _wallBreached;

		private float _nextWarning;

		private float _nextPingDiagnostic;

		private float _nextOutlineShaderRetry;

		private GUIStyle _headingStyle;

		private GUIStyle _countStyle;

		private GUIStyle _nameStyle;

		private GUIStyle _classStyle;

		private GUIStyle _badgeStyle;

		private GUIStyle _healthStyle;

		private GUIStyle _statusStyle;

		private GUIStyle _companionStyle;

		private GUIStyle _alertStyle;

		private GUIStyle _worldNameStyle;

		private GUIStyle _wallStatusStyle;

		private GUIStyle _pingStyle;

		private GUIStyle _buildNameStyle;

		private GUIStyle _buildDetailStyle;

		private GUIStyle _buildHelpStyle;

		private Font _nativeUiFont;

		private float _nextNativeFontLookup;

		private void Awake()
		{
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show the party status HUD when network players are present.");
			_scale = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Scale", 1f, "HUD size multiplier (clamped to 0.65 - 1.8).");
			_readabilityScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "ReadabilityScale", 1.12f, "Extra panel enlargement (1.0 - 1.4), also applied to existing configurations.");
			_autoScaleToResolution = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "AutoScaleToResolution", true, "Match the HUD's on-screen proportions across resolutions (reference 1920x1080). Shrink to fit native UI when necessary. Disable for fixed pixel sizing.");
			_showCompanionHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "ShowCompanionHealth", true, "Show a Hunter's companion health directly below the Hunter's entry.");
			_showWallHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowWallHealth", true, "Show combined defensive wall durability beneath the party roster.");
			_showHostPing = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "ShowHostPing", true, "On the hosting player's screen, show each remote player's real Mirror connection RTT in ms. Other clients never display unverified peer ping.");
			_enableBuildInspector = ((BaseUnityPlugin)this).Config.Bind<bool>("BuildInspector", "Enabled", true, "Host-only teammate ring inspector: F8 to open/close, F9 to switch players, PageDown/PageUp to browse rings. No teammate mod needed.");
			_showTeammateOutlines = ((BaseUnityPlugin)this).Config.Bind<bool>("TeammateOutlines", "Enabled", true, "Outline remote teammates in the world (never the local player).");
			_showPlayerNames = ((BaseUnityPlugin)this).Config.Bind<bool>("TeammateOutlines", "ShowPlayerNames", true, "Show each remote teammate's nickname near their outlined character.");
			_playerNameVerticalOffset = ((BaseUnityPlugin)this).Config.Bind<float>("TeammateOutlines", "PlayerNameVerticalOffset", 14f, "Pixels below the projected top of the teammate model (0 - 80); positive values move name labels down.");
			_outlinesThroughWalls = ((BaseUnityPlugin)this).Config.Bind<bool>("TeammateOutlines", "ThroughWalls", true, "Show teammate silhouettes even when they are behind obstacles.");
			_outlineWidth = ((BaseUnityPlugin)this).Config.Bind<float>("TeammateOutlines", "Width", 3f, "Outline thickness; clamped to 0.5 - 6.0.");
			_anchor = ((BaseUnityPlugin)this).Config.Bind<PanelAnchor>("Appearance", "Anchor", PanelAnchor.TopLeft, "Panel location: TopLeft (recommended) or BottomLeft.");
			_leftOffset = ((BaseUnityPlugin)this).Config.Bind<int>("Appearance", "LeftOffset", 20, "Distance from the left edge, in unscaled pixels.");
			_topOffset = ((BaseUnityPlugin)this).Config.Bind<int>("Appearance", "TopOffset", 105, "Minimum distance from the top when Anchor is TopLeft.");
			_avoidNativeRoster = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "AvoidNativePlayerNames", true, "Keep Party HUD below Stonewards' native player names, including in larger lobbies.");
			_bottomOffset = ((BaseUnityPlugin)this).Config.Bind<int>("Appearance", "BottomOffset", 140, "Distance from the bottom when Anchor is BottomLeft. A safety zone protects native UI.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Party HUD v0.3.1 initialized.");
		}

		private void Update()
		{
			if (!_enabled.Value)
			{
				RemoveAllOutlines();
				CloseBuildInspector();
				return;
			}
			if (!_enableBuildInspector.Value || !NetworkServer.active || !NetworkClient.active)
			{
				CloseBuildInspector();
			}
			else if (!IsBlockingGameMenuOpen())
			{
				if (Input.GetKeyDown((KeyCode)289))
				{
					_showBuilds = !_showBuilds;
					_nextBuildRefresh = 0f;
					if (!_showBuilds)
					{
						_buildPlayers.Clear();
					}
				}
				if (_showBuilds && Input.GetKeyDown((KeyCode)290) && _buildPlayers.Count > 0)
				{
					_buildPlayerIndex = (_buildPlayerIndex + 1) % _buildPlayers.Count;
					_buildPage = 0;
				}
				if (_showBuilds && Input.GetKeyDown((KeyCode)281))
				{
					_buildPage++;
				}
				if (_showBuilds && Input.GetKeyDown((KeyCode)280))
				{
					_buildPage = Math.Max(0, _buildPage - 1);
				}
			}
			if (!(Time.unscaledTime < _nextRefresh))
			{
				_nextRefresh = Time.unscaledTime + 0.2f;
				RefreshRoster();
				RefreshWallHealth();
				UpdateTeammateOutlines();
				if (_showBuilds && Time.unscaledTime >= _nextBuildRefresh)
				{
					_nextBuildRefresh = Time.unscaledTime + 0.8f;
					RefreshBuildInspector();
				}
			}
		}

		private void OnDisable()
		{
			RemoveAllOutlines();
			CloseBuildInspector();
		}

		private void OnDestroy()
		{
			RemoveAllOutlines();
			CloseBuildInspector();
		}

		private void CloseBuildInspector()
		{
			_showBuilds = false;
			_buildPlayers.Clear();
			_buildPlayerIndex = 0;
			_buildPage = 0;
		}

		private void RefreshBuildInspector()
		{
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			FirstPersonController val = ((_buildPlayerIndex >= 0 && _buildPlayerIndex < _buildPlayers.Count) ? _buildPlayers[_buildPlayerIndex].Player : null);
			_buildPlayers.Clear();
			try
			{
				List<FirstPersonController> localPlayers = FirstPersonController.LocalPlayers;
				if (localPlayers == null)
				{
					return;
				}
				RogueLikeUpgradeManager instance = RogueLikeUpgradeManager.Instance;
				foreach (FirstPersonController item in localPlayers)
				{
					if ((Object)(object)item == (Object)null || ((NetworkBehaviour)item).isLocalPlayer)
					{
						continue;
					}
					PlayerBuildEntry playerBuildEntry = new PlayerBuildEntry
					{
						Player = item,
						Name = CleanName(item.NetworkplayerName)
					};
					try
					{
						RunPlayerData runPlayerData = item.RunPlayerData;
						if (runPlayerData != null && runPlayerData.rogueUpgrades != null)
						{
							playerBuildEntry.HasRunData = true;
							foreach (RogueUpgradeData rogueUpgrade in runPlayerData.rogueUpgrades)
							{
								if (rogueUpgrade == null || string.IsNullOrWhiteSpace(rogueUpgrade.upgradeID))
								{
									continue;
								}
								BuildRingEntry buildRingEntry = null;
								foreach (BuildRingEntry ring in playerBuildEntry.Rings)
								{
									if (ring.ID == rogueUpgrade.upgradeID && ring.Rarity == rogueUpgrade.rarity)
									{
										buildRingEntry = ring;
										break;
									}
								}
								if (buildRingEntry != null)
								{
									buildRingEntry.Picks++;
									continue;
								}
								RogueLikeUpgradeSO val2 = null;
								try
								{
									if ((Object)(object)instance != (Object)null)
									{
										val2 = instance.GetUpgradeSOByID(rogueUpgrade.upgradeID);
									}
								}
								catch
								{
								}
								string name = rogueUpgrade.upgradeID;
								Sprite icon = null;
								if ((Object)(object)val2 != (Object)null)
								{
									try
									{
										string localizedTitle = ((BaseUpgradeSO)val2).GetLocalizedTitle();
										if (!string.IsNullOrWhiteSpace(localizedTitle))
										{
											name = localizedTitle;
										}
										icon = ((BaseUpgradeSO)val2).Icon;
									}
									catch
									{
									}
								}
								playerBuildEntry.Rings.Add(new BuildRingEntry
								{
									ID = rogueUpgrade.upgradeID,
									Name = name,
									Rarity = rogueUpgrade.rarity,
									Icon = icon,
									Picks = 1
								});
							}
						}
					}
					catch (Exception ex)
					{
						playerBuildEntry.HasRunData = false;
						playerBuildEntry.Rings.Clear();
						if (Time.unscaledTime >= _nextWarning)
						{
							((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not read ring build for " + playerBuildEntry.Name + ": " + ex));
							_nextWarning = Time.unscaledTime + 10f;
						}
					}
					_buildPlayers.Add(playerBuildEntry);
				}
			}
			catch (Exception ex2)
			{
				_buildPlayers.Clear();
				if (Time.unscaledTime >= _nextWarning)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not inspect host party builds: " + ex2));
					_nextWarning = Time.unscaledTime + 10f;
				}
			}
			_buildPlayerIndex = 0;
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			for (int i = 0; i < _buildPlayers.Count; i++)
			{
				if ((Object)(object)_buildPlayers[i].Player == (Object)(object)val)
				{
					_buildPlayerIndex = i;
					break;
				}
			}
		}

		private unsafe void RefreshRoster()
		{
			//IL_005e: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Invalid comparison between Unknown and I4
			_players.Clear();
			try
			{
				List<FirstPersonController> localPlayers = FirstPersonController.LocalPlayers;
				if (localPlayers == null)
				{
					return;
				}
				bool flag = _showHostPing.Value && NetworkServer.active && NetworkClient.active;
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				for (int i = 0; i < localPlayers.Count; i++)
				{
					FirstPersonController val = localPlayers[i];
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					PlayerClass networkplayerClass = val.NetworkplayerClass;
					PlayerEntry playerEntry = new PlayerEntry
					{
						Name = CleanName(val.NetworkplayerName),
						ClassName = ((object)(*(PlayerClass*)(&networkplayerClass))/*cast due to .constrained prefix*/).ToString(),
						Badge = ClassBadge(networkplayerClass),
						ClassIcon = FindClassIcon(val, networkplayerClass),
						Accent = ClassColor(networkplayerClass),
						ShowHostPing = flag,
						IsLocalHost = (flag && ((NetworkBehaviour)val).isLocalPlayer)
					};
					if (flag && !playerEntry.IsLocalHost)
					{
						num++;
						NetworkConnectionToClient connectionToClient = ((NetworkBehaviour)val).connectionToClient;
						if (connectionToClient != null)
						{
							num2++;
						}
						if (TryReadHostPing(connectionToClient, out var pingMs))
						{
							playerEntry.HasPing = true;
							playerEntry.PingMs = pingMs;
							num3++;
						}
					}
					PlayerStats playerStats = val.PlayerStats;
					if ((Object)(object)playerStats != (Object)null)
					{
						playerEntry.HasStats = true;
						playerEntry.Health = playerStats.GetCurrentHealth();
						playerEntry.MaxHealth = playerStats.NetworksyncMaxHealth;
						playerEntry.IsDead = playerStats.NetworkisDead;
					}
					if (_showCompanionHealth.Value && (int)networkplayerClass == 5)
					{
						Companion val2 = val.NetworksyncCompanion;
						if ((Object)(object)val2 == (Object)null)
						{
							List<Companion> localCompanions = Companion.LocalCompanions;
							if (localCompanions != null)
							{
								for (int j = 0; j < localCompanions.Count; j++)
								{
									Companion val3 = localCompanions[j];
									if ((Object)(object)val3 != (Object)null && (Object)(object)val3.Networkowner == (Object)(object)val)
									{
										val2 = val3;
										break;
									}
								}
							}
						}
						if ((Object)(object)val2 != (Object)null)
						{
							playerEntry.Companion = new CompanionEntry
							{
								Health = val2.NetworkcurrentHealth,
								MaxHealth = val2.NetworkcurrentMaxHealth,
								IsKnockedOut = val2.NetworksyncIsKnockedOut
							};
						}
					}
					_players.Add(playerEntry);
				}
				if (_showHostPing.Value && flag && num > 0 && num3 == 0 && Time.unscaledTime >= _nextPingDiagnostic)
				{
					_nextPingDiagnostic = Time.unscaledTime + 20f;
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Host RTT unavailable: remotePlayers=" + num + ", serverConnections=" + num2 + ", rttMember=" + (HostConnectionRttProperty != null || HostConnectionRttField != null) + ". Only actual RTT samples are displayed."));
				}
			}
			catch (Exception ex)
			{
				_players.Clear();
				if (Time.unscaledTime >= _nextWarning)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not read party state: " + ex));
					_nextWarning = Time.unscaledTime + 10f;
				}
			}
		}

		private static bool TryReadHostPing(NetworkConnectionToClient connection, out int pingMs)
		{
			pingMs = 0;
			if (connection == null || (HostConnectionRttProperty == null && HostConnectionRttField == null))
			{
				return false;
			}
			try
			{
				object obj = ((HostConnectionRttProperty != null) ? HostConnectionRttProperty.GetValue(connection, null) : HostConnectionRttField.GetValue(connection));
				if (obj == null)
				{
					return false;
				}
				double num = Convert.ToDouble(obj);
				if (double.IsNaN(num) || double.IsInfinity(num) || num <= 0.0)
				{
					return false;
				}
				pingMs = (int)Math.Max(1.0, Math.Round(Math.Min(num * 1000.0, 99999.0)));
				return true;
			}
			catch
			{
				return false;
			}
		}

		private void RefreshWallHealth()
		{
			if (Time.unscaledTime < _nextWallRefresh)
			{
				return;
			}
			_nextWallRefresh = Time.unscaledTime + 1f;
			_hasWall = false;
			_wallHealth = 0f;
			_wallMaxHealth = 0f;
			_wallSections = 0;
			_wallBreached = false;
			if (!_showWallHealth.Value)
			{
				return;
			}
			try
			{
				WallStats[] array = Object.FindObjectsByType<WallStats>((FindObjectsSortMode)0);
				foreach (WallStats val in array)
				{
					if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && ((NetworkBehaviour)val).isClient)
					{
						float networkcurrentMaxHealth = val.NetworkcurrentMaxHealth;
						if (!(networkcurrentMaxHealth <= 0f))
						{
							_wallHealth += Mathf.Clamp(val.NetworkcurrentHealth, 0f, networkcurrentMaxHealth);
							_wallMaxHealth += networkcurrentMaxHealth;
							_wallSections++;
							_wallBreached |= val.NetworkisDestroyed;
						}
					}
				}
				_hasWall = _wallSections > 0 && _wallMaxHealth > 0f;
			}
			catch (Exception ex)
			{
				_hasWall = false;
				if (Time.unscaledTime >= _nextWarning)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not read wall health: " + ex));
					_nextWarning = Time.unscaledTime + 10f;
				}
			}
		}

		private static GameObject FindCharacterVisuals(FirstPersonController player)
		{
			if (CharacterVisualsParentField == null)
			{
				return null;
			}
			object value = CharacterVisualsParentField.GetValue(player);
			GameObject val = (GameObject)((value is GameObject) ? value : null);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Component val2 = (Component)((value is Component) ? value : null);
			if (!((Object)(object)val2 != (Object)null))
			{
				return null;
			}
			return val2.gameObject;
		}

		private static bool IsShaderUsable(Material material)
		{
			if ((Object)(object)material == (Object)null || (Object)(object)material.shader == (Object)null)
			{
				return false;
			}
			Shader shader = material.shader;
			if (shader.isSupported)
			{
				return ((Object)shader).name.IndexOf("InternalErrorShader", StringComparison.OrdinalIgnoreCase) < 0;
			}
			return false;
		}

		private static Renderer[] FindOutlineRenderers(GameObject root)
		{
			List<Renderer> list = new List<Renderer>();
			Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!(val is MeshRenderer) && !(val is SkinnedMeshRenderer))
				{
					continue;
				}
				Material[] sharedMaterials = val.sharedMaterials;
				if (sharedMaterials == null || sharedMaterials.Length == 0)
				{
					continue;
				}
				bool flag = true;
				Material[] array = sharedMaterials;
				for (int j = 0; j < array.Length; j++)
				{
					if (!IsShaderUsable(array[j]))
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					list.Add(val);
				}
			}
			return list.ToArray();
		}

		private static bool AreOutlineShadersUsable(QuickOutline outline)
		{
			if ((Object)(object)outline == (Object)null || OutlineMaskMaterialField == null || OutlineFillMaterialField == null)
			{
				return false;
			}
			object? value = OutlineMaskMaterialField.GetValue(outline);
			object? material = ((value is Material) ? value : null);
			object? value2 = OutlineFillMaterialField.GetValue(outline);
			Material material2 = (Material)((value2 is Material) ? value2 : null);
			if (IsShaderUsable((Material)material))
			{
				return IsShaderUsable(material2);
			}
			return false;
		}

		private static bool SameRenderers(Renderer[] previous, Renderer[] current)
		{
			if (previous == null || current == null || previous.Length != current.Length)
			{
				return false;
			}
			for (int i = 0; i < current.Length; i++)
			{
				if ((Object)(object)previous[i] == (Object)null || (Object)(object)previous[i] != (Object)(object)current[i])
				{
					return false;
				}
			}
			return true;
		}

		private static bool HasOutlineMaterial(Renderer renderer, Material mask, Material fill)
		{
			if ((Object)(object)renderer == (Object)null || !renderer.enabled || !((Component)renderer).gameObject.activeInHierarchy)
			{
				return true;
			}
			Material[] sharedMaterials = renderer.sharedMaterials;
			bool flag = false;
			bool flag2 = false;
			Material[] array = sharedMaterials;
			foreach (Material obj in array)
			{
				if ((Object)(object)obj == (Object)(object)mask)
				{
					flag = true;
				}
				if ((Object)(object)obj == (Object)(object)fill)
				{
					flag2 = true;
				}
			}
			return flag && flag2;
		}

		private static bool IsOutlineMaterialMissing(OutlineEntry entry)
		{
			if (OutlineMaskMaterialField == null || OutlineFillMaterialField == null)
			{
				return false;
			}
			object? value = OutlineMaskMaterialField.GetValue(entry.Component);
			Material val = (Material)((value is Material) ? value : null);
			object? value2 = OutlineFillMaterialField.GetValue(entry.Component);
			Material val2 = (Material)((value2 is Material) ? value2 : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				return false;
			}
			Renderer[] renderers = entry.Renderers;
			for (int i = 0; i < renderers.Length; i++)
			{
				if (!HasOutlineMaterial(renderers[i], val, val2))
				{
					return true;
				}
			}
			return false;
		}

		private void UpdateTeammateOutlines()
		{
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			if (!_showTeammateOutlines.Value)
			{
				RemoveAllOutlines();
				return;
			}
			try
			{
				List<FirstPersonController> localPlayers = FirstPersonController.LocalPlayers;
				if (localPlayers == null || localPlayers.Count == 0)
				{
					RemoveAllOutlines();
					return;
				}
				_expiredOutlines.Clear();
				foreach (KeyValuePair<FirstPersonController, OutlineEntry> teamOutline in _teamOutlines)
				{
					FirstPersonController key = teamOutline.Key;
					OutlineEntry value = teamOutline.Value;
					if ((Object)(object)key == (Object)null || !localPlayers.Contains(key) || ((NetworkBehaviour)key).isLocalPlayer || (Object)(object)value.VisualRoot == (Object)null || (Object)(object)value.Component == (Object)null || (Object)(object)FindCharacterVisuals(key) != (Object)(object)value.VisualRoot)
					{
						_expiredOutlines.Add(key);
					}
				}
				foreach (FirstPersonController expiredOutline in _expiredOutlines)
				{
					RemoveOutline(expiredOutline);
				}
				_expiredOutlines.Clear();
				for (int i = 0; i < localPlayers.Count; i++)
				{
					FirstPersonController val = localPlayers[i];
					if ((Object)(object)val == (Object)null || ((NetworkBehaviour)val).isLocalPlayer)
					{
						continue;
					}
					GameObject val2 = FindCharacterVisuals(val);
					if ((Object)(object)val2 == (Object)null || !val2.activeInHierarchy)
					{
						continue;
					}
					Renderer[] array = FindOutlineRenderers(val2);
					if (array.Length == 0)
					{
						continue;
					}
					if (_teamOutlines.TryGetValue(val, out var value2) && !SameRenderers(value2.Renderers, array))
					{
						RemoveOutline(val);
						continue;
					}
					if (!_teamOutlines.TryGetValue(val, out value2))
					{
						if (Time.unscaledTime < _nextOutlineShaderRetry || (Object)(object)val2.GetComponent<QuickOutline>() != (Object)null)
						{
							continue;
						}
						QuickOutline val3 = val2.AddComponent<QuickOutline>();
						if ((Object)(object)val3 == (Object)null)
						{
							continue;
						}
						((Behaviour)val3).enabled = false;
						try
						{
							val3.OutlineMode = (Mode)(!_outlinesThroughWalls.Value);
							val3.OutlineColor = new Color(0.24f, 0.88f, 0.96f, 1f);
							val3.OutlineWidth = Mathf.Clamp(_outlineWidth.Value, 0.5f, 6f);
							val3.Init(array);
							if (!AreOutlineShadersUsable(val3))
							{
								_nextOutlineShaderRetry = Time.unscaledTime + 15f;
								((BaseUnityPlugin)this).Logger.LogWarning((object)"Skipped teammate outline: QuickOutline mask/fill shader is missing or unsupported. Retrying in 15 seconds.");
								Object.Destroy((Object)(object)val3);
								continue;
							}
							((Behaviour)val3).enabled = true;
						}
						catch
						{
							if ((Object)(object)val3 != (Object)null)
							{
								((Behaviour)val3).enabled = false;
								Object.Destroy((Object)(object)val3);
							}
							throw;
						}
						value2 = new OutlineEntry
						{
							VisualRoot = val2,
							Component = val3,
							Renderers = array,
							NextMaterialCheck = Time.unscaledTime + 2f
						};
						_teamOutlines.Add(val, value2);
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Initialized outline for teammate " + val.NetworkplayerName + " (" + array.Length + " renderers)."));
					}
					if ((Object)(object)value2.Component == (Object)null)
					{
						continue;
					}
					if (!AreOutlineShadersUsable(value2.Component))
					{
						_nextOutlineShaderRetry = Time.unscaledTime + 15f;
						RemoveOutline(val);
						continue;
					}
					if (!((Behaviour)value2.Component).enabled)
					{
						((Behaviour)value2.Component).enabled = true;
					}
					if (Time.unscaledTime >= value2.NextMaterialCheck)
					{
						value2.NextMaterialCheck = Time.unscaledTime + 2f;
						if (IsOutlineMaterialMissing(value2))
						{
							RemoveOutline(val);
							continue;
						}
					}
					bool flag = (Object)(object)val.PlayerStats != (Object)null && val.PlayerStats.NetworkisDead;
					value2.Component.OutlineMode = (Mode)(!_outlinesThroughWalls.Value);
					value2.Component.OutlineColor = (flag ? new Color(1f, 0.34f, 0.36f, 1f) : new Color(0.24f, 0.88f, 0.96f, 1f));
					value2.Component.OutlineWidth = Mathf.Clamp(_outlineWidth.Value, 0.5f, 6f);
				}
			}
			catch (Exception ex)
			{
				if (Time.unscaledTime >= _nextWarning)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not update teammate outlines: " + ex));
					_nextWarning = Time.unscaledTime + 10f;
				}
			}
		}

		private void RemoveOutline(FirstPersonController player)
		{
			if (_teamOutlines.TryGetValue(player, out var value))
			{
				if ((Object)(object)value.Component != (Object)null)
				{
					Object.Destroy((Object)(object)value.Component);
				}
				_teamOutlines.Remove(player);
			}
		}

		private void RemoveAllOutlines()
		{
			if (_teamOutlines.Count == 0)
			{
				return;
			}
			foreach (OutlineEntry value in _teamOutlines.Values)
			{
				if ((Object)(object)value.Component != (Object)null)
				{
					Object.Destroy((Object)(object)value.Component);
				}
			}
			_teamOutlines.Clear();
			_expiredOutlines.Clear();
		}

		private void DrawTeammatePlayerNames()
		{
			//IL_0435: 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_003d: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Expected O, but got Unknown
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: 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_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			if (!_showTeammateOutlines.Value || !_showPlayerNames.Value || _teamOutlines.Count == 0)
			{
				return;
			}
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			Color color = GUI.color;
			try
			{
				Vector3 val3 = default(Vector3);
				foreach (KeyValuePair<FirstPersonController, OutlineEntry> teamOutline in _teamOutlines)
				{
					FirstPersonController key = teamOutline.Key;
					OutlineEntry value = teamOutline.Value;
					if ((Object)(object)key == (Object)null || ((NetworkBehaviour)key).isLocalPlayer || (Object)(object)value.Component == (Object)null || (Object)(object)value.VisualRoot == (Object)null || !value.VisualRoot.activeInHierarchy || value.Renderers == null)
					{
						continue;
					}
					bool flag = false;
					Bounds val = default(Bounds);
					Renderer[] renderers = value.Renderers;
					foreach (Renderer val2 in renderers)
					{
						if (!((Object)(object)val2 == (Object)null) && val2.enabled && ((Component)val2).gameObject.activeInHierarchy)
						{
							if (!flag)
							{
								val = val2.bounds;
								flag = true;
							}
							else
							{
								((Bounds)(ref val)).Encapsulate(val2.bounds);
							}
						}
					}
					if (!flag)
					{
						continue;
					}
					((Vector3)(ref val3))..ctor(((Bounds)(ref val)).center.x, ((Bounds)(ref val)).max.y + 0.12f, ((Bounds)(ref val)).center.z);
					Vector3 val4 = main.WorldToScreenPoint(val3);
					if (val4.z <= 0f)
					{
						continue;
					}
					string text = CleanName(key.NetworkplayerName);
					float x = _worldNameStyle.CalcSize(new GUIContent(text)).x;
					if (x > 208f)
					{
						string text2 = text;
						while (text2.Length > 1 && _worldNameStyle.CalcSize(new GUIContent(text2 + "...")).x > 208f)
						{
							text2 = text2.Substring(0, text2.Length - 1);
						}
						text = text2 + "...";
						x = _worldNameStyle.CalcSize(new GUIContent(text)).x;
					}
					float num = Mathf.Clamp(x + 14f, 82f, 220f);
					float num2 = val4.x - num * 0.5f;
					float num3 = (float)Screen.height - val4.y + Mathf.Clamp(_playerNameVerticalOffset.Value, 0f, 80f);
					if (!(num2 < 4f) && !(num3 < 4f) && !(num2 + num > (float)Screen.width - 4f) && !(num3 + 20f > (float)Screen.height - 4f))
					{
						bool flag2 = (Object)(object)key.PlayerStats != (Object)null && key.PlayerStats.NetworkisDead;
						Color color2 = (flag2 ? new Color(1f, 0.35f, 0.4f, 1f) : new Color(0.26f, 0.89f, 0.97f, 1f));
						Fill(new Rect(num2, num3, num, 20f), new Color(0.035f, 0.075f, 0.11f, 0.7f));
						Fill(new Rect(num2, num3 + 20f - 2f, num, 2f), color2);
						_worldNameStyle.normal.textColor = (Color)(flag2 ? new Color(1f, 0.78f, 0.79f, 1f) : Color.white);
						GUI.Label(new Rect(num2 + 3f, num3 + 1f, num - 6f, 16f), text, _worldNameStyle);
					}
				}
			}
			catch (Exception ex)
			{
				if (Time.unscaledTime >= _nextWarning)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not draw teammate player names: " + ex));
					_nextWarning = Time.unscaledTime + 10f;
				}
			}
			finally
			{
				GUI.color = color;
			}
		}

		private static bool IsLoadingScreenVisible()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Invalid comparison between Unknown and I4
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Invalid comparison between Unknown and I4
			if (LoadingScreenInstanceField == null || LoadingScreenElementField == null)
			{
				return false;
			}
			try
			{
				object value = LoadingScreenInstanceField.GetValue(null);
				if (value == null)
				{
					return false;
				}
				object? value2 = LoadingScreenElementField.GetValue(value);
				VisualElement val = (VisualElement)((value2 is VisualElement) ? value2 : null);
				if (val == null || val.panel == null)
				{
					return false;
				}
				for (VisualElement val2 = val; val2 != null; val2 = val2.parent)
				{
					IResolvedStyle resolvedStyle = val2.resolvedStyle;
					if ((int)resolvedStyle.display == 1 || (int)resolvedStyle.visibility == 1 || resolvedStyle.opacity <= 0.01f)
					{
						return false;
					}
				}
				return true;
			}
			catch
			{
				return false;
			}
		}

		private static bool IsBlockingGameMenuOpen()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Invalid comparison between Unknown and I4
			if (IsLoadingScreenVisible())
			{
				return true;
			}
			ShopMenu instance = ShopMenu.Instance;
			if ((Object)(object)instance != (Object)null && ((BaseMenu)instance).IsOpen)
			{
				return true;
			}
			CharacterSelectionScreen instance2 = CharacterSelectionScreen.Instance;
			if ((Object)(object)instance2 != (Object)null && ((BaseMenu)instance2).IsOpen)
			{
				return true;
			}
			GlobalMissionMenu instance3 = GlobalMissionMenu.Instance;
			if ((Object)(object)instance3 != (Object)null && ((BaseMenu)instance3).IsOpen)
			{
				return true;
			}
			InventoryScreen instance4 = InventoryScreen.Instance;
			if ((Object)(object)instance4 != (Object)null && InventoryRootField != null)
			{
				object? value = InventoryRootField.GetValue(instance4);
				VisualElement val = (VisualElement)((value is VisualElement) ? value : null);
				if (val != null && (int)val.resolvedStyle.display != 1)
				{
					return true;
				}
			}
			RogueLikeUpgradeMenu instance5 = RogueLikeUpgradeMenu.Instance;
			if ((Object)(object)instance5 != (Object)null)
			{
				return ((BaseMenu)instance5).IsOpen;
			}
			return false;
		}

		private void OnGUI()
		{
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			if (!_enabled.Value || _players.Count == 0 || !NetworkClient.active || Event.current == null || (int)Event.current.type != 7 || IsBlockingGameMenuOpen())
			{
				return;
			}
			EnsureStyles();
			DrawTeammatePlayerNames();
			float num = 49f + (float)_players.Count * 67f + 8f;
			if (_hasWall)
			{
				num += 66f;
			}
			for (int i = 0; i < _players.Count; i++)
			{
				if (_players[i].Companion != null)
				{
					num += 38f;
				}
			}
			float num2 = Mathf.Clamp(_scale.Value * Mathf.Clamp(_readabilityScale.Value, 1f, 1.4f) * 0.95f, 0.55f, 1.8f);
			float num3 = (_autoScaleToResolution.Value ? Mathf.Min((float)Screen.width / 1920f, (float)Screen.height / 1080f) : 1f);
			float num4 = num2 * num3;
			float num5 = _topOffset.Value;
			if (_avoidNativeRoster.Value)
			{
				num5 = Mathf.Max(num5, 130f + (float)_players.Count * 42f);
			}
			num4 = Mathf.Min(new float[3]
			{
				num4,
				((float)Screen.width - 16f) / 278f,
				((float)Screen.height - 16f) / num
			});
			if (_autoScaleToResolution.Value)
			{
				float num6 = ((_anchor.Value == PanelAnchor.TopLeft) ? Mathf.Max(8f, num5) : Mathf.Max(8f, Mathf.Max((float)_bottomOffset.Value, 132f)));
				num4 = Mathf.Min(num4, ((float)Screen.height - 8f) / (num + num6));
			}
			if (num4 <= 0f)
			{
				return;
			}
			float num7 = (float)Screen.width / num4;
			float num8 = (float)Screen.height / num4;
			float num9 = Mathf.Clamp((float)_leftOffset.Value, 8f, Mathf.Max(8f, num7 - 278f - 8f));
			float num10 = Mathf.Clamp((_anchor.Value == PanelAnchor.TopLeft) ? num5 : (num8 - Mathf.Max((float)_bottomOffset.Value, 132f) - num), 8f, Mathf.Max(8f, num8 - num - 8f));
			Matrix4x4 matrix = GUI.matrix;
			Color color = GUI.color;
			try
			{
				GUI.matrix = Matrix4x4.Scale(new Vector3(num4, num4, 1f));
				DrawPanel(num9, num10, num);
				if (_showBuilds && NetworkServer.active && NetworkClient.active && _enableBuildInspector.Value)
				{
					float x = Mathf.Clamp(num9 + 278f + 12f, 8f, Mathf.Max(8f, num7 - 348f - 8f));
					float y = Mathf.Clamp(num10, 8f, Mathf.Max(8f, num8 - 434f - 8f));
					DrawBuildInspector(x, y);
				}
			}
			finally
			{
				GUI.matrix = matrix;
				GUI.color = color;
			}
		}

		private void DrawPanel(float x, float y, float height)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			DrawStonewardsWindow(x, y, 278f, height);
			GUI.Label(new Rect(x + 20f, y + 2f, 238f, 29f), "PARTY STATUS", _headingStyle);
			int num = 0;
			for (int i = 0; i < _players.Count; i++)
			{
				if (_players[i].IsDead)
				{
					num++;
				}
			}
			if (num > 0)
			{
				GUI.Label(new Rect(x + 14f, y + 28f, 116f, 18f), num + " DOWN", _alertStyle);
			}
			else if (_enableBuildInspector.Value && NetworkServer.active && NetworkClient.active)
			{
				GUI.Label(new Rect(x + 14f, y + 28f, 116f, 18f), _showBuilds ? "F8 CLOSE" : "F8 BUILDS", _buildHelpStyle);
			}
			GUI.Label(new Rect(x + 278f - 80f, y + 2f, 66f, 29f), _players.Count + " / 4", _countStyle);
			float num2 = y + 49f;
			for (int j = 0; j < _players.Count; j++)
			{
				DrawPlayer(x, num2, _players[j], j);
				num2 += 67f;
				if (_players[j].Companion != null)
				{
					DrawCompanion(x, num2, _players[j].Companion);
					num2 += 38f;
				}
			}
			if (_hasWall)
			{
				DrawWallHealth(x, num2);
			}
		}

		private void DrawBuildInspector(float x, float y)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: 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_0304: 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_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: 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_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			DrawStonewardsWindow(x, y, 348f, 434f);
			GUI.Label(new Rect(x + 12f, y + 2f, 324f, 29f), "PLAYER BUILD", _headingStyle);
			if (_buildPlayers.Count == 0)
			{
				GUI.Label(new Rect(x + 18f, y + 70f, 312f, 28f), "NO TEAMMATES TO INSPECT", _buildNameStyle);
				GUI.Label(new Rect(x + 18f, y + 103f, 312f, 30f), "Only the hosting player can inspect party rings.", _buildDetailStyle);
				GUI.Label(new Rect(x + 16f, y + 434f - 28f, 316f, 18f), "F8 CLOSE", _buildHelpStyle);
				return;
			}
			_buildPlayerIndex = Mathf.Clamp(_buildPlayerIndex, 0, _buildPlayers.Count - 1);
			PlayerBuildEntry playerBuildEntry = _buildPlayers[_buildPlayerIndex];
			int num = Mathf.Max(1, (playerBuildEntry.Rings.Count + 6 - 1) / 6);
			_buildPage = Mathf.Clamp(_buildPage, 0, num - 1);
			GUI.Label(new Rect(x + 18f, y + 53f, 243f, 26f), FitText(playerBuildEntry.Name, _buildNameStyle, 243f), _buildNameStyle);
			GUI.Label(new Rect(x + 348f - 85f, y + 55f, 70f, 22f), _buildPlayerIndex + 1 + " / " + _buildPlayers.Count, _countStyle);
			string text = ((!playerBuildEntry.HasRunData) ? "BUILD DATA UNAVAILABLE" : ((playerBuildEntry.Rings.Count == 0) ? "NO RINGS RECORDED" : (playerBuildEntry.Rings.Count + " RING VARIANTS")));
			GUI.Label(new Rect(x + 18f, y + 80f, 312f, 23f), text, _buildDetailStyle);
			Fill(new Rect(x + 12f, y + 108f, 324f, 1f), PanelDivider);
			if (playerBuildEntry.HasRunData)
			{
				int num2 = _buildPage * 6;
				int num3 = Math.Min(num2 + 6, playerBuildEntry.Rings.Count);
				for (int i = num2; i < num3; i++)
				{
					BuildRingEntry buildRingEntry = playerBuildEntry.Rings[i];
					float num4 = y + 112f + (float)(i - num2) * 42f;
					if ((i - num2) % 2 == 1)
					{
						Fill(new Rect(x + 11f, num4, 326f, 42f), new Color(0.3f, 0.33f, 0.39f, 0.14f));
					}
					Color ringRarityColor = GetRingRarityColor(buildRingEntry.Rarity);
					Fill(new Rect(x + 15f, num4 + 7f, 3f, 30f), ringRarityColor);
					Fill(new Rect(x + 23f, num4 + 5f, 33f, 33f), SlotBackground);
					if (!DrawClassIcon(buildRingEntry.Icon, new Rect(x + 26f, num4 + 8f, 27f, 27f)))
					{
						Fill(new Rect(x + 31f, num4 + 13f, 17f, 17f), ringRarityColor);
					}
					GUI.Label(new Rect(x + 64f, num4 + 2f, 213f, 23f), FitText(buildRingEntry.Name, _buildNameStyle, 213f), _buildNameStyle);
					_buildDetailStyle.normal.textColor = ringRarityColor;
					GUI.Label(new Rect(x + 64f, num4 + 23f, 208f, 17f), ((object)Unsafe.As<Rarity, Rarity>(ref buildRingEntry.Rarity)/*cast due to .constrained prefix*/).ToString(), _buildDetailStyle);
					GUI.Label(new Rect(x + 348f - 63f, num4 + 8f, 48f, 25f), "x" + buildRingEntry.Picks, _healthStyle);
				}
			}
			Fill(new Rect(x + 12f, y + 434f - 32f, 324f, 1f), PanelDivider);
			_buildHelpStyle.normal.textColor = new Color(0.92f, 0.83f, 0.7f);
			GUI.Label(new Rect(x + 15f, y + 434f - 28f, 319f, 18f), "F8 CLOSE   F9 NEXT   PGUP/DN " + (_buildPage + 1) + "/" + num, _buildHelpStyle);
		}

		private static Color GetRingRarityColor(Rarity rarity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected I4, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0068: 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)
			return (Color)((rarity - 1) switch
			{
				0 => new Color(0.44f, 0.84f, 0.54f), 
				1 => new Color(0.46f, 0.73f, 0.99f), 
				2 => new Color(0.76f, 0.53f, 0.96f), 
				3 => new Color(1f, 0.77f, 0.37f), 
				_ => new Color(0.85f, 0.84f, 0.82f), 
			});
		}

		private static void DrawStonewardsWindow(float x, float y, float width, float height)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: 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_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			Fill(new Rect(x + 7f, y, width - 14f, height), PanelBackground);
			Fill(new Rect(x, y + 7f, width, height - 14f), PanelBackground);
			Fill(new Rect(x + 7f, y + 2f, width - 14f, 47f), PanelHeader);
			Fill(new Rect(x + 2f, y + 7f, width - 4f, 42f), PanelHeader);
			Fill(new Rect(x + 8f, y, width - 16f, 2f), PanelFrame);
			Fill(new Rect(x + 5f, y + 2f, 3f, 2f), PanelFrame);
			Fill(new Rect(x + 2f, y + 5f, 3f, 2f), PanelFrame);
			Fill(new Rect(x, y + 7f, 2f, height - 14f), PanelFrame);
			Fill(new Rect(x + width - 2f, y + 7f, 2f, height - 14f), PanelFrame);
			Fill(new Rect(x + width - 5f, y + 5f, 3f, 2f), PanelFrame);
			Fill(new Rect(x + width - 8f, y + 2f, 3f, 2f), PanelFrame);
			Fill(new Rect(x + 8f, y + height - 2f, width - 16f, 2f), PanelFrame);
			Fill(new Rect(x + 5f, y + height - 4f, 3f, 2f), PanelFrame);
			Fill(new Rect(x + 2f, y + height - 7f, 3f, 2f), PanelFrame);
			Fill(new Rect(x + width - 5f, y + height - 7f, 3f, 2f), PanelFrame);
			Fill(new Rect(x + width - 8f, y + height - 4f, 3f, 2f), PanelFrame);
			Fill(new Rect(x + 2f, y + 49f - 1f, width - 4f, 1f), PanelFrame);
		}

		private void DrawPlayer(float x, float rowY, PlayerEntry player, int index)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_01f3: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: 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_0565: 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_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			if (player.IsDead)
			{
				Fill(new Rect(x + 3f, rowY, 272f, 67f), new Color(0.48f, 0.12f, 0.14f, 0.36f));
			}
			else if (index % 2 == 1)
			{
				Fill(new Rect(x + 3f, rowY, 272f, 67f), new Color(0.3f, 0.33f, 0.39f, 0.14f));
			}
			Fill(new Rect(x + 6f, rowY + 8f, 3f, 51f), (Color)(player.IsDead ? new Color(0.94f, 0.31f, 0.32f) : player.Accent));
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(x + 14f, rowY + 11f, 38f, 39f);
			Fill(rect, new Color(0.9f, 0.86f, 0.79f));
			Fill(new Rect(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, ((Rect)(ref rect)).width - 4f, ((Rect)(ref rect)).height - 4f), SlotBackground);
			if (!DrawClassIcon(player.ClassIcon, new Rect(((Rect)(ref rect)).x + 3f, ((Rect)(ref rect)).y + 3f, ((Rect)(ref rect)).width - 6f, ((Rect)(ref rect)).height - 6f)))
			{
				Fill(rect, (Color)(player.IsDead ? new Color(0.49f, 0.17f, 0.21f) : player.Accent));
				GUI.Label(new Rect(x + 14f, rowY + 16f, 38f, 28f), player.Badge, _badgeStyle);
			}
			GUI.Label(new Rect(x + 62f, rowY + 6f, 119f, 25f), FitText(player.Name, _nameStyle, 119f), _nameStyle);
			string text = ((player.HasStats && player.MaxHealth > 0f) ? (Mathf.CeilToInt(Mathf.Max(0f, player.Health)) + " / " + Mathf.CeilToInt(player.MaxHealth)) : "-- / --");
			GUI.Label(new Rect(x + 187f, rowY + 8f, 79f, 22f), text, _healthStyle);
			GUI.Label(new Rect(x + 62f, rowY + 30f, 91f, 17f), FitText(player.ClassName, _classStyle, 91f), _classStyle);
			_statusStyle.normal.textColor = (player.IsDead ? new Color(1f, 0.52f, 0.5f) : new Color(0.89f, 0.83f, 0.72f));
			if (player.ShowHostPing)
			{
				string text2 = (player.IsLocalHost ? "HOST" : ((!player.HasPing) ? "--" : ((player.PingMs > 999) ? "999+ms" : (player.PingMs + "ms"))));
				_pingStyle.normal.textColor = (player.IsLocalHost ? new Color(0.95f, 0.81f, 0.56f) : ((!player.HasPing) ? new Color(0.61f, 0.63f, 0.66f) : ((player.PingMs < 100) ? new Color(0.47f, 0.87f, 0.56f) : ((player.PingMs < 200) ? new Color(0.98f, 0.76f, 0.37f) : new Color(0.98f, 0.42f, 0.42f)))));
				GUI.Label(new Rect(x + 156f, rowY + 30f, 58f, 17f), text2, _pingStyle);
				GUI.Label(new Rect(x + 216f, rowY + 30f, 50f, 17f), player.IsDead ? "DOWN" : "ALIVE", _statusStyle);
			}
			else
			{
				GUI.Label(new Rect(x + 155f, rowY + 30f, 111f, 17f), player.IsDead ? "DOWN - REVIVE" : "ALIVE", _statusStyle);
			}
			Fill(new Rect(x + 62f, rowY + 53f, 196f, 8f), BarTrack);
			if (player.HasStats && player.MaxHealth > 0f && !player.IsDead)
			{
				float num = Mathf.Clamp01(player.Health / player.MaxHealth);
				Color color = ((num > 0.65f) ? new Color(0.37f, 0.79f, 0.42f) : ((num > 0.3f) ? new Color(0.97f, 0.72f, 0.3f) : new Color(0.95f, 0.32f, 0.36f)));
				if (num > 0f)
				{
					Fill(new Rect(x + 62f, rowY + 53f, 196f * num, 8f), color);
				}
			}
			Fill(new Rect(x + 12f, rowY + 67f - 1f, 254f, 1f), PanelDivider);
		}

		private void DrawCompanion(float x, float rowY, CompanionEntry companion)
		{
			//IL_0019: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			bool isKnockedOut = companion.IsKnockedOut;
			Fill(new Rect(x + 52f, rowY, 218f, 38f), isKnockedOut ? new Color(0.53f, 0.12f, 0.16f, 0.3f) : new Color(0.3f, 0.36f, 0.42f, 0.19f));
			Fill(new Rect(x + 59f, rowY + 4f, 2f, 29f), isKnockedOut ? new Color(1f, 0.37f, 0.43f) : new Color(0.44f, 0.76f, 0.52f));
			_companionStyle.normal.textColor = (isKnockedOut ? new Color(1f, 0.48f, 0.51f) : new Color(0.87f, 0.79f, 0.64f));
			GUI.Label(new Rect(x + 69f, rowY + 2f, 108f, 21f), isKnockedOut ? "BEAR - DOWN" : "BEAR", _companionStyle);
			string text = ((companion.MaxHealth > 0f) ? (Mathf.CeilToInt(Mathf.Max(0f, companion.Health)) + " / " + Mathf.CeilToInt(companion.MaxHealth)) : "-- / --");
			GUI.Label(new Rect(x + 185f, rowY + 2f, 81f, 22f), text, _healthStyle);
			Fill(new Rect(x + 69f, rowY + 28f, 187f, 6f), BarTrack);
			if (!isKnockedOut && companion.MaxHealth > 0f)
			{
				float num = Mathf.Clamp01(companion.Health / companion.MaxHealth);
				Color color = ((num > 0.3f) ? new Color(0.43f, 0.76f, 0.44f) : new Color(0.96f, 0.64f, 0.3f));
				if (num > 0f)
				{
					Fill(new Rect(x + 69f, rowY + 28f, 187f * num, 6f), color);
				}
			}
		}

		private void DrawWallHealth(float x, float rowY)
		{
			//IL_0012: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			Fill(new Rect(x + 4f, rowY, 270f, 66f), new Color(0.3f, 0.34f, 0.39f, 0.19f));
			Fill(new Rect(x + 12f, rowY, 254f, 1f), PanelDivider);
			Fill(new Rect(x + 12f, rowY + 11f, 4f, 47f), _wallBreached ? new Color(1f, 0.34f, 0.38f) : new Color(0.97f, 0.73f, 0.35f));
			string text = ((_wallSections > 1) ? ("WALL (" + _wallSections + ")") : "WALL");
			GUI.Label(new Rect(x + 23f, rowY + 5f, 128f, 26f), text, _nameStyle);
			string text2 = Mathf.CeilToInt(Mathf.Max(0f, _wallHealth)) + " / " + Mathf.CeilToInt(_wallMaxHealth);
			GUI.Label(new Rect(x + 161f, rowY + 6f, 105f, 26f), text2, _healthStyle);
			_wallStatusStyle.normal.textColor = (_wallBreached ? new Color(1f, 0.49f, 0.47f) : new Color(0.95f, 0.81f, 0.56f));
			GUI.Label(new Rect(x + 23f, rowY + 30f, 232f, 17f), _wallBreached ? "BREACHED - REPAIR" : "DEFENSE", _wallStatusStyle);
			Fill(new Rect(x + 23f, rowY + 51f, 231f, 9f), BarTrack);
			float num = Mathf.Clamp01(_wallHealth / _wallMaxHealth);
			if (num > 0f)
			{
				Color color = ((num > 0.65f) ? new Color(0.95f, 0.73f, 0.33f) : ((num > 0.3f) ? new Color(0.95f, 0.53f, 0.26f) : new Color(0.97f, 0.3f, 0.31f)));
				Fill(new Rect(x + 23f, rowY + 51f, 231f * num, 9f), color);
			}
		}

		private static void Fill(Rect rect, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color2;
		}

		private void EnsureStyles()
		{
			//IL_001d: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			if (_headingStyle == null)
			{
				_headingStyle = MakeStyle(19, new Color(0.98f, 0.79f, 0.51f), (TextAnchor)4, bold: true);
				_countStyle = MakeStyle(12, new Color(0.92f, 0.85f, 0.75f), (TextAnchor)5, bold: true);
				_nameStyle = MakeStyle(16, Color.white, (TextAnchor)3, bold: true);
				_classStyle = MakeStyle(12, new Color(0.82f, 0.83f, 0.86f), (TextAnchor)3, bold: true);
				_badgeStyle = MakeStyle(14, Color.white, (TextAnchor)4, bold: true);
				_healthStyle = MakeStyle(13, Color.white, (TextAnchor)5, bold: true);
				_statusStyle = MakeStyle(12, Color.white, (TextAnchor)5, bold: true);
				_companionStyle = MakeStyle(13, Color.white, (TextAnchor)3, bold: true);
				_alertStyle = MakeStyle(12, new Color(1f, 0.49f, 0.45f), (TextAnchor)3, bold: true);
				_worldNameStyle = MakeStyle(12, Color.white, (TextAnchor)4, bold: true);
				_wallStatusStyle = MakeStyle(12, new Color(0.98f, 0.79f, 0.51f), (TextAnchor)3, bold: true);
				_pingStyle = MakeStyle(12, Color.white, (TextAnchor)3, bold: true);
				_buildNameStyle = MakeStyle(16, Color.white, (TextAnchor)3, bold: true);
				_buildDetailStyle = MakeStyle(12, new Color(0.88f, 0.84f, 0.77f), (TextAnchor)3, bold: true);
				_buildHelpStyle = MakeStyle(11, new Color(0.93f, 0.84f, 0.69f), (TextAnchor)3, bold: true);
			}
			TryApplyNativeFont();
		}

		private void TryApplyNativeFont()
		{
			if ((Object)(object)_nativeUiFont != (Object)null || Time.unscaledTime < _nextNativeFontLookup)
			{
				return;
			}
			_nextNativeFontLookup = Time.unscaledTime + 8f;
			Font val = null;
			Font val2 = null;
			Font[] array = Resources.FindObjectsOfTypeAll<Font>();
			foreach (Font val3 in array)
			{
				if (!((Object)(object)val3 == (Object)null))
				{
					if (((Object)val3).name == "Jersey10-Regular")
					{
						val = val3;
					}
					else if (((Object)val3).name == "Jersey10-Regular2")
					{
						val2 = val3;
					}
				}
			}
			_nativeUiFont = (((Object)(object)val != (Object)null) ? val : val2);
			if (!((Object)(object)_nativeUiFont == (Object)null))
			{
				GUIStyle[] array2 = (GUIStyle[])(object)new GUIStyle[14]
				{
					_headingStyle, _countStyle, _nameStyle, _classStyle, _badgeStyle, _healthStyle, _statusStyle, _companionStyle, _alertStyle, _wallStatusStyle,
					_pingStyle, _buildNameStyle, _buildDetailStyle, _buildHelpStyle
				};
				foreach (GUIStyle obj in array2)
				{
					obj.font = _nativeUiFont;
					obj.fontStyle = (FontStyle)0;
				}
				_headingStyle.fontSize = 24;
				_countStyle.fontSize = 16;
				_nameStyle.fontSize = 20;
				_classStyle.fontSize = 15;
				_badgeStyle.fontSize = 17;
				_healthStyle.fontSize = 16;
				_statusStyle.fontSize = 15;
				_companionStyle.fontSize = 16;
				_alertStyle.fontSize = 15;
				_wallStatusStyle.fontSize = 16;
				_pingStyle.fontSize = 13;
				_buildNameStyle.fontSize = 19;
				_buildDetailStyle.fontSize = 15;
				_buildHelpStyle.fontSize = 12;
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Party HUD is using Stonewards UI font: " + ((Object)_nativeUiFont).name));
			}
		}

		private static GUIStyle MakeStyle(int size, Color color, TextAnchor align, bool bold = false)
		{
			//IL_000a: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = size,
				fontStyle = (FontStyle)(bold ? 1 : 0),
				alignment = align,
				clipping = (TextClipping)1,
				richText = false
			};
			val.normal.textColor = color;
			return val;
		}

		private static string CleanName(string name)
		{
			if (!string.IsNullOrWhiteSpace(name))
			{
				return name;
			}
			return "Connecting...";
		}

		private static string FitText(string text, GUIStyle style, float width)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(text) || style.CalcSize(new GUIContent(text)).x <= width)
			{
				return text;
			}
			int num = text.Length;
			while (num > 0 && style.CalcSize(new GUIContent(text.Substring(0, num) + "...")).x > width)
			{
				num--;
			}
			if (num <= 0)
			{
				return "...";
			}
			return text.Substring(0, num) + "...";
		}

		private static Sprite FindClassIcon(FirstPersonController player, PlayerClass cls)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerArchetypeManager instance = PlayerArchetypeManager.Instance;
				if ((Object)(object)instance != (Object)null)
				{
					PlayerArchetypeSO playerArchetype = instance.GetPlayerArchetype(cls);
					if ((Object)(object)playerArchetype != (Object)null && (Object)(object)playerArchetype.Icon != (Object)null)
					{
						return playerArchetype.Icon;
					}
				}
			}
			catch
			{
			}
			try
			{
				PlayerArchetypeSO playerArchetypeSO = player.PlayerArchetypeSO;
				if ((Object)(object)playerArchetypeSO != (Object)null && playerArchetypeSO.PlayerClass == cls)
				{
					return playerArchetypeSO.Icon;
				}
			}
			catch
			{
			}
			return null;
		}

		private static bool DrawClassIcon(Sprite sprite, Rect area)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)sprite == (Object)null)
			{
				return false;
			}
			try
			{
				Texture2D texture = sprite.texture;
				if ((Object)(object)texture == (Object)null || ((Texture)texture).width == 0 || ((Texture)texture).height == 0)
				{
					return false;
				}
				Rect textureRect = sprite.textureRect;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height);
				Rect rect = sprite.rect;
				if (((Rect)(ref rect)).width <= 0f || ((Rect)(ref rect)).height <= 0f)
				{
					return false;
				}
				float num = ((Rect)(ref rect)).width / ((Rect)(ref rect)).height;
				if (num > 1f)
				{
					float num2 = ((Rect)(ref area)).width / num;
					((Rect)(ref area)).y = ((Rect)(ref area)).y + (((Rect)(ref area)).height - num2) * 0.5f;
					((Rect)(ref area)).height = num2;
				}
				else
				{
					float num3 = ((Rect)(ref area)).height * num;
					((Rect)(ref area)).x = ((Rect)(ref area)).x + (((Rect)(ref area)).width - num3) * 0.5f;
					((Rect)(ref area)).width = num3;
				}
				GUI.DrawTextureWithTexCoords(area, (Texture)(object)texture, val, true);
				return true;
			}
			catch (Exception)
			{
				return false;
			}
		}

		private static string ClassBadge(PlayerClass cls)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected I4, but got Unknown
			return (int)cls switch
			{
				0 => "WA", 
				1 => "AR", 
				2 => "MI", 
				3 => "RO", 
				4 => "BO", 
				5 => "HU", 
				6 => "MA", 
				7 => "HE", 
				_ => "??", 
			};
		}

		private static Color ClassColor(PlayerClass cls)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected I4, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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)
			//IL_00b8: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			return (Color)((int)cls switch
			{
				0 => new Color(0.7f, 0.4f, 0.23f), 
				1 => new Color(0.28f, 0.53f, 0.32f), 
				2 => new Color(0.64f, 0.49f, 0.2f), 
				3 => new Color(0.48f, 0.35f, 0.62f), 
				4 => new Color(0.65f, 0.3f, 0.27f), 
				5 => new Color(0.27f, 0.53f, 0.53f), 
				6 => new Color(0.24f, 0.43f, 0.68f), 
				7 => new Color(0.32f, 0.6f, 0.64f), 
				_ => new Color(0.4f, 0.48f, 0.55f), 
			});
		}
	}
}