Decompiled source of Minimal Menu v1.0.2

com.Omniscye.Wii.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Empress.WiiMainMenu.YapYap.Controllers;
using Empress.WiiMainMenu.YapYap.UI;
using Empress.WiiMainMenu.YapYap.Util;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;
using UnityEngine.Video;
using YAPYAP;

[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("com.Omniscye.Wii")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+174558dd641ee37bf40ded0d24866ac172d24388")]
[assembly: AssemblyProduct("com.Omniscye.Wii")]
[assembly: AssemblyTitle("EmpressWii")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Empress.WiiMainMenu.YapYap
{
	[BepInPlugin("Empress.WiiMainMenu.YapYap", "WiiMainMenu (YapYap)", "1.0.0")]
	public sealed class WiiMainMenuPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "Empress.WiiMainMenu.YapYap";

		public const string PluginName = "WiiMainMenu (YapYap)";

		public const string PluginVersion = "1.0.0";

		private Harmony? _harmony;

		internal static WiiMainMenuPlugin Instance { get; private set; }

		internal static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		private void Awake()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Instance = this;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			_harmony = new Harmony("Empress.WiiMainMenu.YapYap");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			Log.LogInfo((object)"WiiMainMenu (YapYap) v1.0.0 loaded.");
		}

		private void OnDestroy()
		{
			try
			{
				Harmony? harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}
			catch
			{
			}
		}
	}
}
namespace Empress.WiiMainMenu.YapYap.Controllers
{
	internal sealed class WiiMainMenuController : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <BuildRoutine>d__21 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public WiiMainMenuController <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <BuildRoutine>d__21(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				WiiMainMenuController CS$<>8__locals0 = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					goto IL_0042;
				case 1:
					<>1__state = -1;
					goto IL_0042;
				case 2:
					{
						<>1__state = -1;
						CS$<>8__locals0._overlayRoot = WiiOverlayBuilder.BuildOverlayRoot(out CS$<>8__locals0._channelGridRoot, out CS$<>8__locals0._bubbleContainer);
						((Object)CS$<>8__locals0._overlayRoot).hideFlags = (HideFlags)61;
						Object.DontDestroyOnLoad((Object)(object)CS$<>8__locals0._overlayRoot);
						WiiOverlayBuilder.BuildBackground(CS$<>8__locals0._overlayRoot.transform);
						WiiOverlayBuilder.BuildBubbles(CS$<>8__locals0._overlayRoot.transform, CS$<>8__locals0._bubbleContainer);
						CS$<>8__locals0.CreateChannel("Play", "channel_play.mp4", delegate(GameObject btn)
						{
							CS$<>8__locals0.ClickWithAnimation(btn, CS$<>8__locals0.PlayGame);
						});
						CS$<>8__locals0.CreateChannel("Options", "channel_options.mp4", delegate(GameObject btn)
						{
							CS$<>8__locals0.ClickWithAnimation(btn, CS$<>8__locals0.OpenOptions);
						});
						CS$<>8__locals0.CreateChannel("Quit", "channel_quit.mp4", delegate(GameObject btn)
						{
							CS$<>8__locals0.ClickWithAnimation(btn, CS$<>8__locals0.QuitGame);
						});
						CS$<>8__locals0._built = true;
						WiiMainMenuPlugin.Log.LogInfo((object)"[WiiMainMenu] YapYap overlay built.");
						return false;
					}
					IL_0042:
					if ((Object)(object)CS$<>8__locals0._menu == (Object)null)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					<>2__current = AssetLoader.LoadAudioClips(delegate(AudioClip? c)
					{
						CS$<>8__locals0._hoverClip = c;
					}, delegate(AudioClip? c)
					{
						CS$<>8__locals0._selectClip = c;
					});
					<>1__state = 2;
					return true;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const string StateMainMenu = "MainMenu";

		private const string StateOptions = "Options";

		private MenuController? _menu;

		private bool _built;

		private bool _lastShouldShow;

		private bool _suspendOverlay;

		private float _suspendGraceTime;

		private bool _suspendSawVanillaDeactivate;

		private GameObject? _overlayRoot;

		private Transform? _channelGridRoot;

		private Transform? _bubbleContainer;

		private AudioClip? _hoverClip;

		private AudioClip? _selectClip;

		private bool _vanillaHidden;

		private GameObject? _cachedVanillaButtonsRoot;

		public void BindMenu(MenuController menu)
		{
			_menu = menu;
		}

		private void Awake()
		{
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
		}

		private void Start()
		{
			if (!_built)
			{
				((MonoBehaviour)this).StartCoroutine(BuildRoutine());
			}
		}

		private void Update()
		{
			if ((Object)(object)_menu == (Object)null || (Object)(object)_overlayRoot == (Object)null)
			{
				return;
			}
			bool num = ReflectionCache.IsInMenuState(_menu, "MainMenu");
			if (_suspendOverlay && (Object)(object)_cachedVanillaButtonsRoot != (Object)null)
			{
				if (!_cachedVanillaButtonsRoot.activeInHierarchy)
				{
					_suspendSawVanillaDeactivate = true;
				}
				else if (_suspendSawVanillaDeactivate && _suspendGraceTime <= 0f)
				{
					_suspendOverlay = false;
				}
			}
			if (_suspendGraceTime > 0f)
			{
				_suspendGraceTime -= Time.unscaledDeltaTime;
			}
			bool flag = num && !_suspendOverlay;
			if (flag && !_lastShouldShow)
			{
				ResetAllChannelStates();
			}
			_lastShouldShow = flag;
			if (!num)
			{
				_suspendOverlay = false;
			}
			if (_overlayRoot.activeSelf != flag)
			{
				_overlayRoot.SetActive(flag);
			}
			if (flag)
			{
				HideVanillaIfNeeded();
			}
			else
			{
				ShowVanillaIfNeeded();
			}
		}

		private void ResetAllChannelStates()
		{
			if ((Object)(object)_overlayRoot == (Object)null)
			{
				return;
			}
			WiiChannelHover[] componentsInChildren = _overlayRoot.GetComponentsInChildren<WiiChannelHover>(true);
			foreach (WiiChannelHover wiiChannelHover in componentsInChildren)
			{
				try
				{
					wiiChannelHover.ResetState();
				}
				catch
				{
				}
			}
		}

		private void OnDestroy()
		{
			try
			{
				if ((Object)(object)_overlayRoot != (Object)null)
				{
					Object.Destroy((Object)(object)_overlayRoot);
				}
			}
			catch
			{
			}
		}

		[IteratorStateMachine(typeof(<BuildRoutine>d__21))]
		private IEnumerator BuildRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <BuildRoutine>d__21(0)
			{
				<>4__this = this
			};
		}

		private void CreateChannel(string title, string videoFile, Action<GameObject> onClick)
		{
			if (!((Object)(object)_channelGridRoot == (Object)null))
			{
				WiiOverlayBuilder.CreateChannelButton(_channelGridRoot, title, videoFile, _hoverClip, _selectClip, onClick);
			}
		}

		private void ClickWithAnimation(GameObject clickedButton, Action action)
		{
			Action action2 = action;
			if ((Object)(object)clickedButton != (Object)null)
			{
				WiiChannelHover component = clickedButton.GetComponent<WiiChannelHover>();
				if ((Object)(object)component != (Object)null && (Object)(object)_overlayRoot != (Object)null)
				{
					component.PlaySelect(_selectClip);
					component.IsAnimatingClick = true;
					? val = this;
					Transform transform = clickedButton.transform;
					((MonoBehaviour)val).StartCoroutine(WiiOverlayBuilder.ZoomAnimationRoutine((RectTransform?)(object)((transform is RectTransform) ? transform : null), _overlayRoot, delegate
					{
						try
						{
							action2();
						}
						catch (Exception ex2)
						{
							WiiMainMenuPlugin.Log.LogError((object)ex2);
						}
					}));
					return;
				}
			}
			try
			{
				action2();
			}
			catch (Exception ex)
			{
				WiiMainMenuPlugin.Log.LogError((object)ex);
			}
		}

		private void PlayGame()
		{
			if (!((Object)(object)_menu == (Object)null))
			{
				if (TryInvokeAnyMethod(_menu, "OnPlayButton", "Play", "StartGame", "Begin", "BeginGame", "OnStartButton", "OnStart", "OnPlay"))
				{
					SuspendForVanilla();
				}
				else if (TryInvokeOnMemberContaining(_menu, "play") || TryInvokeOnMemberContaining(_menu, "start"))
				{
					SuspendForVanilla();
				}
			}
		}

		private void SuspendForVanilla()
		{
			_suspendOverlay = true;
			_suspendGraceTime = 1f;
			_suspendSawVanillaDeactivate = false;
			ShowVanillaIfNeeded();
			if ((Object)(object)_overlayRoot != (Object)null)
			{
				_overlayRoot.SetActive(false);
			}
		}

		private void OpenOptions()
		{
			if (!((Object)(object)_menu == (Object)null))
			{
				ReflectionCache.CallSetMenuState(_menu, "Options");
			}
		}

		private void QuitGame()
		{
			if (!((Object)(object)_menu == (Object)null) && !TryInvokeAnyMethod(_menu, "OnQuitButton", "Quit", "Exit", "OnExitButton", "OnQuit") && !TryInvokeOnMemberContaining(_menu, "quit") && !TryInvokeOnMemberContaining(_menu, "exit"))
			{
				Application.Quit();
			}
		}

		private void HideVanillaIfNeeded()
		{
			if (!_vanillaHidden && !((Object)(object)_menu == (Object)null))
			{
				if (_cachedVanillaButtonsRoot == null)
				{
					_cachedVanillaButtonsRoot = FindLikelyVanillaButtonsRoot(_menu);
				}
				if ((Object)(object)_cachedVanillaButtonsRoot != (Object)null)
				{
					_cachedVanillaButtonsRoot.SetActive(false);
				}
				_vanillaHidden = true;
			}
		}

		private void ShowVanillaIfNeeded()
		{
			if (_vanillaHidden && !((Object)(object)_menu == (Object)null))
			{
				if ((Object)(object)_cachedVanillaButtonsRoot != (Object)null)
				{
					_cachedVanillaButtonsRoot.SetActive(true);
				}
				_vanillaHidden = false;
			}
		}

		private static GameObject? FindLikelyVanillaButtonsRoot(MenuController menu)
		{
			Type type = ((object)menu).GetType();
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				string text = fieldInfo.Name.ToLowerInvariant();
				if (text.Contains("button") || text.Contains("menu") || text.Contains("container"))
				{
					object obj = null;
					try
					{
						obj = fieldInfo.GetValue(menu);
					}
					catch
					{
					}
					if (TryExtractGameObject(obj, out GameObject go) && (Object)(object)go != (Object)null)
					{
						return go;
					}
				}
			}
			PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (!propertyInfo.CanRead)
				{
					continue;
				}
				string text2 = propertyInfo.Name.ToLowerInvariant();
				if (text2.Contains("button") || text2.Contains("menu") || text2.Contains("container"))
				{
					object obj3 = null;
					try
					{
						obj3 = propertyInfo.GetValue(menu);
					}
					catch
					{
					}
					if (TryExtractGameObject(obj3, out GameObject go2) && (Object)(object)go2 != (Object)null)
					{
						return go2;
					}
				}
			}
			Transform transform = ((Component)menu).transform;
			for (int j = 0; j < transform.childCount; j++)
			{
				Transform child = transform.GetChild(j);
				string text3 = ((Object)child).name.ToLowerInvariant();
				if (text3.Contains("button") || text3.Contains("menu") || text3.Contains("container"))
				{
					return ((Component)child).gameObject;
				}
			}
			return null;
		}

		private static bool TryExtractGameObject(object? obj, out GameObject? go)
		{
			go = null;
			if (obj == null)
			{
				return false;
			}
			GameObject val = (GameObject)((obj is GameObject) ? obj : null);
			if (val != null)
			{
				go = val;
				return true;
			}
			Component val2 = (Component)((obj is Component) ? obj : null);
			if (val2 != null)
			{
				go = val2.gameObject;
				return true;
			}
			return false;
		}

		private static bool TryInvokeAnyMethod(object instance, params string[] methodNames)
		{
			Type type = instance.GetType();
			foreach (string name in methodNames)
			{
				MethodInfo method = type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
				if (!(method == null))
				{
					method.Invoke(instance, null);
					return true;
				}
			}
			return false;
		}

		private static bool TryInvokeOnMemberContaining(object instance, string nameFragmentLower)
		{
			Type type = instance.GetType();
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (fieldInfo.Name.ToLowerInvariant().Contains(nameFragmentLower))
				{
					object obj = null;
					try
					{
						obj = fieldInfo.GetValue(instance);
					}
					catch
					{
					}
					if (obj != null && TryInvokeClickLike(obj))
					{
						return true;
					}
				}
			}
			PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (propertyInfo.CanRead && propertyInfo.Name.ToLowerInvariant().Contains(nameFragmentLower))
				{
					object obj3 = null;
					try
					{
						obj3 = propertyInfo.GetValue(instance);
					}
					catch
					{
					}
					if (obj3 != null && TryInvokeClickLike(obj3))
					{
						return true;
					}
				}
			}
			return false;
		}

		private static bool TryInvokeClickLike(object buttonLike)
		{
			Type type = buttonLike.GetType();
			PropertyInfo property = type.GetProperty("onClick", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null)
			{
				object obj = null;
				try
				{
					obj = property.GetValue(buttonLike);
				}
				catch
				{
				}
				if (obj != null)
				{
					MethodInfo method = obj.GetType().GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
					if (method != null)
					{
						method.Invoke(obj, null);
						return true;
					}
				}
			}
			string[] array = new string[3] { "Click", "Press", "Invoke" };
			foreach (string name in array)
			{
				MethodInfo method2 = type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
				if (method2 != null)
				{
					method2.Invoke(buttonLike, null);
					return true;
				}
			}
			return false;
		}
	}
}
namespace Empress.WiiMainMenu.YapYap.Patches
{
	[HarmonyPatch]
	internal static class MenuControllerPatches
	{
		private static MethodBase TargetMethod()
		{
			return ReflectionCache.GetSetMenuStateMethod();
		}

		[HarmonyPostfix]
		private static void Postfix(MenuController __instance, object __0)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)__instance).gameObject;
			if (!((Object)(object)gameObject == (Object)null))
			{
				if ((Object)(object)gameObject.GetComponent<WiiMainMenuController>() == (Object)null)
				{
					gameObject.AddComponent<WiiMainMenuController>();
				}
				gameObject.GetComponent<WiiMainMenuController>()?.BindMenu(__instance);
			}
		}
	}
}
namespace Empress.WiiMainMenu.YapYap.UI
{
	internal sealed class BubbleBehaviour : MonoBehaviour
	{
		private float _speed;

		private float _wobbleFreq;

		private float _wobbleAmp;

		private float _xOffset;

		private RectTransform? _rt;

		public void Setup(float startX, float startY)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			_rt = ((Component)this).GetComponent<RectTransform>();
			_rt.anchoredPosition = new Vector2(startX, startY);
			_speed = Random.Range(20f, 60f);
			_wobbleFreq = Random.Range(1f, 3f);
			_wobbleAmp = Random.Range(10f, 30f);
			_xOffset = startX;
		}

		private void Update()
		{
			//IL_0015: 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)
			if (!((Object)(object)_rt == (Object)null))
			{
				float num = _rt.anchoredPosition.y + _speed * Time.unscaledDeltaTime;
				float num2 = _xOffset + Mathf.Sin(Time.unscaledTime * _wobbleFreq) * _wobbleAmp;
				if (num > 1200f)
				{
					num = -100f;
				}
				_rt.anchoredPosition = new Vector2(num2, num);
			}
		}
	}
	internal sealed class WiiChannelHover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public bool IsAnimatingClick;

		public AudioClip? HoverClip;

		public AudioClip? SelectClip;

		private VideoPlayer? _vp;

		private RenderTexture? _rt;

		private Outline? _outline;

		private AudioSource? _audio;

		private bool _hasVideo;

		private bool _hover;

		private Color _originalOutlineColor;

		private void Awake()
		{
			_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
			_audio.playOnAwake = false;
			_audio.volume = 0.5f;
		}

		public void SetOutline(Outline outline)
		{
			//IL_0009: 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)
			_outline = outline;
			_originalOutlineColor = ((Shadow)outline).effectColor;
		}

		public void SetupVideo(VideoPlayer vp, RawImage raw, RenderTexture rt)
		{
			_vp = vp;
			_rt = rt;
			_hasVideo = true;
		}

		public void ResetState()
		{
			//IL_0014: 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)
			IsAnimatingClick = false;
			_hover = false;
			((Component)this).transform.localScale = Vector3.one;
			if ((Object)(object)_outline != (Object)null)
			{
				((Shadow)_outline).effectColor = _originalOutlineColor;
			}
			if (_hasVideo && (Object)(object)_vp != (Object)null)
			{
				_vp.Pause();
				_vp.time = 0.0;
			}
		}

		public void PlaySelect(AudioClip? clip)
		{
			if ((Object)(object)clip != (Object)null && (Object)(object)_audio != (Object)null)
			{
				_audio.PlayOneShot(clip);
			}
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAnimatingClick)
			{
				_hover = true;
				if ((Object)(object)_outline != (Object)null)
				{
					((Shadow)_outline).effectColor = new Color(0.14f, 0.8f, 0.98f, 1f);
				}
				if (_hasVideo && (Object)(object)_vp != (Object)null)
				{
					_vp.Play();
				}
				if ((Object)(object)HoverClip != (Object)null && (Object)(object)_audio != (Object)null)
				{
					_audio.PlayOneShot(HoverClip);
				}
			}
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAnimatingClick)
			{
				_hover = false;
				if ((Object)(object)_outline != (Object)null)
				{
					((Shadow)_outline).effectColor = _originalOutlineColor;
				}
				if (_hasVideo && (Object)(object)_vp != (Object)null)
				{
					_vp.Pause();
				}
			}
		}

		private void Update()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAnimatingClick)
			{
				float num = (_hover ? 1.08f : 1f);
				((Component)this).transform.localScale = Vector3.Lerp(((Component)this).transform.localScale, Vector3.one * num, Time.unscaledDeltaTime * 15f);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_rt != (Object)null)
			{
				_rt.Release();
			}
		}
	}
	internal static class WiiOverlayBuilder
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static EventHandler <>9__9_0;

			internal void <TryLoadVideo>b__9_0(VideoPlayer source)
			{
				source.Play();
				source.Pause();
				source.time = 0.0;
			}
		}

		[CompilerGenerated]
		private sealed class <ZoomAnimationRoutine>d__7 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RectTransform target;

			public Action action;

			public GameObject overlayRoot;

			private float <timer>5__2;

			private float <duration>5__3;

			private Vector3 <startScale>5__4;

			private Vector3 <endScale>5__5;

			private Canvas <tempCanvas>5__6;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ZoomAnimationRoutine>d__7(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<tempCanvas>5__6 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: 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_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					if ((Object)(object)target == (Object)null)
					{
						action();
						return false;
					}
					<timer>5__2 = 0f;
					<duration>5__3 = 0.4f;
					<startScale>5__4 = ((Transform)target).localScale;
					<endScale>5__5 = new Vector3(12f, 12f, 1f);
					Canvas component2 = overlayRoot.GetComponent<Canvas>();
					int num = (((Object)(object)component2 != (Object)null) ? component2.sortingOrder : 30000);
					<tempCanvas>5__6 = ((Component)target).gameObject.AddComponent<Canvas>();
					<tempCanvas>5__6.overrideSorting = true;
					<tempCanvas>5__6.sortingOrder = num + 100;
					goto IL_012e;
				}
				case 1:
					<>1__state = -1;
					goto IL_012e;
				case 2:
					{
						<>1__state = -1;
						if ((Object)(object)target != (Object)null)
						{
							((Transform)target).localScale = Vector3.one;
							WiiChannelHover component = ((Component)target).GetComponent<WiiChannelHover>();
							if ((Object)(object)component != (Object)null)
							{
								component.ResetState();
							}
							Object.Destroy((Object)(object)<tempCanvas>5__6);
						}
						return false;
					}
					IL_012e:
					if (<timer>5__2 < <duration>5__3)
					{
						<timer>5__2 += Time.unscaledDeltaTime;
						float num2 = <timer>5__2 / <duration>5__3;
						num2 = num2 * num2 * num2;
						((Transform)target).localScale = Vector3.Lerp(<startScale>5__4, <endScale>5__5, num2);
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					action();
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static Sprite? _cachedRoundedSprite;

		private static Sprite? _cachedGlossSprite;

		private static Sprite? _cachedGridSprite;

		public static GameObject BuildOverlayRoot(out Transform channelGridRoot, out Transform bubbleContainer)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0041: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: 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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: 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_0200: Expected O, but got Unknown
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("WiiOverlayCanvas");
			((Object)val).hideFlags = (HideFlags)61;
			Canvas obj = val.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 30000;
			CanvasScaler obj2 = val.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			val.AddComponent<GraphicRaycaster>();
			if ((Object)(object)_cachedRoundedSprite == (Object)null)
			{
				_cachedRoundedSprite = CreateRoundedRectSprite(128, 128, 24, Color.white);
			}
			if ((Object)(object)_cachedGlossSprite == (Object)null)
			{
				_cachedGlossSprite = CreateGlossSprite(128, 128);
			}
			if ((Object)(object)_cachedGridSprite == (Object)null)
			{
				_cachedGridSprite = CreateGridSprite();
			}
			GameObject val2 = new GameObject("BackgroundLayer", new Type[1] { typeof(RectTransform) });
			val2.transform.SetParent(val.transform, false);
			Stretch(val2.GetComponent<RectTransform>());
			GameObject val3 = new GameObject("SolidFill", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val3.transform.SetParent(val2.transform, false);
			Stretch(val3.GetComponent<RectTransform>());
			((Graphic)val3.GetComponent<Image>()).color = new Color(0.06f, 0.08f, 0.14f, 1f);
			GameObject val4 = new GameObject("GridPattern", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val4.transform.SetParent(val2.transform, false);
			Stretch(val4.GetComponent<RectTransform>());
			Image component = val4.GetComponent<Image>();
			component.sprite = _cachedGridSprite;
			component.type = (Type)2;
			((Graphic)component).color = new Color(1f, 1f, 1f, 0.06f);
			GameObject val5 = new GameObject("BubbleContainer", new Type[1] { typeof(RectTransform) });
			val5.transform.SetParent(val.transform, false);
			Stretch(val5.GetComponent<RectTransform>());
			bubbleContainer = val5.transform;
			GameObject val6 = new GameObject("WiiGrid", new Type[2]
			{
				typeof(RectTransform),
				typeof(GridLayoutGroup)
			});
			val6.transform.SetParent(val.transform, false);
			RectTransform component2 = val6.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0.1f, 0.2f);
			component2.anchorMax = new Vector2(0.9f, 0.9f);
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			GridLayoutGroup component3 = val6.GetComponent<GridLayoutGroup>();
			component3.cellSize = new Vector2(480f, 270f);
			component3.spacing = new Vector2(40f, 40f);
			component3.startCorner = (Corner)0;
			component3.startAxis = (Axis)0;
			((LayoutGroup)component3).childAlignment = (TextAnchor)4;
			component3.constraint = (Constraint)1;
			component3.constraintCount = 4;
			channelGridRoot = val6.transform;
			return val;
		}

		public static void BuildBackground(Transform overlayRoot)
		{
		}

		public static void BuildBubbles(Transform overlayRoot, Transform bubbleContainer)
		{
			//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)
			Sprite sprite = Sprite.Create(CreateBubbleTexture(), new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f));
			for (int i = 0; i < 25; i++)
			{
				SpawnBubble(bubbleContainer, sprite);
			}
		}

		public static void CreateChannelButton(Transform parent, string title, string videoFileName, AudioClip? hoverClip, AudioClip? selectClip, Action<GameObject> onClick)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_009a: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			Action<GameObject> onClick2 = onClick;
			GameObject btnObj = new GameObject("Btn_" + title, new Type[5]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Button),
				typeof(Outline),
				typeof(Mask)
			});
			btnObj.transform.SetParent(parent, false);
			Image component = btnObj.GetComponent<Image>();
			component.sprite = _cachedRoundedSprite;
			component.type = (Type)1;
			((Graphic)component).color = Color.white;
			btnObj.GetComponent<Mask>().showMaskGraphic = true;
			Outline component2 = btnObj.GetComponent<Outline>();
			((Shadow)component2).effectColor = new Color(0.7f, 0.7f, 0.7f, 0.8f);
			((Shadow)component2).effectDistance = new Vector2(4f, -4f);
			Button component3 = btnObj.GetComponent<Button>();
			((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
			{
				onClick2?.Invoke(btnObj);
			});
			ColorBlock colors = ((Selectable)component3).colors;
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).highlightedColor = new Color(0.95f, 0.95f, 0.95f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.8f, 0.8f, 0.8f);
			((Selectable)component3).colors = colors;
			GameObject val = new GameObject("VideoFrame", new Type[2]
			{
				typeof(RectTransform),
				typeof(RawImage)
			});
			val.transform.SetParent(btnObj.transform, false);
			Stretch(val.GetComponent<RectTransform>());
			RawImage component4 = val.GetComponent<RawImage>();
			((Graphic)component4).color = new Color(0.9f, 0.9f, 0.9f, 1f);
			((Graphic)component4).raycastTarget = false;
			GameObject val2 = new GameObject("TextBar", new Type[1] { typeof(RectTransform) });
			val2.transform.SetParent(btnObj.transform, false);
			RectTransform component5 = val2.GetComponent<RectTransform>();
			component5.anchorMin = new Vector2(0f, 0f);
			component5.anchorMax = new Vector2(1f, 0.25f);
			component5.offsetMin = Vector2.zero;
			component5.offsetMax = Vector2.zero;
			GameObject val3 = new GameObject("Label", new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			});
			val3.transform.SetParent(val2.transform, false);
			Stretch(val3.GetComponent<RectTransform>(), 10f);
			TextMeshProUGUI component6 = val3.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component6).text = title;
			((TMP_Text)component6).alignment = (TextAlignmentOptions)1026;
			((Graphic)component6).color = new Color(0.3f, 0.3f, 0.3f, 1f);
			((TMP_Text)component6).fontSize = 28f;
			((TMP_Text)component6).fontStyle = (FontStyles)1;
			((TMP_Text)component6).enableAutoSizing = true;
			((TMP_Text)component6).fontSizeMin = 18f;
			((TMP_Text)component6).fontSizeMax = 32f;
			Shadow obj = val3.AddComponent<Shadow>();
			obj.effectColor = new Color(0f, 0f, 0f, 0.1f);
			obj.effectDistance = new Vector2(1f, -1f);
			WiiChannelHover wiiChannelHover = btnObj.AddComponent<WiiChannelHover>();
			wiiChannelHover.SetOutline(component2);
			wiiChannelHover.HoverClip = hoverClip;
			wiiChannelHover.SelectClip = selectClip;
			TryLoadVideo(btnObj, component4, videoFileName, wiiChannelHover);
		}

		[IteratorStateMachine(typeof(<ZoomAnimationRoutine>d__7))]
		public static IEnumerator ZoomAnimationRoutine(RectTransform? target, GameObject overlayRoot, Action action)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ZoomAnimationRoutine>d__7(0)
			{
				target = target,
				overlayRoot = overlayRoot,
				action = action
			};
		}

		private static void Stretch(RectTransform rt, float padding = 0f)
		{
			//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_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)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			rt.offsetMin = new Vector2(padding, padding);
			rt.offsetMax = new Vector2(0f - padding, 0f - padding);
		}

		private static void TryLoadVideo(GameObject btnObj, RawImage rawImg, string fileName, WiiChannelHover hover)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_0098: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", fileName);
			if (!File.Exists(text))
			{
				((Graphic)rawImg).color = new Color(0.92f, 0.92f, 0.92f, 1f);
				return;
			}
			VideoPlayer val = btnObj.AddComponent<VideoPlayer>();
			val.playOnAwake = false;
			val.isLooping = true;
			val.renderMode = (VideoRenderMode)2;
			val.source = (VideoSource)1;
			val.url = text;
			val.audioOutputMode = (VideoAudioOutputMode)0;
			RenderTexture rt = (RenderTexture)(object)(rawImg.texture = (Texture)(object)(val.targetTexture = new RenderTexture(480, 270, 0)));
			((Graphic)rawImg).color = Color.white;
			val.Prepare();
			object obj = <>c.<>9__9_0;
			if (obj == null)
			{
				EventHandler val4 = delegate(VideoPlayer source)
				{
					source.Play();
					source.Pause();
					source.time = 0.0;
				};
				<>c.<>9__9_0 = val4;
				obj = (object)val4;
			}
			val.prepareCompleted += (EventHandler)obj;
			hover.SetupVideo(val, rawImg, rt);
		}

		private static void SpawnBubble(Transform bubbleContainer, Sprite sprite)
		{
			//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_0044: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Bubble", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(BubbleBehaviour)
			});
			val.transform.SetParent(bubbleContainer, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			component.pivot = new Vector2(0.5f, 0.5f);
			Image component2 = val.GetComponent<Image>();
			component2.sprite = sprite;
			Color color = default(Color);
			((Color)(ref color))..ctor(0.6f, 0.8f, 0.9f, 1f);
			color.a = Random.Range(0.1f, 0.3f);
			((Graphic)component2).color = color;
			((Graphic)component2).raycastTarget = false;
			float num = Random.Range(40f, 150f);
			component.sizeDelta = new Vector2(num, num);
			val.GetComponent<BubbleBehaviour>().Setup(Random.Range(0, 1920), Random.Range(0, 1080));
		}

		private static Texture2D CreateBubbleTexture()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0043: 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_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)
			int num = 64;
			Texture2D val = new Texture2D(num, num, (TextureFormat)5, false);
			Color[] array = (Color[])(object)new Color[num * num];
			float num2 = (float)num / 2f;
			float num3 = (float)num / 2f;
			float num4 = (float)num / 2f;
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num; j++)
				{
					float num5 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num3));
					float num6 = Mathf.Clamp01(1f - num5 / num4);
					num6 = Mathf.Pow(num6, 2f);
					array[i * num + j] = new Color(1f, 1f, 1f, num6);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private static Sprite CreateRoundedRectSprite(int w, int h, int r, Color col)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_013a: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(w, h, (TextureFormat)5, false);
			Color[] array = (Color[])(object)new Color[w * h];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Color.clear;
			}
			for (int j = 0; j < h; j++)
			{
				for (int k = 0; k < w; k++)
				{
					bool num = k < r && j >= h - r;
					bool flag = k >= w - r && j >= h - r;
					bool flag2 = k < r && j < r;
					bool flag3 = k >= w - r && j < r;
					if (num || flag || flag2 || flag3)
					{
						float num2 = ((k < r) ? r : (w - r - 1));
						float num3 = ((j < r) ? r : (h - r - 1));
						if (Vector2.Distance(new Vector2((float)k, (float)j), new Vector2(num2, num3)) <= (float)r)
						{
							array[j * w + k] = col;
						}
					}
					else
					{
						array[j * w + k] = col;
					}
				}
			}
			val.SetPixels(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)w, (float)h), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)r, (float)r, (float)r, (float)r));
		}

		private static Sprite CreateGlossSprite(int w, int h)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0083: 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_004d: 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)
			Texture2D val = new Texture2D(w, h, (TextureFormat)5, false);
			Color[] array = (Color[])(object)new Color[w * h];
			Color val2 = default(Color);
			for (int i = 0; i < h; i++)
			{
				float num = (float)i / (float)h;
				float num2 = Mathf.Clamp01(num * num * 0.4f);
				((Color)(ref val2))..ctor(1f, 1f, 1f, num2);
				for (int j = 0; j < w; j++)
				{
					array[i * w + j] = val2;
				}
			}
			val.SetPixels(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)w, (float)h), new Vector2(0.5f, 0.5f));
		}

		private static Sprite CreateGridSprite()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_001c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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)
			int num = 32;
			Texture2D val = new Texture2D(num, num, (TextureFormat)5, false);
			Color[] array = (Color[])(object)new Color[num * num];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Color.clear;
			}
			for (int j = 0; j < num; j++)
			{
				array[j] = Color.white;
			}
			for (int k = 0; k < num; k++)
			{
				array[k * num] = Color.white;
			}
			val.SetPixels(array);
			val.Apply();
			((Texture)val).filterMode = (FilterMode)0;
			return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), Vector2.zero);
		}
	}
}
namespace Empress.WiiMainMenu.YapYap.Util
{
	internal static class AssetLoader
	{
		[CompilerGenerated]
		private sealed class <LoadAudioClips>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Action<AudioClip?> onHover;

			public Action<AudioClip?> onSelect;

			private string <folder>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LoadAudioClips>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<folder>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<folder>5__2 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";
					<>2__current = LoadOgg(Path.Combine(<folder>5__2, "hover.ogg"), onHover);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = LoadOgg(Path.Combine(<folder>5__2, "select.ogg"), onSelect);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <LoadOgg>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string path;

			public Action<AudioClip?> assign;

			private UnityWebRequest <uwr>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LoadOgg>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<uwr>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Invalid comparison between Unknown and I4
				bool result;
				try
				{
					switch (<>1__state)
					{
					default:
						result = false;
						break;
					case 0:
						<>1__state = -1;
						if (!File.Exists(path))
						{
							assign(null);
							result = false;
							break;
						}
						<uwr>5__2 = UnityWebRequestMultimedia.GetAudioClip("file://" + path, (AudioType)14);
						<>1__state = -3;
						<>2__current = <uwr>5__2.SendWebRequest();
						<>1__state = 1;
						result = true;
						break;
					case 1:
						<>1__state = -3;
						if ((int)<uwr>5__2.result == 1)
						{
							assign(DownloadHandlerAudioClip.GetContent(<uwr>5__2));
						}
						else
						{
							assign(null);
						}
						result = false;
						<>m__Finally1();
						break;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
				return result;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<uwr>5__2 != null)
				{
					((IDisposable)<uwr>5__2).Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const string HoverFile = "hover.ogg";

		private const string SelectFile = "select.ogg";

		[IteratorStateMachine(typeof(<LoadAudioClips>d__2))]
		public static IEnumerator LoadAudioClips(Action<AudioClip?> onHover, Action<AudioClip?> onSelect)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadAudioClips>d__2(0)
			{
				onHover = onHover,
				onSelect = onSelect
			};
		}

		[IteratorStateMachine(typeof(<LoadOgg>d__3))]
		private static IEnumerator LoadOgg(string path, Action<AudioClip?> assign)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadOgg>d__3(0)
			{
				path = path,
				assign = assign
			};
		}
	}
	internal static class ReflectionCache
	{
		private static readonly Type MenuStateType = ResolveMenuStateType();

		private static readonly FieldInfo CurrentStateField = ResolveCurrentStateField();

		private static readonly MethodInfo SetMenuStateMethod = ResolveSetMenuStateMethod();

		public static MethodBase GetSetMenuStateMethod()
		{
			return SetMenuStateMethod;
		}

		public static string GetCurrentMenuStateName(MenuController menu)
		{
			return CurrentStateField.GetValue(menu)?.ToString() ?? string.Empty;
		}

		public static bool IsInMenuState(MenuController menu, string stateName)
		{
			return string.Equals(GetCurrentMenuStateName(menu), stateName, StringComparison.Ordinal);
		}

		public static void CallSetMenuState(MenuController menu, string stateName)
		{
			object obj = Enum.Parse(MenuStateType, stateName, ignoreCase: false);
			SetMenuStateMethod.Invoke(menu, new object[1] { obj });
		}

		private static Type ResolveMenuStateType()
		{
			Type? nestedType = typeof(MenuController).GetNestedType("MenuState", BindingFlags.Public | BindingFlags.NonPublic);
			if (nestedType == null)
			{
				throw new MissingMemberException(typeof(MenuController).FullName, "MenuState (nested enum)");
			}
			return nestedType;
		}

		private static FieldInfo ResolveCurrentStateField()
		{
			FieldInfo? field = typeof(MenuController).GetField("_currentState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				throw new MissingFieldException(typeof(MenuController).FullName, "_currentState");
			}
			return field;
		}

		private static MethodInfo ResolveSetMenuStateMethod()
		{
			MethodInfo? method = typeof(MenuController).GetMethod("SetMenuState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { MenuStateType }, null);
			if (method == null)
			{
				throw new MissingMethodException(typeof(MenuController).FullName, "SetMenuState(MenuState)");
			}
			return method;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ConstantExpectedAttribute : Attribute
	{
		public object? Min { get; set; }

		public object? Max { get; set; }
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class OverloadResolutionPriorityAttribute : Attribute
	{
		public int Priority { get; }

		public OverloadResolutionPriorityAttribute(int priority)
		{
			Priority = priority;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ParamCollectionAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}