Decompiled source of REPOArcade v1.1.3

REPOArcade.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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("REPOArcade")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Client-side R.E.P.O. Arcade v1.1.3 with sixteen built-in games, Creator's Vault exclusive cosmetics, premium animated effects, controller support, accessibility, save backups, XP, challenges, contracts, achievements, and local progression.")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion("1.1.3")]
[assembly: AssemblyProduct("REPOArcade")]
[assembly: AssemblyTitle("REPOArcade")]
[assembly: AssemblyVersion("1.1.3.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 Ricker.REPOArcade
{
	[BepInPlugin("ricker.repoarcade", "R.E.P.O. Arcade", "1.1.3")]
	public sealed class REPOArcadePlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "ricker.repoarcade";

		public const string PluginName = "R.E.P.O. Arcade";

		public const string PluginVersion = "1.1.3";

		private static REPOArcadePlugin _instance;

		private static KeyCode _configuredToggleKey = (KeyCode)289;

		private static volatile int _configuredToggleVirtualKey = 119;

		private Harmony _harmony;

		private bool _menuUpdateHookLogged;

		private bool _playerUpdateHookLogged;

		private ArcadeController _controller;

		private bool _updatePumpLogged;

		private bool _guiPumpLogged;

		private volatile bool _applicationFocused;

		private volatile bool _stopKeyboardWatcher;

		private volatile bool _keyboardWatcherRunning;

		private Thread _keyboardWatcher;

		private int _pendingToggleKey;

		private static string _cachedLocalSteamId64 = string.Empty;

		private static float _nextSteamIdLookupTime;

		public static KeyCode ConfiguredToggleKey => _configuredToggleKey;

		public static string ConfiguredToggleKeyName => ((object)Unsafe.As<KeyCode, KeyCode>(ref _configuredToggleKey)/*cast due to .constrained prefix*/).ToString();

		public static int ConfiguredToggleVirtualKey => _configuredToggleVirtualKey;

		public static bool IsCurrentUserCreator()
		{
			string text = "3cb243aecb558667b64cb1e58e2bcae28d1878578b71de340879b82a9c85a4e2";
			if (!IsSha256Hex(text))
			{
				return false;
			}
			string text2 = TryGetLocalSteamId64();
			if (string.IsNullOrEmpty(text2))
			{
				return false;
			}
			string b = HashSteamId64(text2);
			return string.Equals(text, b, StringComparison.OrdinalIgnoreCase);
		}

		private static bool IsSha256Hex(string value)
		{
			if (string.IsNullOrEmpty(value) || value.Length != 64)
			{
				return false;
			}
			foreach (char c in value)
			{
				if ((c < '0' || c > '9') && (c < 'a' || c > 'f') && (c < 'A' || c > 'F'))
				{
					return false;
				}
			}
			return true;
		}

		private static string HashSteamId64(string steamId64)
		{
			using SHA256 sHA = SHA256.Create();
			byte[] array = sHA.ComputeHash(Encoding.UTF8.GetBytes(steamId64));
			StringBuilder stringBuilder = new StringBuilder(array.Length * 2);
			for (int i = 0; i < array.Length; i++)
			{
				stringBuilder.Append(array[i].ToString("x2", CultureInfo.InvariantCulture));
			}
			return stringBuilder.ToString();
		}

		private static string TryGetLocalSteamId64()
		{
			if (!string.IsNullOrEmpty(_cachedLocalSteamId64))
			{
				return _cachedLocalSteamId64;
			}
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime < _nextSteamIdLookupTime)
			{
				return string.Empty;
			}
			_nextSteamIdLookupTime = unscaledTime + 2f;
			Assembly[] assemblies;
			try
			{
				assemblies = AppDomain.CurrentDomain.GetAssemblies();
			}
			catch
			{
				return string.Empty;
			}
			for (int i = 0; i < assemblies.Length; i++)
			{
				try
				{
					Type type = assemblies[i].GetType("Steamworks.SteamUser", throwOnError: false);
					if (type == null)
					{
						continue;
					}
					MethodInfo method = type.GetMethod("GetSteamID", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null);
					if (method == null)
					{
						continue;
					}
					object obj2 = method.Invoke(null, null);
					if (obj2 == null)
					{
						continue;
					}
					FieldInfo field = obj2.GetType().GetField("m_SteamID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						object value = field.GetValue(obj2);
						if (value != null && ulong.TryParse(Convert.ToString(value, CultureInfo.InvariantCulture), NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) && result != 0)
						{
							_cachedLocalSteamId64 = result.ToString(CultureInfo.InvariantCulture);
							return _cachedLocalSteamId64;
						}
					}
					string text = obj2.ToString();
					if (!IsSteamId64Digits(text))
					{
						continue;
					}
					_cachedLocalSteamId64 = text;
					return _cachedLocalSteamId64;
				}
				catch
				{
				}
			}
			return string.Empty;
		}

		private static bool IsSteamId64Digits(string value)
		{
			if (string.IsNullOrEmpty(value) || value.Length != 17)
			{
				return false;
			}
			for (int i = 0; i < value.Length; i++)
			{
				if (value[i] < '0' || value[i] > '9')
				{
					return false;
				}
			}
			return true;
		}

		public unsafe static void ConfigureToggleKey(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (!IsConfigurableToggleKey(key))
			{
				key = (KeyCode)289;
			}
			_configuredToggleKey = key;
			_configuredToggleVirtualKey = VirtualKeyFor(key);
			REPOArcadePlugin instance = _instance;
			if ((Object)(object)instance != (Object)null)
			{
				((BaseUnityPlugin)instance).Logger.LogInfo((object)("Arcade toggle key set to " + ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString() + "; Insert remains available as the backup key."));
			}
		}

		public static bool IsConfigurableToggleKey(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			if ((int)key != 289 && (int)key != 278 && (int)key != 279 && (int)key != 280)
			{
				return (int)key == 281;
			}
			return true;
		}

		private static int VirtualKeyFor(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected I4, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			switch (key - 278)
			{
			default:
				_ = 289;
				return 119;
			case 0:
				return 36;
			case 1:
				return 35;
			case 2:
				return 33;
			case 3:
				return 34;
			}
		}

		private static string VirtualKeyName(int virtualKey)
		{
			if (virtualKey >= 112 && virtualKey <= 123)
			{
				return "F" + (virtualKey - 111);
			}
			return virtualKey switch
			{
				45 => "Insert", 
				36 => "Home", 
				35 => "End", 
				33 => "PageUp", 
				34 => "PageDown", 
				_ => "VK_" + virtualKey, 
			};
		}

		[DllImport("user32.dll", EntryPoint = "GetAsyncKeyState")]
		private static extern short NativeGetAsyncKeyState(int virtualKey);

		private void Awake()
		{
			try
			{
				_instance = this;
				_applicationFocused = Application.isFocused;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
				EnsureController("plugin Awake");
				StartKeyboardWatcher();
				InstallGameLoopPumps();
				((BaseUnityPlugin)this).Logger.LogInfo((object)("R.E.P.O. Arcade 1.1.3 loaded. Toggle requests are consumed by plugin callbacks and Harmony-patched game Update loops. Main key: " + ConfiguredToggleKeyName + "; backup: Insert."));
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to initialize R.E.P.O. Arcade: " + ex));
				throw;
			}
		}

		private void EnsureController(string reason)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			if ((Object)(object)_controller != (Object)null)
			{
				return;
			}
			GameObject val = null;
			try
			{
				val = GameObject.Find("Ricker_REPOArcade_Controller");
				if ((Object)(object)val != (Object)null)
				{
					_controller = val.GetComponent<ArcadeController>();
					if ((Object)(object)_controller != (Object)null)
					{
						((Behaviour)_controller).enabled = false;
						((BaseUnityPlugin)this).Logger.LogWarning((object)("Recovered the existing arcade controller during " + reason + "."));
						return;
					}
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not inspect the previous arcade controller during " + reason + ": " + ex.GetType().Name + "."));
			}
			if ((Object)(object)val == (Object)null)
			{
				val = new GameObject("Ricker_REPOArcade_Controller");
				Object.DontDestroyOnLoad((Object)(object)val);
			}
			_controller = val.AddComponent<ArcadeController>();
			((Behaviour)_controller).enabled = false;
			_controller.Initialize(((BaseUnityPlugin)this).Logger);
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Created a fresh arcade controller during " + reason + ". Controller host persists across scene changes."));
		}

		private void InstallGameLoopPumps()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			try
			{
				_harmony = new Harmony("ricker.repoarcade.MainThreadPump");
				int num = 0;
				Type type = AccessTools.TypeByName("MenuManager");
				MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "Update", (Type[])null, (Type[])null));
				if (methodInfo != null && !methodInfo.IsAbstract)
				{
					_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(REPOArcadePlugin), "MenuManagerUpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					num++;
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Installed main-thread input pump on MenuManager.Update.");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find MenuManager.Update; plugin callbacks remain as input-pump fallbacks.");
				}
				Type type2 = AccessTools.TypeByName("PlayerAvatar");
				MethodInfo methodInfo2 = ((type2 == null) ? null : AccessTools.Method(type2, "Update", (Type[])null, (Type[])null));
				if (methodInfo2 != null && !methodInfo2.IsAbstract)
				{
					_harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(REPOArcadePlugin), "PlayerAvatarUpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					num++;
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Installed main-thread input pump on PlayerAvatar.Update.");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find PlayerAvatar.Update; mission input pump may rely on other hooks.");
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Arcade main-thread input pumps installed: " + num + ". These pumps consume queued keyboard requests and advance UI state on Unity's main thread."));
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to install optional game-loop input pumps; plugin callbacks remain available. " + ex));
			}
		}

		private static void MenuManagerUpdatePostfix()
		{
			REPOArcadePlugin instance = _instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.PumpFromPatchedGameUpdate("MenuManager.Update");
			}
		}

		private static void PlayerAvatarUpdatePostfix()
		{
			REPOArcadePlugin instance = _instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.PumpFromPatchedGameUpdate("PlayerAvatar.Update");
			}
		}

		private void PumpFromPatchedGameUpdate(string source)
		{
			if (source == "MenuManager.Update" && !_menuUpdateHookLogged)
			{
				_menuUpdateHookLogged = true;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Main-thread pump heartbeat received from MenuManager.Update.");
			}
			else if (source == "PlayerAvatar.Update" && !_playerUpdateHookLogged)
			{
				_playerUpdateHookLogged = true;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Main-thread pump heartbeat received from PlayerAvatar.Update.");
			}
			EnsureController(source);
			ConsumePendingToggle(source);
			if ((Object)(object)_controller != (Object)null)
			{
				_controller.ProcessUpdate();
			}
		}

		private void StartKeyboardWatcher()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((int)Application.platform != 2 && (int)Application.platform != 7)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Windows background keyboard watcher not available on this platform; Unity input fallback will be used.");
				return;
			}
			try
			{
				_stopKeyboardWatcher = false;
				_keyboardWatcher = new Thread(KeyboardWatcherLoop);
				_keyboardWatcher.IsBackground = true;
				_keyboardWatcher.Name = "REPOArcade Keyboard Watcher";
				_keyboardWatcher.Start();
				_keyboardWatcherRunning = true;
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Windows background keyboard watcher started. It polls " + ConfiguredToggleKeyName + " and backup Insert every 10 ms and queues presses for the Unity main thread."));
			}
			catch (Exception ex)
			{
				_keyboardWatcherRunning = false;
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not start Windows background keyboard watcher; Unity input fallback will be used. " + ex.GetType().Name + ": " + ex.Message));
			}
		}

		private void KeyboardWatcherLoop()
		{
			bool flag = false;
			bool flag2 = false;
			try
			{
				while (!_stopKeyboardWatcher)
				{
					int configuredToggleVirtualKey = ConfiguredToggleVirtualKey;
					bool flag3 = _applicationFocused && (NativeGetAsyncKeyState(configuredToggleVirtualKey) & -32768) != 0;
					bool flag4 = configuredToggleVirtualKey != 45 && _applicationFocused && (NativeGetAsyncKeyState(45) & -32768) != 0;
					if (flag3 && !flag && Interlocked.CompareExchange(ref _pendingToggleKey, configuredToggleVirtualKey, 0) == 0)
					{
						string text = VirtualKeyName(configuredToggleVirtualKey);
						try
						{
							((BaseUnityPlugin)this).Logger.LogInfo((object)("Windows background keyboard watcher detected " + text + " and queued an arcade toggle."));
						}
						catch
						{
						}
					}
					if (flag4 && !flag2 && Interlocked.CompareExchange(ref _pendingToggleKey, 45, 0) == 0)
					{
						try
						{
							((BaseUnityPlugin)this).Logger.LogInfo((object)"Windows background keyboard watcher detected Insert and queued an arcade toggle.");
						}
						catch
						{
						}
					}
					flag = flag3;
					flag2 = flag4;
					Thread.Sleep(10);
				}
			}
			catch (Exception ex)
			{
				_keyboardWatcherRunning = false;
				try
				{
					((BaseUnityPlugin)this).Logger.LogError((object)("Windows background keyboard watcher stopped: " + ex.GetType().Name + ": " + ex.Message));
				}
				catch
				{
				}
			}
			finally
			{
				_keyboardWatcherRunning = false;
			}
		}

		private void ConsumePendingToggle(string source)
		{
			int num = Interlocked.Exchange(ref _pendingToggleKey, 0);
			if (num != 0)
			{
				string text = VirtualKeyName(num);
				EnsureController("queued " + text + " request from " + source);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Main-thread pump consumed queued " + text + " toggle via " + source + ". ControllerAvailable=" + ((Object)(object)_controller != (Object)null) + "."));
				if ((Object)(object)_controller == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)("Queued " + text + " request was consumed, but controller recovery failed."));
				}
				else
				{
					_controller.ToggleFromBackgroundWatcher(text);
				}
			}
		}

		private void Update()
		{
			//IL_003d: 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)
			if (!_updatePumpLogged)
			{
				_updatePumpLogged = true;
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Arcade plugin Update pump is running. Focused=" + Application.isFocused + "; platform=" + ((object)Application.platform/*cast due to .constrained prefix*/).ToString() + "."));
			}
			EnsureController("plugin Update");
			ConsumePendingToggle("plugin Update");
			if ((Object)(object)_controller != (Object)null)
			{
				_controller.ProcessUpdate();
			}
		}

		private void OnGUI()
		{
			if (!_guiPumpLogged)
			{
				_guiPumpLogged = true;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Arcade plugin OnGUI pump is running; centered launcher should be rendered while the arcade is closed.");
			}
			EnsureController("plugin OnGUI");
			if (!((Object)(object)_controller == (Object)null))
			{
				ConsumePendingToggle("plugin OnGUI");
				if (!_keyboardWatcherRunning)
				{
					_controller.PollHotkeyFromOnGUI();
				}
				_controller.ProcessUpdate();
				_controller.RenderGUI();
				_controller.RenderFallbackLauncher();
			}
		}

		private void OnApplicationFocus(bool hasFocus)
		{
			_applicationFocused = hasFocus;
			if ((Object)(object)_controller != (Object)null)
			{
				_controller.NotifyApplicationFocus(hasFocus);
			}
		}

		private void OnDestroy()
		{
			_stopKeyboardWatcher = true;
			try
			{
				if (_keyboardWatcher != null && _keyboardWatcher.IsAlive)
				{
					_keyboardWatcher.Join(150);
				}
			}
			catch
			{
			}
			if ((Object)(object)_controller != (Object)null)
			{
				_controller.Shutdown();
			}
			try
			{
				if (_harmony != null)
				{
					_harmony.UnpatchSelf();
				}
			}
			catch
			{
			}
			if ((Object)(object)_instance == (Object)(object)this)
			{
				_instance = null;
			}
		}
	}
	internal enum ArcadeView
	{
		Home,
		GamesLibrary,
		Minesweeper,
		Snake,
		MonsterEscape,
		BrickBreaker,
		Pong,
		NumberMerge,
		BlockDrop,
		SpaceDefender,
		MemoryMatch,
		Achievements,
		Statistics,
		PrizeRoom,
		ChallengeMode,
		DailyChallenge,
		DungeonDelver,
		WhackAMole,
		TurboRun,
		TowerDefense,
		ScrapshotSiege,
		ScrapPutt,
		CircleConquest,
		ArcadeChampionship,
		WeeklyGauntlet,
		Contracts,
		Settings,
		Help
	}
	public sealed class ArcadeController : MonoBehaviour
	{
		private ManualLogSource _log;

		private bool _visible;

		private bool _savedCursor;

		private int _lastToggleFrame = -1;

		private int _lastProcessedFrame = -1;

		private bool _nativeToggleWasDown;

		private bool _nativeInsertWasDown;

		private bool _nativeKeyboardApiUnavailable;

		private bool _controllerUpdateLogged;

		private bool _controllerGuiLogged;

		private CursorLockMode _previousLockState;

		private bool _previousCursorVisible;

		private ArcadeView _view;

		private Rect _windowRect;

		private KeyCode _toggleKey = (KeyCode)289;

		private static readonly KeyCode[] ToggleKeyChoices;

		private string _settingsMessage = "F8 is the default. Insert remains a fixed backup shortcut.";

		private bool _gamepadEnabled = true;

		private bool _highContrast;

		private bool _reduceMotion;

		private bool _largeText;

		private bool _performanceMode;

		private bool _confirmRestoreBackup;

		private int _controlLayout;

		private readonly HashSet<KeyCode> _gamepadPressedKeys = new HashSet<KeyCode>();

		private readonly HashSet<KeyCode> _gamepadHeldKeys = new HashSet<KeyCode>();

		private int _lastGamepadPollFrame = -1;

		private int _lastMenuNavigationFrame = -1;

		private int _navButtonIndex;

		private int _navButtonCountLastFrame = 1;

		private int _navSelectedIndex;

		private int _navConfirmFrame = -1;

		private int _navConfirmConsumedFrame = -1;

		private bool _padLeftWasDown;

		private bool _padRightWasDown;

		private bool _padUpWasDown;

		private bool _padDownWasDown;

		private bool _padAWasDown;

		private bool _padBWasDown;

		private bool _padStartWasDown;

		private float _padLeftRepeatAt;

		private float _padRightRepeatAt;

		private float _padUpRepeatAt;

		private float _padDownRepeatAt;

		private readonly Random _challengeRng = new Random();

		private readonly List<string> _challengeDeck = new List<string>();

		private readonly List<string> _challengeResults = new List<string>();

		private bool _challengeActive;

		private bool _challengeIsDaily;

		private bool _challengeIsWeekly;

		private string _challengeWeeklyKey = string.Empty;

		private string _weeklyLastCompletedKey = string.Empty;

		private string _weeklyGauntletMessage = "A fixed weekly gauntlet with one rotating modifier.";

		private int _weeklyGauntletRunsCompleted;

		private int _weeklyGauntletBestWins;

		private int _weeklyGauntletPerfectRuns;

		private int _selectedChallengeModifier;

		private int _challengeModifier;

		private string _challengeDailyDate = string.Empty;

		private string _dailyLastCompletedDate = string.Empty;

		private int _dailyRunsCompleted;

		private int _dailyCurrentStreak;

		private int _dailyBestStreak;

		private int _dailyBestScore;

		private int _challengeDailyScore;

		private bool _challengeAwaitingNext;

		private int _arcadeXp;

		private int _arcadeLevel = 1;

		private int _totalContractsCompleted;

		private string _contractDailyDate = string.Empty;

		private int _dailyContractGamesFinished;

		private int _dailyContractTicketsEarned;

		private int _dailyContractTurboDistance;

		private bool _dailyGamesContractClaimed;

		private bool _dailyTicketsContractClaimed;

		private bool _dailyTurboContractClaimed;

		private string _contractWeekKey = string.Empty;

		private int _weeklyContractGamesFinished;

		private bool _weeklyContractClaimed;

		private bool _suppressContractTicketProgress;

		private string _contractsMessage = "Complete contract objectives to earn XP and tickets.";

		private bool _challengeRunComplete;

		private int _challengeDifficulty;

		private int _challengeStage;

		private int _challengeWins;

		private int _challengeStreak;

		private int _challengeTicketBonus;

		private int _challengeRunsCompleted;

		private int _challengePerfectRuns;

		private int _challengeRoundsWon;

		private int _bestChallengeWins;

		private int _totalChallengeTickets;

		private string _challengeCurrentGame = string.Empty;

		private string _challengeMessage = "Start a three-game arcade challenge for bonus tickets.";

		private readonly List<string> _championshipDeck = new List<string>();

		private readonly List<string> _championshipResults = new List<string>();

		private bool _championshipActive;

		private bool _championshipAwaitingNext;

		private bool _championshipRunComplete;

		private int _championshipStage;

		private int _championshipWins;

		private int _championshipRunScore;

		private int _championshipBestScore;

		private int _championshipBestWins;

		private int _championshipsCompleted;

		private int _championshipPerfectRuns;

		private int _championshipLifetimePoints;

		private string _championshipCurrentGame = string.Empty;

		private string _championshipMessage = "Five rounds across five arcade categories. Earn a medal based on your results.";

		private MinesweeperGame _mines = new MinesweeperGame();

		private SnakeGame _snake = new SnakeGame();

		private MonsterEscapeGame _escape = new MonsterEscapeGame();

		private BrickBreakerGame _brickBreaker = new BrickBreakerGame();

		private PongGame _pong = new PongGame();

		private NumberMergeGame _numberMerge = new NumberMergeGame();

		private BlockDropGame _blockDrop = new BlockDropGame();

		private SpaceDefenderGame _spaceDefender = new SpaceDefenderGame();

		private MemoryMatchGame _memoryMatch = new MemoryMatchGame();

		private DungeonDelverGame _dungeonDelver = new DungeonDelverGame();

		private WhackAMoleGame _whackAMole = new WhackAMoleGame();

		private TurboRunGame _turboRun = new TurboRunGame();

		private TowerDefenseGame _towerDefense = new TowerDefenseGame();

		private ScrapshotSiegeGame _scrapshot = new ScrapshotSiegeGame();

		private ScrapPuttGame _scrapPutt = new ScrapPuttGame();

		private CircleConquestGame _circleConquest = new CircleConquestGame();

		private bool _circleConquestResultRecorded;

		private bool _circleSendAll;

		private bool _circleMoveMode;

		private string _circleUiMessage = "Select one of your circles, recruit troops, then attack an adjacent circle.";

		private bool _towerDefenseResultRecorded;

		private bool _scrapshotResultRecorded;

		private bool _scrapshotLevelRewardRecorded;

		private bool _scrapshotFinishTracked;

		private bool _scrapshotAiming;

		private bool _scrapshotLongTrajectory = true;

		private Vector2 _scrapshotDragPoint;

		private Vector2 _scrapshotAimStartPoint;

		private bool _scrapPuttResultRecorded;

		private bool _scrapPuttHoleRewardRecorded;

		private bool _scrapPuttAiming;

		private Vector2 _scrapPuttDragPoint;

		private Vector2 _scrapPuttAimStartPoint;

		private bool _mineResultRecorded;

		private bool _snakeResultRecorded;

		private bool _escapeResultRecorded;

		private bool _brickResultRecorded;

		private bool _pongResultRecorded;

		private bool _mergeResultRecorded;

		private bool _blockDropResultRecorded;

		private bool _spaceDefenderResultRecorded;

		private bool _memoryMatchResultRecorded;

		private bool _dungeonResultRecorded;

		private bool _moleResultRecorded;

		private bool _turboRunResultRecorded;

		private int _dungeonRewardedFloors;

		private int _bestDungeonFloor;

		private int _bestMoleScore;

		private int _bestTurboScore;

		private int _bestTurboDistance;

		private int _bestTowerDefenseWave;

		private int _bestTowerDefenseScore;

		private int _totalTowerEnemiesDefeated;

		private int _bestScrapshotLevel;

		private int _bestScrapshotScore;

		private int _totalScrapshotTargetsDestroyed;

		private int _totalScrapshotLevelsCleared;

		private int _totalScrapshotStarsEarned;

		private int _startsScrapshotSiege;

		private int _bestCircleConquestTerritories;

		private int _bestCircleConquestScore;

		private int _bestScrapPuttHoles;

		private int _bestScrapPuttScore;

		private int _totalScrapPuttHolesCompleted;

		private int _startsScrapPutt;

		private int _totalCircleConquestCaptures;

		private int _totalCircleConquestBossesDefeated;

		private int _startsCircleConquest;

		private int _startsTowerDefense;

		private int _totalTurboCoins;

		private int _startsTurboRun;

		private int _totalDungeonFloorsCleared;

		private int _totalDungeonGoldCollected;

		private int _totalMoleHits;

		private int _startsDungeonDelver;

		private int _startsWhackAMole;

		private int _bestSnakeScore;

		private int _bestEscapeLevel;

		private int _bestBrickScore;

		private int _bestPongScore;

		private int _bestMergeScore;

		private int _bestBlockDropScore;

		private int _bestBlockDropLines;

		private int _bestSpaceDefenderScore;

		private int _bestSpaceDefenderWave;

		private int _bestMemoryMatchMs = int.MaxValue;

		private int _bestBeginnerMs = int.MaxValue;

		private int _bestIntermediateMs = int.MaxValue;

		private int _bestExpertMs = int.MaxValue;

		private int _tickets;

		private int _gamesStarted;

		private int _gamesFinished;

		private int _totalTicketsEarned;

		private int _totalTicketsSpent;

		private int _totalEscapeLevelsCleared;

		private int _totalBlockLinesCleared;

		private int _totalSpaceEnemiesDefeated;

		private int _totalSpaceBossesDefeated;

		private int _totalMemoryPairsMatched;

		private int _startsMinesweeper;

		private int _startsSnake;

		private int _startsMonsterEscape;

		private int _startsBrickBreaker;

		private int _startsPong;

		private int _startsNumberMerge;

		private int _startsBlockDrop;

		private int _startsSpaceDefender;

		private int _startsMemoryMatch;

		private int _escapeRewardedLevels;

		private float _escapeMoveRepeat;

		private string _statsPath;

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

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

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

		private string _achievementMessage = "Start playing to unlock achievements.";

		private string _selectedTheme = "classic";

		private string _selectedBoard = "default_board";

		private string _selectedEffect = "none";

		private string _prizeFilter = "ALL";

		private Vector2 _prizeScrollPosition = Vector2.zero;

		private Vector2 _libraryScrollPosition = Vector2.zero;

		private Vector2 _achievementScrollPosition = Vector2.zero;

		private string _libraryCategory = "ALL";

		private string _librarySearch = string.Empty;

		private string _achievementFilter = "ALL";

		private string _prizeMessage = "Earn tickets by playing games, then unlock cosmetics here.";

		private int _towerSelectedType;

		private string _towerStatusMessage = "Choose a tower, then click an empty tile to build. Click an existing tower to upgrade it.";

		private static readonly Color[] BrickRowColors;

		private static readonly CosmeticItem[] PrizeItems;

		private static readonly CosmeticCollectionInfo[] CosmeticCollections;

		private static readonly AchievementInfo[] AchievementDefinitions;

		private bool _stylesReady;

		private Texture2D _panelTexture;

		private Texture2D _panelInsetTexture;

		private Texture2D _solidTexture;

		private Texture2D _circleTexture;

		private Texture2D _buttonTexture;

		private Texture2D _buttonHoverTexture;

		private Texture2D _buttonActiveTexture;

		private Texture2D _hiddenTileTexture;

		private Texture2D _hiddenTileHoverTexture;

		private Texture2D _revealedTileTexture;

		private Texture2D _flagTileTexture;

		private Texture2D _flagTileHoverTexture;

		private Texture2D _mineTileTexture;

		private Texture2D _snakeBoardTexture;

		private Texture2D _snakeGridTexture;

		private Texture2D _snakeBodyTexture;

		private Texture2D _snakeHeadTexture;

		private Texture2D _snakeFoodTexture;

		private Texture2D _boardAltTexture;

		private Texture2D _sparkTexture;

		private Texture2D _escapeFloorTexture;

		private Texture2D _escapeWallTexture;

		private Texture2D _escapePlayerTexture;

		private Texture2D _escapeMonsterTexture;

		private Texture2D _escapeTreasureTexture;

		private Texture2D _escapeExitTexture;

		private Texture2D _escapeGlowTexture;

		private Color _themeAccent = new Color(0.42f, 0.96f, 0.78f);

		private Color _themeMuted = new Color(0.66f, 0.72f, 0.76f);

		private GUIStyle _escapeLabelStyle;

		private GUIStyle _panelStyle;

		private GUIStyle _titleStyle;

		private GUIStyle _subtitleStyle;

		private GUIStyle _bodyStyle;

		private GUIStyle _mutedStyle;

		private GUIStyle _buttonStyle;

		private GUIStyle _cardStyle;

		private GUIStyle _tileStyle;

		private GUIStyle _revealedStyle;

		private GUIStyle _numberStyle;

		private GUIStyle[] _numberStyles;

		private GUIStyle _smallButtonStyle;

		private GUIStyle _mergeTileStyle;

		private GUIStyle _memoryTileStyle;

		private GUIStyle _memoryHiddenStyle;

		private GUIStyle _launcherStyle;

		private bool _launcherDrawLogged;

		private bool _launcherNullEventLogged;

		private float _lastToggleRealtime = -100f;

		private string _lastToggleKeyName = string.Empty;

		private bool _gamepadPollWarningLogged;

		private GUIStyle _mineStyleCache;

		private GUIStyle _flagStyleCache;

		[DllImport("user32.dll")]
		private static extern short GetAsyncKeyState(int virtualKey);

		public void Initialize(ManualLogSource log)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			_log = log;
			_statsPath = Path.Combine(Paths.ConfigPath, "REPOArcade.stats");
			LoadStats();
			_arcadeLevel = CalculateArcadeLevel(_arcadeXp);
			EnsureContractPeriods();
			CheckCollectionCompletions(grantRewards: true);
			REPOArcadePlugin.ConfigureToggleKey(_toggleKey);
			if (_log != null)
			{
				_log.LogInfo((object)("Arcade controller state initialized. Toggle: " + REPOArcadePlugin.ConfiguredToggleKeyName + "; backup: Insert. Challenge Mode and arcade settings are ready."));
			}
		}

		private bool ReadNativeKeyDown(int virtualKey)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((int)Application.platform != 2 && (int)Application.platform != 7)
			{
				return false;
			}
			if (_nativeKeyboardApiUnavailable)
			{
				return false;
			}
			try
			{
				return (GetAsyncKeyState(virtualKey) & 0x8000) != 0;
			}
			catch (Exception ex)
			{
				_nativeKeyboardApiUnavailable = true;
				if (_log != null)
				{
					_log.LogWarning((object)("Windows native keyboard fallback is unavailable; using Unity input only. " + ex.GetType().Name));
				}
				return false;
			}
		}

		private bool ReadNativeToggleDown()
		{
			return ReadNativeKeyDown(REPOArcadePlugin.ConfiguredToggleVirtualKey);
		}

		private bool ReadNativeInsertDown()
		{
			if (REPOArcadePlugin.ConfiguredToggleVirtualKey != 45)
			{
				return ReadNativeKeyDown(45);
			}
			return false;
		}

		private void Update()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if (!_controllerUpdateLogged)
			{
				_controllerUpdateLogged = true;
				if (_log != null)
				{
					_log.LogInfo((object)("ArcadeController.Update heartbeat is running. Focused=" + Application.isFocused + "; platform=" + ((object)Application.platform/*cast due to .constrained prefix*/).ToString() + "."));
				}
			}
			ProcessUpdate();
		}

		private void OnGUI()
		{
			if (!_controllerGuiLogged)
			{
				_controllerGuiLogged = true;
				if (_log != null)
				{
					_log.LogInfo((object)"ArcadeController.OnGUI is running; direct controller input/render path active.");
				}
			}
			PollHotkeyFromOnGUI();
			ProcessUpdate();
			RenderGUI();
		}

		public void PollHotkeyFromOnGUI()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			bool flag = ReadNativeToggleDown();
			bool flag2 = ReadNativeInsertDown();
			bool num = flag && !_nativeToggleWasDown;
			bool flag3 = flag2 && !_nativeInsertWasDown;
			_nativeToggleWasDown = flag;
			_nativeInsertWasDown = flag2;
			if (num)
			{
				HandleToggleHotkey("OnGUI Windows keyboard poll", REPOArcadePlugin.ConfiguredToggleKeyName);
				return;
			}
			if (flag3)
			{
				HandleToggleHotkey("OnGUI Windows keyboard poll", "Insert");
				return;
			}
			try
			{
				if (Input.GetKeyDown(REPOArcadePlugin.ConfiguredToggleKey))
				{
					HandleToggleHotkey("OnGUI Unity input poll", REPOArcadePlugin.ConfiguredToggleKeyName);
				}
				else if (REPOArcadePlugin.ConfiguredToggleVirtualKey != 45 && Input.GetKeyDown((KeyCode)277))
				{
					HandleToggleHotkey("OnGUI Unity input poll", "Insert");
				}
			}
			catch (Exception ex)
			{
				if (_log != null)
				{
					_log.LogWarning((object)("Unity input poll from OnGUI failed: " + ex.GetType().Name));
				}
			}
		}

		public unsafe void RenderFallbackLauncher()
		{
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: 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_0043: 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_0049: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			if (_visible)
			{
				return;
			}
			if (Event.current == null)
			{
				if (!_launcherNullEventLogged)
				{
					_launcherNullEventLogged = true;
					if (_log != null)
					{
						_log.LogWarning((object)"Arcade launcher skipped because Event.current is null inside RenderFallbackLauncher.");
					}
				}
				return;
			}
			int depth = GUI.depth;
			Color backgroundColor = GUI.backgroundColor;
			Color contentColor = GUI.contentColor;
			try
			{
				GUI.depth = -30000;
				float num = Mathf.Clamp((float)Screen.width * 0.34f, 300f, 390f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, 12f, num, 58f);
				if (_launcherStyle == null)
				{
					_launcherStyle = new GUIStyle(GUI.skin.button);
					_launcherStyle.fontSize = 21;
					_launcherStyle.fontStyle = (FontStyle)1;
					_launcherStyle.alignment = (TextAnchor)4;
					_launcherStyle.wordWrap = false;
					_launcherStyle.fixedHeight = 58f;
					_launcherStyle.padding = new RectOffset(14, 14, 8, 8);
					_launcherStyle.normal.textColor = Color.white;
					_launcherStyle.hover.textColor = Color.white;
					_launcherStyle.active.textColor = Color.white;
				}
				GUI.backgroundColor = new Color(0.06f, 0.52f, 0.4f, 1f);
				GUI.contentColor = Color.white;
				if (!_launcherDrawLogged)
				{
					_launcherDrawLogged = true;
					if (_log != null)
					{
						ManualLogSource log = _log;
						string[] obj = new string[7]
						{
							"Arcade launcher draw executed. Screen=",
							Screen.width.ToString(),
							"x",
							Screen.height.ToString(),
							"; button rect=",
							null,
							null
						};
						Rect val2 = val;
						obj[5] = ((object)(*(Rect*)(&val2))/*cast due to .constrained prefix*/).ToString();
						obj[6] = ".";
						log.LogInfo((object)string.Concat(obj));
					}
				}
				if (ArcadeButton(val, "OPEN ARCADE  [" + REPOArcadePlugin.ConfiguredToggleKeyName + "]  •  BACKUP [INSERT]", _launcherStyle))
				{
					OpenArcade();
					if (_log != null)
					{
						_log.LogInfo((object)"Arcade opened using the centered on-screen launcher button.");
					}
				}
			}
			finally
			{
				GUI.backgroundColor = backgroundColor;
				GUI.contentColor = contentColor;
				GUI.depth = depth;
			}
		}

		public void ProcessUpdate()
		{
			int frameCount = Time.frameCount;
			if (_lastProcessedFrame == frameCount)
			{
				return;
			}
			_lastProcessedFrame = frameCount;
			PollGamepadInput();
			bool isFocused = Application.isFocused;
			if (!_visible || !isFocused)
			{
				return;
			}
			if (ArcadeKeyDown((KeyCode)27))
			{
				CloseArcade();
				Input.ResetInputAxes();
				return;
			}
			float num = Mathf.Clamp(Time.unscaledDeltaTime, 0f, 0.05f);
			if (_challengeActive && _challengeModifier == 2)
			{
				num = Mathf.Clamp(num * 1.25f, 0f, 0.0625f);
			}
			switch (_view)
			{
			case ArcadeView.TurboRun:
				if (_turboRun.IsGameOver)
				{
					if (ArcadeKeyDown((KeyCode)114) && !_challengeActive && !_championshipActive)
					{
						StartTurboRun();
					}
				}
				else
				{
					int moveDirection = 0;
					if (ArcadeKeyDown((KeyCode)276))
					{
						moveDirection = -1;
					}
					else if (ArcadeKeyDown((KeyCode)275))
					{
						moveDirection = 1;
					}
					_turboRun.Tick(num, moveDirection);
				}
				if (_turboRun.IsGameOver && !_turboRunResultRecorded)
				{
					bool num4 = _turboRun.Score > _bestTurboScore;
					bool flag = _turboRun.DistanceMeters > _bestTurboDistance;
					if (num4)
					{
						_bestTurboScore = _turboRun.Score;
					}
					if (flag)
					{
						_bestTurboDistance = _turboRun.DistanceMeters;
					}
					_totalTurboCoins += _turboRun.CoinsCollected;
					EnsureContractPeriods();
					_dailyContractTurboDistance = Math.Max(_dailyContractTurboDistance, _turboRun.DistanceMeters);
					if (_turboRun.DistanceMeters >= 500)
					{
						UnlockAchievement("turbo_500");
					}
					AwardTickets(3 + _turboRun.Score / 40 + _turboRun.CoinsCollected * 2, "Turbo Run complete");
					if (num4 || flag)
					{
						AddArcadeXp(15, "Turbo Run personal record");
					}
					TrackGameFinished();
					_turboRunResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.Minesweeper:
				_mines.Tick(num);
				if ((!_mines.IsWon && !_mines.IsLost) || _mineResultRecorded)
				{
					break;
				}
				if (_mines.IsWon)
				{
					RecordMinesweeperResult();
					if (_mines.Difficulty == 2)
					{
						UnlockAchievement("expert_miner");
					}
					if (_mines.Elapsed < 60f)
					{
						UnlockAchievement("quick_sweeper");
					}
				}
				TrackGameFinished();
				_mineResultRecorded = true;
				break;
			case ArcadeView.Snake:
				ReadSnakeInput();
				_snake.Tick(num);
				if (_snake.IsGameOver && !_snakeResultRecorded)
				{
					if (_snake.Score > _bestSnakeScore)
					{
						_bestSnakeScore = _snake.Score;
						AddArcadeXp(15, "New Snake personal record");
					}
					AwardTickets(2 + _snake.Score / 3, "Snake run complete");
					if (_snake.Score >= 25)
					{
						UnlockAchievement("snake_25");
					}
					if (_snake.Score >= 100)
					{
						UnlockAchievement("snake_100");
					}
					TrackGameFinished();
					_snakeResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.MonsterEscape:
				_escape.Tick(num);
				ReadEscapeInput();
				while (_escape.CompletedLevels > _escapeRewardedLevels)
				{
					_escapeRewardedLevels++;
					_totalEscapeLevelsCleared++;
					int amount8 = 8 + _escapeRewardedLevels * 3;
					AwardTickets(amount8, "Escaped level " + _escapeRewardedLevels);
					if (_escape.Level > _bestEscapeLevel)
					{
						_bestEscapeLevel = _escape.Level;
					}
					if (_escape.CompletedLevels >= 3)
					{
						UnlockAchievement("escape_3");
					}
					if (_escape.CompletedLevels >= 5)
					{
						UnlockAchievement("escape_5");
					}
					SaveStats();
				}
				if (_escape.IsGameOver && !_escapeResultRecorded)
				{
					if (_escape.Level > _bestEscapeLevel)
					{
						_bestEscapeLevel = _escape.Level;
					}
					TrackGameFinished();
					SaveStats();
					_escapeResultRecorded = true;
				}
				break;
			case ArcadeView.BrickBreaker:
				ReadBrickBreakerInput(num);
				_brickBreaker.Tick(num);
				if (_brickBreaker.IsGameOver && !_brickResultRecorded)
				{
					if (_brickBreaker.Score > _bestBrickScore)
					{
						_bestBrickScore = _brickBreaker.Score;
						AddArcadeXp(15, "New Brick Breaker personal record");
					}
					int amount6 = 3 + _brickBreaker.Score / 8 + (_brickBreaker.IsWon ? 12 : 0);
					AwardTickets(amount6, _brickBreaker.IsWon ? "Brick Breaker cleared" : "Brick Breaker run complete");
					if (_brickBreaker.IsWon)
					{
						UnlockAchievement("brick_clear");
					}
					TrackGameFinished();
					_brickResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.Pong:
				ReadPongInput(num);
				_pong.Tick(num);
				if (_pong.IsGameOver && !_pongResultRecorded)
				{
					if (_pong.PlayerScore > _bestPongScore)
					{
						_bestPongScore = _pong.PlayerScore;
						AddArcadeXp(15, "New Pong personal record");
					}
					int amount3 = 3 + _pong.PlayerScore * 2 + (_pong.PlayerWon ? 12 : 0);
					AwardTickets(amount3, _pong.PlayerWon ? "Pong match won" : "Pong match complete");
					if (_pong.PlayerWon)
					{
						UnlockAchievement("pong_champion");
					}
					TrackGameFinished();
					_pongResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.NumberMerge:
				ReadNumberMergeInput();
				_numberMerge.Tick(num);
				if (_numberMerge.IsGameOver && !_mergeResultRecorded)
				{
					if (_numberMerge.Score > _bestMergeScore)
					{
						_bestMergeScore = _numberMerge.Score;
						AddArcadeXp(15, "New Number Merge personal record");
					}
					int amount2 = 2 + _numberMerge.Score / 256 + (_numberMerge.Reached2048 ? 25 : 0);
					AwardTickets(amount2, _numberMerge.Reached2048 ? "Number Merge reached 2048" : "Number Merge run complete");
					if (_numberMerge.Reached2048)
					{
						UnlockAchievement("merge_2048");
					}
					TrackGameFinished();
					_mergeResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.BlockDrop:
				ReadBlockDropInput(num);
				_blockDrop.Tick(num);
				if (_blockDrop.IsGameOver && !_blockDropResultRecorded)
				{
					bool num5 = _blockDrop.Score > _bestBlockDropScore || _blockDrop.LinesCleared > _bestBlockDropLines;
					if (_blockDrop.Score > _bestBlockDropScore)
					{
						_bestBlockDropScore = _blockDrop.Score;
					}
					if (_blockDrop.LinesCleared > _bestBlockDropLines)
					{
						_bestBlockDropLines = _blockDrop.LinesCleared;
					}
					if (num5)
					{
						AddArcadeXp(15, "New Block Drop personal record");
					}
					_totalBlockLinesCleared += _blockDrop.LinesCleared;
					if (_totalBlockLinesCleared >= 10)
					{
						UnlockAchievement("blockdrop_10");
					}
					AwardTickets(2 + _blockDrop.Score / 500 + _blockDrop.LinesCleared, "Block Drop run complete");
					TrackGameFinished();
					_blockDropResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.SpaceDefender:
			{
				if (_spaceDefender.IsGameOver && ArcadeKeyDown((KeyCode)114) && !_challengeActive && !_championshipActive)
				{
					StartSpaceDefender();
					break;
				}
				int num6 = 0;
				if (ArcadeKeyHeld((KeyCode)276))
				{
					num6--;
				}
				if (ArcadeKeyHeld((KeyCode)275))
				{
					num6++;
				}
				_spaceDefender.Tick(num, num6, ArcadeKeyHeld((KeyCode)32));
				if (_spaceDefender.IsGameOver && !_spaceDefenderResultRecorded)
				{
					bool num7 = _spaceDefender.Score > _bestSpaceDefenderScore || _spaceDefender.Wave > _bestSpaceDefenderWave;
					if (_spaceDefender.Score > _bestSpaceDefenderScore)
					{
						_bestSpaceDefenderScore = _spaceDefender.Score;
					}
					if (_spaceDefender.Wave > _bestSpaceDefenderWave)
					{
						_bestSpaceDefenderWave = _spaceDefender.Wave;
					}
					if (num7)
					{
						AddArcadeXp(15, "New Space Defender personal record");
					}
					_totalSpaceEnemiesDefeated += _spaceDefender.EnemiesDefeated;
					_totalSpaceBossesDefeated += _spaceDefender.BossesDefeated;
					if (_spaceDefender.BossesDefeated > 0)
					{
						UnlockAchievement("space_boss");
					}
					AwardTickets(3 + _spaceDefender.Score / 100 + _spaceDefender.BossesDefeated * 15, "Space Defender run complete");
					TrackGameFinished();
					_spaceDefenderResultRecorded = true;
					SaveStats();
				}
				break;
			}
			case ArcadeView.MemoryMatch:
				_memoryMatch.Tick(num);
				if (_memoryMatch.IsWon && !_memoryMatchResultRecorded)
				{
					int num3 = Mathf.Max(1, Mathf.RoundToInt(_memoryMatch.Elapsed * 1000f));
					if (num3 < _bestMemoryMatchMs)
					{
						_bestMemoryMatchMs = num3;
						AddArcadeXp(15, "New Memory Match personal record");
					}
					_totalMemoryPairsMatched += _memoryMatch.PairsMatched;
					UnlockAchievement("memory_master");
					int amount4 = 10 + Mathf.Max(0, 45 - Mathf.FloorToInt(_memoryMatch.Elapsed / 2f));
					AwardTickets(amount4, "Memory Match cleared");
					TrackGameFinished();
					_memoryMatchResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.DungeonDelver:
				ReadDungeonDelverInput();
				while (_dungeonDelver.FloorsCleared > _dungeonRewardedFloors)
				{
					_dungeonRewardedFloors++;
					_totalDungeonFloorsCleared++;
					int amount7 = 5 + _dungeonRewardedFloors * 3;
					AwardTickets(amount7, "Dungeon floor " + _dungeonRewardedFloors + " cleared");
					if (_dungeonDelver.Floor >= 5)
					{
						UnlockAchievement("dungeon_5");
					}
					SaveStats();
				}
				if (_dungeonDelver.IsGameOver && !_dungeonResultRecorded)
				{
					if (_dungeonDelver.Floor > _bestDungeonFloor)
					{
						_bestDungeonFloor = _dungeonDelver.Floor;
						AddArcadeXp(15, "New Dungeon Delver personal record");
					}
					_totalDungeonGoldCollected += _dungeonDelver.Gold;
					AwardTickets(2 + _dungeonDelver.Gold / 12 + _dungeonDelver.FloorsCleared, "Dungeon Delver run ended");
					if (_dungeonDelver.Floor >= 5)
					{
						UnlockAchievement("dungeon_5");
					}
					TrackGameFinished();
					_dungeonResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.TowerDefense:
				if (_towerDefense.IsGameOver && ArcadeKeyDown((KeyCode)114) && !_challengeActive && !_championshipActive)
				{
					StartTowerDefense();
				}
				else
				{
					_towerDefense.Tick(num);
				}
				if (_towerDefense.HighestWave >= 5)
				{
					UnlockAchievement("tower_wave5");
				}
				if (_towerDefense.BossesDefeated > 0)
				{
					UnlockAchievement("tower_boss");
				}
				if (_towerDefense.IsGameOver && !_towerDefenseResultRecorded)
				{
					bool num8 = _towerDefense.HighestWave > _bestTowerDefenseWave || _towerDefense.Score > _bestTowerDefenseScore;
					_bestTowerDefenseWave = Math.Max(_bestTowerDefenseWave, _towerDefense.HighestWave);
					_bestTowerDefenseScore = Math.Max(_bestTowerDefenseScore, _towerDefense.Score);
					_totalTowerEnemiesDefeated += _towerDefense.EnemiesDefeated;
					if (num8)
					{
						AddArcadeXp(20, "New Mini Tower Defense personal record");
					}
					if (_towerDefense.IsWon)
					{
						UnlockAchievement("tower_clear");
					}
					AwardTickets(4 + _towerDefense.Score / 80 + _towerDefense.BossesDefeated * 12 + (_towerDefense.IsWon ? 20 : 0), _towerDefense.IsWon ? "Mini Tower Defense cleared" : "Mini Tower Defense ended");
					TrackGameFinished();
					_towerDefenseResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.CircleConquest:
				_circleConquest.Tick(num);
				if (_circleConquest.TerritoriesCaptured >= 1)
				{
					UnlockAchievement("circle_first");
				}
				if (_totalCircleConquestCaptures + _circleConquest.TerritoriesCaptured >= 10)
				{
					UnlockAchievement("circle_territories_10");
				}
				if (_circleConquest.BossesDefeated > 0)
				{
					UnlockAchievement("circle_boss");
				}
				if (_circleConquest.IsGameOver && !_circleConquestResultRecorded)
				{
					bool num2 = _circleConquest.TerritoriesCaptured > _bestCircleConquestTerritories || _circleConquest.Score > _bestCircleConquestScore;
					_bestCircleConquestTerritories = Math.Max(_bestCircleConquestTerritories, _circleConquest.TerritoriesCaptured);
					_bestCircleConquestScore = Math.Max(_bestCircleConquestScore, _circleConquest.Score);
					_totalCircleConquestCaptures += _circleConquest.TerritoriesCaptured;
					_totalCircleConquestBossesDefeated += _circleConquest.BossesDefeated;
					if (num2)
					{
						AddArcadeXp(20, "New Circle Conquest personal record");
					}
					if (_circleConquest.BossesDefeated > 0)
					{
						UnlockAchievement("circle_victory");
						AddArcadeXp(80, "Iron Crown conquered");
					}
					AwardTickets(4 + _circleConquest.TerritoriesCaptured * 4 + _circleConquest.BossesDefeated * 45 + (_circleConquest.IsWon ? 20 : 0), _circleConquest.IsWon ? "Circle Conquest victory" : "Circle Conquest campaign ended");
					TrackGameFinished();
					_circleConquestResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.ScrapshotSiege:
				if (_scrapshot.IsGameOver && !_scrapshot.IsWon && ArcadeKeyDown((KeyCode)114) && !_challengeActive && !_championshipActive)
				{
					RestartScrapshotLevel();
					break;
				}
				_scrapshot.Tick(num);
				if (_scrapshot.IsLevelCleared && !_scrapshotLevelRewardRecorded)
				{
					_totalScrapshotLevelsCleared++;
					_totalScrapshotStarsEarned += _scrapshot.LevelStars;
					_totalScrapshotTargetsDestroyed += _scrapshot.TargetsDestroyedThisLevel;
					_bestScrapshotLevel = Math.Max(_bestScrapshotLevel, _scrapshot.Level);
					_bestScrapshotScore = Math.Max(_bestScrapshotScore, _scrapshot.Score);
					int amount5 = 8 + _scrapshot.Level * 2 + _scrapshot.LevelStars * 5;
					AwardTickets(amount5, "Scrapshot Siege level " + _scrapshot.Level + " cleared (" + _scrapshot.LevelStars + " stars)");
					AddArcadeXp(8 + _scrapshot.LevelStars * 5, "Scrapshot Siege level cleared");
					UnlockAchievement("scrapshot_first");
					if (_totalScrapshotLevelsCleared >= 10)
					{
						UnlockAchievement("scrapshot_10");
					}
					if (_scrapshot.LevelStars >= 3)
					{
						UnlockAchievement("scrapshot_three_star");
					}
					if (_scrapshot.IsWon)
					{
						UnlockAchievement("scrapshot_campaign");
					}
					if (_challengeActive && !_scrapshotFinishTracked)
					{
						TrackGameFinished();
						_scrapshotFinishTracked = true;
					}
					_scrapshotLevelRewardRecorded = true;
					SaveStats();
				}
				if (_scrapshot.IsGameOver && !_scrapshotResultRecorded)
				{
					_bestScrapshotLevel = Math.Max(_bestScrapshotLevel, _scrapshot.Level);
					_bestScrapshotScore = Math.Max(_bestScrapshotScore, _scrapshot.Score);
					if (_scrapshot.IsWon)
					{
						AwardTickets(60, "Scrapshot Siege campaign completed");
						AddArcadeXp(100, "Scrapshot Siege campaign completed");
						UnlockAchievement("scrapshot_campaign");
					}
					if (!_scrapshotFinishTracked)
					{
						TrackGameFinished();
						_scrapshotFinishTracked = true;
					}
					_scrapshotResultRecorded = true;
					SaveStats();
				}
				break;
			case ArcadeView.ScrapPutt:
				_scrapPutt.Tick(num);
				if (_scrapPutt.IsHoleComplete && !_scrapPuttHoleRewardRecorded)
				{
					if (_scrapPutt.HoleWon)
					{
						_totalScrapPuttHolesCompleted++;
						AwardTickets(4 + Mathf.Max(0, _scrapPutt.Par + 2 - _scrapPutt.Strokes) * 2, "Scrap Putt hole cleared");
						AddArcadeXp(5 + Mathf.Max(0, _scrapPutt.Par + 1 - _scrapPutt.Strokes) * 2, "Scrap Putt hole cleared");
						UnlockAchievement("scrapputt_first");
					}
					_scrapPuttHoleRewardRecorded = true;
					SaveStats();
				}
				if (!_scrapPutt.IsGameOver || _scrapPuttResultRecorded)
				{
					break;
				}
				_bestScrapPuttHoles = Math.Max(_bestScrapPuttHoles, _scrapPutt.HolesCompleted);
				_bestScrapPuttScore = Math.Max(_bestScrapPuttScore, _scrapPutt.Score);
				if (_scrapPutt.HolesCompleted >= 18)
				{
					UnlockAchievement("scrapputt_18");
				}
				if (_scrapPutt.IsCampaignComplete)
				{
					AwardTickets(50 + Mathf.Max(0, _scrapPutt.TotalPar - _scrapPutt.TotalStrokes) * 3, "Scrap Putt campaign completed");
					AddArcadeXp(75 + _scrapPutt.Score / 120, "Scrap Putt campaign completed");
					if (_scrapPutt.TotalStrokes < _scrapPutt.TotalPar)
					{
						UnlockAchievement("scrapputt_underpar");
					}
				}
				TrackGameFinished();
				_scrapPuttResultRecorded = true;
				SaveStats();
				break;
			case ArcadeView.WhackAMole:
				_whackAMole.Tick(num);
				if (_whackAMole.IsGameOver && !_moleResultRecorded)
				{
					if (_whackAMole.Score > _bestMoleScore)
					{
						_bestMoleScore = _whackAMole.Score;
						AddArcadeXp(15, "New Whack-a-Mole personal record");
					}
					_totalMoleHits += _whackAMole.SuccessfulHits;
					int amount = 3 + _whackAMole.Score / 5 + _whackAMole.SuccessfulHits / 4;
					AwardTickets(amount, "Whack-a-Mole run complete");
					if (_whackAMole.Score >= 30)
					{
						UnlockAchievement("mole_30");
					}
					TrackGameFinished();
					_moleResultRecorded = true;
					SaveStats();
				}
				break;
			}
			TryResolveChallengeRound();
			TryResolveChampionshipRound();
		}

		public void ToggleFromBackgroundWatcher(string keyName)
		{
			if (_log != null)
			{
				_log.LogInfo((object)("ArcadeController received queued toggle request for " + keyName + ". Current visibility=" + _visible + "."));
			}
			HandleToggleHotkey("main-thread queue", keyName);
		}

		private void HandleToggleHotkey(string inputSource, string keyName)
		{
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (_lastToggleFrame == Time.frameCount)
			{
				if (_log != null)
				{
					_log.LogDebug((object)("Ignored duplicate " + keyName + " toggle in frame " + Time.frameCount + " from " + inputSource + "."));
				}
				return;
			}
			if (realtimeSinceStartup - _lastToggleRealtime < 0.4f)
			{
				if (_log != null)
				{
					_log.LogDebug((object)("Ignored duplicate " + keyName + " toggle within cross-source debounce window from " + inputSource + ". Last key=" + _lastToggleKeyName + "."));
				}
				return;
			}
			_lastToggleFrame = Time.frameCount;
			_lastToggleRealtime = realtimeSinceStartup;
			_lastToggleKeyName = keyName;
			ToggleArcade();
			if (_log != null)
			{
				_log.LogInfo((object)((_visible ? "Arcade opened with " : "Arcade closed with ") + keyName + " (source: " + inputSource + ")."));
			}
			Input.ResetInputAxes();
		}

		private void ToggleArcade()
		{
			if (_visible)
			{
				CloseArcade();
			}
			else
			{
				OpenArcade();
			}
		}

		private void OpenArcade()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			_previousLockState = Cursor.lockState;
			_previousCursorVisible = Cursor.visible;
			_savedCursor = true;
			_visible = true;
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			Input.ResetInputAxes();
		}

		private void CloseArcade()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			_visible = false;
			if (_savedCursor)
			{
				Cursor.lockState = _previousLockState;
				Cursor.visible = _previousCursorVisible;
				_savedCursor = false;
			}
			Input.ResetInputAxes();
		}

		public void Shutdown()
		{
			if (_visible)
			{
				CloseArcade();
			}
			DestroyTextures();
		}

		public void NotifyApplicationFocus(bool hasFocus)
		{
			if (!hasFocus && _visible)
			{
				CloseArcade();
			}
		}

		private void AddGamepadDirection(KeyCode key, bool down, ref bool wasDown, ref float repeatAt)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (down)
			{
				_gamepadHeldKeys.Add(key);
			}
			float unscaledTime = Time.unscaledTime;
			if (down && (!wasDown || unscaledTime >= repeatAt))
			{
				_gamepadPressedKeys.Add(key);
				repeatAt = unscaledTime + (wasDown ? 0.17f : 0.28f);
			}
			if (!down)
			{
				repeatAt = unscaledTime + 0.28f;
			}
			wasDown = down;
		}

		private void PollGamepadInput()
		{
			if (_lastGamepadPollFrame == Time.frameCount)
			{
				return;
			}
			_lastGamepadPollFrame = Time.frameCount;
			_gamepadPressedKeys.Clear();
			_gamepadHeldKeys.Clear();
			if (!_gamepadEnabled || !Application.isFocused)
			{
				_padLeftWasDown = (_padRightWasDown = (_padUpWasDown = (_padDownWasDown = false)));
				_padAWasDown = (_padBWasDown = (_padStartWasDown = false));
				return;
			}
			try
			{
				string[] joystickNames = Input.GetJoystickNames();
				bool flag = false;
				if (joystickNames != null)
				{
					for (int i = 0; i < joystickNames.Length; i++)
					{
						if (!string.IsNullOrEmpty(joystickNames[i]))
						{
							flag = true;
							break;
						}
					}
				}
				if (!flag)
				{
					_padLeftWasDown = (_padRightWasDown = (_padUpWasDown = (_padDownWasDown = false)));
					_padAWasDown = (_padBWasDown = (_padStartWasDown = false));
					return;
				}
				float num = 0f;
				float num2 = 0f;
				try
				{
					num = Input.GetAxisRaw("Horizontal");
					num2 = Input.GetAxisRaw("Vertical");
				}
				catch
				{
				}
				AddGamepadDirection((KeyCode)276, num < -0.55f, ref _padLeftWasDown, ref _padLeftRepeatAt);
				AddGamepadDirection((KeyCode)275, num > 0.55f, ref _padRightWasDown, ref _padRightRepeatAt);
				AddGamepadDirection((KeyCode)273, num2 > 0.55f, ref _padUpWasDown, ref _padUpRepeatAt);
				AddGamepadDirection((KeyCode)274, num2 < -0.55f, ref _padDownWasDown, ref _padDownRepeatAt);
				bool key = Input.GetKey((KeyCode)330);
				bool key2 = Input.GetKey((KeyCode)331);
				bool key3 = Input.GetKey((KeyCode)337);
				bool padAWasDown = _padAWasDown;
				if (key)
				{
					_gamepadHeldKeys.Add((KeyCode)32);
					_gamepadHeldKeys.Add((KeyCode)13);
					_gamepadHeldKeys.Add((KeyCode)271);
				}
				if (key && !padAWasDown)
				{
					_gamepadPressedKeys.Add((KeyCode)32);
					_gamepadPressedKeys.Add((KeyCode)13);
					_gamepadPressedKeys.Add((KeyCode)271);
				}
				_padAWasDown = key;
				bool padBWasDown = _padBWasDown;
				if (key2)
				{
					_gamepadHeldKeys.Add((KeyCode)27);
				}
				if (key2 && !padBWasDown)
				{
					_gamepadPressedKeys.Add((KeyCode)27);
				}
				_padBWasDown = key2;
				bool padStartWasDown = _padStartWasDown;
				if (key3)
				{
					_gamepadHeldKeys.Add((KeyCode)13);
					_gamepadHeldKeys.Add((KeyCode)271);
				}
				if (key3 && !padStartWasDown)
				{
					_gamepadPressedKeys.Add((KeyCode)13);
					_gamepadPressedKeys.Add((KeyCode)271);
				}
				_padStartWasDown = key3;
			}
			catch (Exception ex)
			{
				if (!_gamepadPollWarningLogged && _log != null)
				{
					_gamepadPollWarningLogged = true;
					_log.LogWarning((object)("Gamepad polling failed; keyboard and mouse remain available. " + ex.GetType().Name + ": " + ex.Message));
				}
			}
		}

		private KeyCode AlternativeMovementKey(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if ((int)key == 276)
			{
				if (_controlLayout == 1)
				{
					return (KeyCode)97;
				}
				if (_controlLayout == 2)
				{
					return (KeyCode)106;
				}
			}
			else if ((int)key == 275)
			{
				if (_controlLayout == 1)
				{
					return (KeyCode)100;
				}
				if (_controlLayout == 2)
				{
					return (KeyCode)108;
				}
			}
			else if ((int)key == 273)
			{
				if (_controlLayout == 1)
				{
					return (KeyCode)119;
				}
				if (_controlLayout == 2)
				{
					return (KeyCode)105;
				}
			}
			else if ((int)key == 274)
			{
				if (_controlLayout == 1)
				{
					return (KeyCode)115;
				}
				if (_controlLayout == 2)
				{
					return (KeyCode)107;
				}
			}
			return key;
		}

		private bool ArcadeKeyDown(KeyCode key)
		{
			//IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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)
			if (Input.GetKeyDown(key))
			{
				return true;
			}
			KeyCode val = AlternativeMovementKey(key);
			if (val != key && Input.GetKeyDown(val))
			{
				return true;
			}
			if (_gamepadEnabled)
			{
				return _gamepadPressedKeys.Contains(key);
			}
			return false;
		}

		private bool ArcadeKeyHeld(KeyCode key)
		{
			//IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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)
			if (Input.GetKey(key))
			{
				return true;
			}
			KeyCode val = AlternativeMovementKey(key);
			if (val != key && Input.GetKey(val))
			{
				return true;
			}
			if (_gamepadEnabled)
			{
				return _gamepadHeldKeys.Contains(key);
			}
			return false;
		}

		private bool IsMenuNavigationView()
		{
			switch (_view)
			{
			case ArcadeView.Home:
			case ArcadeView.GamesLibrary:
			case ArcadeView.Minesweeper:
			case ArcadeView.MemoryMatch:
			case ArcadeView.Achievements:
			case ArcadeView.Statistics:
			case ArcadeView.PrizeRoom:
			case ArcadeView.ChallengeMode:
			case ArcadeView.DailyChallenge:
			case ArcadeView.WhackAMole:
			case ArcadeView.TowerDefense:
			case ArcadeView.ScrapshotSiege:
			case ArcadeView.CircleConquest:
			case ArcadeView.ArcadeChampionship:
			case ArcadeView.WeeklyGauntlet:
			case ArcadeView.Contracts:
			case ArcadeView.Settings:
			case ArcadeView.Help:
				return true;
			default:
				return false;
			}
		}

		private void ProcessMenuNavigation(Event currentEvent)
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Invalid comparison between Unknown and I4
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Invalid comparison between Unknown and I4
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Invalid comparison between Unknown and I4
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Invalid comparison between Unknown and I4
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Invalid comparison between Unknown and I4
			if (!_visible || !IsMenuNavigationView() || _lastMenuNavigationFrame == Time.frameCount)
			{
				return;
			}
			_lastMenuNavigationFrame = Time.frameCount;
			int num = Math.Max(1, _navButtonCountLastFrame);
			bool flag = false;
			if (ArcadeKeyDown((KeyCode)273))
			{
				_navSelectedIndex--;
				flag = true;
			}
			else if (ArcadeKeyDown((KeyCode)274))
			{
				_navSelectedIndex++;
				flag = true;
			}
			else if (ArcadeKeyDown((KeyCode)276))
			{
				_navSelectedIndex--;
				flag = true;
			}
			else if (ArcadeKeyDown((KeyCode)275))
			{
				_navSelectedIndex++;
				flag = true;
			}
			if (flag)
			{
				_navSelectedIndex = (_navSelectedIndex % num + num) % num;
				if (currentEvent != null && (int)currentEvent.type == 4 && ((int)currentEvent.keyCode == 273 || (int)currentEvent.keyCode == 274 || (int)currentEvent.keyCode == 276 || (int)currentEvent.keyCode == 275))
				{
					currentEvent.Use();
				}
			}
			if (ArcadeKeyDown((KeyCode)13) || ArcadeKeyDown((KeyCode)271) || _gamepadPressedKeys.Contains((KeyCode)32))
			{
				_navConfirmFrame = Time.frameCount;
			}
		}

		private bool ArcadeButton(Rect rect, string text, GUIStyle style)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			return ArcadeButtonCore(rect, new GUIContent(text), style);
		}

		private bool ArcadeButton(Rect rect, GUIContent content, GUIStyle style)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ArcadeButtonCore(rect, content, style);
		}

		private bool ArcadeButtonCore(Rect rect, GUIContent content, GUIStyle style)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Invalid comparison between Unknown and I4
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			int num = _navButtonIndex++;
			bool num2 = _visible && IsMenuNavigationView() && num == _navSelectedIndex;
			bool flag = GUI.Button(rect, content, style);
			if (flag)
			{
				_navSelectedIndex = num;
			}
			if (num2 && Event.current != null && (int)Event.current.type == 7 && _navConfirmFrame == Time.frameCount && _navConfirmConsumedFrame != Time.frameCount)
			{
				_navConfirmConsumedFrame = Time.frameCount;
				flag = true;
				_navSelectedIndex = num;
			}
			if (num2 && Event.current != null && (int)Event.current.type == 7 && (Object)(object)_solidTexture != (Object)null)
			{
				Color color = GUI.color;
				GUI.color = (_highContrast ? Color.yellow : _themeAccent);
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 2f), (Texture)(object)_solidTexture);
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 2f, ((Rect)(ref rect)).width, 2f), (Texture)(object)_solidTexture);
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 2f, ((Rect)(ref rect)).height), (Texture)(object)_solidTexture);
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - 2f, ((Rect)(ref rect)).y, 2f, ((Rect)(ref rect)).height), (Texture)(object)_solidTexture);
				GUI.color = color;
			}
			return flag;
		}

		private void RefreshAccessibilityStyles()
		{
			RefreshStyles();
			EnsureStyles();
		}

		public unsafe void RenderGUI()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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_008d: Invalid comparison between Unknown and I4
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Invalid comparison between Unknown and I4
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Invalid comparison between Unknown and I4
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			_navButtonIndex = 0;
			ProcessMenuNavigation(current);
			if (current != null && (int)current.type == 4 && (current.keyCode == REPOArcadePlugin.ConfiguredToggleKey || (REPOArcadePlugin.ConfiguredToggleVirtualKey != 45 && (int)current.keyCode == 277)))
			{
				KeyCode keyCode = current.keyCode;
				current.Use();
				HandleToggleHotkey("IMGUI event", ((int)keyCode == 277) ? "Insert" : ((object)(*(KeyCode*)(&keyCode))/*cast due to .constrained prefix*/).ToString());
			}
			else if (_visible)
			{
				if (current != null && (int)current.type == 4 && current.keyCode != REPOArcadePlugin.ConfiguredToggleKey && (int)current.keyCode != 277 && (int)current.keyCode != 27 && GUIUtility.keyboardControl == 0)
				{
					current.Use();
				}
				EnsureStyles();
				float num = Mathf.Max(460f, (float)Screen.width - 28f);
				float num2 = Mathf.Max(400f, (float)Screen.height - 28f);
				float num3 = Mathf.Min(1080f, num);
				float num4 = Mathf.Min(760f, num2);
				_windowRect = new Rect(((float)Screen.width - num3) * 0.5f, ((float)Screen.height - num4) * 0.5f, num3, num4);
				int depth = GUI.depth;
				GUI.depth = -10000;
				GUI.Box(_windowRect, GUIContent.none, _panelStyle);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref _windowRect)).x + 18f, ((Rect)(ref _windowRect)).y + 14f, ((Rect)(ref _windowRect)).width - 36f, ((Rect)(ref _windowRect)).height - 28f);
				GUILayout.BeginArea(val);
				DrawArcadeVisualBackdrop(((Rect)(ref val)).width, ((Rect)(ref val)).height, _view);
				switch (_view)
				{
				case ArcadeView.GamesLibrary:
					DrawGamesLibrary(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.Contracts:
					DrawContracts(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.TurboRun:
					DrawTurboRun(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.TowerDefense:
					DrawTowerDefense(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.ScrapshotSiege:
					DrawScrapshotSiege(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.ScrapPutt:
					DrawScrapPutt(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.CircleConquest:
					DrawCircleConquest(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.WeeklyGauntlet:
					DrawWeeklyGauntlet(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.ArcadeChampionship:
					DrawArcadeChampionship(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.Minesweeper:
					DrawMinesweeper(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.Snake:
					DrawSnake(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.MonsterEscape:
					DrawMonsterEscape(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.BrickBreaker:
					DrawBrickBreaker(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.Pong:
					DrawPong(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.NumberMerge:
					DrawNumberMerge(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.BlockDrop:
					DrawBlockDrop(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.SpaceDefender:
					DrawSpaceDefender(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.MemoryMatch:
					DrawMemoryMatch(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.DungeonDelver:
					DrawDungeonDelver(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.WhackAMole:
					DrawWhackAMole(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.DailyChallenge:
					DrawDailyChallenge(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.Achievements:
					DrawAchievements(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.Statistics:
					DrawStatistics(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.PrizeRoom:
					DrawPrizeRoom(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.ChallengeMode:
					DrawChallengeMode(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.Settings:
					DrawSettings(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				case ArcadeView.Help:
					DrawHelp(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				default:
					DrawHome(((Rect)(ref val)).width, ((Rect)(ref val)).height);
					break;
				}
				if (_challengeActive && IsChallengeGameView(_view))
				{
					string text = (_challengeIsDaily ? "DAILY " : "CHALLENGE ") + _challengeStage + "/3 • " + GetChallengeDifficultyName() + " • " + GetChallengeGameName(_challengeCurrentGame);
					GUI.Box(new Rect(0f, ((Rect)(ref val)).height - 30f, ((Rect)(ref val)).width, 24f), GUIContent.none, _panelStyle);
					GUI.Label(new Rect(8f, ((Rect)(ref val)).height - 29f, ((Rect)(ref val)).width - 16f, 22f), text + " — " + GetChallengeObjective(_challengeCurrentGame), _mutedStyle);
				}
				GUILayout.EndArea();
				_navButtonCountLastFrame = Math.Max(1, _navButtonIndex);
				if (_navSelectedIndex >= _navButtonCountLastFrame)
				{
					_navSelectedIndex = 0;
				}
				DrawOptionalOverlays(val);
				GUI.depth = depth;
			}
		}

		private Color GetArcadeViewAccent(ArcadeView view)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			switch (view)
			{
			case ArcadeView.Minesweeper:
			case ArcadeView.NumberMerge:
			case ArcadeView.BlockDrop:
			case ArcadeView.MemoryMatch:
				return new Color(0.36f, 0.78f, 1f, 1f);
			case ArcadeView.Snake:
			case ArcadeView.BrickBreaker:
			case ArcadeView.Pong:
			case ArcadeView.WhackAMole:
			case ArcadeView.TurboRun:
				return new Color(1f, 0.53f, 0.28f, 1f);
			case ArcadeView.MonsterEscape:
			case ArcadeView.DungeonDelver:
				return new Color(0.72f, 0.43f, 1f, 1f);
			case ArcadeView.TowerDefense:
			case ArcadeView.CircleConquest:
				return new Color(0.28f, 0.91f, 0.68f, 1f);
			case ArcadeView.ScrapshotSiege:
			case ArcadeView.ScrapPutt:
				return new Color(1f, 0.72f, 0.29f, 1f);
			case ArcadeView.SpaceDefender:
				return new Color(0.48f, 0.7f, 1f, 1f);
			case ArcadeView.ChallengeMode:
			case ArcadeView.DailyChallenge:
			case ArcadeView.ArcadeChampionship:
			case ArcadeView.WeeklyGauntlet:
				return new Color(0.97f, 0.75f, 0.3f, 1f);
			default:
				return _themeAccent;
			}
		}

		private void DrawArcadeVisualBackdrop(float width, float height, ArcadeView view)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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)
			//IL_0142: 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_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: 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_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: 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_0a4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a51: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Unknown result type (might be due to invalid IL or missing references)
			//IL_063e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_0774: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_077d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0783: Unknown result type (might be due to invalid IL or missing references)
			//IL_0789: Unknown result type (might be due to invalid IL or missing references)
			//IL_0794: Unknown result type (might be due to invalid IL or missing references)
			//IL_079f: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0801: Unknown result type (might be due to invalid IL or missing references)
			//IL_0818: Unknown result type (might be due to invalid IL or missing references)
			//IL_068f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_069f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_089a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08af: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0943: Unknown result type (might be due to invalid IL or missing references)
			//IL_0949: Unknown result type (might be due to invalid IL or missing references)
			//IL_094f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0963: Unknown result type (might be due to invalid IL or missing references)
			//IL_0987: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_solidTexture == (Object)null || width <= 0f || height <= 0f)
			{
				return;
			}
			Color color = GUI.color;
			Matrix4x4 matrix = GUI.matrix;
			float num = ((_reduceMotion || _performanceMode) ? 0f : Time.unscaledTime);
			Color arcadeViewAccent = GetArcadeViewAccent(view);
			bool flag = IsArcadeGameplayView(view);
			GUI.color = new Color(0.012f, 0.022f, 0.041f, 0.12f);
			GUI.DrawTexture(new Rect(0f, 0f, width, height), (Texture)(object)_solidTexture);
			for (int i = 0; i < 19; i++)
			{
				float num2 = 5f + (width - 10f) * (float)i / 18f;
				float num3 = 0.018f + 0.012f * (0.5f + 0.5f * Mathf.Sin((float)i * 1.77f + num * 0.28f));
				GUI.color = new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, num3);
				GUI.DrawTexture(new Rect(num2, 4f, 1f, Mathf.Max(1f, height - 8f)), (Texture)(object)_solidTexture);
			}
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, flag ? 0.28f : 0.2f);
			DrawGlowQuad(new Rect(8f, 61f, Mathf.Max(1f, width - 16f), 1.1f), color2, 1);
			DrawGlowQuad(new Rect(8f, Mathf.Max(65f, height - 34f), Mathf.Max(1f, width - 16f), 1f), new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.12f), 1);
			float num4 = Mathf.Min(20f, width * 0.045f);
			float num5 = 10f;
			for (int j = 0; j < 4; j++)
			{
				bool num6 = (j & 1) != 0;
				bool flag2 = (j & 2) != 0;
				float num7 = (num6 ? (width - num4 - 5f) : 5f);
				float num8 = (flag2 ? (height - num5 - 5f) : 5f);
				GUI.color = new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.32f);
				GUI.DrawTexture(new Rect(num7, num8, num4, 1.5f), (Texture)(object)_solidTexture);
				GUI.DrawTexture(new Rect(num6 ? (num7 + num4 - 1.5f) : num7, num8, 1.5f, num5), (Texture)(object)_solidTexture);
			}
			switch (view)
			{
			case ArcadeView.Minesweeper:
			case ArcadeView.NumberMerge:
			case ArcadeView.BlockDrop:
			case ArcadeView.MemoryMatch:
			{
				for (int num26 = 0; num26 < 9; num26++)
				{
					float num27 = 12f + (float)num26 * Mathf.Max(1f, (width - 24f) / 9f);
					GUI.color = new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.07f);
					GUI.DrawTexture(new Rect(num27, height - 62f, 1f, 22f), (Texture)(object)_solidTexture);
					GUI.DrawTexture(new Rect(num27, 70f, 1f, 18f), (Texture)(object)_solidTexture);
				}
				break;
			}
			case ArcadeView.Snake:
			case ArcadeView.BrickBreaker:
			case ArcadeView.Pong:
			case ArcadeView.TurboRun:
			{
				for (int n = 0; n < 8; n++)
				{
					float num15 = 82f + Mathf.Repeat((float)n * 43f + num * ((view == ArcadeView.TurboRun) ? 23f : 8f), Mathf.Max(1f, height - 125f));
					float num16 = 7f + (float)(n % 3) * 5f;
					GUI.color = new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.1f + (float)(n % 3) * 0.025f);
					DrawMotionSegment(new Vector2(9f, num15), new Vector2(9f + num16, num15 - 2f), 1f + (float)(n % 2) * 0.4f, GUI.color, glow: false);
					DrawMotionSegment(new Vector2(width - 9f, num15 + 5f), new Vector2(width - 9f - num16, num15 + 3f), 1f + (float)(n % 2) * 0.4f, GUI.color, glow: false);
				}
				break;
			}
			case ArcadeView.SpaceDefender:
			{
				Color color3 = default(Color);
				for (int num20 = 0; num20 < 24; num20++)
				{
					float num21 = 12f + Mathf.Repeat((float)num20 * 71.3f + num * (3f + (float)(num20 % 4)), Mathf.Max(1f, width - 24f));
					float num22 = 74f + Mathf.Repeat((float)num20 * 29.7f + num * (5f + (float)(num20 % 5)), Mathf.Max(1f, height - 116f));
					((Color)(ref color3))..ctor(0.68f, 0.83f, 1f, 0.2f + (float)(num20 % 3) * 0.08f);
					if (num20 % 4 == 0)
					{
						DrawSparkle(new Vector2(num21, num22), 3.5f, color3, num * 20f + (float)num20 * 4f);
						continue;
					}
					GUI.color = color3;
					GUI.DrawTexture(new Rect(num21, num22, 1.6f + (float)(num20 % 2), 1.6f + (float)(num20 % 2)), (Texture)(object)_circleTexture);
				}
				break;
			}
			case ArcadeView.MonsterEscape:
			case ArcadeView.DungeonDelver:
			{
				for (int l = 0; l < 9; l++)
				{
					float num11 = (((l & 1) == 0) ? (11f + (float)(l % 3) * 3f) : (width - 18f - (float)(l % 3) * 3f));
					float num12 = 82f + Mathf.Repeat((float)l * 57f + num * (1.8f + (float)(l % 3)), Mathf.Max(1f, height - 125f));
					GUI.color = new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.12f);
					GUI.DrawTexture(new Rect(num11, num12, 4f + (float)(l % 2) * 2f, 4f + (float)(l % 3)), (Texture)(object)_solidTexture);
					if (l % 3 == 0)
					{
						DrawSparkle(new Vector2(num11 + 2f, num12 + 2f), 3.4f, new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.22f), num * 10f);
					}
				}
				break;
			}
			case ArcadeView.TowerDefense:
			case ArcadeView.CircleConquest:
			{
				Vector2 val = default(Vector2);
				Vector2 val2 = default(Vector2);
				for (int num23 = 0; num23 < 7; num23++)
				{
					float num24 = 15f + Mathf.Repeat((float)num23 * 83f + num * 1.2f, Mathf.Max(1f, width - 30f));
					float num25 = height - 62f + Mathf.Sin(num * 0.45f + (float)num23) * 5f;
					((Vector2)(ref val))..ctor(num24, num25);
					((Vector2)(ref val2))..ctor(Mathf.Min(width - 8f, num24 + 10f + (float)(num23 % 3) * 4f), num25 - 6f);
					DrawMotionSegment(val, val2, 1f, new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.16f), glow: false);
					GUI.color = new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.2f);
					GUI.DrawTexture(new Rect(val.x - 2f, val.y - 2f, 4f, 4f), (Texture)(object)_circleTexture);
					GUI.DrawTexture(new Rect(val2.x - 1.5f, val2.y - 1.5f, 3f, 3f), (Texture)(object)_circleTexture);
				}
				break;
			}
			case ArcadeView.ScrapshotSiege:
			case ArcadeView.ScrapPutt:
			{
				for (int num17 = 0; num17 < 7; num17++)
				{
					float num18 = 12f + Mathf.Repeat((float)num17 * 107f + num * 5f, Mathf.Max(1f, width - 24f));
					float num19 = (((num17 & 1) == 0) ? 81f : (height - 51f));
					DrawMotionSegment(new Vector2(num18, num19), new Vector2(num18 + 11f, num19 - 4f), 1.2f, new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.18f), glow: false);
				}
				break;
			}
			case ArcadeView.WhackAMole:
			{
				for (int m = 0; m < 7; m++)
				{
					float num13 = 0.5f + 0.5f * Mathf.Sin(num * 2.2f + (float)m * 1.1f);
					float num14 = 14f + (float)m * Mathf.Max(1f, (width - 28f) / 7f);
					GUI.color = new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.08f + num13 * 0.05f);
					GUI.DrawTexture(new Rect(num14, height - 58f - num13 * 4f, 5f, 5f), (Texture)(object)_circleTexture);
				}
				break;
			}
			default:
			{
				for (int k = 0; k < 6; k++)
				{
					float num9 = 16f + Mathf.Repeat((float)k * 151f + num * 7f, Mathf.Max(1f, width - 32f));
					float num10 = height - 48f - (float)(k % 3) * 3f;
					DrawSparkle(new Vector2(num9, num10), 3f + (float)(k % 2), new Color(arcadeViewAccent.r, arcadeViewAccent.g, arcadeViewAccent.b, 0.22f), num * 18f + (float)k * 13f);
				}
				break;
			}
			}
			GUI.matrix = matrix;
			GUI.color = color;
		}

		private bool IsArcadeGameplayView(ArcadeView view)
		{
			if ((uint)(view - 2) <= 8u || (uint)(view - 16) <= 6u)
			{
				return true;
			}
			return false;
		}

		private void DrawArcadeBoardFrame(Rect board, Color accent, float thickness = 4f)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: 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_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_solidTexture == (Object)null) && !(((Rect)(ref board)).width <= 0f) && !(((Rect)(ref board)).height <= 0f))
			{
				Color color = GUI.color;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref board)).x - thickness, ((Rect)(ref board)).y - thickness, ((Rect)(ref board)).width + thickness * 2f, ((Rect)(ref board)).height + thickness * 2f);
				GUI.color = new Color(0f, 0f, 0f, 0.42f);
				GUI.DrawTexture(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 3f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), (Texture)(object)_solidTexture);
				GUI.color = new Color(0.045f, 0.065f, 0.085f, 0.96f);
				GUI.DrawTexture(val, (Texture)(object)_solidTexture);
				Color color2 = accent;
				color2.a = 0.68f;
				GUI.color = color2;
				GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 1.4f), (Texture)(object)_solidTexture);
				GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax - 1.4f, ((Rect)(ref val)).width, 1.4f), (Texture)(object)_solidTexture);
				GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, 1.4f, ((Rect)(ref val)).height), (Texture)(object)_solidTexture);
				GUI.DrawTexture(new Rect(((Rect)(ref val)).xMax - 1.4f, ((Rect)(ref val)).y, 1.4f, ((Rect)(ref val)).height), (Texture)(object)_solidTexture);
				Color color3 = accent;
				color3.a = 0.24f;
				DrawGlowQuad(new Rect(((Rect)(ref val)).x + 4f, ((Rect)(ref val)).y + 3f, Mathf.Max(1f, ((Rect)(ref val)).width - 8f), 1f), color3, 1);
				float num = Mathf.Min(13f, Mathf.Min(((Rect)(ref val)).width * 0.08f, ((Rect)(ref val)).height * 0.08f));
				GUI.color = new Color(accent.r, accent.g, accent.b, 0.9f);
				GUI.DrawTexture(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, num, 2f), (Texture)(object)_solidTexture);
				GUI.DrawTexture(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, 2f, num), (Texture)(object)_solidTexture);
				GUI.DrawTexture(new Rect(((Rect)(ref val)).xMax - num - 2f, ((Rect)(ref val)).y + 2f, num, 2f), (Texture)(object)_solidTexture);
				GUI.DrawTexture(new Rect(((Rect)(ref val)).xMax - 4f, ((Rect)(ref val)).y + 2f, 2f, num), (Texture)(obje