Decompiled source of PlayerVoiceVolume v1.1.2

PlayerVoiceVolume.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DG.Tweening;
using HarmonyLib;
using TMPro;
using Unity.Services.Vivox;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PlayerVoiceVolume")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+76e50e66187df7943cf88a109e71ea18486ea0e9")]
[assembly: AssemblyProduct("PlayerVoiceVolume")]
[assembly: AssemblyTitle("PlayerVoiceVolume")]
[assembly: AssemblyVersion("1.1.2.0")]
namespace PlayerVoiceVolume;

internal sealed class ConfigMenu : MonoBehaviour
{
	private ConfigFile _config;

	private string _title;

	private string _symbol;

	private ConfigEntryBase[] _entries;

	private string[] _tabs;

	private int _tab;

	private int _pendingTab = -1;

	private Rect _rect;

	private bool _placed;

	private UiSkin _skin;

	private GUISkin _guiSkin;

	private WindowInputShield _shield;

	private ModDock _dock;

	private Vector2[] _scroll;

	private readonly Dictionary<ConfigEntryBase, string> _drafts = new Dictionary<ConfigEntryBase, string>();

	private readonly HashSet<string> _expanded = new HashSet<string>();

	private readonly Dictionary<string, bool> _pendingExpand = new Dictionary<string, bool>();

	private string _error;

	private int _hotControl;

	internal Action ExtraControls { get; set; }

	internal bool IsOpen => ((Behaviour)this).enabled;

	internal static ConfigMenu Create(GameObject parent, string title, string symbol, ConfigFile config, Func<bool> visible = null)
	{
		ConfigMenu menu = parent.AddComponent<ConfigMenu>();
		((Behaviour)menu).enabled = false;
		menu._title = title;
		menu._symbol = symbol;
		menu._config = config;
		menu._entries = ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)config).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> p) => p.Value).ToArray();
		menu._tabs = menu._entries.Select((ConfigEntryBase e) => Root(e.Definition.Section)).Distinct().ToArray();
		menu._scroll = (Vector2[])(object)new Vector2[menu._tabs.Length];
		menu._shield = new WindowInputShield(title);
		menu._dock = ModDock.Register(title, symbol, menu.Toggle, () => ((Behaviour)menu).enabled, () => title + " · " + UiEnvironment.L("Settings", "Настройки"), visible);
		return menu;
	}

	internal void Toggle()
	{
		SetOpen(!((Behaviour)this).enabled);
	}

	internal void SetOpen(bool open)
	{
		((Behaviour)this).enabled = open;
		_shield?.Set(open);
		if (!open && _hotControl != 0 && GUIUtility.hotControl == _hotControl)
		{
			GUIUtility.hotControl = 0;
		}
		if (!open)
		{
			_hotControl = 0;
			GUI.FocusControl((string)null);
		}
	}

	private void Update()
	{
		if (Input.GetKeyDown((KeyCode)27))
		{
			SetOpen(open: false);
		}
	}

	private void OnDisable()
	{
		_shield?.Set(open: false);
	}

	private void OnGUI()
	{
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Expected O, but got Unknown
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		if (UiEnvironment.PreviewRendering)
		{
			return;
		}
		if (_skin == null)
		{
			_skin = new UiSkin();
			_guiSkin = _skin.CreateGuiSkin(GUI.skin);
		}
		float scale = UiEnvironment.Scale;
		float num = Mathf.Min(600f, (float)Screen.width / scale - 24f);
		float num2 = (float)Screen.height / scale;
		if (!_placed)
		{
			_rect = new Rect(((float)Screen.width / scale - num) * 0.5f, num2 * 0.06f, num, 0f);
			_placed = true;
		}
		((Rect)(ref _rect)).width = num;
		Matrix4x4 matrix = GUI.matrix;
		GUISkin skin = GUI.skin;
		try
		{
			GUI.matrix = Matrix4x4.Scale(new Vector3(scale, scale, 1f));
			GUI.skin = _guiSkin;
			GUI.skin.settings.selectionColor = new Color(0.95f, 0.72f, 0.58f, 0.7f);
			_rect = GUILayout.Window((_title.GetHashCode() & 0x3FFFFFFF) + 3000, _rect, new WindowFunction(DrawWindow), GUIContent.none, _skin.Window, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) });
			((Rect)(ref _rect)).x = Mathf.Clamp(((Rect)(ref _rect)).x, 12f, Mathf.Max(12f, (float)Screen.width / scale - num - 12f));
			((Rect)(ref _rect)).y = Mathf.Clamp(((Rect)(ref _rect)).y, 8f, Mathf.Max(8f, num2 - ((Rect)(ref _rect)).height - 8f));
			_shield.Place(_rect, scale);
		}
		finally
		{
			GUI.skin = skin;
			GUI.matrix = matrix;
		}
	}

	private void DrawWindow(int id)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Invalid comparison between Unknown and I4
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: Unknown result type (might be due to invalid IL or missing references)
		if ((int)Event.current.type == 8)
		{
			if (_pendingTab >= 0)
			{
				_tab = _pendingTab;
				_pendingTab = -1;
				GUI.FocusControl((string)null);
			}
			foreach (KeyValuePair<string, bool> item in _pendingExpand)
			{
				if (item.Value)
				{
					_expanded.Add(item.Key);
				}
				else
				{
					_expanded.Remove(item.Key);
				}
			}
			_pendingExpand.Clear();
		}
		int hotControl = GUIUtility.hotControl;
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label((_symbol == "camera") ? "CU" : ((_symbol == "range") ? "LR" : "PV"), _skin.Logo, Array.Empty<GUILayoutOption>());
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.Label(_title, _skin.Title, Array.Empty<GUILayoutOption>());
		GUILayout.Label(UiEnvironment.L("Settings", "Настройки"), _skin.Subtitle, Array.Empty<GUILayoutOption>());
		GUILayout.EndVertical();
		GUILayout.FlexibleSpace();
		if (GUILayout.Button("×", _skin.CloseButton, Array.Empty<GUILayoutOption>()))
		{
			SetOpen(open: false);
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(8f);
		int num = ((((Rect)(ref _rect)).width < 480f) ? 2 : 4);
		for (int i = 0; i < _tabs.Length; i += num)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			for (int j = i; j < Mathf.Min(i + num, _tabs.Length); j++)
			{
				if (GUILayout.Button(UiLabels.Name(_tabs[j]), (j == _tab) ? _skin.SelectedTab : _skin.Tab, Array.Empty<GUILayoutOption>()))
				{
					_pendingTab = j;
				}
			}
			GUILayout.EndHorizontal();
		}
		GUILayout.Space(8f);
		float num2 = Mathf.Min(520f, Mathf.Max(80f, (float)Screen.height / UiEnvironment.Scale - 220f - (float)(34 * ((_tabs.Length + num - 1) / num))));
		_scroll[_tab] = GUILayout.BeginScrollView(_scroll[_tab], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num2) });
		foreach (IGrouping<string, ConfigEntryBase> item2 in from e in _entries
			where Root(e.Definition.Section) == _tabs[_tab]
			group e by e.Definition.Section)
		{
			bool num3 = item2.Key.Contains(".") || item2.Key == "Quality";
			GUILayout.BeginVertical(_skin.Panel, Array.Empty<GUILayoutOption>());
			bool flag = !num3 || _expanded.Contains(item2.Key);
			if (num3)
			{
				if (GUILayout.Button((flag ? "▼ " : "► ") + UiLabels.Name(item2.Key), _skin.SectionTitle, Array.Empty<GUILayoutOption>()))
				{
					_pendingExpand[item2.Key] = !flag;
				}
			}
			else
			{
				GUILayout.Label(UiLabels.Name(item2.Key), _skin.SectionTitle, Array.Empty<GUILayoutOption>());
			}
			if (flag)
			{
				foreach (ConfigEntryBase item3 in item2)
				{
					DrawEntry(item3);
				}
			}
			GUILayout.EndVertical();
		}
		ExtraControls?.Invoke();
		GUILayout.EndScrollView();
		GUILayout.Space(8f);
		GUILayout.Label(_error ?? UiEnvironment.L("Changes save automatically. Fields: Apply to save.", "Изменения сохраняются сразу. Для полей нажмите «Применить»."), _skin.Hint, Array.Empty<GUILayoutOption>());
		GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _rect)).width - 48f, 62f));
		if (hotControl != GUIUtility.hotControl)
		{
			_hotControl = GUIUtility.hotControl;
		}
	}

	private void DrawEntry(ConfigEntryBase entry)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0490: Unknown result type (might be due to invalid IL or missing references)
		//IL_0495: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c2: Invalid comparison between Unknown and I4
		//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_04da: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0506: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		string text = UiLabels.Name(entry.Definition.Key);
		GUILayout.BeginHorizontal(_skin.Row, Array.Empty<GUILayoutOption>());
		GUIContent val = new GUIContent(text, entry.Description.Description);
		if (entry.SettingType == typeof(bool))
		{
			bool flag = GUILayout.Toggle((bool)entry.BoxedValue, GUIContent.none, _skin.Check, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button(val, _skin.ToggleLabel, Array.Empty<GUILayoutOption>()))
			{
				flag = !(bool)entry.BoxedValue;
			}
			if (flag != (bool)entry.BoxedValue)
			{
				entry.BoxedValue = flag;
			}
		}
		else
		{
			GUILayout.Label(val, _skin.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(Mathf.Clamp((((Rect)(ref _rect)).width - 64f) * 0.4f, 105f, 190f)) });
			bool num = entry.SettingType == typeof(float) || entry.SettingType == typeof(int);
			AcceptableValueBase acceptableValues = entry.Description.AcceptableValues;
			PropertyInfo propertyInfo = ((object)acceptableValues)?.GetType().GetProperty("MinValue");
			PropertyInfo propertyInfo2 = ((object)acceptableValues)?.GetType().GetProperty("MaxValue");
			if (num && propertyInfo != null && propertyInfo2 != null)
			{
				float num2 = Convert.ToSingle(entry.BoxedValue, CultureInfo.InvariantCulture);
				float num3 = GUILayout.HorizontalSlider(num2, Convert.ToSingle(propertyInfo.GetValue(acceptableValues), CultureInfo.InvariantCulture), Convert.ToSingle(propertyInfo2.GetValue(acceptableValues), CultureInfo.InvariantCulture), _skin.Slider, _skin.Thumb, Array.Empty<GUILayoutOption>());
				GUILayout.Label(num2.ToString((entry.SettingType == typeof(int)) ? "0" : "0.##", CultureInfo.InvariantCulture), _skin.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(54f) });
				if (num3 != num2)
				{
					entry.BoxedValue = ((entry.SettingType == typeof(int)) ? ((object)Mathf.RoundToInt(num3)) : ((object)(float)Math.Round(num3, 3)));
				}
			}
			else if (entry.SettingType.IsEnum && entry.SettingType != typeof(KeyCode))
			{
				Array values = Enum.GetValues(entry.SettingType);
				int num4 = Array.IndexOf(values.Cast<object>().ToArray(), entry.BoxedValue);
				if (GUILayout.Button("◄", _skin.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }))
				{
					entry.BoxedValue = values.GetValue((num4 + values.Length - 1) % values.Length);
				}
				GUILayout.Label(UiLabels.Name(entry.BoxedValue.ToString()), _skin.Field, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
				if (GUILayout.Button("►", _skin.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) }))
				{
					entry.BoxedValue = values.GetValue((num4 + 1) % values.Length);
				}
			}
			else
			{
				if (!_drafts.TryGetValue(entry, out var value))
				{
					value = ((entry.SettingType == typeof(Color)) ? ("#" + ColorUtility.ToHtmlStringRGBA((Color)entry.BoxedValue)) : entry.GetSerializedValue());
				}
				string text2 = GUILayout.TextField(value, _skin.EditorHex, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.MinWidth(40f),
					GUILayout.ExpandWidth(true)
				});
				if (text2 != value)
				{
					_drafts[entry] = text2;
				}
				if (GUILayout.Button(UiEnvironment.L("Apply", "Применить"), _skin.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)(UiEnvironment.Russian ? 86 : 54)) }))
				{
					Apply(entry, text2);
				}
			}
		}
		GUILayout.EndHorizontal();
		if (entry.SettingType == typeof(Color))
		{
			Color val2 = (Color)entry.BoxedValue;
			Rect rect = GUILayoutUtility.GetRect(0f, 24f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if ((int)Event.current.type == 7)
			{
				_skin.PreviewPaper.Draw(rect, false, false, false, false);
				GUI.DrawTexture(rect, (Texture)(object)_skin.White, (ScaleMode)0, true, 0f, val2, 0f, 6f);
				GUI.Label(rect, "#" + ColorUtility.ToHtmlStringRGBA(val2), _skin.Value);
			}
		}
	}

	private void Apply(ConfigEntryBase entry, string text)
	{
		//IL_003e: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (entry.SettingType == typeof(Color))
			{
				Color val = default(Color);
				if (!ColorUtility.TryParseHtmlString("#" + text.Trim().TrimStart('#'), ref val))
				{
					throw new FormatException();
				}
				entry.BoxedValue = val;
			}
			else if (entry.SettingType == typeof(KeyCode))
			{
				entry.BoxedValue = Enum.Parse(typeof(KeyCode), text.Trim(), ignoreCase: true);
			}
			else if (entry.SettingType == typeof(KeyboardShortcut))
			{
				string[] array = text.Split('+');
				for (int i = 0; i < array.Length; i++)
				{
					if (!Enum.TryParse<KeyCode>(array[i].Trim(), ignoreCase: true, out KeyCode result) || !Enum.IsDefined(typeof(KeyCode), result))
					{
						throw new FormatException();
					}
				}
				entry.BoxedValue = KeyboardShortcut.Deserialize(text.Trim());
			}
			else if (entry.SettingType == typeof(float))
			{
				if (!float.TryParse(text.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) || float.IsNaN(result2) || float.IsInfinity(result2))
				{
					throw new FormatException();
				}
				entry.BoxedValue = result2;
			}
			else if (entry.SettingType == typeof(int))
			{
				entry.BoxedValue = int.Parse(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
			}
			else
			{
				if (!(entry.SettingType == typeof(string)))
				{
					throw new FormatException();
				}
				entry.BoxedValue = text;
			}
			_drafts.Remove(entry);
			_error = null;
		}
		catch (Exception)
		{
			_error = UiEnvironment.L("Invalid value. The saved setting is unchanged.", "Некорректное значение. Сохранённая настройка не изменена.");
		}
	}

	private static string Root(string section)
	{
		return section.Split('.')[0];
	}

	private void OnDestroy()
	{
		_shield?.Dispose();
		if ((Object)(object)_dock != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_dock).gameObject);
		}
		_skin?.Destroy();
		if ((Object)(object)_guiSkin != (Object)null)
		{
			Object.Destroy((Object)(object)_guiSkin);
		}
	}
}
internal static class DockLayout
{
	internal readonly struct Box
	{
		internal readonly float X;

		internal readonly float Y;

		internal readonly float Width;

		internal readonly float Height;

		internal Box(float x, float y, float width, float height)
		{
			X = x;
			Y = y;
			Width = width;
			Height = height;
		}

		internal bool Overlaps(Box b)
		{
			if (X < b.X + b.Width && X + Width > b.X && Y < b.Y + b.Height)
			{
				return Y + Height > b.Y;
			}
			return false;
		}
	}

	internal static bool Find(float width, float height, float scale, int count, IReadOnlyList<Box> obstacles, out Box result)
	{
		return Find(width, height, 36f * scale, 36f * scale, 6f * scale, 12f * scale, count, obstacles, out result);
	}

	internal static bool FindRight(float width, float height, float x, float buttonWidth, float buttonHeight, float gap, float preferredTop, float margin, int count, IReadOnlyList<Box> obstacles, out Box result)
	{
		result = default(Box);
		float num = buttonHeight + gap;
		float num2 = (float)count * num - gap;
		if (count <= 0 || buttonWidth <= 0f || buttonHeight <= 0f || gap < 0f || x < 0f || x >= width || x + buttonWidth < width || num2 + 2f * margin > height)
		{
			return false;
		}
		int num3 = (int)Math.Ceiling((margin - preferredTop) / num);
		int num4 = (int)Math.Floor((height - margin - num2 - preferredTop) / num);
		List<int> list = new List<int>();
		for (int i = Math.Max(0, num3); i <= num4; i++)
		{
			list.Add(i);
		}
		for (int num5 = Math.Min(-1, num4); num5 >= num3; num5--)
		{
			list.Add(num5);
		}
		foreach (int item in list)
		{
			float y = preferredTop + (float)item * num;
			Box b = new Box(x, y, width - x, num2);
			bool flag = false;
			foreach (Box obstacle in obstacles)
			{
				if (obstacle.Overlaps(b))
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				result = new Box(x, y, buttonWidth, num2);
				return true;
			}
		}
		return false;
	}

	internal static bool Find(float width, float height, float buttonWidth, float buttonHeight, float gap, float margin, int count, IReadOnlyList<Box> obstacles, out Box result)
	{
		float num = (float)count * (buttonHeight + gap) - gap;
		result = default(Box);
		if (count <= 0 || width < buttonWidth + 2f * margin || height < num + 24f || buttonWidth <= 0f || buttonHeight <= 0f)
		{
			return false;
		}
		bool[] array = new bool[2] { true, false };
		for (int i = 0; i < array.Length; i++)
		{
			float x = (array[i] ? (width - margin - buttonWidth) : margin);
			float num2 = Math.Max(12f, Math.Min((height - num) * 0.5f, height - num - 12f));
			for (int j = 0; (float)j < height / (buttonHeight + gap) + 2f; j++)
			{
				int[] array2 = new int[2] { 1, -1 };
				foreach (int num3 in array2)
				{
					float num4 = num2 + (float)j * (buttonHeight + gap) * (float)num3;
					if (num4 < 12f || num4 + num > height - 12f)
					{
						continue;
					}
					Box box = new Box(x, num4, buttonWidth, num);
					bool flag = false;
					foreach (Box obstacle in obstacles)
					{
						if (obstacle.Overlaps(box))
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						result = box;
						return true;
					}
				}
			}
		}
		return false;
	}
}
internal static class SidebarVisibility
{
	internal static bool Show(bool desktop, bool nativeActive, bool canvasEnabled, float alpha)
	{
		if (!desktop && nativeActive && canvasEnabled)
		{
			return alpha > 0.01f;
		}
		return false;
	}
}
internal static class GameAccess
{
	private const float LookupInterval = 1f;

	private static PlayerPanelController _players;

	private static TextChannelManager _chat;

	private static UIManager _ui;

	private static float _nextPlayersLookup;

	private static float _nextChatLookup;

	private static float _nextUiLookup;

	public static PlayerPanelController PlayerPanel
	{
		get
		{
			if ((Object)(object)_players == (Object)null && Time.unscaledTime >= _nextPlayersLookup)
			{
				_nextPlayersLookup = Time.unscaledTime + 1f;
				_players = NetworkSingleton<PlayerPanelController>.I;
			}
			return _players;
		}
		set
		{
			_players = value;
		}
	}

	public static TextChannelManager Chat
	{
		get
		{
			if ((Object)(object)_chat == (Object)null && Time.unscaledTime >= _nextChatLookup)
			{
				_nextChatLookup = Time.unscaledTime + 1f;
				_chat = NetworkSingleton<TextChannelManager>.I;
			}
			return _chat;
		}
	}

	public static UIManager UI
	{
		get
		{
			if ((Object)(object)_ui == (Object)null && Time.unscaledTime >= _nextUiLookup)
			{
				_nextUiLookup = Time.unscaledTime + 1f;
				_ui = MonoSingleton<UIManager>.I;
			}
			return _ui;
		}
	}

	public static bool IsLocalPlayer(PlayerPanelController players, int index)
	{
		TextChannelManager chat = Chat;
		if ((Object)(object)chat == (Object)null || (Object)(object)chat.MainNetTransform == (Object)null)
		{
			return false;
		}
		if (index < players.PlayerTransforms.Count)
		{
			return (Object)(object)players.PlayerTransforms[index] == (Object)(object)chat.MainNetTransform;
		}
		return false;
	}

	public static string RawPlayerName(PlayerPanelController players, int index)
	{
		PlayerController val = ((index < players.PlayerControllers.Count) ? players.PlayerControllers[index] : null);
		TMP_Text val2 = (TMP_Text)(object)(((Object)(object)val != (Object)null) ? val.PlayerNameText : null);
		if (!((Object)(object)val2 != (Object)null))
		{
			return null;
		}
		return val2.text;
	}

	public static string FilterName(string name)
	{
		if (string.IsNullOrEmpty(name))
		{
			return name;
		}
		try
		{
			BadWordFilterManager i = MonoSingleton<BadWordFilterManager>.I;
			return ((Object)(object)i != (Object)null) ? i.FilterString(name) : name;
		}
		catch (Exception)
		{
			return name;
		}
	}

	public static VoiceStatus VoiceStatusOf(PlayerPanelController players, string steamId)
	{
		int num = players.PlayerSteamIDs.IndexOf(steamId);
		if (num >= 0)
		{
			DataManager i = MonoSingleton<DataManager>.I;
			List<string> list = (((Object)(object)i != (Object)null && i.BanData != null) ? i.BanData.VoiceMutedPlayers : null);
			if (list != null && list.Contains(steamId))
			{
				return (VoiceStatus)2;
			}
			if (num < players.IsVoiceChatActive.Count && players.IsVoiceChatActive[num])
			{
				PlayerController val = ((num < players.PlayerControllers.Count) ? players.PlayerControllers[num] : null);
				PlayerVoiceController val2 = (((Object)(object)val != (Object)null) ? val.PlayerVoice : null);
				if ((Object)(object)val2 != (Object)null && val2.IsSpeaking)
				{
					return (VoiceStatus)1;
				}
				return (VoiceStatus)0;
			}
			return (VoiceStatus)3;
		}
		return (VoiceStatus)3;
	}

	public static void PlayUIChange()
	{
		try
		{
			UIManager uI = UI;
			if ((Object)(object)uI != (Object)null)
			{
				uI.PlayUIChange();
			}
		}
		catch (Exception)
		{
		}
	}

	public static void PlayUIClick()
	{
		try
		{
			UIManager uI = UI;
			if ((Object)(object)uI != (Object)null)
			{
				uI.PlayUIClick();
			}
		}
		catch (Exception)
		{
		}
	}
}
internal static class GameRefs
{
	public static readonly FieldRef<PlayerPanelController, GameObject> ServerList = Field<PlayerPanelController, GameObject>("_serverPanel");

	public static readonly FieldRef<PlayerPanelController, GameObject> BannedList = Field<PlayerPanelController, GameObject>("_bannedPanel");

	public static readonly FieldRef<PlayerPanelController, RectTransform> ServerButton = Field<PlayerPanelController, RectTransform>("_serverButtonTransform");

	public static readonly FieldRef<PlayerPanelController, RectTransform> BannedButton = Field<PlayerPanelController, RectTransform>("_bannedButtonTransform");

	public static readonly FieldRef<PlayerPanelController, Color> SelectedColor = Field<PlayerPanelController, Color>("_selectedColor");

	public static readonly FieldRef<PlayerPanelController, Color> ServerColor = Field<PlayerPanelController, Color>("_serverColor");

	public static readonly FieldRef<PlayerPanelController, Color> BannedColor = Field<PlayerPanelController, Color>("_bannedColor");

	public static readonly FieldRef<PlayerPanelController, Color> GreenColor = Field<PlayerPanelController, Color>("_greenColor");

	public static readonly FieldRef<PlayerPanelController, Color> OrangeColor = Field<PlayerPanelController, Color>("_orangeColor");

	public static readonly FieldRef<PlayerPanelController, PlayerPanelType> PanelType = Field<PlayerPanelController, PlayerPanelType>("_playerPanelType");

	public static readonly FieldRef<PlayerPanelController, GameObject> ItemPrefab = Field<PlayerPanelController, GameObject>("_playerItemPrefab");

	public static readonly FieldRef<PlayerPanelController, List<PlayerItemController>> Items = Field<PlayerPanelController, List<PlayerItemController>>("_playerItemControllers");

	public static readonly FieldRef<PlayerPanelController, RectTransform> InfoPanel = Field<PlayerPanelController, RectTransform>("_buttonInfoPanelTransfrom");

	public static readonly FieldRef<PlayerPanelController, CanvasGroup> InfoGroup = Field<PlayerPanelController, CanvasGroup>("_buttonInfoPanelCanvasGroup");

	public static readonly FieldRef<PlayerPanelController, Image> InfoHeaderBg = Field<PlayerPanelController, Image>("_buttonInfoHeaderBgImage");

	public static readonly FieldRef<PlayerPanelController, TextMeshProUGUI> InfoHeader = Field<PlayerPanelController, TextMeshProUGUI>("_buttonInfoHeaderText");

	public static readonly FieldRef<PlayerPanelController, TextMeshProUGUI> InfoText = Field<PlayerPanelController, TextMeshProUGUI>("_buttonInfoText");

	public static readonly FieldRef<PlayerItemController, string> ItemSteamId = Field<PlayerItemController, string>("_playerSteamId");

	public static readonly FieldRef<PlayerItemController, TextMeshProUGUI> ItemName = Field<PlayerItemController, TextMeshProUGUI>("_playerNameText");

	public static readonly FieldRef<PlayerItemController, Button> ItemReport = Field<PlayerItemController, Button>("_reportButton");

	public static readonly FieldRef<PlayerItemController, Button> ItemBan = Field<PlayerItemController, Button>("_banButton");

	public static readonly FieldRef<PlayerItemController, Button> ItemSteam = Field<PlayerItemController, Button>("_steamButton");

	public static readonly FieldRef<PlayerItemController, Button> ItemMute = Field<PlayerItemController, Button>("_muteButton");

	public static readonly FieldRef<PlayerItemController, Button> ItemIgnore = Field<PlayerItemController, Button>("_ignoreButton");

	public static readonly FieldRef<PlayerItemController, Button> ItemVoiceMute = Field<PlayerItemController, Button>("_voiceMuteButton");

	public static readonly FieldRef<PlayerItemController, GameObject> ItemSync = Field<PlayerItemController, GameObject>("_syncButtonObject");

	public static readonly FieldRef<PlayerItemController, GameObject> ItemSyncedWithMe = Field<PlayerItemController, GameObject>("_syncWithMeObject");

	public static readonly FieldRef<PlayerItemController, Image> ItemVoiceIcon = Field<PlayerItemController, Image>("_voiceMuteImage");

	public static readonly FieldRef<PlayerItemController, Image> ItemVoiceBg = Field<PlayerItemController, Image>("_voiceMuteBgImage");

	public static readonly FieldRef<PlayerItemController, Sprite> ItemMicOpen = Field<PlayerItemController, Sprite>("_voiceChatOpen");

	public static readonly FieldRef<PlayerItemController, Sprite> ItemMicMuted = Field<PlayerItemController, Sprite>("_voiceChatMute");

	public static readonly FieldRef<SettingsController, Slider> SettingsVoiceSlider = Field<SettingsController, Slider>("_voiceVolumeSlider");

	public static TField Get<TObject, TField>(FieldRef<TObject, TField> field, TObject instance) where TObject : class
	{
		if (field == null || instance == null)
		{
			return default(TField);
		}
		return field.Invoke(instance);
	}

	private static FieldRef<TObject, TField> Field<TObject, TField>(string name)
	{
		try
		{
			return AccessTools.FieldRefAccess<TObject, TField>(name);
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("Game field " + typeof(TObject).Name + "." + name + " not found (" + ex.Message + "); some UI may be missing."));
			return null;
		}
	}
}
internal static class Icons
{
	private static Sprite _reset;

	public static Sprite Reset
	{
		get
		{
			if ((Object)(object)_reset == (Object)null)
			{
				_reset = CreateResetIcon(64);
			}
			return _reset;
		}
	}

	private static Sprite CreateResetIcon(int size)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_0045: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: 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_00a5: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Expected O, but got Unknown
		//IL_0237: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		float num = 0.6981317f;
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(Mathf.Cos(num), Mathf.Sin(num));
		Vector2 val3 = default(Vector2);
		((Vector2)(ref val3))..ctor(val2.y, 0f - val2.x);
		Vector2 val4 = val + val2 * 0.31f;
		Vector2 a = val4 + val3 * 0.17f;
		Vector2 b = val4 + val2 * 0.16f - val3 * 0.03f;
		Vector2 c = val4 - val2 * 0.16f - val3 * 0.03f;
		float num2 = 5.5850534f;
		Vector2 val5 = val + new Vector2(Mathf.Cos(num2), Mathf.Sin(num2)) * 0.31f;
		Color32[] array = (Color32[])(object)new Color32[size * size];
		Vector2 val6 = default(Vector2);
		for (int i = 0; i < size; i++)
		{
			for (int j = 0; j < size; j++)
			{
				int num3 = 0;
				for (int k = 0; k < 4; k++)
				{
					for (int l = 0; l < 4; l++)
					{
						((Vector2)(ref val6))..ctor(((float)j + ((float)l + 0.5f) / 4f) / (float)size, ((float)i + ((float)k + 0.5f) / 4f) / (float)size);
						if (!OnArc(val6, val, 0.31f, 0.11f, 40f, 320f))
						{
							Vector2 val7 = val6 - val5;
							if (!(((Vector2)(ref val7)).sqrMagnitude <= 0.003025f) && !InTriangle(val6, a, b, c))
							{
								continue;
							}
						}
						num3++;
					}
				}
				byte b2 = (byte)(255 * num3 / 16);
				array[i * size + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b2);
			}
		}
		Texture2D val8 = new Texture2D(size, size, (TextureFormat)4, false)
		{
			name = "PlayerVoiceVolume_Reset",
			filterMode = (FilterMode)1,
			wrapMode = (TextureWrapMode)1,
			hideFlags = (HideFlags)61
		};
		val8.SetPixels32(array);
		val8.Apply(false, true);
		Sprite obj = Sprite.Create(val8, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), (float)size);
		((Object)obj).name = ((Object)val8).name;
		((Object)obj).hideFlags = (HideFlags)61;
		return obj;
	}

	private static bool OnArc(Vector2 p, Vector2 center, float radius, float stroke, float startDeg, float endDeg)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = p - center;
		if (Mathf.Abs(((Vector2)(ref val)).magnitude - radius) > stroke * 0.5f)
		{
			return false;
		}
		float num = Mathf.Atan2(val.y, val.x) * 57.29578f;
		if (num < 0f)
		{
			num += 360f;
		}
		if (num >= startDeg)
		{
			return num <= endDeg;
		}
		return false;
	}

	private static bool InTriangle(Vector2 p, Vector2 a, Vector2 b, Vector2 c)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		float num = Cross(p, a, b);
		float num2 = Cross(p, b, c);
		float num3 = Cross(p, c, a);
		bool flag = num < 0f || num2 < 0f || num3 < 0f;
		bool flag2 = num > 0f || num2 > 0f || num3 > 0f;
		return !(flag && flag2);
	}

	private static float Cross(Vector2 p, Vector2 a, Vector2 b)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		return (p.x - b.x) * (a.y - b.y) - (a.x - b.x) * (p.y - b.y);
	}
}
internal sealed class ModDock : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
{
	private Func<string> _hint;

	private Func<bool> _isOpen;

	private Func<bool> _visible;

	private Image _image;

	private Image _iconImage;

	private Image _outlineImage;

	private Button _control;

	private Button _native;

	private Image _nativeBackground;

	private Image _nativeIcon;

	private Image _nativeOutline;

	private Text _tooltip;

	private RectTransform _tooltipRect;

	private Sprite _background;

	private Sprite _icon;

	private Texture2D _backgroundTexture;

	private Texture2D _iconTexture;

	private CanvasGroup _group;

	private float _nextLayout;

	private bool _hover;

	private readonly List<DockLayout.Box> _obstacles = new List<DockLayout.Box>();

	private readonly Vector3[] _corners = (Vector3[])(object)new Vector3[4];

	internal static ModDock Register(string name, string symbol, Action toggle, Func<bool> open, Func<string> hint, Func<bool> visible = null)
	{
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Expected O, but got Unknown
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: 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_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Expected O, but got Unknown
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Expected O, but got Unknown
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Expected O, but got Unknown
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_0343: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_034e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0353: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0389: Unknown result type (might be due to invalid IL or missing references)
		//IL_0398: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_042c: Expected O, but got Unknown
		//IL_0473: Unknown result type (might be due to invalid IL or missing references)
		//IL_047d: Expected O, but got Unknown
		//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a9: Expected O, but got Unknown
		//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04df: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0546: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.Find("LightShaper.ModDock.v1");
		if ((Object)(object)val == (Object)null)
		{
			val = new GameObject("LightShaper.ModDock.v1", new Type[3]
			{
				typeof(RectTransform),
				typeof(Canvas),
				typeof(GraphicRaycaster)
			});
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas component = val.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.sortingOrder = 32765;
		}
		GameObject val2 = new GameObject(name, new Type[4]
		{
			typeof(RectTransform),
			typeof(Image),
			typeof(Button),
			typeof(CanvasGroup)
		});
		val2.transform.SetParent(val.transform, false);
		ModDock modDock = val2.AddComponent<ModDock>();
		modDock._hint = hint;
		modDock._isOpen = open;
		modDock._visible = visible ?? ((Func<bool>)(() => true));
		modDock._group = val2.GetComponent<CanvasGroup>();
		modDock._group.alpha = 0f;
		((RectTransform)val2.transform).anchoredPosition = new Vector2(-10000f, -10000f);
		modDock._image = val2.GetComponent<Image>();
		modDock._backgroundTexture = RoundedTexture();
		modDock._background = Sprite.Create(modDock._backgroundTexture, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(16f, 16f, 16f, 16f));
		modDock._image.sprite = modDock._background;
		modDock._image.type = (Type)1;
		Button val3 = (modDock._control = val2.GetComponent<Button>());
		((Selectable)val3).targetGraphic = (Graphic)(object)modDock._image;
		Navigation navigation = default(Navigation);
		((Navigation)(ref navigation)).mode = (Mode)0;
		((Selectable)val3).navigation = navigation;
		ColorBlock colors = ((Selectable)val3).colors;
		((ColorBlock)(ref colors)).normalColor = Color.white;
		((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 0.88f, 0.8f);
		((ColorBlock)(ref colors)).pressedColor = new Color(0.95f, 0.8f, 0.68f);
		((Selectable)val3).colors = colors;
		((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
		{
			toggle();
			EventSystem current = EventSystem.current;
			if (current != null)
			{
				current.SetSelectedGameObject((GameObject)null);
			}
		});
		GameObject val4 = new GameObject("Outline", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val4.transform.SetParent(val2.transform, false);
		modDock._outlineImage = val4.GetComponent<Image>();
		((Graphic)modDock._outlineImage).raycastTarget = false;
		((Behaviour)modDock._outlineImage).enabled = false;
		GameObject val5 = new GameObject("Icon", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val5.transform.SetParent(val2.transform, false);
		RectTransform val6 = (RectTransform)val5.transform;
		val6.anchorMin = new Vector2(0.19f, 0.19f);
		val6.anchorMax = new Vector2(0.81f, 0.81f);
		Vector2 offsetMin = (val6.offsetMax = Vector2.zero);
		val6.offsetMin = offsetMin;
		modDock._iconTexture = IconTexture(symbol);
		modDock._icon = Sprite.Create(modDock._iconTexture, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f));
		val5.GetComponent<Image>().sprite = modDock._icon;
		((Graphic)val5.GetComponent<Image>()).color = new Color(0.67f, 0.31f, 0.24f);
		((Graphic)val5.GetComponent<Image>()).raycastTarget = false;
		val5.GetComponent<Image>().preserveAspect = true;
		modDock._iconImage = val5.GetComponent<Image>();
		GameObject val7 = new GameObject("Tooltip", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val7.transform.SetParent(val2.transform, false);
		val7.GetComponent<Image>().sprite = modDock._background;
		val7.GetComponent<Image>().type = (Type)1;
		((Graphic)val7.GetComponent<Image>()).raycastTarget = false;
		modDock._tooltipRect = (RectTransform)val7.transform;
		GameObject val8 = new GameObject("Text", new Type[2]
		{
			typeof(RectTransform),
			typeof(Text)
		});
		val8.transform.SetParent(val7.transform, false);
		RectTransform val9 = (RectTransform)val8.transform;
		val9.anchorMin = Vector2.zero;
		val9.anchorMax = Vector2.one;
		val9.offsetMin = new Vector2(10f, 4f);
		val9.offsetMax = new Vector2(-10f, -4f);
		modDock._tooltip = val8.GetComponent<Text>();
		modDock._tooltip.font = UiEnvironment.GameFont ?? Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
		modDock._tooltip.fontSize = 13;
		((Graphic)modDock._tooltip).color = UiSkin.TextColor;
		modDock._tooltip.alignment = (TextAnchor)4;
		((Graphic)modDock._tooltip).raycastTarget = false;
		modDock._tooltip.supportRichText = false;
		val7.SetActive(false);
		Transform[] array = ((IEnumerable)val.transform).Cast<Transform>().OrderBy<Transform, string>((Transform t) => ((Object)t).name, StringComparer.Ordinal).ToArray();
		for (int num = 0; num < array.Length; num++)
		{
			array[num].SetAsLastSibling();
		}
		return modDock;
	}

	private void Update()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Expected O, but got Unknown
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: 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_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		ApplyNativeStyle();
		float opacity = NativeSidebar.Opacity;
		bool flag = _visible() && opacity > 0.01f && ((RectTransform)((Component)this).transform).anchoredPosition.x > -9000f;
		_group.alpha = (flag ? opacity : 0f);
		_group.blocksRaycasts = flag;
		_group.interactable = flag;
		if (!flag)
		{
			_hover = false;
		}
		((Graphic)_image).color = (((Object)(object)_native != (Object)null) ? NativeSidebar.SurfaceColor(_hover || _isOpen()) : Color.white);
		((Graphic)_iconImage).color = (Color)(((Object)(object)_nativeOutline != (Object)null) ? ((Graphic)_nativeOutline).color : new Color(0.43f, 0.34f, 0.35f, 1f));
		if (((Component)this).transform.GetSiblingIndex() == 0 && Time.unscaledTime >= _nextLayout)
		{
			_nextLayout = Time.unscaledTime + 0.15f;
			LayoutGroup();
		}
		bool flag2 = _hover && _group.alpha > 0f && _group.blocksRaycasts;
		((Component)_tooltipRect).gameObject.SetActive(flag2);
		if (flag2)
		{
			float scale = UiEnvironment.Scale;
			_tooltip.text = _hint();
			_tooltip.fontSize = Mathf.RoundToInt(13f * scale);
			float num = Mathf.Min((float)Screen.width - 24f, Mathf.Max(140f * scale, _tooltip.preferredWidth + 24f));
			RectTransform val = (RectTransform)((Component)this).transform;
			_tooltipRect.pivot = new Vector2(1f, 0.5f);
			RectTransform tooltipRect = _tooltipRect;
			RectTransform tooltipRect2 = _tooltipRect;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0f, 0.5f);
			tooltipRect2.anchorMax = val2;
			tooltipRect.anchorMin = val2;
			_tooltipRect.sizeDelta = new Vector2(num, 32f * scale);
			float num2 = Mathf.Min((float)Screen.width - 12f, val.anchoredPosition.x - 8f);
			num2 = Mathf.Max(num + 12f, num2);
			_tooltipRect.anchoredPosition = new Vector2(num2 - val.anchoredPosition.x, 0f);
		}
	}

	private void ApplyNativeStyle()
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Invalid comparison between Unknown and I4
		//IL_005a: 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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		Button button = NativeSidebar.Button;
		if ((Object)(object)button == (Object)null)
		{
			return;
		}
		Image val = NativeSidebar.Background(button);
		if (!((Object)(object)val == (Object)null))
		{
			_native = button;
			_nativeBackground = val;
			_nativeIcon = NativeSidebar.Icon(button);
			_nativeOutline = NativeSidebar.Outline(button);
			((Selectable)_control).transition = (Transition)(((int)((Selectable)button).transition == 1) ? ((int)((Selectable)button).transition) : 0);
			((Selectable)_control).colors = ((Selectable)button).colors;
			NativeSidebar.CopyImage(_nativeBackground, _image);
			float num = NativeSidebar.PixelScale(val);
			if ((Object)(object)_nativeOutline != (Object)null)
			{
				((Behaviour)_outlineImage).enabled = true;
				NativeSidebar.CopyImage(_nativeOutline, _outlineImage);
				NativeSidebar.CopyRect(((Graphic)_nativeOutline).rectTransform, ((Graphic)_outlineImage).rectTransform, num);
			}
			else
			{
				((Behaviour)_outlineImage).enabled = false;
			}
			if ((Object)(object)_nativeIcon != (Object)null)
			{
				NativeSidebar.CopyRect(((Graphic)_nativeIcon).rectTransform, ((Graphic)_iconImage).rectTransform, num);
				Rect rect = ((Graphic)_nativeIcon).rectTransform.rect;
				float width = ((Rect)(ref rect)).width;
				rect = ((Graphic)_nativeIcon).rectTransform.rect;
				float num2 = Mathf.Min(width, ((Rect)(ref rect)).height) * num;
				((Graphic)_iconImage).rectTransform.sizeDelta = new Vector2(num2, num2);
			}
		}
	}

	private void LayoutGroup()
	{
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Invalid comparison between Unknown and I4
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: 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_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_038d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0398: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: 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_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: 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_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: 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)
		_obstacles.Clear();
		Graphic[] array = GraphicRegistryAll();
		foreach (Graphic val in array)
		{
			if (!((Behaviour)val).isActiveAndEnabled || (Object)(object)val.canvas == (Object)null || (int)val.canvas.renderMode == 2 || ((Component)val).transform.IsChildOf(((Component)this).transform.parent))
			{
				continue;
			}
			bool flag = false;
			Transform val2 = ((Component)val).transform;
			while ((Object)(object)val2 != (Object)null)
			{
				if (((Object)val2).name.IndexOf("chat", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					flag = true;
					break;
				}
				val2 = val2.parent;
			}
			if (!val.raycastTarget && !flag)
			{
				continue;
			}
			bool flag2 = ((Object)((Component)val).transform.root).name == "LightShaper.ModWindows.v1";
			if (flag2 || (!((flag ? 1f : val.color.a) * val.canvasRenderer.GetInheritedAlpha() < 0.03f) && !val.canvasRenderer.cull))
			{
				val.rectTransform.GetWorldCorners(_corners);
				Camera obj = (((int)val.canvas.renderMode == 0) ? null : val.canvas.worldCamera);
				Vector2 val3 = RectTransformUtility.WorldToScreenPoint(obj, _corners[0]);
				Vector2 val4 = RectTransformUtility.WorldToScreenPoint(obj, _corners[2]);
				Rect val5 = Rect.MinMaxRect(Mathf.Min(val3.x, val4.x), (float)Screen.height - Mathf.Max(val3.y, val4.y), Mathf.Max(val3.x, val4.x), (float)Screen.height - Mathf.Min(val3.y, val4.y));
				if (!(((Rect)(ref val5)).width > (float)Screen.width * 0.95f) || !(((Rect)(ref val5)).height > (float)Screen.height * 0.95f) || flag2)
				{
					((Rect)(ref val5)).xMin = ((Rect)(ref val5)).xMin - 6f;
					((Rect)(ref val5)).yMin = ((Rect)(ref val5)).yMin - 6f;
					((Rect)(ref val5)).xMax = ((Rect)(ref val5)).xMax + 6f;
					((Rect)(ref val5)).yMax = ((Rect)(ref val5)).yMax + 6f;
					_obstacles.Add(new DockLayout.Box(((Rect)(ref val5)).x, ((Rect)(ref val5)).y, ((Rect)(ref val5)).width, ((Rect)(ref val5)).height));
				}
			}
		}
		Transform[] array2 = (from Transform t in (IEnumerable)((Component)this).transform.parent
			where (Object)(object)((Component)t).GetComponent<Button>() != (Object)null
			select t).ToArray();
		float scale = UiEnvironment.Scale;
		Rect bounds;
		float gap;
		float preferredTop;
		bool num = NativeSidebar.TryGeometry(out bounds, out gap, out preferredTop);
		Vector2 size = ((Rect)(ref bounds)).size;
		DockLayout.Box result = default(DockLayout.Box);
		bool flag3 = num && DockLayout.FindRight(Screen.width, Screen.height, ((Rect)(ref bounds)).x, size.x, size.y, gap, preferredTop, 6f * scale, array2.Length, _obstacles, out result);
		Vector2 val7 = default(Vector2);
		for (int num2 = 0; num2 < array2.Length; num2++)
		{
			RectTransform val6 = (RectTransform)array2[num2];
			((Vector2)(ref val7))..ctor(0f, 1f);
			val6.pivot = val7;
			Vector2 anchorMin = (val6.anchorMax = val7);
			val6.anchorMin = anchorMin;
			val6.sizeDelta = size;
			val6.anchoredPosition = (flag3 ? new Vector2(result.X, 0f - result.Y - (float)num2 * (size.y + gap)) : new Vector2(-10000f, -10000f));
		}
	}

	private static Graphic[] GraphicRegistryAll()
	{
		return Object.FindObjectsByType<Graphic>((FindObjectsInactive)0, (FindObjectsSortMode)0);
	}

	public void OnPointerEnter(PointerEventData data)
	{
		_hover = true;
	}

	public void OnPointerExit(PointerEventData data)
	{
		_hover = false;
	}

	private void OnDestroy()
	{
		Object.Destroy((Object)(object)_background);
		Object.Destroy((Object)(object)_icon);
		Object.Destroy((Object)(object)_backgroundTexture);
		Object.Destroy((Object)(object)_iconTexture);
		if ((Object)(object)((Component)this).transform.parent != (Object)null && ((Component)this).transform.parent.childCount == 1)
		{
			Object.Destroy((Object)(object)((Component)((Component)this).transform.parent).gameObject);
		}
	}

	private static Texture2D RoundedTexture()
	{
		//IL_0065: 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_00a2: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		Color[] array = (Color[])(object)new Color[4096];
		for (int i = 0; i < 64; i++)
		{
			for (int j = 0; j < 64; j++)
			{
				float num = Mathf.Abs((float)j + 0.5f - 32f) - 18f;
				float num2 = Mathf.Abs((float)i + 0.5f - 32f) - 18f;
				Vector2 val = new Vector2(Mathf.Max(num, 0f), Mathf.Max(num2, 0f));
				float num3 = ((Vector2)(ref val)).magnitude + Mathf.Min(Mathf.Max(num, num2), 0f) - 14f;
				Color val2 = Color.Lerp(new Color(0.43f, 0.34f, 0.35f, 1f), new Color(1f, 0.95f, 0.86f, 1f), Mathf.Clamp01(0.5f - num3 - 4f));
				val2.a = Mathf.Clamp01(0.5f - num3);
				array[i * 64 + j] = val2;
			}
		}
		return Texture(array, 64);
	}

	private static Texture2D IconTexture(string symbol)
	{
		//IL_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_0489: Unknown result type (might be due to invalid IL or missing references)
		//IL_048d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0494: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_04be: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_053f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0544: Unknown result type (might be due to invalid IL or missing references)
		List<Vector4> lines = new List<Vector4>();
		switch (symbol)
		{
		case "camera":
			Box(4f, 9f, 24f, 17f);
			Box(10f, 5f, 10f, 4f);
			Circle(lines, 16f, 17f, 6f);
			break;
		case "sound":
			Box(4f, 13f, 6f, 8f);
			Line(10f, 13f, 17f, 7f);
			Line(17f, 7f, 17f, 26f);
			Line(17f, 26f, 10f, 21f);
			Line(22f, 11f, 26f, 15f);
			Line(26f, 15f, 26f, 19f);
			Line(26f, 19f, 22f, 23f);
			break;
		case "range":
			Circle(lines, 16f, 16f, 11f);
			Line(16f, 2f, 16f, 9f);
			Line(16f, 23f, 16f, 30f);
			Line(2f, 16f, 9f, 16f);
			Line(23f, 16f, 30f, 16f);
			break;
		case "voice":
			Box(12f, 4f, 8f, 17f);
			Line(7f, 16f, 7f, 23f);
			Line(7f, 23f, 25f, 23f);
			Line(25f, 23f, 25f, 16f);
			Line(16f, 23f, 16f, 29f);
			Line(10f, 29f, 22f, 29f);
			break;
		case "move":
			Line(16f, 29f, 16f, 3f);
			Line(16f, 3f, 10f, 9f);
			Line(16f, 3f, 22f, 9f);
			Line(16f, 29f, 10f, 23f);
			Line(16f, 29f, 22f, 23f);
			Line(3f, 16f, 29f, 16f);
			Line(3f, 16f, 9f, 10f);
			Line(3f, 16f, 9f, 22f);
			Line(29f, 16f, 23f, 10f);
			Line(29f, 16f, 23f, 22f);
			break;
		default:
			Box(4f, 5f, 24f, 18f);
			Line(9f, 23f, 9f, 28f);
			Line(9f, 28f, 15f, 23f);
			Line(10f, 11f, 22f, 11f);
			Line(10f, 17f, 18f, 17f);
			break;
		}
		Color[] array = (Color[])(object)new Color[1024];
		Vector2 val = default(Vector2);
		Vector2 val2 = default(Vector2);
		for (int i = 0; i < 32; i++)
		{
			for (int j = 0; j < 32; j++)
			{
				((Vector2)(ref val))..ctor((float)j + 0.5f, 31.5f - (float)i);
				float num = 100f;
				foreach (Vector4 item in lines)
				{
					((Vector2)(ref val2))..ctor(item.x, item.y);
					Vector2 val3 = new Vector2(item.z, item.w) - val2;
					float num2 = num;
					Vector2 val4 = val - val2 - val3 * Mathf.Clamp01(Vector2.Dot(val - val2, val3) / ((Vector2)(ref val3)).sqrMagnitude);
					num = Mathf.Min(num2, ((Vector2)(ref val4)).magnitude);
				}
				array[i * 32 + j] = new Color(1f, 1f, 1f, Mathf.Clamp01(2.2f - num));
			}
		}
		return Texture(array);
		void Box(float x, float y, float w, float h)
		{
			Line(x, y, x + w, y);
			Line(x + w, y, x + w, y + h);
			Line(x + w, y + h, x, y + h);
			Line(x, y + h, x, y);
		}
		void Line(float x, float y, float a, float b)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			lines.Add(new Vector4(x, y, a, b));
		}
	}

	private static void Circle(List<Vector4> lines, float x, float y, float radius)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < 32; i++)
		{
			float num = (float)i * MathF.PI / 16f;
			float num2 = (float)(i + 1) * MathF.PI / 16f;
			lines.Add(new Vector4(x + Mathf.Cos(num) * radius, y + Mathf.Sin(num) * radius, x + Mathf.Cos(num2) * radius, y + Mathf.Sin(num2) * radius));
		}
	}

	private static Texture2D Texture(Color[] pixels, int size = 32)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
		{
			hideFlags = (HideFlags)61,
			filterMode = (FilterMode)1,
			wrapMode = (TextureWrapMode)1
		};
		val.SetPixels(pixels);
		val.Apply(false, true);
		return val;
	}
}
internal static class NativeSidebar
{
	private static readonly FieldInfo RightButtons = AccessTools.Field(typeof(OverlayManager), "_rightTopButtons");

	private static readonly FieldInfo IdleColor = AccessTools.Field(typeof(UIManager), "_extraButtonColor");

	private static readonly FieldInfo HoverColor = AccessTools.Field(typeof(UIManager), "_extraButtonHoverColor");

	private static UIManager _ui;

	private static OverlayManager _overlay;

	private static Button _button;

	private static float _retry;

	private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4];

	internal static Button Button
	{
		get
		{
			if (((Object)(object)_overlay == (Object)null || (Object)(object)_button == (Object)null) && Time.unscaledTime >= _retry)
			{
				_retry = Time.unscaledTime + 0.5f;
				_overlay = Object.FindAnyObjectByType<OverlayManager>();
				if ((Object)(object)_overlay != (Object)null && RightButtons?.GetValue(_overlay) is List<GameObject> list)
				{
					foreach (GameObject item in list)
					{
						if ((Object)(object)item == (Object)null)
						{
							continue;
						}
						Button componentInChildren = item.GetComponentInChildren<Button>(true);
						if (!((Object)(object)componentInChildren == (Object)null))
						{
							Image obj = Background(componentInChildren);
							if (!((Object)(object)((obj != null) ? obj.sprite : null) == (Object)null))
							{
								_button = componentInChildren;
								break;
							}
						}
					}
				}
			}
			return _button;
		}
	}

	internal static float Opacity
	{
		get
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			Button button = Button;
			Image val = Background(button);
			if ((Object)(object)_overlay == (Object)null || (Object)(object)button == (Object)null || (Object)(object)val == (Object)null)
			{
				return 0f;
			}
			Canvas canvas = ((Graphic)val).canvas;
			float inheritedAlpha = ((Graphic)val).canvasRenderer.GetInheritedAlpha();
			if (!SidebarVisibility.Show((int)_overlay.ResolutionMode == 3, ((Component)button).gameObject.activeInHierarchy, (Object)(object)canvas != (Object)null && ((Behaviour)canvas).isActiveAndEnabled, inheritedAlpha))
			{
				return 0f;
			}
			return inheritedAlpha;
		}
	}

	internal static Vector2 Size
	{
		get
		{
			//IL_002d: 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_0049: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			Button button = Button;
			Image val = Background(button);
			if ((Object)(object)button == (Object)null || (Object)(object)val == (Object)null || (Object)(object)((Graphic)val).canvas == (Object)null)
			{
				return Vector2.zero;
			}
			Rect val2 = ScreenRect((RectTransform)((Component)button).transform, ((Graphic)val).canvas);
			return ((Rect)(ref val2)).size;
		}
	}

	internal static Image Background(Button button)
	{
		object obj;
		if (!((Object)(object)button == (Object)null))
		{
			obj = ((Component)button).GetComponent<Image>();
			if (obj == null)
			{
				Graphic targetGraphic = ((Selectable)button).targetGraphic;
				return (Image)(object)((targetGraphic is Image) ? targetGraphic : null);
			}
		}
		else
		{
			obj = null;
		}
		return (Image)obj;
	}

	internal static Image Outline(Button button)
	{
		if (!((Object)(object)button == (Object)null))
		{
			Transform obj = ((Component)button).transform.Find("Image_Outline");
			if (obj == null)
			{
				return null;
			}
			return ((Component)obj).GetComponent<Image>();
		}
		return null;
	}

	internal static Image Icon(Button button)
	{
		if (!((Object)(object)button == (Object)null))
		{
			Transform obj = ((Component)button).transform.Find("Image_Icon");
			if (obj == null)
			{
				return null;
			}
			return ((Component)obj).GetComponent<Image>();
		}
		return null;
	}

	internal static Color SurfaceColor(bool highlighted)
	{
		//IL_0075: 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_0054: 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)
		if ((Object)(object)_ui == (Object)null)
		{
			_ui = Object.FindAnyObjectByType<UIManager>();
		}
		FieldInfo fieldInfo = (highlighted ? HoverColor : IdleColor);
		if ((Object)(object)_ui != (Object)null)
		{
			object obj = fieldInfo?.GetValue(_ui);
			if (obj is Color)
			{
				return (Color)obj;
			}
		}
		return new Color(0.9608f, 0.9294f, 0.8824f, highlighted ? 1f : 0.749f);
	}

	internal static Rect ScreenRect(RectTransform rect, Canvas canvas)
	{
		//IL_000c: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: 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_006e: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		rect.GetWorldCorners(Corners);
		Camera obj = (((int)canvas.renderMode == 0) ? null : canvas.worldCamera);
		Vector2 val = RectTransformUtility.WorldToScreenPoint(obj, Corners[0]);
		Vector2 val2 = RectTransformUtility.WorldToScreenPoint(obj, Corners[2]);
		return Rect.MinMaxRect(Mathf.Min(val.x, val2.x), (float)Screen.height - Mathf.Max(val.y, val2.y), Mathf.Max(val.x, val2.x), (float)Screen.height - Mathf.Min(val.y, val2.y));
	}

	internal static float PixelScale(Image image)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		Rect val = ScreenRect(((Graphic)image).rectTransform, ((Graphic)image).canvas);
		float height = ((Rect)(ref val)).height;
		val = ((Graphic)image).rectTransform.rect;
		return height / Mathf.Max(1f, ((Rect)(ref val)).height);
	}

	internal static void CopyImage(Image source, Image target)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		target.sprite = source.sprite;
		target.type = source.type;
		((Graphic)target).material = ((Graphic)source).material;
		((Graphic)target).color = ((Graphic)source).color;
		target.preserveAspect = source.preserveAspect;
		target.fillCenter = source.fillCenter;
		((MaskableGraphic)target).maskable = ((MaskableGraphic)source).maskable;
		float num = ((Graphic)target).canvas.referencePixelsPerUnit / ((Graphic)source).canvas.referencePixelsPerUnit;
		target.pixelsPerUnitMultiplier = source.pixelsPerUnitMultiplier * num / Mathf.Max(0.01f, PixelScale(source));
	}

	internal static void CopyRect(RectTransform source, RectTransform target, float scale)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		target.anchorMin = source.anchorMin;
		target.anchorMax = source.anchorMax;
		target.pivot = source.pivot;
		target.sizeDelta = source.sizeDelta * scale;
		target.anchoredPosition = source.anchoredPosition * scale;
		((Transform)target).localScale = ((Transform)source).localScale;
		((Transform)target).localRotation = ((Transform)source).localRotation;
	}

	internal static bool TryGeometry(out Rect bounds, out float gap, out float preferredTop)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Expected O, but got Unknown
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Expected O, but got Unknown
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		bounds = default(Rect);
		gap = (preferredTop = 0f);
		Button button = Button;
		Image val = Background(button);
		if ((Object)(object)val == (Object)null || (Object)(object)((Graphic)val).canvas == (Object)null)
		{
			return false;
		}
		bounds = ScreenRect((RectTransform)((Component)button).transform, ((Graphic)val).canvas);
		if (((Rect)(ref bounds)).width < 1f || ((Rect)(ref bounds)).height < 1f)
		{
			return false;
		}
		float num = float.MaxValue;
		float num2 = ((Rect)(ref bounds)).y;
		if ((Object)(object)_overlay != (Object)null && RightButtons?.GetValue(_overlay) is List<GameObject> list)
		{
			foreach (GameObject item in list)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				Button[] componentsInChildren = item.GetComponentsInChildren<Button>(true);
				foreach (Button val2 in componentsInChildren)
				{
					Image val3 = Background(val2);
					if (!((Component)val2).gameObject.activeInHierarchy || (Object)(object)val3 == (Object)null || (Object)(object)((Graphic)val3).canvas == (Object)null || (Object)(object)val3.sprite != (Object)(object)val.sprite)
					{
						continue;
					}
					Rect val4 = ScreenRect((RectTransform)((Component)val2).transform, ((Graphic)val3).canvas);
					if (!(Mathf.Abs(((Rect)(ref val4)).x - ((Rect)(ref bounds)).x) > ((Rect)(ref bounds)).height * 0.15f) && !(Mathf.Abs(((Rect)(ref val4)).height - ((Rect)(ref bounds)).height) > ((Rect)(ref bounds)).height * 0.15f))
					{
						num2 = Mathf.Max(num2, ((Rect)(ref val4)).y);
						float num3 = Mathf.Abs(((Rect)(ref val4)).y - ((Rect)(ref bounds)).y);
						if (num3 > ((Rect)(ref bounds)).height)
						{
							num = Mathf.Min(num, num3);
						}
					}
				}
			}
		}
		gap = ((num < float.MaxValue) ? (num - ((Rect)(ref bounds)).height) : (((Rect)(ref bounds)).height * 0.35f));
		preferredTop = num2 + ((Rect)(ref bounds)).height + gap;
		return true;
	}
}
internal static class Patches
{
	public static void Apply(Harmony harmony)
	{
		Postfix(harmony, "Start", "PlayerListStarted");
		Postfix(harmony, "ButtonServer", "ServerTabSelected");
		Postfix(harmony, "ButtonBanned", "BannedTabSelected");
		Postfix(harmony, "ButtonClosePanel", "PlayerListClosed");
		Postfix(harmony, "UpdateServerPanelOnChange", "PlayersChanged");
	}

	private static void Postfix(Harmony harmony, string method, string patch)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		try
		{
			MethodInfo methodInfo = AccessTools.Method(typeof(PlayerPanelController), method, (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				Plugin.Log.LogWarning((object)("PlayerPanelController." + method + " not found; the Voice tab may not work."));
			}
			else
			{
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), patch, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}
		catch (Exception arg)
		{
			Plugin.Log.LogError((object)$"Could not patch PlayerPanelController.{method}: {arg}");
		}
	}

	private static void PlayerListStarted(PlayerPanelController __instance)
	{
		Run(delegate
		{
			GameAccess.PlayerPanel = __instance;
			VoiceTab.EnsureInjected(__instance);
		});
	}

	private static void ServerTabSelected(PlayerPanelController __instance)
	{
		Run(delegate
		{
			GameTabSelected(__instance, GameRefs.Get<PlayerPanelController, RectTransform>(GameRefs.ServerButton, __instance));
		});
	}

	private static void BannedTabSelected(PlayerPanelController __instance)
	{
		Run(delegate
		{
			GameTabSelected(__instance, GameRefs.Get<PlayerPanelController, RectTransform>(GameRefs.BannedButton, __instance));
		});
	}

	private static void GameTabSelected(PlayerPanelController players, RectTransform button)
	{
		VoiceTab.EnsureInjected(players);
		VoiceTab current = VoiceTab.Current;
		if ((Object)(object)current != (Object)null && (Object)(object)current.Panel == (Object)(object)players)
		{
			current.OnGameTabSelected(button);
		}
	}

	private static void PlayerListClosed()
	{
		Run(delegate
		{
			Plugin.Instance.Store.Save();
		});
	}

	private static void PlayersChanged()
	{
		Run(delegate
		{
			VoiceTab current = VoiceTab.Current;
			if ((Object)(object)current != (Object)null)
			{
				current.MarkPlayersChanged();
			}
		});
	}

	private static void Run(Action action)
	{
		try
		{
			action();
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)("Player list hook failed: " + ex));
		}
	}
}
[BepInPlugin("ontogether.playervoicevolume", "PlayerVoiceVolume", "1.1.2")]
[BepInProcess("OnTogether.exe")]
public sealed class Plugin : BaseUnityPlugin
{
	public const string PluginGuid = "ontogether.playervoicevolume";

	public const string PluginName = "PlayerVoiceVolume";

	public const string PluginVersion = "1.1.2";

	internal ConfigEntry<int> MaxVolume;

	internal ConfigEntry<int> DefaultVolume;

	private VoiceApplier _applier;

	private Harmony _harmony;

	internal static Plugin Instance { get; private set; }

	internal static ManualLogSource Log { get; private set; }

	internal VolumeStore Store { get; private set; }

	private void Awake()
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		MaxVolume = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxVolumePercent", 200, new ConfigDescription("Right end of the per-player volume slider, in percent. 100% leaves a player unchanged; every doubling is +10 dB, so 200% sounds about twice as loud. Values above 200% can distort loud voices.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(100, 400), Array.Empty<object>()));
		DefaultVolume = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DefaultVolumePercent", 100, new ConfigDescription("Volume of players you have not adjusted, in percent. The reset button on a player returns them to this value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 400), Array.Empty<object>()));
		Store = new VolumeStore(Path.Combine(Paths.ConfigPath, "ontogether.playervoicevolume.volumes.json"));
		Store.Load();
		_applier = new VoiceApplier();
		ConfigMenu.Create(((Component)this).gameObject, "PlayerVoiceVolume", "voice", ((BaseUnityPlugin)this).Config, () => (Object)(object)GameAccess.PlayerPanel != (Object)null).ExtraControls = delegate
		{
			GUILayout.Label(UiEnvironment.L("Per-player volume: Tab → Voice", "Громкость игроков: Tab → Голос"), Array.Empty<GUILayoutOption>());
		};
		_harmony = new Harmony("ontogether.playervoicevolume");
		UiEnvironment.InstallInputGuard(_harmony);
		Patches.Apply(_harmony);
		((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged;
		Log.LogInfo((object)string.Format("{0} {1} loaded; {2} saved player volume(s).", "PlayerVoiceVolume", "1.1.2", Store.Count));
	}

	private void Update()
	{
		_applier.Tick();
		Store.SaveIfDue();
	}

	internal int VolumeFor(string steamId)
	{
		int percent;
		return Mathf.Clamp(Store.TryGet(steamId, out percent) ? percent : DefaultVolume.Value, 0, MaxVolume.Value);
	}

	internal bool HasSavedVolume(string steamId)
	{
		int percent;
		return Store.TryGet(steamId, out percent);
	}

	internal void SetVolume(string steamId, string playerName, int percent)
	{
		Store.Set(steamId, playerName, percent);
		_applier.ApplySoon();
	}

	internal void ResetVolume(string steamId)
	{
		Store.Remove(steamId);
		_applier.ApplySoon();
	}

	private void OnSettingChanged(object sender, SettingChangedEventArgs e)
	{
		_applier.ApplySoon();
		VoiceTab current = VoiceTab.Current;
		if ((Object)(object)current != (Object)null)
		{
			current.RefreshVolumes();
		}
	}

	private void OnApplicationQuit()
	{
		Store.Save();
	}

	private void OnDestroy()
	{
		((BaseUnityPlugin)this).Config.SettingChanged -= OnSettingChanged;
		Store.Save();
		if (_harmony != null)
		{
			_harmony.UnpatchSelf();
		}
	}
}
internal static class Strings
{
	private static string _language = "en";

	public static string Tab => Pick("Voice", "Голос", "Voix", "Voz", "Voz", "ボイス", "语音");

	public static string Hint => Pick("only for you", "только для вас", "pour vous seulement", "solo para ti", "só para você", "自分にだけ反映", "仅对你生效");

	public static string NoPlayers => Pick("No other players here yet.", "Других игроков пока нет.", "Aucun autre joueur ici pour l'instant.", "Todavía no hay otros jugadores aquí.", "Ainda não há outros jogadores aqui.", "まだ他のプレイヤーはいません。", "这里还没有其他玩家。");

	public static string ResetTitle => Pick("Reset Volume", "Сбросить громкость", "Réinitialiser le volume", "Restablecer volumen", "Redefinir volume", "音量をリセット", "重置音量");

	public static string ResetInfo => Pick("Set this player's volume back to {0}.", "Вернуть громкость этого игрока к {0}.", "Remettre le volume de ce joueur à {0}.", "Devuelve el volumen de este jugador a {0}.", "Volta o volume deste jogador para {0}.", "このプレイヤーの音量を{0}に戻します。", "将该玩家的音量恢复为{0}。");

	public static string Header => GameString("VoiceVolume") ?? Pick("Voice Volume", "Громкость голоса", "Volume de la voix", "Volumen de voz", "Volume da voz", "ボイス音量", "语音音量");

	public static void Refresh()
	{
		try
		{
			_language = CurrentLanguage() ?? "en";
		}
		catch (Exception)
		{
			_language = "en";
		}
	}

	private static string CurrentLanguage()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		Locale selectedLocale = LocalizationSettings.SelectedLocale;
		object obj;
		if (!((Object)(object)selectedLocale != (Object)null))
		{
			obj = null;
		}
		else
		{
			LocaleIdentifier identifier = selectedLocale.Identifier;
			obj = ((LocaleIdentifier)(ref identifier)).Code;
		}
		string text = (string)obj;
		if (string.IsNullOrEmpty(text))
		{
			return null;
		}
		int num = text.IndexOfAny(new char[2] { '-', '_' });
		return ((num > 0) ? text.Substring(0, num) : text).ToLowerInvariant();
	}

	private static string GameString(string key)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			string localizedString = LocalizationSettings.StringDatabase.GetLocalizedString(TableReference.op_Implicit("General"), TableEntryReference.op_Implicit(key), (Locale)null, (FallbackBehavior)0, Array.Empty<object>());
			if (string.IsNullOrEmpty(localizedString) || localizedString.StartsWith("No translation", StringComparison.OrdinalIgnoreCase))
			{
				return null;
			}
			return localizedString;
		}
		catch (Exception)
		{
			return null;
		}
	}

	private static string Pick(string en, string ru, string fr, string es, string pt, string ja, string zh)
	{
		return _language switch
		{
			"ru" => ru, 
			"fr" => fr, 
			"es" => es, 
			"pt" => pt, 
			"ja" => ja, 
			"zh" => zh, 
			_ => en, 
		};
	}
}
internal static class UiEnvironment
{
	internal const string DockName = "LightShaper.ModDock.v1";

	internal const string WindowName = "LightShaper.ModWindows.v1";

	private static GameObject _windows;

	private static Font _font;

	private static float _fontRetry;

	private static CanvasScaler _gameScaler;

	private static float _scaleRetry;

	private static readonly FieldInfo[] Inputs = (from f in typeof(InputManager).GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
		where f.Name.StartsWith("<") && f.Name.EndsWith(">k__BackingField") && (f.FieldType == typeof(bool) || f.FieldType == typeof(float))
		select f).ToArray();

	internal static Func<bool> LanguageOverride { get; set; }

	internal static bool Russian
	{
		get
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (LanguageOverride != null)
			{
				return LanguageOverride();
			}
			try
			{
				Locale selectedLocale = LocalizationSettings.SelectedLocale;
				int result;
				if (selectedLocale == null)
				{
					result = 0;
				}
				else
				{
					LocaleIdentifier identifier = selectedLocale.Identifier;
					result = ((((LocaleIdentifier)(ref identifier)).Code?.StartsWith("ru", StringComparison.OrdinalIgnoreCase) == true) ? 1 : 0);
				}
				return (byte)result != 0;
			}
			catch
			{
				return false;
			}
		}
	}

	internal static Font GameFont
	{
		get
		{
			if ((Object)(object)_font == (Object)null && Time.unscaledTime >= _fontRetry)
			{
				_fontRetry = Time.unscaledTime + 2f;
				_font = Resources.FindObjectsOfTypeAll<TMP_Text>().Select(delegate(TMP_Text t)
				{
					TMP_FontAsset font = t.font;
					return (font == null) ? null : font.sourceFontFile;
				}).FirstOrDefault((Func<Font, bool>)((Font f) => (Object)(object)f != (Object)null));
			}
			return _font;
		}
	}

	internal static float Scale
	{
		get
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Invalid comparison between Unknown and I4
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Invalid comparison between Unknown and I4
			if ((Object)(object)_gameScaler == (Object)null && Time.unscaledTime >= _scaleRetry)
			{
				_scaleRetry = Time.unscaledTime + 2f;
				_gameScaler = ((IEnumerable<CanvasScaler>)Object.FindObjectsByType<CanvasScaler>((FindObjectsInactive)0, (FindObjectsSortMode)0)).FirstOrDefault((Func<CanvasScaler, bool>)delegate(CanvasScaler s)
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: Invalid comparison between Unknown and I4
					Canvas component = ((Component)s).GetComponent<Canvas>();
					return component == null || (int)component.renderMode != 2;
				});
			}
			float num = 1f;
			if ((Object)(object)_gameScaler != (Object)null)
			{
				if ((int)_gameScaler.uiScaleMode == 0)
				{
					num = _gameScaler.scaleFactor;
				}
				else if ((int)_gameScaler.uiScaleMode == 1)
				{
					Vector2 referenceResolution = _gameScaler.referenceResolution;
					float num2 = (float)Screen.width / Mathf.Max(1f, referenceResolution.x);
					float num3 = (float)Screen.height / Mathf.Max(1f, referenceResolution.y);
					float num4 = (((int)_gameScaler.screenMatchMode == 1) ? Mathf.Min(num2, num3) : (((int)_gameScaler.screenMatchMode == 2) ? Mathf.Max(num2, num3) : Mathf.Pow(2f, Mathf.Lerp(Mathf.Log(num2, 2f), Mathf.Log(num3, 2f), _gameScaler.matchWidthOrHeight))));
					num = ((Component)_gameScaler).GetComponent<Canvas>().scaleFactor / Mathf.Max(0.01f, num4);
				}
			}
			return Mathf.Min(Mathf.Clamp((float)Screen.height / 1080f, 0.65f, 3f) * Mathf.Clamp(num, 0.5f, 2f), Mathf.Max(0.3f, (float)Screen.width / 360f));
		}
	}

	internal static bool PreviewRendering
	{
		get
		{
			object data = AppDomain.CurrentDomain.GetData("LightShaper.PreviewRendering.v1");
			bool flag = default(bool);
			int num;
			if (data is bool)
			{
				flag = (bool)data;
				num = 1;
			}
			else
			{
				num = 0;
			}
			return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
		}
	}

	internal static bool AnyWindowOpen
	{
		get
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_windows == (Object)null)
			{
				_windows = GameObject.Find("LightShaper.ModWindows.v1");
			}
			if ((Object)(object)_windows == (Object)null)
			{
				return false;
			}
			foreach (Transform item in _windows.transform)
			{
				if (((Component)item).gameObject.activeSelf)
				{
					return true;
				}
			}
			return false;
		}
	}

	internal static GameObject Windows
	{
		get
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			if ((Object)(object)_windows == (Object)null)
			{
				_windows = GameObject.Find("LightShaper.ModWindows.v1");
			}
			if ((Object)(object)_windows == (Object)null)
			{
				_windows = new GameObject("LightShaper.ModWindows.v1");
				Object.DontDestroyOnLoad((Object)(object)_windows);
			}
			return _windows;
		}
	}

	internal static string L(string en, string ru)
	{
		if (!Russian)
		{
			return en;
		}
		return ru;
	}

	internal static void InstallInputGuard(Harmony harmony)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		harmony.Patch((MethodBase)AccessTools.Method(typeof(InputManager), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(UiEnvironment), "BlockGameInput", (Type[])null)
		{
			priority = 0
		}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	private static void BlockGameInput(InputManager __instance)
	{
		if (AnyWindowOpen)
		{
			FieldInfo[] inputs = Inputs;
			foreach (FieldInfo fieldInfo in inputs)
			{
				fieldInfo.SetValue(__instance, (fieldInfo.FieldType == typeof(bool)) ? ((object)false) : ((object)0f));
			}
		}
	}
}
internal sealed class WindowInputShield : IDisposable
{
	private GameObject _host;

	private RectTransform _panel;

	internal WindowInputShield(string name)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Expected O, but got Unknown
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Expected O, but got Unknown
		//IL_00fc: 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_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		_host = new GameObject(name, new Type[3]
		{
			typeof(RectTransform),
			typeof(Canvas),
			typeof(GraphicRaycaster)
		});
		_host.transform.SetParent(UiEnvironment.Windows.transform, false);
		Canvas component = _host.GetComponent<Canvas>();
		component.renderMode = (RenderMode)0;
		component.sortingOrder = 32760;
		GameObject val = new GameObject("Window", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val.transform.SetParent(_host.transform, false);
		((Graphic)val.GetComponent<Image>()).color = Color.clear;
		_panel = (RectTransform)val.transform;
		RectTransform panel = _panel;
		RectTransform panel2 = _panel;
		RectTransform panel3 = _panel;
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(0f, 1f);
		panel3.pivot = val2;
		panel.anchorMin = (panel2.anchorMax = val2);
		_host.SetActive(false);
	}

	internal void Set(bool open)
	{
		if ((Object)(object)_host != (Object)null)
		{
			_host.SetActive(open);
		}
	}

	internal void Place(Rect rect, float scale)
	{
		//IL_0019: 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_0031: Unknown result type (might be due to invalid IL or missing references)
		_panel.anchoredPosition = new Vector2(((Rect)(ref rect)).x * scale, (0f - ((Rect)(ref rect)).y) * scale);
		_panel.sizeDelta = ((Rect)(ref rect)).size * scale;
	}

	public void Dispose()
	{
		if ((Object)(object)_host != (Object)null)
		{
			Object.Destroy((Object)(object)_host);
		}
	}
}
internal static class UiLabels
{
	private static readonly Dictionary<string, string[]> Names = new Dictionary<string, string[]>
	{
		["General"] = new string[2] { "General", "Общее" },
		["Range"] = new string[2] { "Range", "Радиус" },
		["Appearance"] = new string[2] { "Appearance", "Вид" },
		["Quality"] = new string[2] { "Quality", "Качество" },
		["Orbit"] = new string[2] { "Orbit", "Обзор" },
		["Lens"] = new string[2] { "Lens", "Объектив" },
		["FreeCamera"] = new string[2] { "Free camera", "Свободная камера" },
		["Screenshots"] = new string[2] { "Screenshots", "Снимки" },
		["FreeCamera.Keys"] = new string[2] { "Movement keys", "Клавиши движения" },
		["Enabled"] = new string[2] { "Enabled", "Включено" },
		["ToggleKey"] = new string[2] { "Toggle key", "Клавиша переключения" },
		["VisibilityMode"] = new string[2] { "Show range", "Показывать радиус" },
		["HighlightPlayersInRange"] = new string[2] { "Mark nearby players", "Отмечать игроков рядом" },
		["AutoDetectRadius"] = new string[2] { "Detect radius", "Определять радиус" },
		["Radius"] = new string[2] { "Radius (m)", "Радиус (м)" },
		["FillColor"] = new string[2] { "Area color", "Цвет области" },
		["OutlineColor"] = new string[2] { "Edge color", "Цвет границы" },
		["OutlineWidth"] = new string[2] { "Edge width (m)", "Ширина границы (м)" },
		["OutlineOnTop"] = new string[2] { "Edge above objects", "Граница поверх объектов" },
		["PlayerMarkerColor"] = new string[2] { "Player marker", "Метки игроков" },
		["Segments"] = new string[2] { "Circle detail", "Детализация круга" },
		["Rings"] = new string[2] { "Surface samples", "Слои поверхности" },
		["EdgeRefineSteps"] = new string[2] { "Edge detail", "Уточнение границы" },
		["UpdateInterval"] = new string[2] { "Update interval (s)", "Интервал обновления (с)" },
		["MaxStepUp"] = new string[2] { "Max step height (m)", "Высота ступени (м)" },
		["SurfaceOffset"] = new string[2] { "Surface offset (m)", "Отступ от земли (м)" },
		["MinDistance"] = new string[2] { "Near limit (m)", "Ближний предел (м)" },
		["MaxDistance"] = new string[2] { "Far limit (m)", "Дальний предел (м)" },
		["MinPitch"] = new string[2] { "Lower angle (°)", "Нижний угол (°)" },
		["MaxPitch"] = new string[2] { "Upper angle (°)", "Верхний угол (°)" },
		["ZoomStepPercent"] = new string[2] { "Zoom step (%)", "Шаг приближения (%)" },
		["TiltSensitivity"] = new string[2] { "Tilt sensitivity", "Чувствительность наклона" },
		["CameraCollision"] = new string[2] { "Camera collisions", "Столкновения камеры" },
		["FieldOfView"] = new string[2] { "Field of view (0 = game)", "Поле зрения (0 = игра)" },
		["ShiftWheelChangesFov"] = new string[2] { "Shift + wheel: FOV", "Shift + колесо: поле зрения" },
		["Speed"] = new string[2] { "Speed (m/s)", "Скорость (м/с)" },
		["FastMultiplier"] = new string[2] { "Fast multiplier", "Ускорение" },
		["SlowMultiplier"] = new string[2] { "Slow multiplier", "Замедление" },
		["LookSensitivity"] = new string[2] { "Look sensitivity", "Чувствительность мыши" },
		["InvertY"] = new string[2] { "Invert Y", "Инверсия Y" },
		["Smoothing"] = new string[2] { "Smoothing", "Сглаживание" },
		["HideUiWhileFlying"] = new string[2] { "Hide UI in flight", "Скрывать интерфейс в полёте" },
		["Forward"] = new string[2] { "Forward", "Вперёд" },