Decompiled source of Repo Classes v1.1.0

RepoClasses.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EmpressRepoClasses.Core;
using EmpressRepoClasses.Runtime;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Empress")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.4.1.0")]
[assembly: AssemblyInformationalVersion("2.4.1")]
[assembly: AssemblyProduct("RepoClasses")]
[assembly: AssemblyTitle("RepoClasses")]
[assembly: AssemblyVersion("2.4.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EmpressRepoClasses
{
	[BepInPlugin("empress.repo.repoclasses", "Repo Classes", "2.4.1")]
	public sealed class RepoClassesPlugin : BaseUnityPlugin
	{
		internal const string PluginGuid = "empress.repo.repoclasses";

		internal const string PluginName = "Repo Classes";

		internal const string PluginVersion = "2.4.1";

		internal ConfigEntry<bool> Enabled;

		internal ConfigEntry<KeyboardShortcut> QueueRoleHotkey;

		internal ConfigEntry<KeyboardShortcut> ToggleHudHotkey;

		internal ConfigEntry<KeyboardShortcut> AbilityHotkey;

		internal RepoClassesBalanceConfig Balance;

		private Harmony? _harmony;

		private RepoClassesRuntime? _runtime;

		internal static RepoClassesPlugin Instance { get; private set; }

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

		private void Awake()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			if ((Object)(object)Instance != (Object)null && Instance != this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			((Component)this).transform.SetParent((Transform)null);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch for Repo Classes.");
			QueueRoleHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "QueueRoleChange", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Opens the next-level class picker while you are in a run.");
			ToggleHudHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "ToggleHudPanel", new KeyboardShortcut((KeyCode)118, Array.Empty<KeyCode>()), "Toggles the local class HUD.");
			AbilityHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "UseAbility", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), "Uses your current class ability.");
			Balance = RepoClassesBalanceConfig.Bind(((BaseUnityPlugin)this).Config);
			_harmony = new Harmony("empress.repo.repoclasses");
			_harmony.PatchAll();
			_runtime = ((Component)this).gameObject.GetComponent<RepoClassesRuntime>() ?? ((Component)this).gameObject.AddComponent<RepoClassesRuntime>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Repo Classes 2.4.1 loaded. [modal selection build]");
			((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)(object)_runtime != (Object)null) ? "Repo Classes runtime component attached to plugin object." : "Repo Classes runtime component FAILED to attach."));
		}

		private void OnDestroy()
		{
			if ((Object)(object)_runtime != (Object)null)
			{
				Object.Destroy((Object)(object)_runtime);
				_runtime = null;
			}
			try
			{
				Harmony? harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}
			catch
			{
			}
			_harmony = null;
			if (Instance == this)
			{
				Instance = null;
			}
		}
	}
}
namespace EmpressRepoClasses.Runtime
{
	public sealed class RepoClassesRuntime : MonoBehaviour
	{
		private readonly struct PlayerSlot
		{
			public int ActorNumber { get; }

			public string DisplayName { get; }

			public bool IsLocal { get; }

			public bool IsHost { get; }

			public PlayerAvatar? Avatar { get; }

			public Player? RoomPlayer { get; }

			public string? SteamId => TryGetAvatarSteamId(Avatar);

			public PlayerSlot(int actorNumber, string displayName, bool isLocal, bool isHost, PlayerAvatar? avatar, Player? roomPlayer)
			{
				ActorNumber = actorNumber;
				DisplayName = displayName;
				IsLocal = isLocal;
				IsHost = isHost;
				Avatar = avatar;
				RoomPlayer = roomPlayer;
			}
		}

		private readonly struct AbilityCastRequest
		{
			public int RequestId { get; }

			public RepoAbilityKind AbilityKind { get; }

			public Vector3 Origin { get; }

			public Vector3 Direction { get; }

			public AbilityCastRequest(int requestId, RepoAbilityKind abilityKind, Vector3 origin, Vector3 direction)
			{
				//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_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				RequestId = requestId;
				AbilityKind = abilityKind;
				Origin = origin;
				Direction = direction;
			}
		}

		private const string RoomAssignmentsKey = "empress.repo.classes.assignments";

		private const string RoomSelectionPhaseKey = "empress.repo.classes.phase";

		private const string RoomSelectionIdKey = "empress.repo.classes.selectionid";

		private const string RoomSelectionOptionsKey = "empress.repo.classes.options";

		private const string RoomInitialSelectionDoneKey = "empress.repo.classes.initialdone";

		private const string RoomBalanceProfileKey = "empress.repo.classes.balance";

		private const string PlayerPresenceKey = "empress.repo.classes.present";

		private const string PlayerStartPickKey = "empress.repo.classes.startpick";

		private const string PlayerQueuedRoleKey = "empress.repo.classes.queued";

		private const string PlayerAbilityCastKey = "empress.repo.classes.cast";

		private const string SelectionPhaseMatchStart = "matchstart";

		private const int OfflineActorNumber = 0;

		private const float PresenceSyncGraceSeconds = 4f;

		private static readonly Dictionary<string, FieldInfo?> ReflectedFields = new Dictionary<string, FieldInfo>(StringComparer.Ordinal);

		private readonly Dictionary<int, RepoClassId> _assignmentsByActor = new Dictionary<int, RepoClassId>();

		private readonly Dictionary<string, RepoClassId> _appliedPassivesBySteamId = new Dictionary<string, RepoClassId>(StringComparer.Ordinal);

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

		private readonly Dictionary<int, float> _hostAbilityReadyAtByActor = new Dictionary<int, float>();

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

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

		private Texture2D? _selectionCursorTexture;

		private bool _hudVisible = true;

		private bool _queueOverlayOpen;

		private bool _cursorCaptured;

		private bool _previousCursorVisible;

		private bool _loggedFirstUpdate;

		private bool _loggedFirstOnGui;

		private bool _initialSelectionDone;

		private bool _offlineGlobalSelectionActive;

		private bool _queuedPromotionPending;

		private int _selectedCardIndex;

		private int _roomSelectionId;

		private int _offlineSelectionId;

		private int _localAbilityCastId;

		private CursorLockMode _previousCursorLockState;

		private float _nextHostSyncTime;

		private float _nextBalanceSyncTime;

		private float _nextNameplateSyncTime;

		private float _nextRoomPollTime;

		private float _selectionPresenceGraceUntil;

		private float _localAbilityReadyAt;

		private float _bannerUntil;

		private RepoClassId _lastLocalClass;

		private RepoClassId _offlineSubmittedPick;

		private RepoClassId _offlineQueuedRole;

		private string _lastLevelName = string.Empty;

		private string _lastSceneName = string.Empty;

		private string _lastSeenSerializedAssignments = string.Empty;

		private string _lastSeenSerializedBalance = string.Empty;

		private string _lastPublishedSerializedBalance = string.Empty;

		private string _roomSelectionPhase = string.Empty;

		private string _bannerTitle = string.Empty;

		private string _bannerSubtitle = string.Empty;

		private Color _bannerAccent = Color.white;

		private GUIStyle? _guiWindowStyle;

		private GUIStyle? _guiHeaderStyle;

		private GUIStyle? _guiBodyStyle;

		private GUIStyle? _guiMutedStyle;

		private GUIStyle? _guiCardTitleStyle;

		private GUIStyle? _guiCardBodyStyle;

		private GUIStyle? _guiCardStateStyle;

		private GUIStyle? _guiHudHeaderStyle;

		private GUIStyle? _guiBannerTitleStyle;

		private GUIStyle? _guiBannerSubtitleStyle;

		private Material? _fxLineMaterial;

		private Material? _fxMeshMaterial;

		private GameObject? _explosionFxPrefab;

		private RepoClassBalanceProfile _networkBalanceProfile = RepoClassBalanceProfile.CreateDefault();

		private bool _hasNetworkBalanceProfile;

		public static RepoClassesRuntime? Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			RepoClassesPlugin.EmpressLog.LogInfo((object)"Repo Classes runtime Awake hit.");
		}

		private void OnEnable()
		{
			RepoClassesPlugin.EmpressLog.LogInfo((object)"Repo Classes runtime OnEnable hit.");
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnDisable()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			RestoreCursorState();
		}

		private void OnDestroy()
		{
			RestoreCursorState();
			if (Instance == this)
			{
				Instance = null;
			}
		}

		private void Update()
		{
			if ((Object)(object)RepoClassesPlugin.Instance == (Object)null || !RepoClassesPlugin.Instance.Enabled.Value)
			{
				_queueOverlayOpen = false;
				RestoreCursorState();
				return;
			}
			if (!_loggedFirstUpdate)
			{
				_loggedFirstUpdate = true;
				RepoClassesPlugin.EmpressLog.LogInfo((object)"Repo Classes runtime Update is alive.");
			}
			PublishLocalPresence();
			PollRoomState();
			HandleHostBalanceSync();
			HandleSceneTransitions();
			HandleInput();
			HandleHostSelectionProgress();
			HandleHostPassiveSync();
			HandleHostAbilityRequests();
			HandleAbilityCastVisuals();
			CleanupLocalQueuedRoleIfApplied();
			UpdateNameplates();
			HandleLocalClassTransition();
			HandleOverlayPresentation();
		}

		private void OnGUI()
		{
			if (!((Object)(object)RepoClassesPlugin.Instance == (Object)null) && RepoClassesPlugin.Instance.Enabled.Value)
			{
				if (!_loggedFirstOnGui)
				{
					_loggedFirstOnGui = true;
					RepoClassesPlugin.EmpressLog.LogInfo((object)"Repo Classes OnGUI is alive.");
				}
				EnsureGuiStyles();
				GUI.depth = -1000;
				DrawSelectionOverlay();
				DrawHudGui();
				DrawBannerGui();
			}
		}

		public bool TryBeginMatchStartSelection(RunManager runManager, bool completedLevel, bool levelFailed, ChangeLevelType changeLevelType)
		{
			return false;
		}

		public bool TryBeginLobbyStartSelection(MenuPageLobby? lobbyPage)
		{
			return false;
		}

		private void PublishLocalPresence()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			if (SemiFuncSafeIsMultiplayer() && PhotonNetwork.InRoom && PhotonNetwork.LocalPlayer != null && (!((Dictionary<object, object>)(object)PhotonNetwork.LocalPlayer.CustomProperties).TryGetValue((object)"empress.repo.classes.present", out object value) || !string.Equals(value as string, "2.4.1", StringComparison.Ordinal)))
			{
				PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable { [(object)"empress.repo.classes.present"] = "2.4.1" }, (Hashtable)null, (WebFlags)null);
			}
		}

		private void PollRoomState()
		{
			if (Time.unscaledTime < _nextRoomPollTime)
			{
				return;
			}
			_nextRoomPollTime = Time.unscaledTime + 0.2f;
			if (!SemiFuncSafeIsMultiplayer() || !PhotonNetwork.InRoom || PhotonNetwork.CurrentRoom == null)
			{
				_roomSelectionPhase = string.Empty;
				_roomSelectionId = 0;
				_hasNetworkBalanceProfile = false;
				_lastSeenSerializedBalance = string.Empty;
				return;
			}
			Room currentRoom = PhotonNetwork.CurrentRoom;
			object value;
			string text = (((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"empress.repo.classes.assignments", out value) ? ((value as string) ?? string.Empty) : string.Empty);
			object value2;
			string text2 = (((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"empress.repo.classes.phase", out value2) ? ((value2 as string) ?? string.Empty) : string.Empty);
			object value3;
			int num2 = ((((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"empress.repo.classes.selectionid", out value3) && value3 is int num) ? num : 0);
			object value4;
			bool initialSelectionDone = ((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"empress.repo.classes.initialdone", out value4) && value4 is bool flag && flag;
			object value5;
			string text3 = (((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"empress.repo.classes.balance", out value5) ? ((value5 as string) ?? string.Empty) : string.Empty);
			if (!string.Equals(text, _lastSeenSerializedAssignments, StringComparison.Ordinal))
			{
				RefreshAssignmentsFromSerialized(text);
			}
			if (!string.Equals(text3, _lastSeenSerializedBalance, StringComparison.Ordinal))
			{
				RefreshBalanceProfileFromSerialized(text3);
			}
			if (!string.Equals(text2, _roomSelectionPhase, StringComparison.Ordinal) || num2 != _roomSelectionId)
			{
				_roomSelectionPhase = text2;
				_roomSelectionId = num2;
				_selectedCardIndex = GetPreferredCardIndex();
			}
			_initialSelectionDone = initialSelectionDone;
		}

		private void HandleSceneTransitions()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string text = ((Scene)(ref activeScene)).name ?? string.Empty;
			if (!string.Equals(text, _lastSceneName, StringComparison.Ordinal))
			{
				_lastSceneName = text;
				_nameplateCacheByActor.Clear();
			}
			string currentLevelName = GetCurrentLevelName();
			if (!string.Equals(currentLevelName, _lastLevelName, StringComparison.Ordinal))
			{
				bool flag = !string.IsNullOrWhiteSpace(_lastLevelName);
				_lastLevelName = currentLevelName;
				if (IsMainMenuContext() || IsLobbyMenuContext())
				{
					ResetForFreshLobby();
					return;
				}
				if (!_initialSelectionDone && ShouldAutoOpenInitialSelectionScene())
				{
					BeginInitialSelectionAfterLoad();
				}
				else if (flag && _initialSelectionDone)
				{
					_queuedPromotionPending = true;
				}
			}
			if (_queuedPromotionPending && CanPromoteQueuedAssignmentsNow())
			{
				PromoteQueuedAssignmentsIfNeeded();
				_queuedPromotionPending = false;
			}
		}

		private void HandleLocalClassTransition()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			RepoClassId localAssignedClass = GetLocalAssignedClass();
			if (localAssignedClass != _lastLocalClass)
			{
				_localAbilityReadyAt = 0f;
				_lastLocalClass = localAssignedClass;
				if (localAssignedClass != 0 && ShouldShowClassBanner())
				{
					RepoClassDefinition repoClassDefinition = RepoClassDatabase.Get(localAssignedClass);
					StartBanner(repoClassDefinition.DisplayName.ToUpperInvariant(), repoClassDefinition.Tagline, repoClassDefinition.AccentColor, 2.4f);
				}
			}
		}

		private void HandleOverlayPresentation()
		{
			if (ShouldDrawSelectionOverlay())
			{
				ApplySelectionCursor();
				if (ShouldFreezeForOverlay())
				{
					KeepPlayerFrozen();
				}
			}
			else
			{
				RestoreCursorState();
			}
		}

		private void CaptureCursorState()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (!_cursorCaptured)
			{
				_previousCursorVisible = Cursor.visible;
				_previousCursorLockState = Cursor.lockState;
				_cursorCaptured = true;
			}
		}

		private void RestoreCursorState()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (_cursorCaptured)
			{
				Cursor.SetCursor((Texture2D)null, Vector2.zero, (CursorMode)0);
				Cursor.visible = _previousCursorVisible;
				Cursor.lockState = _previousCursorLockState;
				if ((_previousCursorVisible || (int)_previousCursorLockState == 0) && (Object)(object)MenuCursor.instance != (Object)null)
				{
					MenuCursor.instance.Show();
				}
				_cursorCaptured = false;
			}
		}

		private void ApplySelectionCursor()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			CaptureCursorState();
			EnsureSelectionCursorTexture();
			SuppressGameCursorSystems();
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			Cursor.SetCursor(_selectionCursorTexture, new Vector2((float)((Texture)_selectionCursorTexture).width * 0.5f, (float)((Texture)_selectionCursorTexture).height * 0.5f), (CursorMode)0);
		}

		private void SuppressGameCursorSystems()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			WriteFieldValue(CursorManager.instance, "unlockTimer", -1234f);
			if (!((Object)(object)MenuCursor.instance == (Object)null))
			{
				WriteFieldValue(MenuCursor.instance, "showTimer", 0f);
				WriteFieldValue(MenuCursor.instance, "overridePosTimer", 0f);
				GameObject val = ReadFieldValue<GameObject>(MenuCursor.instance, "mesh", null);
				if ((Object)(object)val != (Object)null && val.activeSelf)
				{
					val.SetActive(false);
				}
				((Component)MenuCursor.instance).transform.localScale = Vector3.zero;
			}
		}

		private void EnsureSelectionCursorTexture()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_selectionCursorTexture != (Object)null)
			{
				return;
			}
			_selectionCursorTexture = new Texture2D(32, 32, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				hideFlags = (HideFlags)61
			};
			for (int i = 0; i < ((Texture)_selectionCursorTexture).height; i++)
			{
				for (int j = 0; j < ((Texture)_selectionCursorTexture).width; j++)
				{
					float num = (float)j - 15.5f;
					float num2 = (float)i - 15.5f;
					float num3 = Mathf.Sqrt(num * num + num2 * num2);
					Color clear = Color.clear;
					if (num3 <= 2.25f)
					{
						((Color)(ref clear))..ctor(1f, 0.97f, 0.93f, 1f);
					}
					else if (num3 <= 5.2f)
					{
						((Color)(ref clear))..ctor(0.96f, 0.49f, 0.16f, 1f);
					}
					else if (num3 <= 7.4f)
					{
						((Color)(ref clear))..ctor(1f, 0.4f, 0.12f, 0.38f);
					}
					_selectionCursorTexture.SetPixel(j, i, clear);
				}
			}
			_selectionCursorTexture.Apply();
		}

		private static void KeepPlayerFrozen()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)PlayerController.instance == (Object)null))
			{
				PlayerController.instance.InputDisable(0.2f);
				if ((Object)(object)PlayerController.instance.rb != (Object)null && !PlayerController.instance.rb.isKinematic)
				{
					PlayerController.instance.rb.velocity = Vector3.zero;
					PlayerController.instance.rb.angularVelocity = Vector3.zero;
				}
				PlayerController.instance.Kinematic(0.2f);
				GameDirector instance = GameDirector.instance;
				if (instance != null)
				{
					instance.SetDisableInput(0.2f);
				}
			}
		}

		private bool ShouldFreezeForOverlay()
		{
			if (_queueOverlayOpen || IsGlobalSelectionActive())
			{
				if (!SemiFuncSafeRunIsLevel())
				{
					return SemiFuncSafeRunIsShop();
				}
				return true;
			}
			return false;
		}

		private bool CanPromoteQueuedAssignmentsNow()
		{
			if (IsMainMenuContext() || IsLobbyMenuContext() || IsGlobalSelectionActive())
			{
				return false;
			}
			if (!SemiFuncSafeIsMultiplayer())
			{
				return !string.IsNullOrWhiteSpace(_lastLevelName);
			}
			if (PhotonNetwork.InRoom)
			{
				return IsHostController();
			}
			return false;
		}

		private bool ShouldAutoOpenInitialSelectionScene()
		{
			if (!IsGlobalSelectionActive())
			{
				if (!SemiFuncSafeRunIsLevel())
				{
					return SemiFuncSafeRunIsShop();
				}
				return true;
			}
			return false;
		}

		private void BeginInitialSelectionAfterLoad()
		{
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			if (_initialSelectionDone || IsGlobalSelectionActive())
			{
				return;
			}
			if (SemiFuncSafeIsMultiplayer())
			{
				if (IsHostController() && PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null)
				{
					_roomSelectionId = Math.Max(1, _roomSelectionId + 1);
					_roomSelectionPhase = "matchstart";
					_selectedCardIndex = GetPreferredCardIndex();
					_queueOverlayOpen = false;
					_selectionPresenceGraceUntil = Time.unscaledTime + 4f;
					PhotonNetwork.CurrentRoom.SetCustomProperties(new Hashtable
					{
						[(object)"empress.repo.classes.phase"] = "matchstart",
						[(object)"empress.repo.classes.selectionid"] = _roomSelectionId,
						[(object)"empress.repo.classes.options"] = SerializeSelectionOptions(),
						[(object)"empress.repo.classes.initialdone"] = false
					}, (Hashtable)null, (WebFlags)null);
					StartBanner("OPENING ROLE", "Pick your class. It activates the moment the crew locks in.", new Color(0.94f, 0.68f, 0.28f, 1f), 2.4f);
				}
			}
			else
			{
				_offlineGlobalSelectionActive = true;
				_offlineSelectionId++;
				_offlineSubmittedPick = RepoClassId.None;
				_selectedCardIndex = GetPreferredCardIndex();
				_queueOverlayOpen = false;
				StartBanner("OPENING ROLE", "Pick your class. Your first role activates immediately.", new Color(0.94f, 0.68f, 0.28f, 1f), 2.4f);
			}
		}

		private static bool IsLobbyJoiningPlayer(MenuPageLobby? lobbyPage)
		{
			return ReadFieldValue(lobbyPage, "joiningPlayer", fallback: false);
		}

		private static int GetRunLoadLevel()
		{
			return ReadFieldValue(RunManager.instance, "loadLevel", 0);
		}

		private static PhotonView? GetPunManagerPhotonView()
		{
			if ((Object)(object)PunManager.instance == (Object)null)
			{
				return null;
			}
			return ((Component)PunManager.instance).GetComponent<PhotonView>() ?? ((Component)PunManager.instance).GetComponentInChildren<PhotonView>(true) ?? ReadFieldValue<PhotonView>(PunManager.instance, "photonView", null);
		}

		private static string GetCurrentLevelName()
		{
			if (!((Object)(object)RunManager.instance != (Object)null) || !((Object)(object)RunManager.instance.levelCurrent != (Object)null))
			{
				return string.Empty;
			}
			return ((Object)RunManager.instance.levelCurrent).name ?? string.Empty;
		}

		private void HandleInput()
		{
			//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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			RepoClassesPlugin instance = RepoClassesPlugin.Instance;
			KeyboardShortcut value = instance.ToggleHudHotkey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() || Input.GetKeyDown((KeyCode)118))
			{
				_hudVisible = !_hudVisible;
			}
			if (IsGlobalSelectionActive())
			{
				HandleSelectionInput(matchStartSelection: true);
				return;
			}
			value = instance.QueueRoleHotkey.Value;
			if ((((KeyboardShortcut)(ref value)).IsDown() || Input.GetKeyDown((KeyCode)287)) && CanQueueRoleChange())
			{
				_queueOverlayOpen = !_queueOverlayOpen;
				_selectedCardIndex = GetPreferredCardIndex();
			}
			if (_queueOverlayOpen)
			{
				HandleSelectionInput(matchStartSelection: false);
				return;
			}
			value = instance.AbilityHotkey.Value;
			if ((((KeyboardShortcut)(ref value)).IsDown() || Input.GetKeyDown((KeyCode)103)) && CanUseAbilitiesNow())
			{
				TryUseLocalAbility();
			}
		}

		private void HandleSelectionInput(bool matchStartSelection)
		{
			if (SemiFuncSafeNoTextInputs() && RepoClassDatabase.SelectionOptions.Count != 0 && !matchStartSelection && (Input.GetKeyDown((KeyCode)27) || Input.GetMouseButtonDown(1)))
			{
				_queueOverlayOpen = false;
			}
		}

		private void CommitSelection(RepoClassId classId, bool matchStartSelection)
		{
			if (matchStartSelection)
			{
				CommitMatchStartPick(classId);
			}
			else
			{
				CommitQueuedRole(classId);
			}
		}

		private void CommitMatchStartPick(RepoClassId classId)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			RepoClassDefinition repoClassDefinition = RepoClassDatabase.Get(classId);
			_selectedCardIndex = GetCardIndex(classId);
			if (SemiFuncSafeIsMultiplayer())
			{
				if (PhotonNetwork.InRoom && PhotonNetwork.LocalPlayer != null)
				{
					PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable { [(object)"empress.repo.classes.startpick"] = $"{_roomSelectionId}:{repoClassDefinition.Token}" }, (Hashtable)null, (WebFlags)null);
					StartBanner("LOCKED IN", repoClassDefinition.DisplayName + " selected. Waiting for the rest of the crew.", repoClassDefinition.AccentColor, 1.8f);
				}
			}
			else
			{
				_offlineSubmittedPick = classId;
				_assignmentsByActor[0] = classId;
				ResetAbilityCooldownForActor(0);
				_offlineGlobalSelectionActive = false;
				_initialSelectionDone = true;
				StartBanner("ROLE ACTIVE", repoClassDefinition.DisplayName + " is live for this run.", repoClassDefinition.AccentColor, 1.8f);
			}
		}

		private void CommitQueuedRole(RepoClassId classId)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			RepoClassDefinition repoClassDefinition = RepoClassDatabase.Get(classId);
			_selectedCardIndex = GetCardIndex(classId);
			_queueOverlayOpen = false;
			if (SemiFuncSafeIsMultiplayer())
			{
				if (PhotonNetwork.LocalPlayer == null)
				{
					return;
				}
				PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable { [(object)"empress.repo.classes.queued"] = repoClassDefinition.Token }, (Hashtable)null, (WebFlags)null);
			}
			else
			{
				_offlineQueuedRole = classId;
			}
			StartBanner("NEXT ROLE", repoClassDefinition.DisplayName + " will activate on the next level.", repoClassDefinition.AccentColor, 2.2f);
		}

		private void HandleHostSelectionProgress()
		{
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			if (!IsHostController() || !SemiFuncSafeIsMultiplayer() || !PhotonNetwork.InRoom || !string.Equals(_roomSelectionPhase, "matchstart", StringComparison.Ordinal))
			{
				return;
			}
			List<Player> selectionEligiblePlayers = GetSelectionEligiblePlayers();
			if (selectionEligiblePlayers.Count == 0 || (Time.unscaledTime < _selectionPresenceGraceUntil && selectionEligiblePlayers.Count < PhotonNetwork.PlayerList.Length))
			{
				return;
			}
			bool flag = false;
			bool flag2 = true;
			foreach (Player item in selectionEligiblePlayers)
			{
				if (!TryGetStartPick(item, _roomSelectionId, out var classId))
				{
					flag2 = false;
				}
				else if (GetAssignedClass(item.ActorNumber) != classId)
				{
					_assignmentsByActor[item.ActorNumber] = classId;
					ResetAbilityCooldownForActor(item.ActorNumber);
					flag = true;
				}
			}
			if (flag)
			{
				PushAssignmentsToRoom();
			}
			if (flag2)
			{
				SetRoomInitialSelectionDone(done: true);
				ClearRoomSelectionPhase();
				_selectionPresenceGraceUntil = 0f;
				StartBanner("ROLES LOCKED", "Opening roles are live. Good hunting.", new Color(0.94f, 0.68f, 0.28f, 1f), 1.8f);
			}
		}

		private void PromoteQueuedAssignmentsIfNeeded()
		{
			if (IsGlobalSelectionActive())
			{
				return;
			}
			if (SemiFuncSafeIsMultiplayer())
			{
				if (!PhotonNetwork.InRoom || !IsHostController())
				{
					return;
				}
				bool flag = false;
				Player[] playerList = PhotonNetwork.PlayerList;
				foreach (Player val in playerList)
				{
					if (TryGetQueuedRole(val, out var classId) && classId != 0 && GetAssignedClass(val.ActorNumber) != classId)
					{
						_assignmentsByActor[val.ActorNumber] = classId;
						ResetAbilityCooldownForActor(val.ActorNumber);
						flag = true;
					}
				}
				if (flag)
				{
					RepoClassesPlugin.EmpressLog.LogInfo((object)("Promoting queued classes for level '" + _lastLevelName + "'."));
					PushAssignmentsToRoom();
				}
			}
			else if (_offlineQueuedRole != 0 && GetAssignedClass(0) != _offlineQueuedRole)
			{
				_assignmentsByActor[0] = _offlineQueuedRole;
				ResetAbilityCooldownForActor(0);
			}
		}

		private void ResetForFreshLobby()
		{
			_initialSelectionDone = false;
			_offlineGlobalSelectionActive = false;
			_queueOverlayOpen = false;
			_queuedPromotionPending = false;
			_roomSelectionPhase = string.Empty;
			_roomSelectionId = 0;
			_offlineSelectionId = 0;
			_offlineSubmittedPick = RepoClassId.None;
			_nameplateCacheByActor.Clear();
			_processedAbilityCastIdsByActor.Clear();
			_shownAbilityCastIdsByActor.Clear();
			_hostAbilityReadyAtByActor.Clear();
			_bannerUntil = 0f;
			_selectionPresenceGraceUntil = 0f;
			_localAbilityReadyAt = 0f;
			_nextBalanceSyncTime = 0f;
			_lastSeenSerializedBalance = string.Empty;
			_lastPublishedSerializedBalance = string.Empty;
			_hasNetworkBalanceProfile = false;
			if (IsHostController())
			{
				ClearAssignmentsAndPassives();
				SetRoomInitialSelectionDone(done: false);
				ClearRoomSelectionPhase();
				PushAssignmentsToRoom();
			}
			else
			{
				_assignmentsByActor.Clear();
				_lastSeenSerializedAssignments = string.Empty;
			}
			ClearLocalStartPick();
			ClearLocalQueuedRole();
			ClearLocalAbilityCast();
		}

		private void ClearAssignmentsAndPassives()
		{
			KeyValuePair<string, RepoClassId>[] array = _appliedPassivesBySteamId.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				KeyValuePair<string, RepoClassId> keyValuePair = array[i];
				TrySendClassDelta(keyValuePair.Key, keyValuePair.Value, RepoClassId.None);
			}
			_appliedPassivesBySteamId.Clear();
			_assignmentsByActor.Clear();
			_hostAbilityReadyAtByActor.Clear();
			_lastSeenSerializedAssignments = string.Empty;
		}

		private void CleanupLocalQueuedRoleIfApplied()
		{
			RepoClassId localQueuedRole = GetLocalQueuedRole();
			if (localQueuedRole != 0 && localQueuedRole == GetLocalAssignedClass())
			{
				ClearLocalQueuedRole();
			}
		}

		private void HandleHostBalanceSync()
		{
			//IL_007c: 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_0096: Expected O, but got Unknown
			if (!((Object)(object)RepoClassesPlugin.Instance == (Object)null) && SemiFuncSafeIsMultiplayer() && PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null && IsHostController() && !(Time.unscaledTime < _nextBalanceSyncTime))
			{
				_nextBalanceSyncTime = Time.unscaledTime + 1f;
				string serializedProfile = RepoClassesPlugin.Instance.Balance.GetSerializedProfile();
				if (!string.Equals(serializedProfile, _lastPublishedSerializedBalance, StringComparison.Ordinal))
				{
					_lastPublishedSerializedBalance = serializedProfile;
					RefreshBalanceProfileFromSerialized(serializedProfile);
					PhotonNetwork.CurrentRoom.SetCustomProperties(new Hashtable { [(object)"empress.repo.classes.balance"] = serializedProfile }, (Hashtable)null, (WebFlags)null);
				}
			}
		}

		private void HandleHostPassiveSync()
		{
			if (!IsHostController() || Time.unscaledTime < _nextHostSyncTime)
			{
				return;
			}
			_nextHostSyncTime = Time.unscaledTime + 0.35f;
			foreach (PlayerSlot playerSlot in GetPlayerSlots())
			{
				string steamId = playerSlot.SteamId;
				if (!string.IsNullOrWhiteSpace(steamId))
				{
					EnsurePassiveState(steamId, GetAssignedClass(playerSlot.ActorNumber));
				}
			}
		}

		private void RefreshBalanceProfileFromSerialized(string serializedBalance)
		{
			_lastSeenSerializedBalance = serializedBalance;
			if (string.IsNullOrWhiteSpace(serializedBalance))
			{
				_hasNetworkBalanceProfile = false;
				return;
			}
			if (!RepoClassBalanceProfile.TryDeserialize(serializedBalance, out RepoClassBalanceProfile profile))
			{
				_hasNetworkBalanceProfile = false;
				return;
			}
			_networkBalanceProfile = profile;
			_hasNetworkBalanceProfile = true;
		}

		private void HandleHostAbilityRequests()
		{
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFuncSafeIsMultiplayer() || !PhotonNetwork.InRoom || !IsHostController())
			{
				return;
			}
			foreach (Player selectionEligiblePlayer in GetSelectionEligiblePlayers())
			{
				if (!TryGetAbilityCast(selectionEligiblePlayer, out var request) || (_processedAbilityCastIdsByActor.TryGetValue(selectionEligiblePlayer.ActorNumber, out var value) && request.RequestId <= value))
				{
					continue;
				}
				_processedAbilityCastIdsByActor[selectionEligiblePlayer.ActorNumber] = request.RequestId;
				_shownAbilityCastIdsByActor[selectionEligiblePlayer.ActorNumber] = request.RequestId;
				RepoClassId assignedClass = GetAssignedClass(selectionEligiblePlayer.ActorNumber);
				if (assignedClass != 0 && RepoClassDatabase.Get(assignedClass).AbilityKind == request.AbilityKind)
				{
					RepoRoleBalance classBalance = GetClassBalance(assignedClass);
					if ((!_hostAbilityReadyAtByActor.TryGetValue(selectionEligiblePlayer.ActorNumber, out var value2) || !(Time.unscaledTime < value2)) && ExecuteAbilityWorldEffect(request.AbilityKind, request.Origin, request.Direction))
					{
						_hostAbilityReadyAtByActor[selectionEligiblePlayer.ActorNumber] = Time.unscaledTime + classBalance.CooldownSeconds;
					}
				}
			}
		}

		private void HandleAbilityCastVisuals()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFuncSafeIsMultiplayer() || !PhotonNetwork.InRoom)
			{
				return;
			}
			foreach (Player selectionEligiblePlayer in GetSelectionEligiblePlayers())
			{
				if (TryGetAbilityCast(selectionEligiblePlayer, out var request) && (!_shownAbilityCastIdsByActor.TryGetValue(selectionEligiblePlayer.ActorNumber, out var value) || request.RequestId > value))
				{
					_shownAbilityCastIdsByActor[selectionEligiblePlayer.ActorNumber] = request.RequestId;
					PlayAbilityVisuals(request.AbilityKind, request.Origin, request.Direction);
				}
			}
		}

		private void UpdateNameplates()
		{
			if (Time.unscaledTime < _nextNameplateSyncTime)
			{
				return;
			}
			_nextNameplateSyncTime = Time.unscaledTime + 0.15f;
			foreach (PlayerAvatar avatar in GetAvatarList())
			{
				if ((Object)(object)avatar == (Object)null)
				{
					continue;
				}
				TextMeshProUGUI avatarNameplateTextComponent = GetAvatarNameplateTextComponent(avatar);
				if (!((Object)(object)avatarNameplateTextComponent == (Object)null))
				{
					int actorNumber = GetActorNumber(avatar);
					string text = BuildNameplateText(ResolveDisplayName(avatar, null, actorNumber), GetAssignedClass(actorNumber));
					if (!_nameplateCacheByActor.TryGetValue(actorNumber, out string value) || !string.Equals(value, text, StringComparison.Ordinal))
					{
						((TMP_Text)avatarNameplateTextComponent).text = text;
						_nameplateCacheByActor[actorNumber] = text;
					}
				}
			}
		}

		private void DrawSelectionOverlay()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			if (!ShouldDrawSelectionOverlay() || _guiWindowStyle == null || _guiHeaderStyle == null || _guiBodyStyle == null || _guiMutedStyle == null || _guiCardTitleStyle == null || _guiCardBodyStyle == null || _guiCardStateStyle == null)
			{
				return;
			}
			IReadOnlyList<RepoClassDefinition> selectionOptions = RepoClassDatabase.SelectionOptions;
			if (selectionOptions.Count != 0)
			{
				Color color = GUI.color;
				GUI.color = new Color(0.02f, 0.03f, 0.05f, 0.88f);
				GUI.Box(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), GUIContent.none, _guiWindowStyle);
				GUI.color = color;
				float num = Mathf.Min(1520f, (float)Screen.width - 80f);
				float num2 = Mathf.Min(840f, (float)Screen.height - 80f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2);
				GUI.Box(val, GUIContent.none, _guiWindowStyle);
				GUI.color = new Color(0.94f, 0.68f, 0.28f, 1f);
				GUI.Box(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 8f), GUIContent.none);
				GUI.color = color;
				GUI.Label(new Rect(((Rect)(ref val)).x + 26f, ((Rect)(ref val)).y + 18f, ((Rect)(ref val)).width - 52f, 56f), BuildSelectionHeader(), _guiHeaderStyle);
				GUI.Label(new Rect(((Rect)(ref val)).x + 26f, ((Rect)(ref val)).y + 76f, ((Rect)(ref val)).width - 52f, 86f), BuildSelectionSubtitle(), _guiBodyStyle);
				float num3 = ((Rect)(ref val)).y + 170f;
				float num4 = 18f;
				float num5 = (((Rect)(ref val)).width - 52f - num4 * (float)(selectionOptions.Count - 1)) / (float)selectionOptions.Count;
				float num6 = ((Rect)(ref val)).height - 250f;
				RepoClassId localQueuedRole = GetLocalQueuedRole();
				RepoClassId localAssignedClass = GetLocalAssignedClass();
				RepoClassId localSubmittedMatchStartPick = GetLocalSubmittedMatchStartPick();
				bool flag = IsGlobalSelectionActive();
				Rect rect = default(Rect);
				for (int i = 0; i < selectionOptions.Count; i++)
				{
					RepoClassDefinition repoClassDefinition = selectionOptions[i];
					((Rect)(ref rect))..ctor(((Rect)(ref val)).x + 26f + (float)i * (num5 + num4), num3, num5, num6);
					bool isSelected = i == _selectedCardIndex;
					bool isCurrent = localAssignedClass == repoClassDefinition.Id;
					bool isQueued = !flag && localQueuedRole == repoClassDefinition.Id;
					bool isSubmitted = flag && localSubmittedMatchStartPick == repoClassDefinition.Id;
					DrawRoleCard(rect, repoClassDefinition, i, isSelected, isCurrent, isQueued, isSubmitted, flag);
				}
				GUI.Label(new Rect(((Rect)(ref val)).x + 26f, ((Rect)(ref val)).yMax - 62f, ((Rect)(ref val)).width - 52f, 40f), BuildSelectionFooter(), _guiMutedStyle);
			}
		}

		private void DrawRoleCard(Rect rect, RepoClassDefinition definition, int index, bool isSelected, bool isCurrent, bool isQueued, bool isSubmitted, bool matchStartSelection)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			if (_guiCardTitleStyle == null || _guiCardBodyStyle == null || _guiCardStateStyle == null || _guiMutedStyle == null)
			{
				return;
			}
			bool flag = ((Rect)(ref rect)).Contains(Event.current.mousePosition);
			if (flag)
			{
				_selectedCardIndex = index;
			}
			bool num = isSelected || flag;
			Color color = GUI.color;
			GUI.color = (num ? new Color(0.12f, 0.17f, 0.24f, 0.98f) : new Color(0.07f, 0.09f, 0.13f, 0.96f));
			GUI.Box(rect, GUIContent.none, _guiWindowStyle);
			GUI.color = definition.AccentColor;
			GUI.Box(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 10f), GUIContent.none);
			GUI.color = color;
			if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
			{
				CommitSelection(definition.Id, matchStartSelection);
			}
			GUI.Label(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 20f, ((Rect)(ref rect)).width - 32f, 36f), definition.DisplayName.ToUpperInvariant(), _guiCardTitleStyle);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 58f, ((Rect)(ref rect)).width - 32f, 52f), definition.Tagline, _guiMutedStyle);
			RepoRoleBalance classBalance = GetClassBalance(definition.Id);
			StringBuilder stringBuilder = new StringBuilder();
			foreach (string passiveLine in GetPassiveLines(definition.Id))
			{
				stringBuilder.Append("Passive: ");
				stringBuilder.AppendLine(passiveLine);
			}
			stringBuilder.AppendLine();
			stringBuilder.Append("Power: ");
			stringBuilder.Append(definition.AbilityName);
			stringBuilder.Append("  (");
			KeyboardShortcut value = RepoClassesPlugin.Instance.AbilityHotkey.Value;
			stringBuilder.Append(((KeyboardShortcut)(ref value)).MainKey);
			stringBuilder.AppendLine(")");
			stringBuilder.AppendLine(definition.AbilityDescription);
			stringBuilder.AppendLine();
			stringBuilder.Append("Cooldown: ");
			stringBuilder.Append(classBalance.CooldownSeconds.ToString("0.#"));
			stringBuilder.Append("s");
			GUI.Label(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 116f, ((Rect)(ref rect)).width - 32f, ((Rect)(ref rect)).height - 206f), stringBuilder.ToString().TrimEnd(), _guiCardBodyStyle);
			string text = (isSubmitted ? "LOCKED IN FOR THIS RUN" : (isQueued ? "QUEUED FOR NEXT LEVEL" : (isCurrent ? "CURRENT ACTIVE ROLE" : (matchStartSelection ? "CLICK TO LOCK IN" : "CLICK TO QUEUE"))));
			GUI.color = definition.AccentColor;
			GUI.Box(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).yMax - 66f, ((Rect)(ref rect)).width - 32f, 42f), GUIContent.none);
			GUI.color = Color.white;
			GUI.Label(new Rect(((Rect)(ref rect)).x + 24f, ((Rect)(ref rect)).yMax - 60f, ((Rect)(ref rect)).width - 48f, 30f), text, _guiCardStateStyle);
			GUI.color = color;
		}

		private void DrawHudGui()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			if (!_hudVisible || IsMainMenuContext() || IsLobbyMenuContext() || _guiWindowStyle == null || _guiHudHeaderStyle == null || _guiBodyStyle == null)
			{
				return;
			}
			RepoClassId localAssignedClass = GetLocalAssignedClass();
			if (localAssignedClass != 0)
			{
				RepoClassDefinition repoClassDefinition = RepoClassDatabase.Get(localAssignedClass);
				Color accentColor = repoClassDefinition.AccentColor;
				float num = Mathf.Min(540f, (float)Screen.width - 40f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(20f, (float)Screen.height - 188f, num, 168f);
				Color color = GUI.color;
				GUI.Box(val, GUIContent.none, _guiWindowStyle);
				GUI.color = accentColor;
				GUI.Box(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, 10f, ((Rect)(ref val)).height), GUIContent.none);
				GUI.color = color;
				GUI.Label(new Rect(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).y + 16f, ((Rect)(ref val)).width - 48f, 34f), repoClassDefinition.DisplayName.ToUpperInvariant(), _guiHudHeaderStyle);
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("Power: ");
				stringBuilder.AppendLine(repoClassDefinition.AbilityName);
				stringBuilder.AppendLine(repoClassDefinition.AbilityDescription);
				stringBuilder.Append("Use ");
				KeyboardShortcut value = RepoClassesPlugin.Instance.AbilityHotkey.Value;
				stringBuilder.Append(((KeyboardShortcut)(ref value)).MainKey);
				stringBuilder.Append("  |  ");
				stringBuilder.Append(BuildCooldownText(repoClassDefinition));
				GUI.Label(new Rect(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).y + 54f, ((Rect)(ref val)).width - 48f, 62f), stringBuilder.ToString(), _guiBodyStyle);
				Rect val2 = new Rect(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).yMax - 40f, 116f, 28f);
				value = RepoClassesPlugin.Instance.ToggleHudHotkey.Value;
				if (GUI.Button(val2, $"Hide [{((KeyboardShortcut)(ref value)).MainKey}]"))
				{
					_hudVisible = false;
				}
			}
		}

		private void DrawBannerGui()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			if (!(_bannerUntil <= Time.unscaledTime) && _guiWindowStyle != null && _guiBannerTitleStyle != null && _guiBannerSubtitleStyle != null)
			{
				float num = _bannerUntil - Time.unscaledTime;
				float num2 = ((num < 0.25f) ? (num / 0.25f) : 1f);
				Color color = GUI.color;
				GUI.color = new Color(1f, 1f, 1f, Mathf.Clamp01(num2));
				float num3 = Mathf.Min(760f, (float)Screen.width - 120f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((float)Screen.width - num3) * 0.5f, 24f, num3, 120f);
				GUI.Box(val, GUIContent.none, _guiWindowStyle);
				GUI.color = new Color(_bannerAccent.r, _bannerAccent.g, _bannerAccent.b, Mathf.Clamp01(num2));
				GUI.Box(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 8f), GUIContent.none);
				GUI.color = new Color(1f, 1f, 1f, Mathf.Clamp01(num2));
				GUI.Label(new Rect(((Rect)(ref val)).x + 18f, ((Rect)(ref val)).y + 18f, ((Rect)(ref val)).width - 36f, 42f), _bannerTitle, _guiBannerTitleStyle);
				GUI.Label(new Rect(((Rect)(ref val)).x + 18f, ((Rect)(ref val)).y + 60f, ((Rect)(ref val)).width - 36f, 34f), _bannerSubtitle, _guiBannerSubtitleStyle);
				GUI.color = color;
			}
		}

		private void EnsureGuiStyles()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0047: Expected O, but got Unknown
			//IL_0052: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_016a: 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_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			if (_guiWindowStyle == null)
			{
				_guiWindowStyle = new GUIStyle(GUI.skin.box)
				{
					fontSize = 16,
					richText = true,
					wordWrap = true,
					padding = new RectOffset(18, 18, 18, 18)
				};
				_guiHeaderStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 28,
					fontStyle = (FontStyle)1,
					richText = true,
					wordWrap = true,
					alignment = (TextAnchor)0
				};
				_guiBodyStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 16,
					richText = true,
					wordWrap = true,
					alignment = (TextAnchor)0
				};
				_guiMutedStyle = new GUIStyle(_guiBodyStyle)
				{
					fontSize = 15
				};
				_guiCardTitleStyle = new GUIStyle(_guiHeaderStyle)
				{
					fontSize = 24
				};
				_guiCardBodyStyle = new GUIStyle(_guiBodyStyle)
				{
					fontSize = 15
				};
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14,
					fontStyle = (FontStyle)1,
					richText = true,
					wordWrap = true,
					alignment = (TextAnchor)4
				};
				val.normal.textColor = Color.white;
				_guiCardStateStyle = val;
				_guiHudHeaderStyle = new GUIStyle(_guiHeaderStyle)
				{
					fontSize = 22
				};
				_guiBannerTitleStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 28,
					fontStyle = (FontStyle)1,
					richText = true,
					wordWrap = true,
					alignment = (TextAnchor)4
				};
				_guiBannerSubtitleStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 16,
					richText = true,
					wordWrap = true,
					alignment = (TextAnchor)4
				};
			}
		}

		private string BuildSelectionHeader()
		{
			if (!IsGlobalSelectionActive())
			{
				return "Queue Next Role";
			}
			return "Choose Opening Role";
		}

		private string BuildSelectionSubtitle()
		{
			if (!IsGlobalSelectionActive())
			{
				RepoClassId localQueuedRole = GetLocalQueuedRole();
				if (localQueuedRole != 0)
				{
					return "Pick a role for the next level. Current queue: " + RepoClassDatabase.Get(localQueuedRole).DisplayName + ".";
				}
				return "Choose now. The new role will not activate until the next level change.";
			}
			if (!SemiFuncSafeIsMultiplayer())
			{
				if (_offlineSubmittedPick != 0)
				{
					return "Locked in. Your opening role is now active.";
				}
				return "Choose your opening role. Your first pick activates immediately.";
			}
			List<string> playersStillChoosing = GetPlayersStillChoosing();
			if (playersStillChoosing.Count == 0)
			{
				return "All players locked in. Launching the level.";
			}
			return string.Format("{0} player(s) left to choose: {1}.", playersStillChoosing.Count, string.Join(", ", playersStillChoosing));
		}

		private string BuildSelectionFooter()
		{
			if (!IsGlobalSelectionActive())
			{
				return "Click a role card to queue it for the next level. Press Esc to close this picker.";
			}
			return "Click a role card to lock in. Opening roles go live once every synced player chooses.";
		}

		private List<string> GetPlayersStillChoosing()
		{
			List<string> list = new List<string>();
			if (!SemiFuncSafeIsMultiplayer() || !PhotonNetwork.InRoom)
			{
				if (_offlineSubmittedPick == RepoClassId.None)
				{
					list.Add("You");
				}
				return list;
			}
			foreach (Player selectionEligiblePlayer in GetSelectionEligiblePlayers())
			{
				if (!TryGetStartPick(selectionEligiblePlayer, _roomSelectionId, out var _))
				{
					list.Add(ResolveDisplayName(null, selectionEligiblePlayer, selectionEligiblePlayer.ActorNumber));
				}
			}
			return list;
		}

		private bool ShouldDrawSelectionOverlay()
		{
			if (!IsGlobalSelectionActive())
			{
				return _queueOverlayOpen;
			}
			return true;
		}

		private bool IsGlobalSelectionActive()
		{
			if (!SemiFuncSafeIsMultiplayer())
			{
				return _offlineGlobalSelectionActive;
			}
			return string.Equals(_roomSelectionPhase, "matchstart", StringComparison.Ordinal);
		}

		private bool CanQueueRoleChange()
		{
			if (!IsGlobalSelectionActive())
			{
				if (!SemiFuncSafeRunIsLevel())
				{
					return SemiFuncSafeRunIsShop();
				}
				return true;
			}
			return false;
		}

		private string BuildNameplateText(string playerName, RepoClassId classId)
		{
			if (classId == RepoClassId.None)
			{
				return playerName;
			}
			RepoClassDefinition repoClassDefinition = RepoClassDatabase.Get(classId);
			return playerName + "\n<size=55%><color=" + repoClassDefinition.AccentHex + ">" + repoClassDefinition.DisplayName.ToUpperInvariant() + "</color></size>";
		}

		private string BuildCooldownText(RepoClassDefinition definition)
		{
			float cooldownSeconds = GetClassBalance(definition.Id).CooldownSeconds;
			float num = Mathf.Max(0f, _localAbilityReadyAt - Time.unscaledTime);
			if (!(num <= 0f))
			{
				return $"Cooldown {num:0.0}s";
			}
			return $"READY ({cooldownSeconds:0.#}s)";
		}

		private void TryUseLocalAbility()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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)
			RepoClassId localAssignedClass = GetLocalAssignedClass();
			if (localAssignedClass == RepoClassId.None || Time.unscaledTime < _localAbilityReadyAt || !CanUseAbilitiesNow())
			{
				return;
			}
			RepoClassDefinition repoClassDefinition = RepoClassDatabase.Get(localAssignedClass);
			RepoRoleBalance classBalance = GetClassBalance(localAssignedClass);
			PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
			PlayerHealth avatarHealthComponent = GetAvatarHealthComponent(val);
			if ((Object)(object)val == (Object)null || (Object)(object)avatarHealthComponent == (Object)null || GetAvatarHealthValue(val, avatarHealthComponent) <= 0)
			{
				return;
			}
			Vector3 abilityOrigin = GetAbilityOrigin(val);
			Vector3 abilityDirection = GetAbilityDirection(val);
			bool flag = false;
			if (SemiFuncSafeIsMultiplayer() && PhotonNetwork.LocalPlayer != null)
			{
				if (!SubmitAbilityCast(repoClassDefinition.AbilityKind, abilityOrigin, abilityDirection, out var requestId))
				{
					return;
				}
				_shownAbilityCastIdsByActor[PhotonNetwork.LocalPlayer.ActorNumber] = requestId;
				if (IsHostController())
				{
					_processedAbilityCastIdsByActor[PhotonNetwork.LocalPlayer.ActorNumber] = requestId;
					flag = ExecuteAbilityWorldEffect(repoClassDefinition.AbilityKind, abilityOrigin, abilityDirection);
				}
				else
				{
					PlayAbilityVisuals(repoClassDefinition.AbilityKind, abilityOrigin, abilityDirection);
					flag = true;
				}
			}
			else
			{
				flag = ExecuteAbilityWorldEffect(repoClassDefinition.AbilityKind, abilityOrigin, abilityDirection);
			}
			if (flag)
			{
				_localAbilityReadyAt = Time.unscaledTime + classBalance.CooldownSeconds;
				if (SemiFuncSafeIsMultiplayer() && PhotonNetwork.LocalPlayer != null && IsHostController())
				{
					_hostAbilityReadyAtByActor[PhotonNetwork.LocalPlayer.ActorNumber] = _localAbilityReadyAt;
				}
				StartBanner(repoClassDefinition.AbilityName.ToUpperInvariant(), repoClassDefinition.AbilityDescription, repoClassDefinition.AccentColor, 1.8f);
			}
		}

		private bool ExecuteAbilityWorldEffect(RepoAbilityKind abilityKind, Vector3 origin, Vector3 direction, bool playVisuals = true)
		{
			//IL_001e: 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_0023: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			RepoClassBalanceProfile activeBalanceProfile = GetActiveBalanceProfile();
			Vector3 direction2 = ((((Vector3)(ref direction)).sqrMagnitude > 0.001f) ? ((Vector3)(ref direction)).normalized : Vector3.forward);
			if (playVisuals)
			{
				PlayAbilityVisuals(abilityKind, origin, direction2);
			}
			return abilityKind switch
			{
				RepoAbilityKind.MeteorSlam => UseMeteorSlam(origin, activeBalanceProfile.MeteorSlam), 
				RepoAbilityKind.Kamehameha => UseKamehameha(origin, direction2, activeBalanceProfile.Kamehameha), 
				RepoAbilityKind.LaserEyes => UseLaserEyes(origin, direction2, activeBalanceProfile.LaserEyes), 
				RepoAbilityKind.BlackHole => UseBlackHole(origin, activeBalanceProfile.BlackHole), 
				_ => false, 
			};
		}

		private bool UseMeteorSlam(Vector3 origin, RepoMeteorSlamBalance balance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			foreach (Enemy enemy in GetEnemyList())
			{
				Vector3 val = GetEnemyCenter(enemy) - origin;
				if (!(((Vector3)(ref val)).magnitude > balance.Radius))
				{
					Vector3 val2 = val + Vector3.up * 0.45f;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					HurtEnemy(enemy, balance.Damage, normalized, balance.Impulse, balance.StunSeconds);
				}
			}
			return true;
		}

		private bool UseKamehameha(Vector3 origin, Vector3 direction, RepoKamehamehaBalance balance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = origin + direction * 1.2f;
			foreach (Enemy enemy in GetEnemyList())
			{
				Vector3 val2 = GetEnemyCenter(enemy) - val;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				if (!(magnitude > balance.Range) && !(Vector3.Dot(direction, ((Vector3)(ref val2)).normalized) < balance.MinAimDot))
				{
					Vector3 val3 = Vector3.Cross(direction, val2);
					if (!(((Vector3)(ref val3)).magnitude > balance.Width))
					{
						int damage = ((magnitude < balance.CloseDamageDistance) ? balance.CloseDamage : balance.FarDamage);
						HurtEnemy(enemy, damage, direction + Vector3.up * 0.08f, balance.Impulse, balance.StunSeconds);
					}
				}
			}
			return true;
		}

		private bool UseLaserEyes(Vector3 origin, Vector3 direction, RepoLaserEyesBalance balance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = origin + direction * 0.6f;
			foreach (Enemy enemy in GetEnemyList())
			{
				Vector3 val2 = GetEnemyCenter(enemy) - val;
				if (!(((Vector3)(ref val2)).magnitude > balance.Range) && !(Vector3.Dot(direction, ((Vector3)(ref val2)).normalized) < balance.MinAimDot))
				{
					Vector3 val3 = Vector3.Cross(direction, val2);
					float magnitude = ((Vector3)(ref val3)).magnitude;
					if (!(magnitude > balance.Width))
					{
						int damage = ((magnitude < balance.InnerDamageWidth) ? balance.InnerDamage : balance.OuterDamage);
						HurtEnemy(enemy, damage, direction + Vector3.up * 0.04f, balance.Impulse, balance.StunSeconds);
					}
				}
			}
			return true;
		}

		private bool UseBlackHole(Vector3 origin, RepoBlackHoleBalance balance)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			foreach (Enemy enemy in GetEnemyList())
			{
				Vector3 val = origin - GetEnemyCenter(enemy);
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (!(magnitude > balance.Radius))
				{
					Vector3 val2 = val + Vector3.up * 0.12f;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					int damage = ((magnitude < balance.CloseDamageDistance) ? balance.CloseDamage : ((magnitude < balance.MidDamageDistance) ? balance.MidDamage : balance.FarDamage));
					float impulse = Mathf.Lerp(balance.MaxImpulse, balance.MinImpulse, Mathf.InverseLerp(balance.MaxImpulseDistance, balance.MinImpulseDistance, magnitude));
					HurtEnemy(enemy, damage, normalized, impulse, balance.StunSeconds);
				}
			}
			return true;
		}

		private static Vector3 GetAbilityOrigin(PlayerAvatar localAvatar)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			Transform abilityAimTransform = GetAbilityAimTransform(localAvatar);
			if (!((Object)(object)abilityAimTransform != (Object)null))
			{
				return Vector3.zero;
			}
			return abilityAimTransform.position + abilityAimTransform.forward * 0.35f;
		}

		private static Vector3 GetAbilityDirection(PlayerAvatar localAvatar)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Transform abilityAimTransform = GetAbilityAimTransform(localAvatar);
			if ((Object)(object)abilityAimTransform != (Object)null)
			{
				return abilityAimTransform.forward;
			}
			if (!((Object)(object)localAvatar != (Object)null))
			{
				return Vector3.forward;
			}
			return ((Component)localAvatar).transform.forward;
		}

		private static Transform? GetAbilityAimTransform(PlayerAvatar? localAvatar)
		{
			if ((Object)(object)localAvatar != (Object)null && (Object)(object)localAvatar.localCamera != (Object)null)
			{
				return ((Component)localAvatar.localCamera).transform;
			}
			if ((Object)(object)Camera.main != (Object)null)
			{
				return ((Component)Camera.main).transform;
			}
			try
			{
				return ((Object)(object)SemiFunc.MainCamera() != (Object)null) ? ((Component)SemiFunc.MainCamera()).transform : ((localAvatar != null) ? ((Component)localAvatar).transform : null);
			}
			catch
			{
				return (localAvatar != null) ? ((Component)localAvatar).transform : null;
			}
		}

		private static List<Enemy> GetEnemyList()
		{
			if ((Object)(object)EnemyDirector.instance == (Object)null || EnemyDirector.instance.enemiesSpawned == null)
			{
				return new List<Enemy>();
			}
			List<Enemy> list = new List<Enemy>();
			foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned)
			{
				if (!((Object)(object)item == (Object)null))
				{
					Enemy val = ((Component)item).GetComponentInChildren<Enemy>(true) ?? ReadFieldValue<Enemy>(item, "Enemy", null);
					if (!((Object)(object)val == (Object)null))
					{
						list.Add(val);
					}
				}
			}
			return list;
		}

		private static Vector3 GetEnemyCenter(Enemy enemy)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ReadFieldValue<Transform>(enemy, "CenterTransform", null) ?? ((Component)enemy).GetComponentInChildren<Transform>(true);
			if (!((Object)(object)val != (Object)null))
			{
				return ((Component)enemy).transform.position;
			}
			return val.position;
		}

		private static void HurtEnemy(Enemy? enemy, int damage, Vector3 forceDirection, float impulse, float stunTime)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)enemy == (Object)null)
			{
				return;
			}
			try
			{
				EnemyHealth val = ((Component)enemy).GetComponent<EnemyHealth>() ?? ((Component)enemy).GetComponentInChildren<EnemyHealth>(true) ?? ReadFieldValue<EnemyHealth>(enemy, "Health", null);
				if (!((Object)(object)val == (Object)null) && !ReadFieldValue(val, "dead", fallback: false) && !ReadFieldValue(val, "deadImpulse", fallback: false))
				{
					EnemyStateStunned val2 = ((Component)enemy).GetComponent<EnemyStateStunned>() ?? ((Component)enemy).GetComponentInChildren<EnemyStateStunned>(true) ?? ReadFieldValue<EnemyStateStunned>(enemy, "StateStunned", null);
					EnemyRigidbody val3 = ((Component)enemy).GetComponent<EnemyRigidbody>() ?? ((Component)enemy).GetComponentInChildren<EnemyRigidbody>(true) ?? ReadFieldValue<EnemyRigidbody>(enemy, "Rigidbody", null);
					Vector3 val4 = ((((Vector3)(ref forceDirection)).sqrMagnitude > 0.001f) ? ((Vector3)(ref forceDirection)).normalized : Vector3.up);
					Rigidbody val5 = ReadFieldValue<Rigidbody>(val3, "rb", null) ?? ((val3 != null) ? ((Component)val3).GetComponent<Rigidbody>() : null) ?? ((val3 != null) ? ((Component)val3).GetComponentInChildren<Rigidbody>(true) : null) ?? ((Component)enemy).GetComponent<Rigidbody>() ?? ((Component)enemy).GetComponentInChildren<Rigidbody>(true);
					bool flag = (Object)(object)val5 != (Object)null && !val5.isKinematic;
					bool flag2 = (Object)(object)val5 == (Object)null || flag;
					val.Hurt(damage, val4);
					if ((Object)(object)val2 != (Object)null && stunTime > 0f && flag2)
					{
						val2.Set(stunTime);
					}
					if (flag && impulse > 0f)
					{
						val5.AddForce(val4 * impulse, (ForceMode)1);
					}
				}
			}
			catch
			{
			}
		}

		private static string SerializeVector3(Vector3 value)
		{
			//IL_000a: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			return string.Format(CultureInfo.InvariantCulture, "{0:0.###},{1:0.###},{2:0.###}", value.x, value.y, value.z);
		}

		private static bool TryParseVector3(string raw, out Vector3 value)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			value = default(Vector3);
			string[] array = raw.Split(',');
			if (array.Length != 3 || !float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || !float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) || !float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3))
			{
				return false;
			}
			value = new Vector3(result, result2, result3);
			return true;
		}

		private void PlayAbilityVisuals(RepoAbilityKind abilityKind, Vector3 origin, Vector3 direction)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: 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_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: 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_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: 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_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((((Vector3)(ref direction)).sqrMagnitude > 0.001f) ? ((Vector3)(ref direction)).normalized : Vector3.forward);
			switch (abilityKind)
			{
			case RepoAbilityKind.MeteorSlam:
				TrySpawnExplosionVisual(origin, 1.45f);
				TrySpawnImpactVisual(origin);
				((MonoBehaviour)this).StartCoroutine(AnimateRingVisual(origin + Vector3.up * 0.12f, new Color(1f, 0.72f, 0.24f, 1f), 2.4f, 19f, 0.7f, 0.34f, 60, 0f));
				((MonoBehaviour)this).StartCoroutine(AnimateSpherePulse(origin + Vector3.up * 0.8f, new Color(1f, 0.58f, 0.16f, 1f), 2.8f, 15.5f, 0.34f, 0.42f));
				((MonoBehaviour)this).StartCoroutine(AnimateLightPulse(origin + Vector3.up * 1.2f, new Color(1f, 0.76f, 0.32f, 1f), 0.32f, 16f, 7f));
				break;
			case RepoAbilityKind.Kamehameha:
			{
				Vector3 beamVisualEndpoint2 = GetBeamVisualEndpoint(origin, val, 56f);
				((MonoBehaviour)this).StartCoroutine(AnimateSpherePulse(origin + val * 1.1f, new Color(0.58f, 1f, 1f, 1f), 0.9f, 2.8f, 0.18f, 0.5f));
				((MonoBehaviour)this).StartCoroutine(AnimateBeamVisual(origin, beamVisualEndpoint2, new Color(0.58f, 1f, 1f, 1f), 1.35f, 0.46f, 0.2f, 32));
				((MonoBehaviour)this).StartCoroutine(AnimateBeamVisual(origin, beamVisualEndpoint2, Color.white, 0.58f, 0.28f, 0.08f, 22));
				TrySpawnImpactVisual(beamVisualEndpoint2);
				TrySpawnExplosionVisual(beamVisualEndpoint2, 0.85f);
				((MonoBehaviour)this).StartCoroutine(AnimateSpherePulse(beamVisualEndpoint2, new Color(0.72f, 1f, 1f, 1f), 1.2f, 4.8f, 0.26f, 0.46f));
				((MonoBehaviour)this).StartCoroutine(AnimateLightPulse(beamVisualEndpoint2, new Color(0.62f, 1f, 1f, 1f), 0.22f, 10f, 4.6f));
				break;
			}
			case RepoAbilityKind.LaserEyes:
			{
				Vector3 beamVisualEndpoint = GetBeamVisualEndpoint(origin, val, 44f);
				Vector3 val2 = Vector3.Cross(Vector3.up, val);
				if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
				{
					val2 = Vector3.Cross(Vector3.right, val);
				}
				((Vector3)(ref val2)).Normalize();
				Vector3 val3 = val2 * 0.12f;
				((MonoBehaviour)this).StartCoroutine(AnimateSpherePulse(origin - val3 + val * 0.5f, new Color(1f, 0.25f, 0.2f, 1f), 0.24f, 0.9f, 0.12f, 0.45f));
				((MonoBehaviour)this).StartCoroutine(AnimateSpherePulse(origin + val3 + val * 0.5f, new Color(1f, 0.72f, 0.18f, 1f), 0.24f, 0.9f, 0.12f, 0.45f));
				((MonoBehaviour)this).StartCoroutine(AnimateBeamVisual(origin - val3, beamVisualEndpoint - val3 * 0.25f, new Color(1f, 0.2f, 0.2f, 1f), 0.42f, 0.24f, 0.045f, 16));
				((MonoBehaviour)this).StartCoroutine(AnimateBeamVisual(origin + val3, beamVisualEndpoint + val3 * 0.25f, new Color(1f, 0.58f, 0.18f, 1f), 0.42f, 0.24f, 0.045f, 16));
				TrySpawnImpactVisual(beamVisualEndpoint);
				TrySpawnExplosionVisual(beamVisualEndpoint, 0.35f);
				((MonoBehaviour)this).StartCoroutine(AnimateSpherePulse(beamVisualEndpoint, new Color(1f, 0.4f, 0.2f, 1f), 0.4f, 2.2f, 0.14f, 0.4f));
				((MonoBehaviour)this).StartCoroutine(AnimateLightPulse(origin + val * 0.8f, new Color(1f, 0.3f, 0.25f, 1f), 0.16f, 6f, 2.8f));
				break;
			}
			case RepoAbilityKind.BlackHole:
				TrySpawnExplosionVisual(origin, 0.7f);
				TrySpawnImpactVisual(origin);
				((MonoBehaviour)this).StartCoroutine(AnimateRingVisual(origin + Vector3.up * 0.15f, new Color(0.45f, 0.7f, 1f, 1f), 13f, 1.1f, 1f, 0.24f, 44, 4f));
				((MonoBehaviour)this).StartCoroutine(AnimateRingVisual(origin + Vector3.up * 0.45f, new Color(0.88f, 0.95f, 1f, 1f), 9f, 0.5f, 1.2f, 0.12f, 32, -5f));
				((MonoBehaviour)this).StartCoroutine(AnimateSpherePulse(origin + Vector3.up * 0.55f, new Color(0.24f, 0.38f, 1f, 1f), 7f, 1f, 0.95f, 0.34f));
				((MonoBehaviour)this).StartCoroutine(AnimateVortexVisual(origin + Vector3.up * 0.4f, new Color(0.22f, 0.45f, 1f, 1f), 1.2f, 7.8f));
				((MonoBehaviour)this).StartCoroutine(AnimateLightPulse(origin + Vector3.up * 0.8f, new Color(0.42f, 0.6f, 1f, 1f), 0.45f, 8f, 5.2f));
				break;
			}
		}

		private Vector3 GetBeamVisualEndpoint(Vector3 origin, Vector3 direction, float maxDistance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			Vector3 result = origin + direction * maxDistance;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(origin, direction, ref val, maxDistance, -1, (QueryTriggerInteraction)1))
			{
				result = ((RaycastHit)(ref val)).point;
			}
			return result;
		}

		private void TrySpawnImpactVisual(Vector3 position)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)AssetManager.instance != (Object)null)
				{
					AssetManager.instance.PhysImpactEffect(position);
				}
			}
			catch
			{
			}
		}

		private void TrySpawnExplosionVisual(Vector3 position, float size)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (_explosionFxPrefab == null)
				{
					_explosionFxPrefab = Resources.Load<GameObject>("Effects/Part Prefab Explosion");
				}
				if ((Object)(object)_explosionFxPrefab == (Object)null)
				{
					return;
				}
				ParticlePrefabExplosion component = Object.Instantiate<GameObject>(_explosionFxPrefab, position, Quaternion.identity).GetComponent<ParticlePrefabExplosion>();
				if (!((Object)(object)component == (Object)null))
				{
					WriteFieldValue(component, "onlyParticleEffect", value: true);
					WriteFieldValue(component, "SkipHurtColliderSetup", value: true);
					WriteFieldValue(component, "HurtColliderActive", value: false);
					WriteFieldValue(component, "HurtColliderFirstSetup", value: false);
					WriteFieldValue(component, "HurtColliderSecondSetup", value: false);
					WriteFieldValue(component, "explosionSize", size);
					WriteFieldValue(component, "explosionDamage", 0);
					WriteFieldValue(component, "explosionDamageEnemy", 0);
					HurtCollider val = ReadFieldValue<HurtCollider>(component, "HurtCollider", null);
					if ((Object)(object)val != (Object)null)
					{
						((Component)val).gameObject.SetActive(false);
					}
				}
			}
			catch
			{
			}
		}

		private Material GetOrCreateFxLineMaterial()
		{
			//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_0050: Expected O, but got Unknown
			if ((Object)(object)_fxLineMaterial != (Object)null)
			{
				return _fxLineMaterial;
			}
			Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Legacy Shaders/Particles/Alpha Blended");
			_fxLineMaterial = new Material(val)
			{
				hideFlags = (HideFlags)61
			};
			return _fxLineMaterial;
		}

		private Material GetOrCreateFxMeshMaterial()
		{
			//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_0050: Expected O, but got Unknown
			if ((Object)(object)_fxMeshMaterial != (Object)null)
			{
				return _fxMeshMaterial;
			}
			Shader val = Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Legacy Shaders/Diffuse");
			_fxMeshMaterial = new Material(val)
			{
				hideFlags = (HideFlags)61
			};
			return _fxMeshMaterial;
		}

		private IEnumerator AnimateBeamVisual(Vector3 start, Vector3 end, Color color, float width, float duration, float wobbleAmplitude, int segmentCount)
		{
			//IL_000e: 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_0015: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			GameObject beamObject = new GameObject("RepoClassesBeamFx")
			{
				hideFlags = (HideFlags)61
			};
			LineRenderer lineRenderer = beamObject.AddComponent<LineRenderer>();
			((Renderer)lineRenderer).material = GetOrCreateFxLineMaterial();
			lineRenderer.textureMode = (LineTextureMode)0;
			lineRenderer.alignment = (LineAlignment)0;
			lineRenderer.numCapVertices = 6;
			lineRenderer.positionCount = Mathf.Max(2, segmentCount);
			Vector3 v