Decompiled source of BrigadeDps v1.0.0

BrigadeDps.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BrigadeDps")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ab9de33cec7e0398983eaf22163617eb406916f4")]
[assembly: AssemblyProduct("BrigadeDps")]
[assembly: AssemblyTitle("BrigadeDps")]
[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 BrigadeDps
{
	[BepInPlugin("slikfoul.BrigadeDps", "Brigade DPS", "1.0.0")]
	[BepInIncompatibility("girthy_mods.DamageMeter")]
	public sealed class EntryPoint : BasePlugin
	{
		public const string Id = "slikfoul.BrigadeDps";

		internal static EntryPoint Instance;

		internal static Options Settings;

		private MeterView view;

		public override void Load()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Settings = new Options(((BasePlugin)this).Config);
			new Harmony("slikfoul.BrigadeDps").PatchAll(typeof(GameBridge));
			view = ((BasePlugin)this).AddComponent<MeterView>();
			((BasePlugin)this).Log.LogInfo((object)"Brigade DPS 1.0.0 loaded: F3 meter, F4 spells, F5 settings; configurable growth directions and draggable settings, per-spell DPS, RU/EN.");
		}
	}
	internal sealed class Options
	{
		internal readonly ConfigEntry<bool> Enabled;

		internal readonly ConfigEntry<bool> Visible;

		internal readonly ConfigEntry<bool> Spells;

		internal readonly ConfigEntry<bool> Icons;

		internal readonly ConfigEntry<bool> Boss;

		internal readonly ConfigEntry<bool> Results;

		internal readonly ConfigEntry<bool> Solo;

		internal readonly ConfigEntry<bool> Locked;

		internal readonly ConfigEntry<bool> SpellNames;

		internal readonly ConfigEntry<bool> AbbreviateSpells;

		internal readonly ConfigEntry<float> Scale;

		internal readonly ConfigEntry<float> Opacity;

		internal readonly ConfigEntry<float> X;

		internal readonly ConfigEntry<float> Y;

		internal readonly ConfigEntry<float> Height;

		internal readonly ConfigEntry<bool> PlacementStored;

		internal readonly ConfigEntry<bool> AnchorRight;

		internal readonly ConfigEntry<bool> AnchorBottom;

		internal readonly ConfigEntry<float> EdgeMarginX;

		internal readonly ConfigEntry<float> EdgeMarginY;

		internal readonly ConfigEntry<float> SettingsX;

		internal readonly ConfigEntry<float> SettingsY;

		internal readonly ConfigEntry<int> Window;

		internal readonly ConfigEntry<int> SpellLimit;

		internal readonly ConfigEntry<int> BossHoldSeconds;

		internal readonly ConfigEntry<DpsDisplayMode> DpsMode;

		internal readonly ConfigEntry<string> ToggleKey;

		internal readonly ConfigEntry<string> DetailKey;

		internal readonly ConfigEntry<string> SettingsKey;

		internal readonly ConfigFile File;

		internal Options(ConfigFile file)
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Expected O, but got Unknown
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Expected O, but got Unknown
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Expected O, but got Unknown
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Expected O, but got Unknown
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Expected O, but got Unknown
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Expected O, but got Unknown
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Expected O, but got Unknown
			File = file;
			Enabled = file.Bind<bool>("General", "Enabled", true, "Enable display and host damage collection.");
			Visible = file.Bind<bool>("Display", "Visible", true, "Show the panel; F3 toggles it.");
			Spells = file.Bind<bool>("Display", "Spells", true, "Show damage by spell.");
			Icons = file.Bind<bool>("Display", "Icons", true, "Show the game's spell icons.");
			Boss = file.Bind<bool>("Display", "Boss", true, "Show the current or last boss encounter.");
			BossHoldSeconds = file.Bind<int>("Display", "BossHoldSeconds", 10, new ConfigDescription("Real-time seconds to keep defeated boss statistics visible. 0 hides them immediately. Local display preference.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 3600), Array.Empty<object>()));
			Results = file.Bind<bool>("Display", "Results", true, "Show only while the run results panel is open.");
			Solo = file.Bind<bool>("Display", "Solo", true, "Show during solo runs.");
			Locked = file.Bind<bool>("Window", "Locked", false, "Prevent moving the panel.");
			SpellNames = file.Bind<bool>("Display", "SpellNames", true, "Show spell names; when off, spell icons are always shown.");
			AbbreviateSpells = file.Bind<bool>("Display", "AbbreviateSpells", false, "Use the first letter of each word of the localized spell name.");
			Scale = file.Bind<float>("Window", "Scale", 1f, new ConfigDescription("Panel scale.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 1.8f), Array.Empty<object>()));
			Opacity = file.Bind<float>("Window", "Opacity", 0.88f, new ConfigDescription("Panel background opacity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			X = file.Bind<float>("Window", "X", 0.02f, new ConfigDescription("Horizontal position within available screen space (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Y = file.Bind<float>("Window", "Y", 0.18f, new ConfigDescription("Vertical position from top within available screen space (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PlacementStored = file.Bind<bool>("Window", "PlacementStored", false, "Whether the saved edge placement has been initialized.");
			AnchorRight = file.Bind<bool>("Window", "AnchorRight", false, "Keep the right edge fixed and grow leftward.");
			AnchorBottom = file.Bind<bool>("Window", "AnchorBottom", false, "Keep the bottom edge fixed and grow upward.");
			SettingsX = file.Bind<float>("SettingsWindow", "X", 0.5f, new ConfigDescription("Horizontal position within available screen space.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			SettingsY = file.Bind<float>("SettingsWindow", "Y", 0.5f, new ConfigDescription("Vertical position within available screen space.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			EdgeMarginX = file.Bind<float>("Window", "EdgeMarginX", 0.02f, new ConfigDescription("Distance from the chosen horizontal edge as fraction of screen width.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			EdgeMarginY = file.Bind<float>("Window", "EdgeMarginY", 0.18f, new ConfigDescription("Distance from the chosen vertical edge as fraction of screen height.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Height = file.Bind<float>("Window", "MaxHeight", 0.72f, new ConfigDescription("Maximum height as fraction of the screen; scroll overflowing rows.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 0.95f), Array.Empty<object>()));
			Window = file.Bind<int>("General", "DpsSeconds", 10, new ConfigDescription("Rolling DPS window, controlled by host.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 60), Array.Empty<object>()));
			DpsMode = file.Bind<DpsDisplayMode>("Display", "DpsMode", DpsDisplayMode.Rolling, "Rolling: recent host-defined interval. Game: each spell's native DPS since it was equipped; player row sums equipped spells. Boss DPS remains rolling. Local display preference.");
			SpellLimit = file.Bind<int>("Display", "SpellLimit", 8, new ConfigDescription("Maximum spell rows per player.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
			ToggleKey = file.Bind<string>("Keys", "Meter", "F3", "Unity Input System key name.");
			DetailKey = file.Bind<string>("Keys", "Spells", "F4", "Unity Input System key name.");
			SettingsKey = file.Bind<string>("Keys", "Settings", "F5", "Unity Input System key name.");
		}

		internal void SavePlacement(float x, float y, float width, float height, float screenWidth, float screenHeight, float padding)
		{
			WindowAnchorAxis windowAnchorAxis = WindowAnchorAxis.Capture(x, width, screenWidth, padding, AnchorRight.Value);
			WindowAnchorAxis windowAnchorAxis2 = WindowAnchorAxis.Capture(y, height, screenHeight, padding, AnchorBottom.Value);
			bool saveOnConfigSet = File.SaveOnConfigSet;
			File.SaveOnConfigSet = false;
			try
			{
				EdgeMarginX.Value = windowAnchorAxis.MarginFraction;
				EdgeMarginY.Value = windowAnchorAxis2.MarginFraction;
				X.Value = ((screenWidth > width) ? Math.Clamp(x / (screenWidth - width), 0f, 1f) : 0f);
				Y.Value = ((screenHeight > height) ? Math.Clamp(y / (screenHeight - height), 0f, 1f) : 0f);
				PlacementStored.Value = true;
			}
			finally
			{
				File.SaveOnConfigSet = saveOnConfigSet;
			}
			File.Save();
		}

		internal void ResetPosition()
		{
			X.Value = 0.02f;
			Y.Value = 0.18f;
			Scale.Value = 1f;
			Locked.Value = false;
			PlacementStored.Value = false;
		}
	}
	public static class FrameArtwork
	{
		public const int Size = 192;

		public const int Slice = 48;

		public static uint[] CreatePixels()
		{
			uint[] array = new uint[36864];
			for (int i = 0; i < 192; i++)
			{
				for (int j = 0; j < 192; j++)
				{
					double num = 0.0;
					double num2 = 0.0;
					double num3 = 0.0;
					double num4 = 0.0;
					for (int k = 0; k < 2; k++)
					{
						for (int l = 0; l < 2; l++)
						{
							double num5 = Math.Min((double)j + ((double)l + 0.5) / 2.0, (double)(192 - j) - ((double)l + 0.5) / 2.0);
							double num6 = Math.Min((double)i + ((double)k + 0.5) / 2.0, (double)(192 - i) - ((double)k + 0.5) / 2.0);
							double num7 = Math.Min(Math.Min(num5 - 2.0, num6 - 2.0), (num5 + num6 - 13.0) * 0.7071);
							if ((num5 > 35.0 && num5 < 42.0 && num6 < 6.0) || (num6 > 35.0 && num6 < 42.0 && num5 < 6.0))
							{
								num7 -= 3.0;
							}
							if (!(num7 < 0.0) && !(Math.Min(num5, num6) > 34.0))
							{
								double num8 = ((num7 < 3.0) ? 0.16 : ((num7 < 8.0) ? 0.27 : 0.19));
								if (num5 + num6 < 26.0 && num7 > 3.0 && num7 < 7.0)
								{
									num8 = 0.34;
								}
								if ((num5 > 38.0 && num5 < 43.0 && num6 > 26.0) || (num6 > 38.0 && num6 < 43.0 && num5 > 26.0))
								{
									num8 *= 0.7;
								}
								double val = Math.Abs(Math.Sqrt((num5 - 22.0) * (num5 - 22.0) + (num6 - 22.0) * (num6 - 22.0)) - 7.0);
								if (num5 >= 30.0)
								{
									val = Math.Min(val, Math.Min(Math.Abs(num6 - 14.0), Math.Abs(num6 - 23.0)));
								}
								if (num6 >= 30.0)
								{
									val = Math.Min(val, Math.Min(Math.Abs(num5 - 14.0), Math.Abs(num5 - 23.0)));
								}
								val = Math.Min(val, Segment(num5, num6, 22.0, 15.0, 34.0, 14.0));
								val = Math.Min(val, Segment(num5, num6, 15.0, 22.0, 14.0, 34.0));
								val = Math.Min(val, Segment(num5, num6, 29.0, 22.0, 34.0, 23.0));
								val = Math.Min(val, Segment(num5, num6, 22.0, 29.0, 23.0, 34.0));
								val = Math.Min(val, Segment(num5, num6, 9.0, 22.0, 10.0, 10.0));
								val = Math.Min(val, Segment(num5, num6, 10.0, 10.0, 22.0, 9.0));
								val = Math.Min(val, Segment(num5, num6, 10.0, 17.0, 17.0, 10.0));
								val = Math.Min(val, Segment(num5, num6, 30.0, 34.0, 34.0, 30.0));
								val = Math.Min(val, Segment(num5, num6, 34.0, 30.0, 34.0, 34.0));
								val = Math.Min(val, Segment(num5, num6, 34.0, 34.0, 30.0, 34.0));
								double num9 = 0.3 * Math.Exp((0.0 - val) * val / 7.0);
								double num10 = Math.Clamp(1.25 - val, 0.0, 1.0);
								num += Math.Min(1.0, (num8 + num9) * (1.0 - num10) + 0.98 * num10);
								num2 += Math.Min(1.0, (num8 * 0.97 + num9) * (1.0 - num10) + 0.98 * num10);
								num3 += Math.Min(1.0, (num8 * 1.13 + num9) * (1.0 - num10) + 1.0 * num10);
								num4 += 1.0;
							}
						}
					}
					if (num4 != 0.0)
					{
						array[i * 192 + j] = ((uint)Math.Round(num4 / 4.0 * 255.0) << 24) | ((uint)Math.Round(num / num4 * 255.0) << 16) | ((uint)Math.Round(num2 / num4 * 255.0) << 8) | (uint)Math.Round(num3 / num4 * 255.0);
					}
				}
			}
			return array;
		}

		private static double Segment(double x, double y, double ax, double ay, double bx, double by)
		{
			double num = bx - ax;
			double num2 = by - ay;
			double num3 = Math.Clamp(((x - ax) * num + (y - ay) * num2) / (num * num + num2 * num2), 0.0, 1.0);
			num = x - ax - num3 * num;
			num2 = y - ay - num3 * num2;
			return Math.Sqrt(num * num + num2 * num2);
		}
	}
	[HarmonyPatch]
	internal static class GameBridge
	{
		private const string Channel = "slikfoul.BrigadeDps/state/2";

		internal const int ExplosionSource = -10;

		internal const int TornadoSource = -20;

		internal const int MiscSource = -30;

		private static readonly BattleLedger ledger = new BattleLedger();

		private static readonly HashSet<ulong> observedBosses = new HashSet<ulong>();

		private static readonly HashSet<ulong> livingBosses = new HashSet<ulong>();

		private static PlayerStats[] nativePlayerStats = Array.Empty<PlayerStats>();

		private static RunManager run;

		private static RunOverviewPanel results;

		private static CustomMessagingManager messaging;

		private static HandleNamedMessageDelegate receiver;

		private static float nextRoster;

		private static float nextSend;

		private static float nextPanelLookup;

		private static float nextError;

		private static double lastTime;

		private static double lastBossDeath;

		private static bool ended;

		internal static MeterSnapshot Current = new MeterSnapshot();

		internal static bool Received { get; private set; }

		internal static bool IsHost
		{
			get
			{
				if ((Object)(object)NetworkManager.Singleton != (Object)null)
				{
					return NetworkManager.Singleton.IsServer;
				}
				return false;
			}
		}

		internal static bool Running
		{
			get
			{
				if (!ended && (Object)(object)run != (Object)null && !((Il2CppObjectBase)run).WasCollected && ((NetworkBehaviour)run).IsSpawned)
				{
					return run.runHasStarted;
				}
				return false;
			}
		}

		internal static bool ResultsOpen
		{
			get
			{
				if ((Object)(object)results != (Object)null && !((Il2CppObjectBase)results).WasCollected && ((Panel)results).IsOpen)
				{
					return ((Component)results).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		internal static bool Solo
		{
			get
			{
				NetworkManager singleton = NetworkManager.Singleton;
				if (!((Object)(object)singleton == (Object)null))
				{
					if (singleton.IsServer)
					{
						return Current.Players.Count <= 1;
					}
					return false;
				}
				return true;
			}
		}

		private static double Clock
		{
			get
			{
				if (!((Object)(object)run != (Object)null) || ((Il2CppObjectBase)run).WasCollected)
				{
					return lastTime;
				}
				return Math.Max(lastTime, run.currentRunTimeInSeconds);
			}
		}

		internal static void Tick()
		{
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				NetworkManager singleton = NetworkManager.Singleton;
				CustomMessagingManager val = (((Object)(object)singleton != (Object)null && singleton.IsListening) ? singleton.CustomMessagingManager : null);
				if (val != null && (messaging == null || ((Il2CppObjectBase)messaging).Pointer != ((Il2CppObjectBase)val).Pointer))
				{
					messaging = val;
					if (receiver == null)
					{
						receiver = DelegateSupport.ConvertDelegate<HandleNamedMessageDelegate>((Delegate)new Action<ulong, FastBufferReader>(Receive));
					}
					val.RegisterNamedMessageHandler("slikfoul.BrigadeDps/state/2", receiver);
				}
				if (val == null)
				{
					messaging = null;
				}
				if (Time.unscaledTime >= nextPanelLookup)
				{
					nextPanelLookup = Time.unscaledTime + 1f;
					if ((Object)(object)results == (Object)null || ((Il2CppObjectBase)results).WasCollected)
					{
						results = Object.FindObjectOfType<RunOverviewPanel>(true);
					}
					if ((Object)(object)run == (Object)null || ((Il2CppObjectBase)run).WasCollected)
					{
						run = Object.FindObjectOfType<RunManager>();
					}
				}
				if (!IsHost)
				{
					return;
				}
				if (ledger.BossActive && livingBosses.Count == 0)
				{
					lastTime = Clock;
					ledger.FinishBoss(lastBossDeath);
					Current = CreateSnapshot();
					Publish();
				}
				if (!Running)
				{
					return;
				}
				lastTime = Clock;
				if (Time.unscaledTime >= nextRoster)
				{
					nextRoster = Time.unscaledTime + 2f;
					foreach (GameplayPlayerIdentity item in Object.FindObjectsOfType<GameplayPlayerIdentity>())
					{
						if (((NetworkBehaviour)item).IsSpawned)
						{
							ledger.Identify(((NetworkBehaviour)item).OwnerClientId, item.GetDisplayName(), ColorUtility.ToHtmlStringRGB(item.PlayerColor));
						}
					}
					nativePlayerStats = Il2CppArrayBase<PlayerStats>.op_Implicit(ZLinqDropInExtensions.ToArray<PlayerStats>(Object.FindObjectsOfType<PlayerStats>()));
				}
				Current = CreateSnapshot();
				if (Time.unscaledTime >= nextSend)
				{
					Publish();
				}
			}
			catch (Exception ex)
			{
				Error("Update", ex);
			}
		}

		private static MeterSnapshot CreateSnapshot()
		{
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected I4, but got Unknown
			MeterSnapshot meterSnapshot = ledger.Snapshot(lastTime, EntryPoint.Settings.Window.Value);
			foreach (PlayerScore player in meterSnapshot.Players)
			{
				PlayerScore playerScore = Current.Players.FirstOrDefault((PlayerScore p) => p.Id == player.Id);
				if (playerScore != null)
				{
					player.GameDps = playerScore.GameDps;
					foreach (SpellScore spell in player.Spells)
					{
						spell.GameDps = playerScore.Spells.FirstOrDefault((SpellScore s) => s.Spell == spell.Spell)?.GameDps;
					}
				}
				if (ended)
				{
					continue;
				}
				PlayerStats val = ((IEnumerable<PlayerStats>)nativePlayerStats).FirstOrDefault((Func<PlayerStats, bool>)((PlayerStats p) => (Object)(object)p != (Object)null && !((Il2CppObjectBase)p).WasCollected && ((NetworkBehaviour)p).IsSpawned && ((NetworkBehaviour)p).OwnerClientId == player.Id));
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				try
				{
					Dictionary<int, double?> dictionary = new Dictionary<int, double?>();
					Enumerator<SpellType, SpellAttributes> enumerator3 = val.GetEquippedSpellStats().GetEnumerator();
					while (enumerator3.MoveNext())
					{
						KeyValuePair<SpellType, SpellAttributes> current = enumerator3.Current;
						SpellAttributes value = current.Value;
						if (value != null)
						{
							dictionary[(int)current.Key] = DpsDisplay.NativeValue(value.Dps, value.TotalPerformedDamage, value.TotalTime);
						}
					}
					player.GameDps = DpsDisplay.Sum(dictionary.Values);
					foreach (SpellScore spell2 in player.Spells)
					{
						spell2.GameDps = (dictionary.TryGetValue(spell2.Spell, out var value2) ? value2 : ((double?)null));
					}
				}
				catch (Exception ex)
				{
					Error("Native spell DPS", ex);
				}
			}
			return meterSnapshot;
		}

		private static void Publish()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			nextSend = Time.unscaledTime + 0.5f;
			if (!IsHost || messaging == null)
			{
				return;
			}
			string text = JsonSerializer.Serialize(Current);
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(text.Length * 2 + 64, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe(text, false);
				messaging.SendNamedMessageToAll("slikfoul.BrigadeDps/state/2", val, (NetworkDelivery)4);
			}
			finally
			{
				((FastBufferWriter)(ref val)).Dispose();
			}
		}

		private static void Receive(ulong sender, FastBufferReader reader)
		{
			try
			{
				if (IsHost || sender != NetworkManager.ServerClientId || ((FastBufferReader)(ref reader)).Length > 262144)
				{
					return;
				}
				string json = default(string);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref json, false);
				MeterSnapshot meterSnapshot = JsonSerializer.Deserialize<MeterSnapshot>(json);
				if (meterSnapshot == null || meterSnapshot.Protocol != 2 || meterSnapshot.Players == null || meterSnapshot.Players.Count > 16)
				{
					return;
				}
				bool flag = !double.IsFinite(meterSnapshot.Seconds) || meterSnapshot.Seconds < 0.0;
				if (!flag)
				{
					int window = meterSnapshot.Window;
					bool flag2 = ((window < 1 || window > 60) ? true : false);
					flag = flag2;
				}
				if (flag)
				{
					return;
				}
				double? bossEndedAt = meterSnapshot.BossEndedAt;
				if (bossEndedAt.HasValue)
				{
					double valueOrDefault = bossEndedAt.GetValueOrDefault();
					if (!double.IsFinite(valueOrDefault) || valueOrDefault < 0.0 || valueOrDefault > meterSnapshot.Seconds)
					{
						return;
					}
				}
				foreach (PlayerScore player in meterSnapshot.Players)
				{
					if (player == null || player.Spells == null || player.Spells.Count > 256 || !double.IsFinite(player.Damage) || !double.IsFinite(player.Dps) || !double.IsFinite(player.BossDamage) || !double.IsFinite(player.BossDps) || player.Damage < 0.0 || player.BossDamage < 0.0 || player.Spells.Any((SpellScore s) => s == null || !double.IsFinite(s.Dps) || !double.IsFinite(s.Damage) || s.Dps < 0.0 || s.Damage < 0.0) || (player.GameDps.HasValue && (!double.IsFinite(player.GameDps.Value) || player.GameDps.Value < 0.0)) || player.Spells.Any((SpellScore s) => s.GameDps.HasValue && (!double.IsFinite(s.GameDps.Value) || s.GameDps.Value < 0.0)))
					{
						return;
					}
				}
				Current = meterSnapshot;
				Received = true;
			}
			catch (Exception ex)
			{
				Error("Network snapshot", ex);
			}
		}

		private static void NewRun(RunManager instance)
		{
			run = instance;
			ended = false;
			lastTime = 0.0;
			lastBossDeath = 0.0;
			ledger.Clear();
			observedBosses.Clear();
			livingBosses.Clear();
			nativePlayerStats = Array.Empty<PlayerStats>();
			Current = new MeterSnapshot();
			Received = false;
			nextSend = (nextRoster = 0f);
		}

		[HarmonyPatch(typeof(RunManager), "OnNetworkSpawn")]
		[HarmonyPostfix]
		private static void Spawned(RunManager __instance)
		{
			NewRun(__instance);
		}

		[HarmonyPatch(typeof(RunManager), "StartRunOnClientRpc")]
		[HarmonyPrefix]
		private static void Starting(RunManager __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1)
			{
				NewRun(__instance);
			}
		}

		[HarmonyPatch(typeof(RunManager), "OnDestroy")]
		[HarmonyPrefix]
		private static void LeavingRun(RunManager __instance)
		{
			try
			{
				if (!((Object)(object)run == (Object)null) && !(((Il2CppObjectBase)run).Pointer != ((Il2CppObjectBase)__instance).Pointer) && IsHost)
				{
					lastTime = Clock;
					if (ledger.BossActive)
					{
						ledger.FinishBoss((livingBosses.Count == 0) ? lastBossDeath : lastTime);
					}
					Current = CreateSnapshot();
					Publish();
				}
			}
			catch (Exception ex)
			{
				Error("Final snapshot", ex);
			}
			finally
			{
				ended = true;
				run = null;
			}
		}

		[HarmonyPatch(typeof(RunOverviewPanel), "Open")]
		[HarmonyPostfix]
		private static void ResultsShown(RunOverviewPanel __instance)
		{
			results = __instance;
			try
			{
				if (IsHost && !ended)
				{
					lastTime = Clock;
					if (ledger.BossActive)
					{
						ledger.FinishBoss((livingBosses.Count == 0) ? lastBossDeath : lastTime);
					}
					Current = CreateSnapshot();
					Publish();
				}
			}
			catch (Exception ex)
			{
				Error("Results snapshot", ex);
			}
			finally
			{
				ended = true;
			}
		}

		private static void ObserveBoss(EnemyHealthContainer enemy)
		{
			if (!IsHost || !enemy.IsBoss || !((NetworkBehaviour)enemy).IsSpawned)
			{
				return;
			}
			ulong networkObjectId = ((NetworkBehaviour)enemy).NetworkObjectId;
			if (observedBosses.Add(networkObjectId))
			{
				if (livingBosses.Count == 0)
				{
					ledger.StartBoss(Clock);
				}
				livingBosses.Add(networkObjectId);
			}
		}

		[HarmonyPatch(typeof(HealthContainer), "OnNetworkSpawn")]
		[HarmonyPostfix]
		private static void HealthSpawned(HealthContainer __instance)
		{
			try
			{
				EnemyHealthContainer val = ((Il2CppObjectBase)__instance).TryCast<EnemyHealthContainer>();
				if ((Object)(object)val != (Object)null)
				{
					ObserveBoss(val);
				}
			}
			catch (Exception ex)
			{
				Error("Boss spawn", ex);
			}
		}

		[HarmonyPatch(typeof(EnemyHealthContainer), "Initialize")]
		[HarmonyPostfix]
		private static void EnemyInitialized(EnemyHealthContainer __instance)
		{
			try
			{
				ObserveBoss(__instance);
			}
			catch (Exception ex)
			{
				Error("Boss initialization", ex);
			}
		}

		[HarmonyPatch(typeof(EnemyHealthContainer), "HealthDepleted")]
		[HarmonyPostfix]
		private static void BossDied(EnemyHealthContainer __instance)
		{
			RetireBoss((HealthContainer)(object)__instance);
		}

		[HarmonyPatch(typeof(HealthContainer), "OnNetworkDespawn")]
		[HarmonyPrefix]
		private static void HealthDespawned(HealthContainer __instance)
		{
			RetireBoss(__instance);
		}

		private static void RetireBoss(HealthContainer target)
		{
			try
			{
				if (IsHost && livingBosses.Remove(((NetworkBehaviour)target).NetworkObjectId) && livingBosses.Count == 0)
				{
					lastBossDeath = Clock;
				}
			}
			catch (Exception ex)
			{
				Error("Boss end", ex);
			}
		}

		[HarmonyPatch(typeof(EnemyHealthContainer), "RecordDamageDealtToEnemy")]
		[HarmonyPostfix]
		private static void DamageRecorded(EnemyHealthContainer __instance, float amount, DamageInfo damageSource)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected I4, but got Unknown
			try
			{
				if (!IsHost || !EntryPoint.Settings.Enabled.Value || !float.IsFinite(amount) || amount <= 0f || damageSource == null)
				{
					return;
				}
				PlayerSpellDamageInfo val = ((Il2CppObjectBase)damageSource).TryCast<PlayerSpellDamageInfo>();
				ulong id;
				int spell;
				if (val != null)
				{
					id = ((PlayerDamageInfo)val).OwnerClientId;
					spell = (int)val.Spell;
				}
				else
				{
					PlayerDamageInfo val2 = ((Il2CppObjectBase)damageSource).TryCast<PlayerDamageInfo>();
					PlayerExplosionDamageInfo val3 = ((Il2CppObjectBase)damageSource).TryCast<PlayerExplosionDamageInfo>();
					InfusedTornadoDamageInfo val4 = ((Il2CppObjectBase)damageSource).TryCast<InfusedTornadoDamageInfo>();
					if (val2 != null)
					{
						id = val2.OwnerClientId;
						spell = -30;
					}
					else if (val3 != null)
					{
						id = val3.OwnerClientId;
						spell = -10;
					}
					else
					{
						if (val4 == null)
						{
							return;
						}
						id = val4.InfusedByPlayerId;
						spell = -20;
					}
				}
				bool isBoss = __instance.IsBoss;
				if (isBoss)
				{
					ObserveBoss(__instance);
				}
				ledger.Record(id, spell, amount, Clock, isBoss);
			}
			catch (Exception ex)
			{
				Error("Damage event", ex);
			}
		}

		internal static void Error(string operation, Exception ex)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if (!(Time.unscaledTime < nextError))
			{
				nextError = Time.unscaledTime + 10f;
				ManualLogSource log = ((BasePlugin)EntryPoint.Instance).Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(2, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(operation);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}
	}
	public sealed class MeterView : MonoBehaviour
	{
		private sealed class TableLine
		{
			internal readonly RectTransform Root;

			internal readonly Image Background;

			internal readonly Image Icon;

			internal readonly TextMeshProUGUI Name;

			internal readonly TextMeshProUGUI Dps;

			internal readonly TextMeshProUGUI Damage;

			internal readonly TextMeshProUGUI Share;

			internal bool IsNote;

			internal float Indent;

			internal float SpellInset;

			internal TableLine(MeterView owner, Transform parent)
			{
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: Unknown result type (might be due to invalid IL or missing references)
				//IL_014f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ab: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				Root = Rect("Row", parent, 0f, 0f, 0f, 25f);
				Root.anchorMax = new Vector2(1f, 1f);
				Background = ((Component)Root).gameObject.AddComponent<Image>();
				((Graphic)Background).raycastTarget = false;
				Icon = ((Component)Rect("SpellIcon", (Transform)(object)Root, 4f, 3f, 19f, 19f)).gameObject.AddComponent<Image>();
				Icon.preserveAspect = true;
				((Graphic)Icon).raycastTarget = false;
				Name = owner.Text((Transform)(object)Root, "", 0f, 0f, 1f, 25f, 14f, Paper);
				((TMP_Text)Name).richText = false;
				Dps = owner.Text((Transform)(object)Root, "", 0f, 0f, 1f, 25f, 14f, Paper);
				Damage = owner.Text((Transform)(object)Root, "", 0f, 0f, 1f, 25f, 14f, Paper);
				Share = owner.Text((Transform)(object)Root, "", 0f, 0f, 1f, 25f, 14f, Paper);
				TextMeshProUGUI dps = Dps;
				TextMeshProUGUI damage = Damage;
				TextMeshProUGUI share = Share;
				TextAlignmentOptions val = (TextAlignmentOptions)4100;
				((TMP_Text)share).alignment = (TextAlignmentOptions)4100;
				((TMP_Text)dps).alignment = (((TMP_Text)damage).alignment = val);
			}

			internal void Set(string name, string dps, string damage, string share, Color tint, Sprite sprite, bool bold, float indent)
			{
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: 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_00e6: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: 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)
				((TMP_Text)Name).text = name;
				((TMP_Text)Dps).text = dps;
				((TMP_Text)Damage).text = damage;
				((TMP_Text)Share).text = share;
				Indent = indent;
				SpellInset = 0f;
				IsNote = false;
				((TMP_Text)Name).alignment = (TextAlignmentOptions)4097;
				TextMeshProUGUI dps2 = Dps;
				TextMeshProUGUI damage2 = Damage;
				TextMeshProUGUI share2 = Share;
				TextAlignmentOptions val = (TextAlignmentOptions)4100;
				((TMP_Text)share2).alignment = (TextAlignmentOptions)4100;
				TextAlignmentOptions alignment = (((TMP_Text)damage2).alignment = val);
				((TMP_Text)dps2).alignment = alignment;
				((Graphic)Name).color = tint;
				((TMP_Text)Name).fontStyle = (FontStyles)(bold ? 1 : 0);
				((TMP_Text)Name).fontSize = (bold ? 15 : 13);
				TextMeshProUGUI dps3 = Dps;
				TextMeshProUGUI damage3 = Damage;
				Color val3 = (((Graphic)Share).color = (bold ? Paper : Muted));
				Color color = (((Graphic)damage3).color = val3);
				((Graphic)dps3).color = color;
				Icon.sprite = sprite;
				((Component)Icon).gameObject.SetActive((Object)(object)sprite != (Object)null);
				((Graphic)Background).color = (Color)(bold ? new Color(0.6f, 0.65f, 0.65f, 0.06f) : Color.clear);
			}

			internal float Measure(TextMeshProUGUI label)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				if (!string.IsNullOrEmpty(((TMP_Text)label).text))
				{
					return Mathf.Ceil(((TMP_Text)label).GetPreferredValues(((TMP_Text)label).text).x) + 2f;
				}
				return 0f;
			}

			internal void Layout(float width, float nameWidth, float dpsWidth, float damageWidth, float shareWidth)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				((Graphic)Icon).rectTransform.anchoredPosition = new Vector2(4f + SpellInset, -3f);
				Position(Name, 4f + Indent + SpellInset, IsNote ? (width - 8f) : Mathf.Max(0f, nameWidth - Indent - SpellInset));
				float num = 4f + nameWidth + 6f;
				Position(Dps, num, dpsWidth);
				num += dpsWidth + 6f;
				Position(Damage, num, damageWidth);
				num += damageWidth + 6f;
				Position(Share, num, shareWidth);
			}

			private static void Position(TextMeshProUGUI label, float x, float width)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				((TMP_Text)label).rectTransform.anchoredPosition = new Vector2(x, 0f);
				((TMP_Text)label).rectTransform.sizeDelta = new Vector2(width, 25f);
			}
		}

		private const float PanelWidth = 320f;

		private const float RowHeight = 25f;

		private const float ColumnGap = 6f;

		private const float RowInset = 4f;

		private const float FramePadding = 18f;

		private static readonly Color Ink = new Color(0.115f, 0.105f, 0.13f);

		private static readonly Color Paper = new Color(0.95f, 0.94f, 0.97f);

		private static readonly Color Gold = new Color(0.82f, 0.79f, 0.89f);

		private static readonly Color Muted = new Color(0.62f, 0.68f, 0.68f);

		private RectTransform root;

		private RectTransform window;

		private RectTransform body;

		private RectTransform viewport;

		private RectTransform settings;

		private RectTransform settingsBody;

		private Canvas canvas;

		private ScrollRect meterScroll;

		private Image background;

		private TextMeshProUGUI settingsCaption;

		private TMP_FontAsset font;

		private Sprite stoneBorder;

		private Sprite stoneFill;

		private Texture2D generatedFrameTexture;

		private Sprite generatedFrame;

		private Texture2D windowFrameTexture;

		private Sprite windowFrame;

		private Sprite cardStone;

		private Sprite cardLines;

		private NativeCardFrame meterCardFrame;

		private NativeCardFrame settingsCardFrame;

		private NativeCardDivider bossDivider;

		private readonly BossDisplayLifetime bossLifetime = new BossDisplayLifetime();

		private TMP_InputField bossRetentionInput;

		private readonly List<UnityAction<string>> textActions = new List<UnityAction<string>>();

		private int dividerAfterRow = -1;

		private float nextCardSearch;

		private readonly List<UnityAction> actions = new List<UnityAction>();

		private readonly List<TableLine> lines = new List<TableLine>();

		private readonly List<Action> settingsRefresh = new List<Action>();

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

		private readonly List<(TextMeshProUGUI Label, string Key)> localizedLabels = new List<(TextMeshProUGUI, string)>();

		private readonly Dictionary<int, Sprite> sprites = new Dictionary<int, Sprite>();

		private readonly Dictionary<int, string> spellNames = new Dictionary<int, string>();

		private string locale;

		private int used;

		private bool settingsOpen;

		private bool dragging;

		private bool settingsDragging;

		private bool cursorOwned;

		private CursorLockMode savedLock;

		private bool savedVisible;

		private Vector2 dragOrigin;

		private Vector2 dragWindow;

		private Vector2 settingsDragOrigin;

		private Vector2 settingsDragWindow;

		private float nextDraw;

		private float currentHeight = 120f;

		private float currentWidth = 320f;

		private ConfigEntry<string> capturingKey;

		private Options cfg
		{
			[HideFromIl2Cpp]
			get
			{
				return EntryPoint.Settings;
			}
		}

		public MeterView(IntPtr pointer)
			: base(pointer)
		{
		}

		public void Update()
		{
			try
			{
				if (capturingKey != null)
				{
					CaptureKey();
				}
				else if ((Object)(object)bossRetentionInput == (Object)null || !bossRetentionInput.isFocused)
				{
					if (KeyPressed(cfg.ToggleKey.Value))
					{
						cfg.Visible.Value = !cfg.Visible.Value;
					}
					if (KeyPressed(cfg.DetailKey.Value))
					{
						cfg.Spells.Value = !cfg.Spells.Value;
					}
					if (KeyPressed(cfg.SettingsKey.Value))
					{
						settingsOpen = !settingsOpen;
					}
					if (settingsOpen && KeyPressed("Escape"))
					{
						settingsOpen = false;
					}
				}
				if (Time.unscaledTime >= nextDraw)
				{
					nextDraw = Time.unscaledTime + 0.2f;
					UpdateLanguage();
					GameBridge.Tick();
					bossLifetime.Observe(GameBridge.Current, Time.unscaledTimeAsDouble);
					bool flag = VisibilityPolicy.Show(cfg.Enabled.Value, GameBridge.Running, GameBridge.ResultsOpen, cfg.Results.Value);
					if (!cfg.Solo.Value && GameBridge.Solo && !GameBridge.ResultsOpen)
					{
						flag = false;
					}
					bool flag2 = flag && cfg.Visible.Value;
					if ((flag2 || settingsOpen) && (Object)(object)root == (Object)null)
					{
						Build();
					}
					if ((Object)(object)root == (Object)null)
					{
						return;
					}
					((Component)window).gameObject.SetActive(flag2);
					((Component)settings).gameObject.SetActive(settingsOpen);
					if (flag2)
					{
						DrawScores();
					}
					if (settingsOpen)
					{
						foreach (Action item in settingsRefresh)
						{
							item();
						}
					}
					if (!flag2)
					{
						EndDrag();
					}
					Place();
					UpdateCardFrames();
				}
				if (!((Object)(object)root == (Object)null))
				{
					if (((Component)window).gameObject.activeSelf)
					{
						Drag();
					}
					DragSettings();
					if (!settingsOpen)
					{
						capturingKey = null;
					}
				}
			}
			catch (Exception ex)
			{
				GameBridge.Error("Interface", ex);
			}
		}

		public void LateUpdate()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			PlaceBossDivider();
			bool flag = Keyboard.current != null && (((ButtonControl)Keyboard.current.leftAltKey).isPressed || ((ButtonControl)Keyboard.current.rightAltKey).isPressed);
			if (settingsOpen || dragging || (flag && (Object)(object)window != (Object)null && ((Component)window).gameObject.activeSelf))
			{
				if (!cursorOwned)
				{
					savedLock = Cursor.lockState;
					savedVisible = Cursor.visible;
					cursorOwned = true;
				}
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
			else
			{
				ReleaseCursor();
			}
		}

		private void ReleaseCursor()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (cursorOwned)
			{
				Cursor.lockState = savedLock;
				Cursor.visible = savedVisible;
				cursorOwned = false;
			}
		}

		public void OnDestroy()
		{
			EndDrag();
			EndSettingsDrag();
			ReleaseCursor();
			bossDivider?.DestroyArtwork();
			if ((Object)(object)root != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)root).gameObject);
			}
			if ((Object)(object)generatedFrame != (Object)null)
			{
				Object.Destroy((Object)(object)generatedFrame);
			}
			if ((Object)(object)generatedFrameTexture != (Object)null)
			{
				Object.Destroy((Object)(object)generatedFrameTexture);
			}
			if ((Object)(object)windowFrame != (Object)null)
			{
				Object.Destroy((Object)(object)windowFrame);
			}
			if ((Object)(object)windowFrameTexture != (Object)null)
			{
				Object.Destroy((Object)(object)windowFrameTexture);
			}
		}

		private static bool KeyPressed(string value)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (Keyboard.current != null && Enum.TryParse<Key>(value, ignoreCase: true, out Key result) && (int)result != 0)
			{
				return ((ButtonControl)Keyboard.current[result]).wasPressedThisFrame;
			}
			return false;
		}

		private void CaptureKey()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Keyboard current = Keyboard.current;
			if (current == null)
			{
				return;
			}
			if (((ButtonControl)current.escapeKey).wasPressedThisFrame)
			{
				capturingKey = null;
				return;
			}
			Enumerator<KeyControl> enumerator = current.allKeys.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyControl current2 = enumerator.Current;
				if (((ButtonControl)current2).wasPressedThisFrame)
				{
					capturingKey.Value = ((object)current2.keyCode/*cast due to .constrained prefix*/).ToString();
					capturingKey = null;
					break;
				}
			}
		}

		private string Tr(string text)
		{
			return UiText.Translate(text, locale);
		}

		private void UpdateLanguage()
		{
			Locale selectedLocale = LocalizationSettings.SelectedLocale;
			string text = ((selectedLocale != null) ? selectedLocale.Identifier.Code : null) ?? "en";
			if (locale == text)
			{
				return;
			}
			locale = text;
			spellNames.Clear();
			SelectGameFont();
			foreach (TextMeshProUGUI textElement in textElements)
			{
				if ((Object)(object)font != (Object)null)
				{
					((TMP_Text)textElement).font = font;
				}
			}
			foreach (var localizedLabel in localizedLabels)
			{
				((TMP_Text)localizedLabel.Label).text = Tr(localizedLabel.Key);
			}
		}

		private void SelectGameFont()
		{
			foreach (TMP_FontAsset item in Resources.FindObjectsOfTypeAll<TMP_FontAsset>())
			{
				if (!(((Object)item).name != "TitilliumWeb-Regular SDF"))
				{
					font = item;
					break;
				}
			}
			if ((Object)(object)font == (Object)null)
			{
				font = TMP_Settings.defaultFontAsset;
			}
		}

		private void Build()
		{
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: 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_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			SelectGameFont();
			if ((Object)(object)font == (Object)null)
			{
				((BasePlugin)EntryPoint.Instance).Log.LogWarning((object)"No game font available yet.");
				return;
			}
			foreach (Sprite item in Resources.FindObjectsOfTypeAll<Sprite>())
			{
				if (((Object)item).name == "ui_button_frame_default")
				{
					stoneBorder = item;
				}
				if (((Object)item).name == "ui_button_frame_background")
				{
					stoneFill = item;
				}
				if (((Object)item).name == "ui_store_card")
				{
					cardStone = item;
				}
				if (((Object)item).name == "ui_store_card_lines_white")
				{
					cardLines = item;
				}
			}
			if ((Object)(object)stoneBorder == (Object)null)
			{
				stoneBorder = CreateStoneFrame();
			}
			windowFrame = CreateWindowFrame();
			root = Rect("BrigadeDps.UI", null, 0f, 0f, 0f, 0f);
			Object.DontDestroyOnLoad((Object)(object)((Component)root).gameObject);
			canvas = ((Component)root).gameObject.AddComponent<Canvas>();
			canvas.renderMode = (RenderMode)0;
			canvas.sortingOrder = 450;
			CanvasScaler obj = ((Component)root).gameObject.AddComponent<CanvasScaler>();
			obj.uiScaleMode = (ScaleMode)1;
			obj.referenceResolution = new Vector2(1920f, 1080f);
			obj.matchWidthOrHeight = 0.5f;
			((Component)root).gameObject.AddComponent<GraphicRaycaster>();
			window = Framed("Meter", (Transform)(object)root, 320f, currentHeight);
			background = ((Component)window).GetComponent<Image>();
			ScrollRect val = (meterScroll = ((Component)Rect("Scroll", (Transform)(object)window, 18f, 18f, 284f, 100f)).gameObject.AddComponent<ScrollRect>());
			viewport = Rect("Viewport", ((Component)val).transform, 0f, 0f, 284f, 100f);
			((Component)viewport).gameObject.AddComponent<RectMask2D>();
			((Graphic)((Component)viewport).gameObject.AddComponent<Image>()).color = Color.clear;
			body = Rect("Rows", (Transform)(object)viewport, 0f, 0f, 284f, 100f);
			val.viewport = viewport;
			val.content = body;
			val.horizontal = false;
			val.vertical = true;
			val.movementType = (MovementType)2;
			val.scrollSensitivity = 24f;
			settings = Framed("Settings", (Transform)(object)root, 550f, 700f);
			settingsCaption = Text((Transform)(object)settings, "BRIGADE DPS · НАСТРОЙКИ", 18f, 8f, 480f, 32f, 20f, Gold);
			((TMP_Text)settingsCaption).overflowMode = (TextOverflowModes)0;
			Button((Transform)(object)settings, "×", 510f, 12f, 28f, 26f, delegate
			{
				settingsOpen = false;
			});
			Text((Transform)(object)settings, "Изменения применяются и сохраняются сразу", 18f, 46f, 514f, 25f, 13f, Muted);
			ScrollRect val2 = ((Component)Rect("Scroll", (Transform)(object)settings, 14f, 82f, 522f, 550f)).gameObject.AddComponent<ScrollRect>();
			RectTransform val3 = Rect("Viewport", ((Component)val2).transform, 0f, 0f, 522f, 550f);
			((Component)val3).gameObject.AddComponent<RectMask2D>();
			((Graphic)((Component)val3).gameObject.AddComponent<Image>()).color = Color.clear;
			settingsBody = Rect("Options", (Transform)(object)val3, 0f, 0f, 522f, 760f);
			val2.viewport = val3;
			val2.content = settingsBody;
			val2.horizontal = false;
			val2.vertical = true;
			val2.movementType = (MovementType)2;
			val2.scrollSensitivity = 28f;
			BuildSettings();
			Button((Transform)(object)settings, "Сбросить положение", 18f, 648f, 260f, 30f, delegate
			{
				cfg.ResetPosition();
				LayoutMeter();
				Place();
			});
			Button((Transform)(object)settings, "Готово", 376f, 648f, 156f, 30f, delegate
			{
				settingsOpen = false;
			});
			((Component)window).gameObject.SetActive(false);
			((Component)settings).gameObject.SetActive(settingsOpen);
		}

		private void BuildSettings()
		{
			//IL_0272: 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)
			float y = 0f;
			Toggle("Мод включён", cfg.Enabled, ref y);
			Toggle("Показывать окно", cfg.Visible, ref y);
			Toggle("Строки заклинаний", cfg.Spells, ref y);
			Toggle("Иконки заклинаний", cfg.Icons, ref y);
			Toggle("Названия заклинаний", cfg.SpellNames, ref y);
			Toggle("Названия по первым буквам", cfg.AbbreviateSpells, ref y);
			Toggle("Статистика босса", cfg.Boss, ref y);
			BossRetentionField(ref y);
			Toggle("На экране результатов", cfg.Results, ref y);
			Toggle("В одиночной игре", cfg.Solo, ref y);
			Toggle("Закрепить окно", cfg.Locked, ref y);
			Direction("Рост по горизонтали", cfg.AnchorRight, "Вправо", "Влево", ref y);
			Direction("Рост по вертикали", cfg.AnchorBottom, "Вниз", "Вверх", ref y);
			Stepper("Масштаб", () => cfg.Scale.Value.ToString("0.0", CultureInfo.InvariantCulture), delegate(int d)
			{
				cfg.Scale.Value = Mathf.Clamp(cfg.Scale.Value + 0.1f * (float)d, 0.6f, 1.8f);
			}, ref y);
			Stepper("Непрозрачность", () => $"{cfg.Opacity.Value:P0}", delegate(int d)
			{
				cfg.Opacity.Value = Mathf.Clamp(cfg.Opacity.Value + 0.1f * (float)d, 0.1f, 1f);
			}, ref y);
			Stepper("Предел высоты", () => $"{cfg.Height.Value:P0}", delegate(int d)
			{
				cfg.Height.Value = Mathf.Clamp(cfg.Height.Value + 0.05f * (float)d, 0.3f, 0.95f);
			}, ref y);
			Stepper("Заклинаний на игрока", () => cfg.SpellLimit.Value.ToString(), delegate(int d)
			{
				cfg.SpellLimit.Value = Math.Clamp(cfg.SpellLimit.Value + d, 1, 20);
			}, ref y);
			DpsModeSetting(ref y);
			Stepper("Окно УВС (задаёт хост)", () => $"{((GameBridge.IsHost || !GameBridge.Running) ? cfg.Window.Value : GameBridge.Current.Window)} {Tr("с")}", delegate(int d)
			{
				if (GameBridge.IsHost || !GameBridge.Running)
				{
					cfg.Window.Value = Math.Clamp(cfg.Window.Value + d, 1, 60);
				}
			}, ref y);
			Shortcut("Показать / скрыть", cfg.ToggleKey, ref y);
			Shortcut("Строки заклинаний", cfg.DetailKey, ref y);
			Shortcut("Открыть настройки", cfg.SettingsKey, ref y);
			Text((Transform)(object)settingsBody, "Таблица двигается за верхнюю строку, настройки — за заголовок.\nКак в игре: УВС с получения спелла; у игрока — сумма спеллов.\nУВС босса всегда за интервал хоста. Alt освобождает курсор.\nИгровые значения требуют хоста 0.1.10+; без данных показано —.", 4f, y + 10f, 504f, 110f, 12f, Muted);
			settingsBody.sizeDelta = new Vector2(522f, y + 130f);
		}

		[HideFromIl2Cpp]
		private void DpsModeSetting(ref float y)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			Text((Transform)(object)settingsBody, "УВС команды и заклинаний", 4f, y, 326f, 31f, 15f, Paper);
			TextMeshProUGUI value = Button((Transform)(object)settingsBody, "", 350f, y, 150f, 29f, delegate
			{
				cfg.DpsMode.Value = ((cfg.DpsMode.Value == DpsDisplayMode.Rolling) ? DpsDisplayMode.Game : DpsDisplayMode.Rolling);
			});
			settingsRefresh.Add(delegate
			{
				((TMP_Text)value).text = Tr((cfg.DpsMode.Value == DpsDisplayMode.Game) ? "Как в игре" : "За интервал");
			});
			y += 37f;
		}

		[HideFromIl2Cpp]
		private void BossRetentionField(ref float y)
		{
			//IL_0022: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			Text((Transform)(object)settingsBody, "Итоги босса после смерти (с)", 4f, y, 322f, 31f, 15f, Paper);
			Button((Transform)(object)settingsBody, "−", 350f, y, 32f, 29f, delegate
			{
				cfg.BossHoldSeconds.Value = Math.Max(0, cfg.BossHoldSeconds.Value - 1);
			});
			RectTransform val = Rect("BossHoldSeconds", (Transform)(object)settingsBody, 387f, y, 76f, 29f);
			Image val2 = ((Component)val).gameObject.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.16f, 0.15f, 0.19f, 1f);
			TextMeshProUGUI val3 = Text((Transform)(object)val, "", 3f, 0f, 70f, 29f, 14f, Gold);
			((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val3).richText = false;
			bossRetentionInput = ((Component)val).gameObject.AddComponent<TMP_InputField>();
			bossRetentionInput.textViewport = val;
			bossRetentionInput.textComponent = (TMP_Text)(object)val3;
			((Selectable)bossRetentionInput).targetGraphic = (Graphic)(object)val2;
			bossRetentionInput.contentType = (ContentType)2;
			bossRetentionInput.characterLimit = 4;
			bossRetentionInput.lineType = (LineType)0;
			UnityAction<string> val4 = DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)(Action<string>)delegate(string value)
			{
				if (int.TryParse(value, out var result))
				{
					cfg.BossHoldSeconds.Value = Math.Clamp(result, 0, 3600);
				}
				bossRetentionInput.SetTextWithoutNotify(cfg.BossHoldSeconds.Value.ToString(CultureInfo.InvariantCulture));
			});
			textActions.Add(val4);
			((UnityEvent<string>)(object)bossRetentionInput.onEndEdit).AddListener(val4);
			Button((Transform)(object)settingsBody, "+", 468f, y, 32f, 29f, delegate
			{
				cfg.BossHoldSeconds.Value = Math.Min(3600, cfg.BossHoldSeconds.Value + 1);
			});
			settingsRefresh.Add(delegate
			{
				if (!bossRetentionInput.isFocused)
				{
					bossRetentionInput.SetTextWithoutNotify(cfg.BossHoldSeconds.Value.ToString(CultureInfo.InvariantCulture));
				}
			});
			y += 37f;
		}

		[HideFromIl2Cpp]
		private void Toggle(string title, ConfigEntry<bool> option, ref float y)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Text((Transform)(object)settingsBody, title, 4f, y, 326f, 31f, 15f, Paper);
			TextMeshProUGUI value = Button((Transform)(object)settingsBody, "", 350f, y, 150f, 29f, delegate
			{
				option.Value = !option.Value;
				if (option == cfg.SpellNames && !option.Value)
				{
					cfg.Icons.Value = true;
				}
				if (option == cfg.Icons && !option.Value)
				{
					cfg.SpellNames.Value = true;
				}
			});
			settingsRefresh.Add(delegate
			{
				//IL_0049: 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)
				((TMP_Text)value).text = Tr(option.Value ? "ВКЛ" : "ВЫКЛ");
				((Graphic)value).color = (option.Value ? Paper : Muted);
			});
			y += 37f;
		}

		[HideFromIl2Cpp]
		private void Direction(string title, ConfigEntry<bool> option, string near, string far, ref float y)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Text((Transform)(object)settingsBody, title, 4f, y, 326f, 31f, 15f, Paper);
			TextMeshProUGUI value = Button((Transform)(object)settingsBody, "", 350f, y, 150f, 29f, delegate
			{
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: 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_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				option.Value = !option.Value;
				if (cfg.PlacementStored.Value)
				{
					float num = EffectiveScale();
					Options options = cfg;
					float x = window.anchoredPosition.x;
					float y2 = 0f - window.anchoredPosition.y;
					float width = currentWidth * num;
					float height = currentHeight * num;
					Rect rect = root.rect;
					float width2 = ((Rect)(ref rect)).width;
					rect = root.rect;
					options.SavePlacement(x, y2, width, height, width2, ((Rect)(ref rect)).height, 6f * num);
				}
			});
			settingsRefresh.Add(delegate
			{
				((TMP_Text)value).text = Tr(option.Value ? far : near);
			});
			y += 37f;
		}

		[HideFromIl2Cpp]
		private void Stepper(string title, Func<string> read, Action<int> change, ref float y)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Text((Transform)(object)settingsBody, title, 4f, y, 322f, 31f, 15f, Paper);
			Button((Transform)(object)settingsBody, "−", 350f, y, 32f, 29f, delegate
			{
				change(-1);
			});
			TextMeshProUGUI value = Text((Transform)(object)settingsBody, "", 384f, y, 80f, 29f, 14f, Gold);
			((TMP_Text)value).alignment = (TextAlignmentOptions)514;
			Button((Transform)(object)settingsBody, "+", 468f, y, 32f, 29f, delegate
			{
				change(1);
			});
			settingsRefresh.Add(delegate
			{
				((TMP_Text)value).text = read();
			});
			y += 37f;
		}

		[HideFromIl2Cpp]
		private void Shortcut(string title, ConfigEntry<string> option, ref float y)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Text((Transform)(object)settingsBody, title, 4f, y, 322f, 31f, 15f, Paper);
			TextMeshProUGUI value = Button((Transform)(object)settingsBody, "", 350f, y, 150f, 29f, delegate
			{
				capturingKey = option;
			});
			settingsRefresh.Add(delegate
			{
				((TMP_Text)value).text = ((capturingKey == option) ? Tr("Нажми клавишу…") : option.Value);
			});
			y += 37f;
		}

		private void DrawScores()
		{
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: 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_02eb: Unknown result type (might be due to invalid IL or missing references)
			MeterSnapshot current = GameBridge.Current;
			used = 0;
			dividerAfterRow = -1;
			if (cfg.Boss.Value && bossLifetime.Show(Time.unscaledTimeAsDouble, cfg.BossHoldSeconds.Value))
			{
				Section(current.BossActive ? "БОСС · БОЙ" : "БОСС · ИТОГ", Gold);
				double total = current.Players.Sum((PlayerScore p) => p.BossDamage);
				foreach (PlayerScore item in current.Players.OrderByDescending((PlayerScore p) => p.BossDamage))
				{
					AddLine(PlayerName(item), item.BossDps, item.BossDamage, Percent(item.BossDamage, total), PlayerTint(item.Color), -1, player: true);
				}
				dividerAfterRow = used;
			}
			Section("КОМАНДА", Paper);
			if (!GameBridge.IsHost && !GameBridge.Received)
			{
				Note("Ожидание хоста с Brigade DPS 0.1.2…", Gold);
			}
			else if (current.Players.Count == 0)
			{
				Note("Урон ещё не нанесён", Muted);
			}
			double total2 = current.Players.Sum((PlayerScore p) => p.Damage);
			foreach (PlayerScore player in current.Players)
			{
				AddLine(PlayerName(player), DpsDisplay.Select(cfg.DpsMode.Value, player.Dps, player.GameDps), player.Damage, Percent(player.Damage, total2), PlayerTint(player.Color), -1, player: true);
				if (!cfg.Spells.Value)
				{
					continue;
				}
				int num = 0;
				foreach (SpellScore spell in player.Spells)
				{
					if (UiText.IsSpell(spell.Spell))
					{
						if (num++ >= cfg.SpellLimit.Value)
						{
							break;
						}
						string name = UiText.SpellLabel(SpellName(spell.Spell), cfg.SpellNames.Value, cfg.AbbreviateSpells.Value);
						AddLine(name, DpsDisplay.Select(cfg.DpsMode.Value, spell.Dps, spell.GameDps), spell.Damage, Percent(spell.Damage, player.Damage), Paper, spell.Spell, player: false);
					}
				}
			}
			for (int num2 = used; num2 < lines.Count; num2++)
			{
				((Component)lines[num2].Root).gameObject.SetActive(false);
			}
			LayoutMeter();
			((Graphic)background).color = (Color)((meterCardFrame != null) ? Color.clear : new Color(Ink.r, Ink.g, Ink.b, cfg.Opacity.Value));
		}

		private string PlayerName(PlayerScore player)
		{
			if (!string.IsNullOrWhiteSpace(player.Name))
			{
				return player.Name;
			}
			return $"{Tr("Игрок")} {player.Id + 1}";
		}

		private void LayoutMeter()
		{
			//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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: 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_0259: Unknown result type (might be due to invalid IL or missing references)
			float num = EffectiveScale();
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			float num5 = 0f;
			float num6 = 0f;
			for (int i = 0; i < used; i++)
			{
				TableLine tableLine = lines[i];
				if (tableLine.IsNote)
				{
					num6 = Mathf.Max(num6, tableLine.Measure(tableLine.Name));
					continue;
				}
				num2 = Mathf.Max(num2, tableLine.Measure(tableLine.Name) + tableLine.Indent + tableLine.SpellInset);
				num3 = Mathf.Max(num3, tableLine.Measure(tableLine.Dps));
				num4 = Mathf.Max(num4, tableLine.Measure(tableLine.Damage));
				num5 = Mathf.Max(num5, tableLine.Measure(tableLine.Share));
			}
			float num7 = num3 + num4 + num5 + 18f;
			float num8 = Mathf.Max(num2 + num7, num6) + 8f + 36f;
			float num9 = Mathf.Max(100f, num8);
			Rect rect = root.rect;
			currentWidth = Mathf.Min(num9, ((Rect)(ref rect)).width / num - 12f);
			num2 = Mathf.Max(0f, currentWidth - 36f - 8f - num7);
			float num10 = (float)used * 25f + ((dividerAfterRow >= 0) ? 24f : 0f);
			rect = root.rect;
			float val = ((Rect)(ref rect)).height - 12f * num;
			rect = root.rect;
			float num11 = Mathf.Max(61f, Math.Min(val, ((Rect)(ref rect)).height * cfg.Height.Value) / num);
			currentHeight = Mathf.Min(num10 + 36f, num11);
			window.sizeDelta = new Vector2(currentWidth, currentHeight);
			body.sizeDelta = new Vector2(currentWidth - 36f, num10);
			viewport.sizeDelta = new Vector2(currentWidth - 36f, currentHeight - 36f);
			((Il2CppObjectBase)((Transform)viewport).parent).Cast<RectTransform>().sizeDelta = viewport.sizeDelta;
			for (int j = 0; j < used; j++)
			{
				lines[j].Layout(currentWidth - 36f, num2, num3, num4, num5);
			}
		}

		private void Section(string title, Color color)
		{
			//IL_002a: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0063: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			TableLine tableLine = Next();
			tableLine.Set(Tr(title), Tr("УВС"), Tr("УРОН"), "%", color, null, bold: true, 0f);
			TextMeshProUGUI name = tableLine.Name;
			TextMeshProUGUI dps = tableLine.Dps;
			TextMeshProUGUI damage = tableLine.Damage;
			TextMeshProUGUI share = tableLine.Share;
			TextAlignmentOptions val = (TextAlignmentOptions)514;
			((TMP_Text)share).alignment = (TextAlignmentOptions)514;
			TextAlignmentOptions val2 = (((TMP_Text)damage).alignment = val);
			TextAlignmentOptions alignment = (((TMP_Text)dps).alignment = val2);
			((TMP_Text)name).alignment = alignment;
			((Graphic)tableLine.Background).color = new Color(0.27f, 0.3f, 0.28f, 0.55f);
		}

		private void Note(string message, Color color)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			TableLine tableLine = Next();
			tableLine.Set(Tr(message), "", "", "", color, null, bold: false, 0f);
			tableLine.IsNote = true;
		}

		private void AddLine(string name, double? dps, double damage, string share, Color tint, int spell, bool player)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Sprite val = ((!player && (cfg.Icons.Value || !cfg.SpellNames.Value)) ? SpellIcon(spell) : null);
			if (!player && (Object)(object)val == (Object)null && string.IsNullOrEmpty(name))
			{
				name = UiText.SpellLabel(SpellName(spell), showNames: true, abbreviate: true);
			}
			TableLine tableLine = Next();
			tableLine.Set(name, dps.HasValue ? Number(dps.Value) : "—", Number(damage), share, tint, val, player, (!player) ? (((Object)(object)val != (Object)null) ? 23 : 8) : 0);
			tableLine.SpellInset = ((!player && (!cfg.SpellNames.Value || cfg.AbbreviateSpells.Value)) ? 8 : 0);
		}

		[HideFromIl2Cpp]
		private TableLine Next()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (used == lines.Count)
			{
				lines.Add(new TableLine(this, (Transform)(object)body));
			}
			TableLine tableLine = lines[used];
			float num = ((dividerAfterRow >= 0 && used >= dividerAfterRow) ? 24f : 0f);
			tableLine.Root.anchoredPosition = new Vector2(0f, -25f * (float)used++ - num);
			((Component)tableLine.Root).gameObject.SetActive(true);
			return tableLine;
		}

		private Sprite SpellIcon(int spell)
		{
			if (spell < 0)
			{
				return null;
			}
			if (sprites.TryGetValue(spell, out var value) && (Object)(object)value != (Object)null && !((Il2CppObjectBase)value).WasCollected)
			{
				return value;
			}
			SpellConfiguration obj = SpellConfigurationRepository.Get((SpellType)spell);
			object obj2;
			if (obj == null)
			{
				obj2 = null;
			}
			else
			{
				SpellIconContainer iconContainer = obj.IconContainer;
				obj2 = ((iconContainer != null) ? iconContainer.DefaultIcon : null);
			}
			Sprite val = (Sprite)obj2;
			if ((Object)(object)val != (Object)null)
			{
				sprites[spell] = val;
			}
			return val;
		}

		private string SpellName(int spell)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (spellNames.TryGetValue(spell, out var value))
			{
				return value;
			}
			string text = ((object)(SpellType)spell/*cast due to .constrained prefix*/).ToString();
			try
			{
				string localizedString = LocalizationSettings.StringDatabase.GetLocalizedString(TableEntryReference.op_Implicit("SpellName_" + text), (Locale)null, (FallbackBehavior)0, (Il2CppReferenceArray<Object>)null);
				if (!string.IsNullOrWhiteSpace(localizedString) && !localizedString.Contains("No translation") && !localizedString.StartsWith("SpellName_"))
				{
					return spellNames[spell] = localizedString;
				}
			}
			catch
			{
			}
			return text;
		}

		private float EffectiveScale()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			float value = cfg.Scale.Value;
			Rect rect = root.rect;
			return Mathf.Min(value, (((Rect)(ref rect)).width - 12f) / 240f);
		}

		private void Place()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0139: 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_0150: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_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_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: 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_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			float num = EffectiveScale();
			((Transform)window).localScale = new Vector3(num, num, 1f);
			float num2 = currentWidth * num;
			float num3 = currentHeight * num;
			float padding = 6f * num;
			Rect rect;
			if (!cfg.PlacementStored.Value && ((Component)window).gameObject.activeSelf)
			{
				Options options = cfg;
				float value = cfg.X.Value;
				rect = root.rect;
				float x = value * Math.Max(0f, ((Rect)(ref rect)).width - num2);
				float value2 = cfg.Y.Value;
				rect = root.rect;
				float y = value2 * Math.Max(0f, ((Rect)(ref rect)).height - num3);
				rect = root.rect;
				float width = ((Rect)(ref rect)).width;
				rect = root.rect;
				options.SavePlacement(x, y, num2, num3, width, ((Rect)(ref rect)).height, padding);
			}
			if (dragging)
			{
				RectTransform obj = window;
				float x2 = window.anchoredPosition.x;
				rect = root.rect;
				float num4 = WindowAnchorAxis.Clamp(x2, num2, ((Rect)(ref rect)).width, padding);
				float position = 0f - window.anchoredPosition.y;
				rect = root.rect;
				obj.anchoredPosition = new Vector2(num4, 0f - WindowAnchorAxis.Clamp(position, num3, ((Rect)(ref rect)).height, padding));
			}
			else if (cfg.PlacementStored.Value)
			{
				WindowAnchorAxis windowAnchorAxis = new WindowAnchorAxis(cfg.AnchorRight.Value, cfg.EdgeMarginX.Value);
				WindowAnchorAxis windowAnchorAxis2 = new WindowAnchorAxis(cfg.AnchorBottom.Value, cfg.EdgeMarginY.Value);
				RectTransform obj2 = window;
				rect = root.rect;
				float num5 = windowAnchorAxis.Resolve(num2, ((Rect)(ref rect)).width, padding);
				rect = root.rect;
				obj2.anchoredPosition = new Vector2(num5, 0f - windowAnchorAxis2.Resolve(num3, ((Rect)(ref rect)).height, padding));
			}
			rect = root.rect;
			float num6 = (((Rect)(ref rect)).height - 24f) / 700f;
			rect = root.rect;
			float num7 = Mathf.Min(1f, Mathf.Min(num6, (((Rect)(ref rect)).width - 24f) / 550f));
			((Transform)settings).localScale = new Vector3(num7, num7, 1f);
			rect = root.rect;
			float num8 = Mathf.Max(0f, ((Rect)(ref rect)).width - 550f * num7 - 12f);
			rect = root.rect;
			float num9 = Mathf.Max(0f, ((Rect)(ref rect)).height - 700f * num7 - 12f);
			settings.anchoredPosition = (settingsDragging ? new Vector2(Mathf.Clamp(settings.anchoredPosition.x, 6f, 6f + num8), 0f - Mathf.Clamp(0f - settings.anchoredPosition.y, 6f, 6f + num9)) : new Vector2(6f + cfg.SettingsX.Value * num8, 0f - (6f + cfg.SettingsY.Value * num9)));
			((Transform)settings).SetAsLastSibling();
		}

		private void DragSettings()
		{
			//IL_0025: 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_003b: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00c0: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			Mouse current = Mouse.current;
			if (!settingsOpen || current == null || !Application.isFocused)
			{
				EndSettingsDrag();
				return;
			}
			Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue();
			Vector2 val2 = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(settings, val, (Camera)null, ref val2);
			bool flag = val2.x >= 8f && val2.x < 502f && val2.y <= -4f && val2.y >= -44f;
			if (current.leftButton.wasPressedThisFrame && flag)
			{
				settingsDragging = true;
				settingsDragOrigin = val;
				settingsDragWindow = settings.anchoredPosition;
			}
			if (settingsDragging)
			{
				settings.anchoredPosition = settingsDragWindow + (val - settingsDragOrigin) / canvas.scaleFactor;
				Place();
				if (!current.leftButton.isPressed)
				{
					EndSettingsDrag();
				}
			}
		}

		private void EndSettingsDrag()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_005a: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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)
			if (settingsDragging)
			{
				settingsDragging = false;
				Rect rect = root.rect;
				float width = ((Rect)(ref rect)).width;
				rect = settings.rect;
				float num = width - ((Rect)(ref rect)).width * ((Transform)settings).localScale.x - 12f;
				rect = root.rect;
				float height = ((Rect)(ref rect)).height;
				rect = settings.rect;
				float num2 = height - ((Rect)(ref rect)).height * ((Transform)settings).localScale.y - 12f;
				cfg.SettingsX.Value = ((num > 0f) ? Mathf.Clamp01((settings.anchoredPosition.x - 6f) / num) : 0.5f);
				cfg.SettingsY.Value = ((num2 > 0f) ? Mathf.Clamp01((0f - settings.anchoredPosition.y - 6f) / num2) : 0.5f);
			}
		}

		private void Drag()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_00a0: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			Mouse current = Mouse.current;
			if (current == null || cfg.Locked.Value || settingsOpen || !Application.isFocused)
			{
				EndDrag();
				return;
			}
			Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue();
			Vector2 val2 = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(window, val, (Camera)null, ref val2);
			bool flag = val2.x >= 0f && val2.x <= currentWidth && val2.y <= 0f && val2.y >= -43f;
			if (current.leftButton.wasPressedThisFrame && flag)
			{
				dragging = true;
				dragOrigin = val;
				dragWindow = window.anchoredPosition;
				meterScroll.StopMovement();
				((Behaviour)meterScroll).enabled = false;
			}
			if (dragging)
			{
				Vector2 val3 = (val - dragOrigin) / canvas.scaleFactor;
				window.anchoredPosition = dragWindow + val3;
				Place();
				if (!current.leftButton.isPressed)
				{
					EndDrag();
				}
			}
		}

		private void EndDrag()
		{
			//IL_0023: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if (dragging)
			{
				dragging = false;
				float num = EffectiveScale();
				Options options = cfg;
				float x = window.anchoredPosition.x;
				float y = 0f - window.anchoredPosition.y;
				float width = currentWidth * num;
				float height = currentHeight * num;
				Rect rect = root.rect;
				float width2 = ((Rect)(ref rect)).width;
				rect = root.rect;
				options.SavePlacement(x, y, width, height, width2, ((Rect)(ref rect)).height, 6f * num);
				if ((Object)(object)meterScroll != (Object)null)
				{
					((Behaviour)meterScroll).enabled = true;
				}
			}
		}

		private RectTransform Framed(string name, Transform parent, float width, float height)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00ad: 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_00d7: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_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 missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: 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_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Rect(name, parent, 0f, 0f, width, height);
			((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = new Color(Ink.r, Ink.g, Ink.b, 0.96f);
			if ((Object)(object)windowFrame != (Object)null)
			{
				StoneEdge(val, 2f, windowFrame);
				return val;
			}
			Border((Transform)(object)val, "Top", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, -2f), new Vector2(-8f, 2f));
			Border((Transform)(object)val, "Bottom", new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 2f), new Vector2(-8f, 2f));
			Border((Transform)(object)val, "Left", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(2f, 0f), new Vector2(2f, -8f));
			Border((Transform)(object)val, "Right", new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(-2f, 0f), new Vector2(2f, -8f));
			Vector2[] array = (Vector2[])(object)new Vector2[4]
			{
				new Vector2(0f, 0f),
				new Vector2(1f, 0f),
				new Vector2(0f, 1f),
				new Vector2(1f, 1f)
			};
			foreach (Vector2 val2 in array)
			{
				RectTransform obj = Rect("Corner", (Transform)(object)val, 0f, 0f, 7f, 7f);
				Vector2 anchorMin = (obj.anchorMax = val2);
				obj.anchorMin = anchorMin;
				obj.pivot = new Vector2(0.5f, 0.5f);
				obj.anchoredPosition = Vector2.zero;
				((Transform)obj).localRotation = Quaternion.Euler(0f, 0f, 45f);
				Image obj2 = ((Component)obj).gameObject.AddComponent<Image>();
				((Graphic)obj2).color = Gold;
				((Graphic)obj2).raycastTarget = false;
			}
			return val;
		}

		private void UpdateCardFrames()
		{
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)(object)cardStone == (Object)null || (Object)(object)cardLines == (Object)null) && Time.unscaledTime >= nextCardSearch)
			{
				nextCardSearch = Time.unscaledTime + 2f;
				foreach (Sprite item in Resources.FindObjectsOfTypeAll<Sprite>())
				{
					if (((Object)item).name == "ui_store_card")
					{
						cardStone = item;
					}
					if (((Object)item).name == "ui_store_card_lines_white")
					{
						cardLines = item;
					}
				}
			}
			if ((Object)(object)cardStone == (Object)null || (Object)(object)cardLines == (Object)null)
			{
				return;
			}
			if (meterCardFrame == null)
			{
				meterCardFrame = new NativeCardFrame(window, cardStone, cardLines);
				settingsCardFrame = new NativeCardFrame(settings, cardStone, cardLines);
				bossDivider = new NativeCardDivider(window, cardStone, cardLines);
				Transform obj = ((Transform)window).Find("StoneFrame");
				if (obj != null)
				{
					((Component)obj).gameObject.SetActive(false);
				}
				Transform obj2 = ((Transform)settings).Find("StoneFrame");
				if (obj2 != null)
				{
					((Component)obj2).gameObject.SetActive(false);
				}
				((Graphic)background).color = Color.clear;
				((Graphic)((Component)settings).GetComponent<Image>()).color = Color.clear;
				((BasePlugin)EntryPoint.Instance).Log.LogInfo((object)"Native subdued card frames ready; upper ornaments mirror the lower edge.");
			}
			meterCardFrame.Layout(cfg.Opacity.Value);
			settingsCardFrame.Layout(0.96f);
			PlaceBossDivider();
		}

		private void PlaceBossDivider()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (bossDivider != null)
			{
				NativeCardDivider nativeCardDivider = bossDivider;
				bool visible = ((Component)window).gameObject.activeSelf && dividerAfterRow >= 0;
				float width = currentWidth;
				Rect rect = viewport.rect;
				nativeCardDivider.Place(visible, width, ((Rect)(ref rect)).height, 18f, (float)dividerAfterRow * 25f, body.anchoredPosition.y);
			}
		}

		private Sprite CreateStoneFrame()
		{
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			Color[] array = (Color[])(object)new Color[65536];
			for (int i = 0; i < 256; i++)
			{
				for (int j = 0; j < 256; j++)
				{
					float num = Math.Min(j, 255 - j);
					float num2 = Math.Min(i, 255 - i);
					float num3 = Math.Min(Math.Min(num, num2), (num + num2 - 25f) * 0.7071f);
					if ((num > 29f && num < 38f && num2 < 7f) || (num2 > 36f && num2 < 43f && num < 5f))
					{
						num3 -= 5f;
					}
					Color clear = Color.clear;
					if (num3 >= 0f && num3 < 34f)
					{
						if (num3 < 4f)
						{
							((Color)(ref clear))..ctor(0.11f, 0.095f, 0.14f);
						}
						else if (num3 < 12f)
						{
							((Color)(ref clear))..ctor(0.25f, 0.22f, 0.31f);
						}
						else if (num3 < 20f)
						{
							((Color)(ref clear))..ctor(0.39f, 0.35f, 0.46f);
						}
						else if (num3 < 25f)
						{
							((Color)(ref clear))..ctor(0.2f, 0.18f, 0.25f);
						}
						else if (num3 < 28f)
						{
							((Color)(ref clear))..ctor(0.86f, 0.83f, 0.93f);
						}
						else
						{
							((Color)(ref clear))..ctor(0.28f, 0.25f, 0.34f);
						}
					}
					array[i * 256 + j] = clear;
				}
			}
			generatedFrameTexture = new Texture2D(256, 256, (TextureFormat)4, false);
			((Object)generatedFrameTexture).name = "BrigadeDps.StoneFrame";
			generatedFrameTexture.SetPixels(Il2CppStructArray<Color>.op_Implicit(array));
			generatedFrameTexture.Apply();
			generatedFrame = Sprite.Create(generatedFrameTexture, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(55f, 55f, 55f, 55f));
			return generatedFrame;
		}

		private Sprite CreateWindowFrame()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			uint[] array = FrameArtwork.CreatePixels();
			Color[] array2 = (Color[])(object)new Color[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				uint num = array[i];
				array2[i] = new Color((float)((num >> 16) & 0xFF) / 255f, (float)((num >> 8) & 0xFF) / 255f, (float)(num & 0xFF) / 255f, (float)(num >> 24) / 255f);
			}
			windowFrameTexture = new Texture2D(192, 192, (TextureFormat)4, false);
			((Object)windowFrameTexture).name = "BrigadeDps.CardFrame";
			((Texture)windowFrameTexture).wrapMode = (TextureWrapMode)1;
			((Texture)windowFrameTexture).filterMode = (FilterMode)1;
			windowFrameTexture.SetPixels(Il2CppStructArray<Color>.op_Implicit(array2));
			windowFrameTexture.Apply();
			return Sprite.Create(windowFrameTexture, new Rect(0f, 0f, 192f, 192f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(48f, 48f, 48f, 48f));
		}

		private void StoneEdge(RectTransform parent, float multiplier, Sprite artwork = null)
		{
			//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_0040: 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)
			RectTransform obj = Rect("StoneFrame", (Transform)(object)parent, 0f, 0f, 0f, 0f);
			obj.anchorMin = Vector2.zero;
			obj.anchorMax = Vector2.one;
			obj.offsetMin = new Vector2(-5f, -5f);
			obj.offsetMax = new Vector2(5f, 5f);
			Image obj2 = ((Component)obj).gameObject.AddComponent<Image>();
			obj2.sprite = (((Object)(object)artwork != (Object)null) ? artwork : stoneBorder);
			obj2.type = (Type)1;
			obj2.fillCenter = false;
			obj2.pixelsPerUnitMultiplier = multiplier;
			((Graphic)obj2).raycastTarget = false;
		}

		private void Border(Transform parent, string name, Vector2 min, Vector2 max, Vector2 position, Vector2 size)
		{
			//IL_001c: 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_0035: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Rect(name, parent, 0f, 0f, 0f, 0f);
			obj.anchorMin = min;
			obj.anchorMax = max;
			obj.pivot = new Vector2(0.5f, 0.5f);
			obj.anchoredPosition = position;
			obj.sizeDelta = size;
			Image obj2 = ((Component)obj).gameObject.AddComponent<Image>();
			((Graphic)obj2).color = Gold;
			((Graphic)obj2).raycastTarget = false;
		}

		private static RectTransform Rect(string name, Transform parent, float x, float y, float width, float height)
		{
			//IL_0001: 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_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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = new GameObject(name).AddComponent<RectTransform>();
			if ((Object)(object)parent != (Object)null)
			{
				((Transform)val).SetParent(parent, false);
			}
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0f, 1f);
			val.pivot = val2;
			Vector2 anchorMin = (val.anchorMax = val2);
			val.anchorMin = anchorMin;
			val.anchoredPosition = new Vector2(x, 0f - y);
			val.sizeDelta = new Vector2(width, height);
			return val;
		}

		private TextMeshProUGUI Text(Transform parent, string value, float x, float y, float width, float height, float size, Color color)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = ((Component)Rect("Label", parent, x, y, width, height)).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val).font = font;
			((TMP_Text)val).fontSize = size;
			((Graphic)val).color = color;
			((TMP_Text)val).text = Tr(value);
			textElements.Add(val);
			if (UiText.Has(value))
			{
				localizedLabels.Add((val, value));
			}
			((Graphic)val).raycastTarget = false;
			((TMP_Text)val).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)val).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)val).overflowMode = (TextOverflowModes)1;
			return val;
		}

		[HideFromIl2Cpp]
		private TextMeshProUGUI Button(Transform parent, string label, float x, float y, float width, float height, Action action)
		{
			//IL_0034: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Rect("Button", parent, x, y, width, height);
			Image val2 = ((Component)val).gameObject.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.24f, 0.22f, 0.3f, 0.95f);
			if ((Object)(object)stoneFill != (Object)null)
			{
				val2.sprite = stoneFill;
				val2.type = (Type)1;
				val2.pixelsPerUnitMultiplier = 7f;
				((Graphic)val2).color = new Color(0.24f, 0.22f, 0.3f, 1f);
			}
			if ((Object)(object)stoneBorder != (Object)null)
			{
				StoneEdge(val, 7f);
			}
			Button obj = ((Component)val).gameObject.AddComponent<Button>();
			((Selectable)obj).targetGraphic = (Graphic)(object)val2;
			ColorBlock colors = ((Selectable)obj).colors;
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).highlightedColor = new Color(1.25f, 1.2f, 1.35f);
			((ColorBlock)(ref colors)).selectedColor = ((ColorBlock)(ref colors)).highlightedColor;
			((ColorBlock)(ref colors)).pressedColor = new Color(0.75f, 0.7f, 0.85f);
			((Selectable)obj).colors = colors;
			Navigation navigation = ((Selectable)obj).navigation;
			navigation.mode = (Mode)0;
			((Selectable)obj).navigation = navigation;
			UnityAction val3 = DelegateSupport.ConvertDelegate<UnityAction>((Delegate)action);
			actions.Add(val3);
			((UnityEvent)obj.onClick).AddListener(val3);
			TextMeshProUGUI obj2 = Text((Transform)(object)val, label, 3f, 0f, width - 6f, height, 13f, Paper);
			((TMP_Text)obj2).alignment = (TextAlignmentOptions)514;
			return obj2;
		}

		private static string Percent(double part, double total)
		{
			if (!(total > 0.0))
			{
				return "0.0";
			}
			return (100.0 * part / total).ToString("0.0", CultureInfo.InvariantCulture);
		}

		private static string Number(double value)
		{
			if (!(value >= 1000000.0))
			{
				if (!(value >= 10000.0))
				{
					return value.ToString("0", CultureInfo.InvariantCulture);
				}
				return (value / 1000.0).ToString("0.#", CultureInfo.InvariantCulture) + "k";
			}
			return (value / 1000000.0).ToString("0.##", CultureInfo.InvariantCulture) + "M";
		}

		private static Color PlayerTint(string value)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0053: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				uint num = Convert.ToUInt32(value, 16);
				return Color.Lerp(new Color((float)((num >> 16) & 0xFF) / 255f, (float)((num >> 8) & 0xFF) / 255f