Decompiled source of LethalOddyseyMenu v1.0.0

LethalOddysey.MainMenu.dll

Decompiled 15 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("LethalOddysey.MainMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalOddysey.MainMenu")]
[assembly: AssemblyTitle("LethalOddysey.MainMenu")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalOddysey.MainMenu
{
	internal class EmberField : MonoBehaviour
	{
		private class Spark
		{
			public RectTransform Rect;

			public Image Image;

			public float Speed;

			public float DriftPhase;

			public float DriftSpeed;

			public float TwinklePhase;

			public float TwinkleSpeed;

			public float BaseAlpha;

			public float Width;

			public float Height;
		}

		private Spark[] _sparks;

		private RectTransform _bounds;

		public void Init(RectTransform bounds, Sprite sparkSprite, int count, Color[] palette)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			_bounds = bounds;
			_sparks = new Spark[count];
			for (int i = 0; i < count; i++)
			{
				GameObject val = new GameObject("Spark" + i, new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val.transform.SetParent(((Component)this).transform, false);
				Image component = val.GetComponent<Image>();
				component.sprite = sparkSprite;
				((Graphic)component).raycastTarget = false;
				float num = Random.Range(3f, 8f);
				float num2 = Random.Range(0.12f, 0.45f);
				Color val2 = palette[Random.Range(0, palette.Length)];
				((Graphic)component).color = new Color(val2.r, val2.g, val2.b, num2);
				RectTransform component2 = val.GetComponent<RectTransform>();
				component2.sizeDelta = new Vector2(num, num);
				Spark obj = new Spark
				{
					Rect = component2,
					Image = component,
					Speed = Random.Range(6f, 18f),
					DriftPhase = Random.Range(0f, (float)Math.PI * 2f),
					DriftSpeed = Random.Range(0.15f, 0.4f),
					TwinklePhase = Random.Range(0f, (float)Math.PI * 2f),
					TwinkleSpeed = Random.Range(0.3f, 0.9f),
					BaseAlpha = num2
				};
				Rect rect = bounds.rect;
				obj.Width = ((Rect)(ref rect)).width;
				rect = bounds.rect;
				obj.Height = ((Rect)(ref rect)).height;
				Spark spark = obj;
				PlaceRandom(spark, anyHeight: true);
				_sparks[i] = spark;
			}
		}

		private void PlaceRandom(Spark s, bool anyHeight)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			float num = Random.Range((0f - s.Width) * 0.5f, s.Width * 0.5f);
			float num2 = (anyHeight ? Random.Range((0f - s.Height) * 0.5f, s.Height * 0.5f) : ((0f - s.Height) * 0.5f - 20f));
			s.Rect.anchoredPosition = new Vector2(num, num2);
		}

		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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			if (_sparks == null)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			Spark[] sparks = _sparks;
			foreach (Spark spark in sparks)
			{
				Vector2 anchoredPosition = spark.Rect.anchoredPosition;
				anchoredPosition.y += spark.Speed * Time.unscaledDeltaTime;
				anchoredPosition.x += Mathf.Sin((unscaledTime + spark.DriftPhase) * spark.DriftSpeed) * 4f * Time.unscaledDeltaTime;
				if (anchoredPosition.y > spark.Height * 0.5f + 20f)
				{
					anchoredPosition.y = (0f - spark.Height) * 0.5f - 20f;
					anchoredPosition.x = Random.Range((0f - spark.Width) * 0.5f, spark.Width * 0.5f);
				}
				spark.Rect.anchoredPosition = anchoredPosition;
				float num = 0.6f + 0.4f * Mathf.Sin((unscaledTime + spark.TwinklePhase) * spark.TwinkleSpeed * (float)Math.PI * 2f);
				Color color = ((Graphic)spark.Image).color;
				color.a = spark.BaseAlpha * num;
				((Graphic)spark.Image).color = color;
			}
		}
	}
	internal class FadeInCanvasGroup : MonoBehaviour
	{
		public float Duration = 0.6f;

		private void Start()
		{
			((MonoBehaviour)this).StartCoroutine(Fade());
		}

		private IEnumerator Fade()
		{
			CanvasGroup cg = ((Component)this).GetComponent<CanvasGroup>();
			if (!((Object)(object)cg == (Object)null))
			{
				float t = 0f;
				cg.alpha = 0f;
				while (t < Duration)
				{
					t += Time.unscaledDeltaTime;
					cg.alpha = Mathf.Clamp01(t / Duration);
					yield return null;
				}
				cg.alpha = 1f;
			}
		}
	}
	internal class MenuOverhaul : MonoBehaviour
	{
		private Canvas _canvas;

		private Transform _mainButtons;

		private Image _header;

		private RectTransform _selectionBox;

		private readonly List<RectTransform> _menuButtons = new List<RectTransform>();

		private readonly Dictionary<RectTransform, TextMeshProUGUI> _labels = new Dictionary<RectTransform, TextMeshProUGUI>();

		private Color _labelColor = new Color(0.98f, 0.55f, 0.16f);

		private bool _boxVisible;

		private RectTransform _lastHoverTarget;

		private MenuManager _menuManager;

		private TMP_FontAsset _menuFont;

		private float _setupRetryTimer;

		private bool _ready;

		private void Start()
		{
			TrySetup();
		}

		private void Update()
		{
			if (!_ready)
			{
				_setupRetryTimer += Time.unscaledDeltaTime;
				if (_setupRetryTimer > 0.25f)
				{
					_setupRetryTimer = 0f;
					TrySetup();
				}
			}
		}

		private void LateUpdate()
		{
			//IL_0064: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			if (!_ready)
			{
				return;
			}
			if (Plugin.CfgHideVanillaLogo.Value && (Object)(object)_header != (Object)null && ((Behaviour)_header).enabled)
			{
				((Behaviour)_header).enabled = false;
			}
			foreach (KeyValuePair<RectTransform, TextMeshProUGUI> label in _labels)
			{
				TextMeshProUGUI value = label.Value;
				if ((Object)(object)value != (Object)null && ((Graphic)value).color != _labelColor)
				{
					((Graphic)value).color = _labelColor;
				}
			}
			UpdateSelectionBox();
		}

		private void TrySetup()
		{
			GameObject val = GameObject.Find("Canvas/MenuContainer");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			_canvas = val.GetComponentInParent<Canvas>();
			if ((Object)(object)_canvas == (Object)null)
			{
				return;
			}
			GameObject val2 = GameObject.Find("Canvas/MenuContainer/MainButtons/HeaderImage");
			if (!((Object)(object)val2 == (Object)null))
			{
				_header = val2.GetComponent<Image>();
				_mainButtons = val2.transform.parent;
				_menuManager = Object.FindObjectOfType<MenuManager>();
				Transform obj = _mainButtons.Find("HostButton");
				TextMeshProUGUI val3 = ((obj != null) ? ((Component)obj).GetComponentInChildren<TextMeshProUGUI>() : null);
				_menuFont = (((Object)(object)val3 != (Object)null) ? ((TMP_Text)val3).font : null);
				Image component = ((Component)_mainButtons).GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					((Behaviour)component).enabled = false;
				}
				if (Plugin.CfgBackdrop.Value)
				{
					BuildBackdrop();
				}
				if (Plugin.CfgTerminalHud.Value)
				{
					BuildTerminalHud();
				}
				if (Plugin.CfgMenuAccents.Value)
				{
					((MonoBehaviour)this).StartCoroutine(BuildAccentsWhenSettled());
				}
				_ready = true;
				Plugin.Log.LogInfo((object)"Lethal Oddysey menu v2 applied.");
			}
		}

		private void BuildBackdrop()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)_canvas).transform;
			if (!((Object)(object)transform.Find("OddyseyBackdrop") != (Object)null))
			{
				GameObject val = new GameObject("OddyseyBackdrop", new Type[2]
				{
					typeof(RectTransform),
					typeof(CanvasGroup)
				});
				val.transform.SetParent(transform, false);
				val.transform.SetSiblingIndex(0);
				StretchFull(val.GetComponent<RectTransform>());
				val.AddComponent<FadeInCanvasGroup>().Duration = 1f;
				if ((Object)(object)Plugin.BgTexture != (Object)null)
				{
					RawImage obj = ((Component)NewLayer(val.transform, "Artwork")).gameObject.AddComponent<RawImage>();
					((Graphic)obj).raycastTarget = false;
					obj.texture = (Texture)(object)Plugin.BgTexture;
					((Graphic)obj).color = Color.white;
					obj.uvRect = CoverCropUv(Plugin.BgTexture);
				}
				else
				{
					RawImage obj2 = ((Component)NewLayer(val.transform, "Wash")).gameObject.AddComponent<RawImage>();
					((Graphic)obj2).raycastTarget = false;
					obj2.texture = (Texture)(object)TextureFactory.CreateVerticalGradient(new Color(0.07f, 0.03f, 0.01f, 1f), new Color(0.01f, 0.008f, 0.01f, 1f));
				}
				RawImage obj3 = ((Component)NewLayer(val.transform, "Scanlines")).gameObject.AddComponent<RawImage>();
				((Graphic)obj3).raycastTarget = false;
				obj3.texture = (Texture)(object)TextureFactory.CreateScanlines();
				((Graphic)obj3).color = new Color(1f, 1f, 1f, 0.16f);
				Rect pixelRect = _canvas.pixelRect;
				float num = Mathf.Max(1f, ((Rect)(ref pixelRect)).height / 3f);
				obj3.uvRect = new Rect(0f, 0f, 1f, num);
				Image obj4 = ((Component)NewLayer(val.transform, "Vignette")).gameObject.AddComponent<Image>();
				((Graphic)obj4).raycastTarget = false;
				obj4.sprite = TextureFactory.ToSprite(TextureFactory.CreateVignette(512, 288, new Color(0.01f, 0.004f, 0f), 0.55f));
				int num2 = Mathf.Clamp(Plugin.CfgEmberCount.Value, 0, 60);
				if (num2 > 0)
				{
					RectTransform val2 = NewLayer(val.transform, "Embers");
					((Component)val2).gameObject.AddComponent<EmberField>().Init(val2, Plugin.SoftCircle, num2, (Color[])(object)new Color[3]
					{
						Plugin.Accent,
						Plugin.Accent,
						Plugin.AccentDim
					});
				}
				BuildBorder(val.transform);
			}
		}

		private Rect CoverCropUv(Texture2D tex)
		{
			//IL_000b: 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)
			//IL_008b: 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)
			Rect rect = ((Component)_canvas).GetComponent<RectTransform>().rect;
			float num = ((((Rect)(ref rect)).height > 1f) ? (((Rect)(ref rect)).width / ((Rect)(ref rect)).height) : 1.7777778f);
			float num2 = (float)((Texture)tex).width / (float)((Texture)tex).height;
			if (num2 > num)
			{
				float num3 = num / num2;
				return new Rect((1f - num3) / 2f, 0f, num3, 1f);
			}
			float num4 = num2 / num;
			return new Rect(0f, (1f - num4) / 2f, 1f, num4);
		}

		private void BuildBorder(Transform parent)
		{
			//IL_0045: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: 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_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			RectTransform parent2 = NewLayer(parent, "Border");
			Color color = default(Color);
			((Color)(ref color))..ctor(Plugin.Accent.r, Plugin.Accent.g, Plugin.Accent.b, 0.55f);
			EdgeRect(parent2, "Top", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -9f), new Vector2(-18f, 1.6f), color);
			EdgeRect(parent2, "Bottom", new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 9f), new Vector2(-18f, 1.6f), color);
			EdgeRect(parent2, "Left", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(0f, 0.5f), new Vector2(9f, 0f), new Vector2(1.6f, -18f), color);
			EdgeRect(parent2, "Right", new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(1f, 0.5f), new Vector2(-9f, 0f), new Vector2(1.6f, -18f), color);
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(Plugin.Accent.r, Plugin.Accent.g, Plugin.Accent.b, 0.95f);
			CornerMark(parent2, new Vector2(0f, 1f), new Vector2(1f, -1f), color2, 26f, 3f, 9f);
			CornerMark(parent2, new Vector2(1f, 1f), new Vector2(-1f, -1f), color2, 26f, 3f, 9f);
			CornerMark(parent2, new Vector2(0f, 0f), new Vector2(1f, 1f), color2, 26f, 3f, 9f);
			CornerMark(parent2, new Vector2(1f, 0f), new Vector2(-1f, 1f), color2, 26f, 3f, 9f);
		}

		private static void EdgeRect(RectTransform parent, string name, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 pos, Vector2 size, Color color)
		{
			//IL_0021: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent((Transform)(object)parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = anchorMin;
			component.anchorMax = anchorMax;
			component.pivot = pivot;
			component.anchoredPosition = pos;
			component.sizeDelta = size;
			Image component2 = val.GetComponent<Image>();
			((Graphic)component2).color = color;
			((Graphic)component2).raycastTarget = false;
		}

		private static void CornerMark(RectTransform parent, Vector2 corner, Vector2 dir, Color color, float len, float thick, float inset)
		{
			//IL_000f: 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)
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0047: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			float num = inset - 2f;
			EdgeRect(parent, "CornerH", corner, corner, corner, new Vector2(dir.x * num, dir.y * num), new Vector2(len, thick), color);
			EdgeRect(parent, "CornerV", corner, corner, corner, new Vector2(dir.x * num, dir.y * num), new Vector2(thick, len), color);
		}

		private void BuildTerminalHud()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_015b: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: 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_02e7: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)_canvas).transform;
			if ((Object)(object)transform.Find("OddyseyHud") != (Object)null)
			{
				return;
			}
			GameObject val = new GameObject("OddyseyHud", new Type[2]
			{
				typeof(RectTransform),
				typeof(CanvasGroup)
			});
			val.transform.SetParent(transform, false);
			val.transform.SetSiblingIndex(1);
			StretchFull(val.GetComponent<RectTransform>());
			val.AddComponent<FadeInCanvasGroup>().Duration = 1.6f;
			int result = 0;
			GameObject obj = GameObject.Find("Canvas/MenuContainer/VersionNum");
			TextMeshProUGUI val2 = ((obj != null) ? obj.GetComponent<TextMeshProUGUI>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				Match match = Regex.Match(((TMP_Text)val2).text ?? "", "\\d+");
				if (match.Success)
				{
					int.TryParse(match.Value, out result);
				}
			}
			if (result == 0 && (Object)(object)GameNetworkManager.Instance != (Object)null)
			{
				result = GameNetworkManager.Instance.gameVersionNum;
				if (result > 9950)
				{
					result -= 9950;
				}
			}
			bool flag = (Object)(object)GameNetworkManager.Instance != (Object)null && GameNetworkManager.Instance.disableSteam;
			Color color = default(Color);
			((Color)(ref color))..ctor(Plugin.Accent.r, Plugin.Accent.g, Plugin.Accent.b, 0.85f);
			HudText(val.transform, "TlLine1", new Vector2(0f, 1f), new Vector2(34f, -24f), "// LETHAL ODYSSEY TERMINAL", (TextAlignmentOptions)257, color);
			HudText(val.transform, "TlLine2", new Vector2(0f, 1f), new Vector2(34f, -41f), (result > 0) ? $"// v{result} - MAIN MENU" : "// MAIN MENU", (TextAlignmentOptions)257, color);
			float num = 36f;
			float[] array = new float[5] { 34f, 6f, 6f, 6f, 13f };
			foreach (float num2 in array)
			{
				EdgeRect(val.GetComponent<RectTransform>(), "Dash", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num, -62f), new Vector2(num2, 5f), color);
				num += num2 + 5f;
			}
			string text = (flag ? "> CONNECTION: <color=#FF5545>LAN</color>" : "> CONNECTION: <color=#3DFF59>ONLINE</color>");
			HudText(val.transform, "TrLine1", new Vector2(1f, 1f), new Vector2(-34f, -24f), text, (TextAlignmentOptions)260, color);
			HudText(val.transform, "TrLine2", new Vector2(1f, 1f), new Vector2(-34f, -41f), "> REGION: AUTO", (TextAlignmentOptions)260, color);
		}

		private void HudText(Transform parent, string name, Vector2 anchor, Vector2 pos, string text, TextAlignmentOptions align, Color color)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_003b: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = anchor;
			component.anchorMax = anchor;
			component.pivot = anchor;
			component.anchoredPosition = pos;
			component.sizeDelta = new Vector2(360f, 16f);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)_menuFont != (Object)null)
			{
				((TMP_Text)val2).font = _menuFont;
			}
			((TMP_Text)val2).fontSize = 11f;
			((Graphic)val2).color = color;
			((TMP_Text)val2).alignment = align;
			((TMP_Text)val2).richText = true;
			((TMP_Text)val2).text = text;
			((Graphic)val2).raycastTarget = false;
			((TMP_Text)val2).characterSpacing = 4f;
		}

		private IEnumerator BuildAccentsWhenSettled()
		{
			yield return (object)new WaitForSecondsRealtime(1f);
			if (!((Object)(object)_mainButtons == (Object)null))
			{
				_menuButtons.Clear();
				_menuButtons.AddRange(CollectMenuButtons());
				CacheLabelBounds();
				DisableVanillaHighlights();
				BuildSeparators();
				BuildSelectionBox();
			}
		}

		private void CacheLabelBounds()
		{
			//IL_0040: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			_labels.Clear();
			foreach (RectTransform menuButton in _menuButtons)
			{
				TextMeshProUGUI componentInChildren = ((Component)menuButton).GetComponentInChildren<TextMeshProUGUI>(true);
				if (!((Object)(object)componentInChildren == (Object)null))
				{
					_labels[menuButton] = componentInChildren;
					Color color = ((Graphic)componentInChildren).color;
					if (((Color)(ref color)).maxColorComponent > 0.25f)
					{
						_labelColor = ((Graphic)componentInChildren).color;
					}
				}
			}
		}

		private void DisableVanillaHighlights()
		{
			foreach (RectTransform menuButton in _menuButtons)
			{
				Transform val = ((Transform)menuButton).Find("SelectionHighlight");
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
		}

		private void BuildSeparators()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_015a: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			List<RectTransform> menuButtons = _menuButtons;
			if (menuButtons.Count >= 2)
			{
				float num = 0f;
				for (int i = 1; i < menuButtons.Count; i++)
				{
					num += menuButtons[i - 1].anchoredPosition.y - menuButtons[i].anchoredPosition.y;
				}
				num /= (float)(menuButtons.Count - 1);
				Color color = default(Color);
				((Color)(ref color))..ctor(Plugin.Accent.r, Plugin.Accent.g, Plugin.Accent.b, 0.22f);
				for (int j = 0; j < menuButtons.Count; j++)
				{
					float num2 = menuButtons[j].anchoredPosition.y - ((j < menuButtons.Count - 1) ? ((menuButtons[j].anchoredPosition.y - menuButtons[j + 1].anchoredPosition.y) / 2f) : (num / 2f));
					GameObject val = new GameObject("OddyseySeparator", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					val.transform.SetParent(_mainButtons, false);
					RectTransform component = val.GetComponent<RectTransform>();
					component.anchorMin = Vector2.zero;
					component.anchorMax = Vector2.zero;
					component.pivot = new Vector2(0f, 0.5f);
					component.anchoredPosition = new Vector2(26f, num2);
					component.sizeDelta = new Vector2(360f, 1.2f);
					Image component2 = val.GetComponent<Image>();
					((Graphic)component2).color = color;
					((Graphic)component2).raycastTarget = false;
				}
			}
		}

		private List<RectTransform> CollectMenuButtons()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			List<RectTransform> list = new List<RectTransform>();
			foreach (Transform mainButton in _mainButtons)
			{
				Transform val = mainButton;
				if (((Component)val).gameObject.activeInHierarchy && !((Object)(object)((Component)val).GetComponent<Button>() == (Object)null))
				{
					RectTransform val2 = (RectTransform)(object)((val is RectTransform) ? val : null);
					if (!((Object)(object)val2 == (Object)null) && !(val2.anchoredPosition.x < 60f) && !(val2.anchoredPosition.x > 320f))
					{
						list.Add(val2);
					}
				}
			}
			list.Sort((RectTransform a, RectTransform b) => b.anchoredPosition.y.CompareTo(a.anchoredPosition.y));
			return list;
		}

		private void BuildSelectionBox()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0061: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("OddyseySelection", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(_mainButtons, false);
			val.transform.SetAsFirstSibling();
			Image component = val.GetComponent<Image>();
			component.sprite = Plugin.SelectionOutline;
			component.type = (Type)1;
			((Graphic)component).color = Plugin.Accent;
			((Graphic)component).raycastTarget = false;
			_selectionBox = val.GetComponent<RectTransform>();
			_selectionBox.anchorMin = Vector2.zero;
			_selectionBox.anchorMax = Vector2.zero;
			_selectionBox.pivot = new Vector2(0.5f, 0.5f);
			Color color = default(Color);
			((Color)(ref color))..ctor(Plugin.Accent.r, Plugin.Accent.g, Plugin.Accent.b, 1f);
			Vector2[] array = (Vector2[])(object)new Vector2[4]
			{
				new Vector2(0f, 0f),
				new Vector2(0f, 1f),
				new Vector2(1f, 0f),
				new Vector2(1f, 1f)
			};
			foreach (Vector2 val2 in array)
			{
				float num = ((val2.x < 0.5f) ? (-1f) : 1f);
				GameObject val3 = new GameObject("Tick", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val3.transform.SetParent(val.transform, false);
				RectTransform component2 = val3.GetComponent<RectTransform>();
				component2.anchorMin = val2;
				component2.anchorMax = val2;
				component2.pivot = new Vector2((val2.x < 0.5f) ? 1f : 0f, val2.y);
				component2.anchoredPosition = new Vector2(num * 1.5f, 0f);
				component2.sizeDelta = new Vector2(7f, 2.6f);
				Image component3 = val3.GetComponent<Image>();
				((Graphic)component3).color = color;
				((Graphic)component3).raycastTarget = false;
			}
			val.SetActive(false);
			PulseGlow pulseGlow = val.AddComponent<PulseGlow>();
			pulseGlow.MinAlpha = 0.78f;
			pulseGlow.MaxAlpha = 1f;
			pulseGlow.Speed = 0.55f;
		}

		private void UpdateSelectionBox()
		{
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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)
			if ((Object)(object)_selectionBox == (Object)null)
			{
				return;
			}
			RectTransform val = HoveredButton();
			if ((Object)(object)val != (Object)(object)_lastHoverTarget)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)_menuManager != (Object)null && (Object)(object)_menuManager.MenuAudio != (Object)null && (Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.buttonSelectSFX != (Object)null)
				{
					_menuManager.MenuAudio.PlayOneShot(GameNetworkManager.Instance.buttonSelectSFX);
				}
				_lastHoverTarget = val;
			}
			if ((Object)(object)val == (Object)null)
			{
				if (_boxVisible)
				{
					_boxVisible = false;
					((Component)_selectionBox).gameObject.SetActive(false);
				}
				return;
			}
			Vector3 val2;
			Vector2 sizeDelta = default(Vector2);
			if (_labels.TryGetValue(val, out var value) && (Object)(object)value != (Object)null && TryGetGlyphBounds(value, out var bounds))
			{
				val2 = ((Transform)((TMP_Text)value).rectTransform).TransformPoint(((Bounds)(ref bounds)).center);
				((Vector2)(ref sizeDelta))..ctor(((Bounds)(ref bounds)).size.x + 26f, ((Bounds)(ref bounds)).size.y + 11f);
			}
			else
			{
				Rect rect = val.rect;
				val2 = ((Transform)val).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center));
				rect = val.rect;
				float num = ((Rect)(ref rect)).width + 20f;
				rect = val.rect;
				((Vector2)(ref sizeDelta))..ctor(num, ((Rect)(ref rect)).height + 12f);
			}
			_selectionBox.sizeDelta = sizeDelta;
			if (!_boxVisible)
			{
				_boxVisible = true;
				((Component)_selectionBox).gameObject.SetActive(true);
				((Transform)_selectionBox).position = val2;
			}
			else
			{
				((Transform)_selectionBox).position = Vector3.Lerp(((Transform)_selectionBox).position, val2, 1f - Mathf.Exp(-22f * Time.unscaledDeltaTime));
			}
		}

		private static bool TryGetGlyphBounds(TextMeshProUGUI tmp, out Bounds bounds)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_0087: 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_00b0: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			bounds = default(Bounds);
			TMP_TextInfo textInfo = ((TMP_Text)tmp).textInfo;
			if (textInfo == null || textInfo.characterCount == 0)
			{
				return false;
			}
			float num = float.MaxValue;
			float num2 = float.MaxValue;
			float num3 = float.MinValue;
			float num4 = float.MinValue;
			bool flag = false;
			for (int i = 0; i < textInfo.characterCount; i++)
			{
				TMP_CharacterInfo val = textInfo.characterInfo[i];
				if (val.isVisible)
				{
					flag = true;
					if (val.bottomLeft.x < num)
					{
						num = val.bottomLeft.x;
					}
					if (val.bottomLeft.y < num2)
					{
						num2 = val.bottomLeft.y;
					}
					if (val.topRight.x > num3)
					{
						num3 = val.topRight.x;
					}
					if (val.topRight.y > num4)
					{
						num4 = val.topRight.y;
					}
				}
			}
			if (!flag)
			{
				return false;
			}
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor((num + num3) / 2f, (num2 + num4) / 2f, 0f);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(num3 - num, num4 - num2, 0f);
			bounds = new Bounds(val2, val3);
			return true;
		}

		private RectTransform HoveredButton()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			if (_menuButtons.Count == 0 || !((Component)_mainButtons).gameObject.activeInHierarchy)
			{
				return null;
			}
			Mouse current = Mouse.current;
			if (current == null)
			{
				return null;
			}
			Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue();
			Camera val2 = (((int)_canvas.renderMode == 0) ? null : _canvas.worldCamera);
			foreach (RectTransform menuButton in _menuButtons)
			{
				if (!((Object)(object)menuButton == (Object)null) && ((Component)menuButton).gameObject.activeInHierarchy && RectTransformUtility.RectangleContainsScreenPoint(menuButton, val, val2))
				{
					return menuButton;
				}
			}
			return null;
		}

		private static RectTransform NewLayer(Transform parent, string name)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			StretchFull(component);
			return component;
		}

		private static void StretchFull(RectTransform rect)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = Vector2.zero;
			rect.anchorMax = Vector2.one;
			rect.offsetMin = Vector2.zero;
			rect.offsetMax = Vector2.zero;
		}
	}
	[BepInPlugin("oddysey.lethaloddysey.mainmenu", "Lethal Oddysey - Main Menu", "2.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string PluginGuid = "oddysey.lethaloddysey.mainmenu";

		private const string PluginName = "Lethal Oddysey - Main Menu";

		private const string PluginVersion = "2.0.0";

		internal static readonly Color Accent = new Color(0.97f, 0.52f, 0.12f);

		internal static readonly Color AccentDim = new Color(0.8f, 0.38f, 0.1f);

		internal static readonly Color OnlineGreen = new Color(0.24f, 1f, 0.35f);

		internal static readonly Color WarnRed = new Color(1f, 0.33f, 0.27f);

		internal static ManualLogSource Log;

		internal static Texture2D BgTexture;

		internal static Sprite SoftCircle;

		internal static Sprite SelectionOutline;

		internal static ConfigEntry<bool> CfgBackdrop;

		internal static ConfigEntry<bool> CfgHideVanillaLogo;

		internal static ConfigEntry<bool> CfgTerminalHud;

		internal static ConfigEntry<bool> CfgMenuAccents;

		internal static ConfigEntry<int> CfgEmberCount;

		private void Awake()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			CfgBackdrop = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu", "Backdrop", true, "Show the Lethal Oddysey background artwork (bg.png next to the plugin DLL), scanlines and border frame.");
			CfgHideVanillaLogo = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu", "HideVanillaLogo", true, "Hide the vanilla / MoreCompany header logo (the Oddysey emblem is part of the backdrop).");
			CfgTerminalHud = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu", "TerminalHud", true, "Show the terminal-style corner readouts (LETHAL ODYSSEY TERMINAL / CONNECTION status).");
			CfgMenuAccents = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu", "MenuAccents", true, "Show button separator lines and the animated selection outline.");
			CfgEmberCount = ((BaseUnityPlugin)this).Config.Bind<int>("Menu", "EmberCount", 12, new ConfigDescription("How many drifting embers to render (0 to disable).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 60), Array.Empty<object>()));
			SoftCircle = TextureFactory.ToSprite(TextureFactory.CreateSoftCircle(64));
			SelectionOutline = TextureFactory.CreateSelectionOutline();
			BgTexture = LoadBgTexture();
			SceneManager.sceneLoaded += OnSceneLoaded;
			Log.LogInfo((object)("Lethal Oddysey menu v2 loaded. Background: " + (((Object)(object)BgTexture != (Object)null) ? "ok" : "MISSING (bg.png)") + "."));
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Scene)(ref scene)).name != "MainMenu"))
			{
				new GameObject("OddyseyMenuOverhaul").AddComponent<MenuOverhaul>();
			}
		}

		private Texture2D LoadBgTexture()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			try
			{
				string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "bg.png");
				if (!File.Exists(path))
				{
					return null;
				}
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
				{
					Log.LogError((object)"bg.png exists but could not be decoded.");
					return null;
				}
				((Texture)val).filterMode = (FilterMode)1;
				((Texture)val).wrapMode = (TextureWrapMode)1;
				return val;
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Failed loading bg.png: {arg}");
				return null;
			}
		}
	}
	internal class PulseGlow : MonoBehaviour
	{
		public float MinAlpha = 0.18f;

		public float MaxAlpha = 0.38f;

		public float Speed = 0.35f;

		private Image _image;

		private float _phase;

		private void Awake()
		{
			_image = ((Component)this).GetComponent<Image>();
			_phase = Random.Range(0f, (float)Math.PI * 2f);
		}

		private void Update()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_image == (Object)null))
			{
				float num = 0.5f + 0.5f * Mathf.Sin(Time.unscaledTime * Speed * (float)Math.PI * 2f + _phase);
				Color color = ((Graphic)_image).color;
				color.a = Mathf.Lerp(MinAlpha, MaxAlpha, num);
				((Graphic)_image).color = color;
			}
		}
	}
	internal static class TextureFactory
	{
		public static Sprite ToSprite(Texture2D tex)
		{
			//IL_0019: 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)
			return Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f), 100f);
		}

		public static Texture2D CreateSoftCircle(int size)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//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)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			float num = (float)size / 2f;
			Color32[] array = (Color32[])(object)new Color32[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num2 = ((float)j + 0.5f - num) / num;
					float num3 = ((float)i + 0.5f - num) / num;
					float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3);
					float num5 = Mathf.Clamp01(1f - num4);
					num5 *= num5;
					array[i * size + j] = Color32.op_Implicit(new Color(1f, 1f, 1f, num5));
				}
			}
			val.SetPixels32(array);
			val.Apply(false, true);
			return val;
		}

		public static Texture2D CreateScanlines()
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 3, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)0,
				filterMode = (FilterMode)0
			};
			val.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.55f));
			val.SetPixel(0, 1, Color.clear);
			val.SetPixel(0, 2, Color.clear);
			val.Apply(false, true);
			return val;
		}

		public static Sprite CreateSelectionOutline()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(96, 96, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			float num = 48f;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(num - 9f - 2.5f, num - 9f - 2.5f);
			Vector2 val3 = default(Vector2);
			Vector2 val4 = default(Vector2);
			for (int i = 0; i < 96; i++)
			{
				for (int j = 0; j < 96; j++)
				{
					((Vector2)(ref val3))..ctor((float)j + 0.5f - num, (float)i + 0.5f - num);
					((Vector2)(ref val4))..ctor(Mathf.Abs(val3.x) - val2.x, Mathf.Abs(val3.y) - val2.y);
					Vector2 val5 = new Vector2(Mathf.Max(val4.x, 0f), Mathf.Max(val4.y, 0f));
					float num2 = ((Vector2)(ref val5)).magnitude + Mathf.Min(Mathf.Max(val4.x, val4.y), 0f) - 2.5f;
					float num3 = 1f - Mathf.Clamp01((Mathf.Abs(num2) - 1.1f) / 1.2f);
					float num4 = ((num2 > 0f) ? (0.34f * Mathf.Exp((0f - num2) / 4.0499997f)) : 0f);
					float num5 = ((num2 < 0f) ? 0.09f : 0f);
					float num6 = Mathf.Clamp01(Mathf.Max(num3, Mathf.Max(num4, num5)));
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num6));
				}
			}
			val.Apply(false, false);
			return Sprite.Create(val, new Rect(0f, 0f, 96f, 96f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(34f, 34f, 34f, 34f));
		}

		public static Color FadeEdges(Texture2D tex, float marginFraction)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			Color[] pixels = tex.GetPixels();
			int width = ((Texture)tex).width;
			int height = ((Texture)tex).height;
			Color result = (pixels[0] + pixels[width - 1] + pixels[(height - 1) * width] + pixels[height * width - 1]) / 4f;
			float num = Mathf.Max(2f, (float)Mathf.Min(width, height) * marginFraction);
			for (int i = 0; i < height; i++)
			{
				float num2 = Mathf.Clamp01((float)Mathf.Min(i, height - 1 - i) / num);
				num2 = num2 * num2 * (3f - 2f * num2);
				for (int j = 0; j < width; j++)
				{
					float num3 = Mathf.Clamp01((float)Mathf.Min(j, width - 1 - j) / num);
					num3 = num3 * num3 * (3f - 2f * num3);
					int num4 = i * width + j;
					Color val = pixels[num4];
					val.a *= num3 * num2;
					pixels[num4] = val;
				}
			}
			tex.SetPixels(pixels);
			tex.Apply(false, false);
			return result;
		}

		public static Texture2D CreateVerticalGradient(Color bottom, Color top)
		{
			//IL_0005: 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_0019: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 64, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			for (int i = 0; i < 64; i++)
			{
				float num = (float)i / 63f;
				num = num * num * (3f - 2f * num);
				val.SetPixel(0, i, Color.Lerp(bottom, top, num));
			}
			val.Apply(false, true);
			return val;
		}

		public static Texture2D CreateFogNoise(int size)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)0,
				filterMode = (FilterMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num = (float)j / (float)size;
					float num2 = (float)i / (float)size;
					float num3 = 0f;
					float num4 = 0.55f;
					float num5 = 1.5f;
					for (int k = 0; k < 3; k++)
					{
						float num6 = Mathf.Cos(num * (float)Math.PI * 2f) * num5;
						float num7 = Mathf.Sin(num * (float)Math.PI * 2f) * num5;
						float num8 = Mathf.Cos(num2 * (float)Math.PI * 2f) * num5;
						float num9 = Mathf.Sin(num2 * (float)Math.PI * 2f) * num5;
						num3 += num4 * (Mathf.PerlinNoise(num6 + num8 * 0.7f, num7 + num9 * 0.7f) - 0.5f);
						num4 *= 0.5f;
						num5 *= 2f;
					}
					float num10 = Mathf.Clamp01(0.5f + num3);
					num10 *= num10;
					array[i * size + j] = Color32.op_Implicit(new Color(1f, 1f, 1f, num10));
				}
			}
			val.SetPixels32(array);
			val.Apply(false, true);
			return val;
		}

		public static Texture2D CreateVignette(int width, int height, Color edgeColor, float strength)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(width, height, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[width * height];
			float num = (float)width / 2f;
			float num2 = (float)height / 2f;
			float num3 = Mathf.Sqrt(num * num + num2 * num2);
			Color val2 = default(Color);
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					float num4 = ((float)j + 0.5f - num) / num3;
					float num5 = ((float)i + 0.5f - num2) / num3;
					float num6 = Mathf.Clamp01((Mathf.Sqrt(num4 * num4 + num5 * num5) - 0.25f) / 0.9f);
					num6 = num6 * num6 * (3f - 2f * num6);
					float num7 = num6 * strength;
					((Color)(ref val2))..ctor(edgeColor.r, edgeColor.g, edgeColor.b, num7);
					array[i * width + j] = Color32.op_Implicit(val2);
				}
			}
			val.SetPixels32(array);
			val.Apply(false, true);
			return val;
		}
	}
}