Decompiled source of Vampire Auras v1.0.0

VampireAuras.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Hook;
using FMOD;
using FMOD.Studio;
using HarmonyLib;
using Il2CppInterop.Common;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppInterop.Runtime.Runtime;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.UI;
using Stunlock.Core;
using Stunlock.Fmod;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using VampireAuras.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : System.Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal sealed class NullableAttribute : System.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]
	[Embedded]
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal sealed class RefSafetyRulesAttribute : System.Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace VampireAuras
{
	[BepInPlugin("com.zeeCameLsnake.VampireAuras", "VampireAuras", "1.0.0")]
	public class VampireAurasPlugin : BasePlugin
	{
		public const string PluginGUID = "com.zeeCameLsnake.VampireAuras";

		public const string PluginName = "VampireAuras";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log;

		private Harmony _harmony;

		private bool _skippedOnServer;

		public override void Load()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			if (Application.productName == "VRisingServer")
			{
				_skippedOnServer = true;
				ManualLogSource log = Log;
				val = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("VampireAuras");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is a client mod, skipping on server.");
				}
				log.LogInfo(val);
				return;
			}
			AuraConfig.Bind(((BasePlugin)this).Config);
			AuraManager.Init();
			_harmony = new Harmony("com.zeeCameLsnake.VampireAuras");
			_harmony.PatchAll(typeof(AbilityBarPatches));
			_harmony.PatchAll(typeof(EditModePatches));
			ConsumedInputsDetour.Apply();
			ManualLogSource log2 = Log;
			val = new BepInExInfoLogInterpolatedStringHandler(36, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("VampireAuras");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded. Reload key: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Hotkey>(AuraConfig.ReloadKey);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", edit mode: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Hotkey>(AuraConfig.EditModeKey);
			}
			log2.LogInfo(val);
		}

		public override bool Unload()
		{
			if (_skippedOnServer)
			{
				return true;
			}
			AuraManager.Teardown("plugin unload");
			ConsumedInputsDetour.Dispose();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}
	}
	internal class SlotConfig
	{
		public string Key;

		public string EntryName;

		public ConfigEntry<bool> Enabled;

		public ConfigEntry<float> PosX;

		public ConfigEntry<float> PosY;

		public ConfigEntry<bool> CustomScale;

		public ConfigEntry<float> Scale;

		public ConfigEntry<bool> CustomIdleOpacity;

		public ConfigEntry<float> IdleOpacity;

		public ConfigEntry<bool> CustomIdleSize;

		public ConfigEntry<int> IdleSizePercent;

		public ConfigEntry<SlotSoundChoice> ReadySound;

		public ConfigEntry<float> ReadySoundVolume;

		public float EffectiveScale => CustomScale.Value ? Scale.Value : AuraConfig.GlobalScale.Value;

		public float EffectiveIdleOpacity => CustomIdleOpacity.Value ? IdleOpacity.Value : AuraConfig.IdleOpacity.Value;

		public float EffectiveIdleSizeFactor => (float)(CustomIdleSize.Value ? IdleSizePercent.Value : AuraConfig.IdleSizePercent.Value) / 100f;
	}
	public enum SoundChoice
	{
		T01_SpellUnlocked,
		T02_JewelEquip,
		T03_ChargeTick,
		T04_ImportantSelect,
		T05_TraderPurchase,
		T06_JewelcraftDone,
		T07_FusionForgeDone,
		T08_JewelUnequip,
		T09_Whisper_MPCaution,
		T10_ClanOnline_MPCaution,
		Custom
	}
	public enum SlotSoundChoice
	{
		Default,
		Off,
		T01_SpellUnlocked,
		T02_JewelEquip,
		T03_ChargeTick,
		T04_ImportantSelect,
		T05_TraderPurchase,
		T06_JewelcraftDone,
		T07_FusionForgeDone,
		T08_JewelUnequip,
		T09_Whisper_MPCaution,
		T10_ClanOnline_MPCaution,
		Custom
	}
	public enum HotkeyKey
	{
		None,
		F1,
		F2,
		F3,
		F4,
		F5,
		F6,
		F7,
		F8,
		F9,
		F10,
		F11,
		F12,
		PageUp,
		PageDown,
		Home,
		End,
		Insert,
		Delete,
		Pause,
		ScrollLock,
		Alpha0,
		Alpha1,
		Alpha2,
		Alpha3,
		Alpha4,
		Alpha5,
		Alpha6,
		Alpha7,
		Alpha8,
		Alpha9,
		A,
		B,
		C,
		D,
		E,
		F,
		G,
		H,
		I,
		J,
		K,
		L,
		M,
		N,
		O,
		P,
		Q,
		R,
		S,
		T,
		U,
		V,
		W,
		X,
		Y,
		Z,
		Keypad0,
		Keypad1,
		Keypad2,
		Keypad3,
		Keypad4,
		Keypad5,
		Keypad6,
		Keypad7,
		Keypad8,
		Keypad9,
		KeypadPeriod,
		KeypadDivide,
		KeypadMultiply,
		KeypadMinus,
		KeypadPlus,
		KeypadEnter,
		UpArrow,
		DownArrow,
		LeftArrow,
		RightArrow,
		Tab,
		Space,
		Return,
		Backspace,
		BackQuote,
		Minus,
		Equals,
		LeftBracket,
		RightBracket,
		Backslash,
		Semicolon,
		Quote,
		Comma,
		Period,
		Slash,
		Mouse3,
		Mouse4,
		Mouse5,
		Mouse6
	}
	public enum HotkeyModifier
	{
		None,
		Shift,
		Control,
		Alt
	}
	internal class Hotkey
	{
		public ConfigEntry<HotkeyKey> Key;

		public ConfigEntry<HotkeyModifier> Modifier;

		private HotkeyKey _cachedKey = HotkeyKey.None;

		private KeyCode _cachedKeyCode = (KeyCode)0;

		public KeyCode KeyCode
		{
			get
			{
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				HotkeyKey value = Key.Value;
				if (value != _cachedKey)
				{
					_cachedKey = value;
					KeyCode val = default(KeyCode);
					_cachedKeyCode = (KeyCode)(System.Enum.TryParse<KeyCode>(((object)value/*cast due to .constrained prefix*/).ToString(), ref val) ? ((int)val) : 0);
				}
				return _cachedKeyCode;
			}
		}

		public bool IsBound => (int)KeyCode > 0;

		internal static Hotkey Bind(ConfigFile cfg, string section, string name, HotkeyKey defaultKey, string description)
		{
			return new Hotkey
			{
				Key = cfg.Bind<HotkeyKey>(section, name, defaultKey, description + " None = not bound."),
				Modifier = cfg.Bind<HotkeyModifier>(section, name + "Modifier", HotkeyModifier.None, "Modifier for " + name + ": None (no modifier held), Shift, Control or Alt.")
			};
		}

		public bool IsDown()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			KeyCode keyCode = KeyCode;
			if ((int)keyCode == 0 || !Input.GetKeyDown(keyCode))
			{
				return false;
			}
			bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303);
			bool flag2 = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305);
			bool flag3 = Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307) || Input.GetKey((KeyCode)313);
			return Modifier.Value switch
			{
				HotkeyModifier.Shift => flag && !flag2 && !flag3, 
				HotkeyModifier.Control => flag2 && !flag && !flag3, 
				HotkeyModifier.Alt => flag3 && !flag && !flag2, 
				_ => !flag && !flag2 && !flag3, 
			};
		}

		public virtual string ToString()
		{
			if (!IsBound)
			{
				return "not bound";
			}
			return Modifier.Value switch
			{
				HotkeyModifier.Shift => "Shift+" + ((object)Key.Value/*cast due to .constrained prefix*/).ToString(), 
				HotkeyModifier.Control => "Ctrl+" + ((object)Key.Value/*cast due to .constrained prefix*/).ToString(), 
				HotkeyModifier.Alt => "Alt+" + ((object)Key.Value/*cast due to .constrained prefix*/).ToString(), 
				_ => ((object)Key.Value/*cast due to .constrained prefix*/).ToString(), 
			};
		}
	}
	public enum EditHighlight
	{
		Overlay,
		Glow,
		Off
	}
	internal class GlowConfig
	{
		public string Name;

		public ConfigEntry<bool> Enabled;

		public ConfigEntry<string> ColorHex;

		public ConfigEntry<float> Size;

		public ConfigEntry<GlowShape> Shape;

		public Color FallbackColor;
	}
	internal static class AuraConfig
	{
		internal const float MinScale = 0.4f;

		internal const float MaxScale = 3f;

		internal const int MinIdleSizePercent = 30;

		internal const int MaxIdleSizePercent = 150;

		private const string SectionGeneral = "1. General";

		private const string SectionEditMode = "1.1 Edit Mode";

		private const string SectionAppearance = "2. Appearance";

		private const string SectionReady = "3. Ready Effect & Fade";

		private const string SectionReadyGlow = "3.1 Ready Glow";

		private const string SectionChargeGlow = "3.2 Charge Glow";

		private const string SectionFlash = "3.3 Ready Flash";

		private const string SectionSound = "3.4 Ready Sound";

		private const string SectionDebug = "5. Debug";

		internal const string LayoutFileName = "com.zeeCameLsnake.VampireAuras.Layout.cfg";

		private const string LayoutWarning = "ATTENTION, read description before editing! This file is written by the in-game edit mode. Mod managers like Gale do not notice that and keep the old values. If you change anything here after using the edit mode without restarting the mod manager first, your in-game changes are reset to the old values. Easiest: use the in-game edit mode instead. This switch itself does nothing.";

		internal static ConfigFile File;

		internal static ConfigFile LayoutFile;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> LiveReload;

		internal static Hotkey ReloadKey;

		internal static Hotkey EditModeKey;

		internal static ConfigEntry<EditHighlight> EditModeHighlight;

		internal static ConfigEntry<bool> EditModeSnapToSlot;

		internal static ConfigEntry<float> EditModeSnapDistance;

		internal static ConfigEntry<bool> EditModeSnapMatchSize;

		internal static ConfigEntry<bool> EditModeShowHelp;

		internal static ConfigEntry<bool> EditModeShowLabels;

		internal static ConfigEntry<float> GlobalScale;

		internal static ConfigEntry<float> ActiveOpacity;

		internal static ConfigEntry<float> IdleOpacity;

		internal static ConfigEntry<int> IdleSizePercent;

		internal static ConfigEntry<bool> ShowKeybind;

		internal static ConfigEntry<bool> ShowCooldownNumber;

		internal static ConfigEntry<bool> ShowCooldownSweep;

		internal static ConfigEntry<bool> ShowChargesText;

		internal static ConfigEntry<bool> FadeWhenReady;

		internal static ConfigEntry<float> FadeOutDuration;

		internal static ConfigEntry<bool> EnableReadyPulse;

		internal static ConfigEntry<float> PulseScaleMultiplier;

		internal static ConfigEntry<float> PulseDuration;

		internal static GlowConfig ReadyGlow;

		internal static GlowConfig ChargeGlow;

		internal static ConfigEntry<bool> FlashEnabled;

		internal static ConfigEntry<bool> FlashOnChargeReady;

		internal static ConfigEntry<string> FlashColor;

		internal static ConfigEntry<float> FlashOpacity;

		internal static ConfigEntry<float> FlashDuration;

		internal static ConfigEntry<FlashShape> FlashShapeSetting;

		internal static ConfigEntry<float> FlashStarSize;

		internal static ConfigEntry<float> FlashStarShortPoints;

		internal static ConfigEntry<float> FlashStarPointWidth;

		internal static ConfigEntry<bool> SoundEnabled;

		internal static ConfigEntry<SoundChoice> SoundChoiceSetting;

		internal static ConfigEntry<string> SoundCustomEvent;

		internal static ConfigEntry<float> SoundVolume;

		internal static ConfigEntry<bool> SoundOnChargeReady;

		internal static Hotkey SoundCheckKey;

		internal static Hotkey SoundCheckPreviousKey;

		internal static ConfigEntry<bool> DumpSoundEvents;

		internal static ConfigEntry<bool> LogAbilityData;

		internal static ConfigEntry<bool> EditModeInputDetour;

		internal static SlotConfig[] Slots;

		private const string PrimaryAttackNote = "The 1st slot (primary attack) has no cooldown apart from a minimal global cooldown, so it gets no Aura.";

		internal static void Bind(ConfigFile cfg)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Expected O, but got Unknown
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Expected O, but got Unknown
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Expected O, but got Unknown
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Expected O, but got Unknown
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Expected O, but got Unknown
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Expected O, but got Unknown
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Expected O, but got Unknown
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Expected O, but got Unknown
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Expected O, but got Unknown
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Expected O, but got Unknown
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: Expected O, but got Unknown
			File = cfg;
			BepInPlugin val = new BepInPlugin("com.zeeCameLsnake.VampireAuras", "VampireAuras", "1.0.0");
			LayoutFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "com.zeeCameLsnake.VampireAuras.Layout.cfg"), true, val);
			Enabled = cfg.Bind<bool>("1. General", "Enabled", true, "Master switch. Off: no Auras, no ready effects and no sounds. The mod never changes the vanilla ability bar itself.");
			LiveReload = cfg.Bind<bool>("1. General", "LiveReload", true, "Re-reads this config file automatically within about a second after it was saved (e.g. by a mod manager or text editor), so changes show up in-game without pressing ReloadKey. The layout file (com.zeeCameLsnake.VampireAuras.Layout.cfg) is not watched, because the edit mode writes it.");
			ReloadKey = Hotkey.Bind(cfg, "1. General", "ReloadKey", HotkeyKey.F10, "Re-reads this config file and the layout file (com.zeeCameLsnake.VampireAuras.Layout.cfg) in-game, so changes made in a mod manager or text editor while the game runs take effect without a restart. With LiveReload on, this file is re-read automatically; the key is still needed for the layout file. In the edit mode, the key re-reads only this file.");
			EditModeKey = Hotkey.Bind(cfg, "1. General", "EditModeKey", HotkeyKey.F9, "Edit mode: drag Auras with the left mouse button, resize them with the mouse wheel (switches the slot's CustomScale on), middle click goes back to GlobalScale. Auras snap onto their own vanilla bar slot. Game input is blocked while editing. Press the key again (or ESC) to finish. Positions and sizes are saved to their own file, com.zeeCameLsnake.VampireAuras.Layout.cfg, so changing this config in a mod manager cannot overwrite them.");
			EditModeHighlight = cfg.Bind<EditHighlight>("1.1 Edit Mode", "Highlight", EditHighlight.Overlay, "How the Aura under the mouse is highlighted in the edit mode. Overlay: faint white square exactly the Aura's size (best for precise placement). Glow: the ready glow around it. Off: no highlight.");
			EditModeSnapToSlot = cfg.Bind<bool>("1.1 Edit Mode", "SnapToSlot", true, "While dragging, an Aura snaps exactly onto its own slot of the vanilla ability bar when it comes close. Useful to get the ready effects right on the vanilla bar.");
			EditModeSnapDistance = cfg.Bind<float>("1.1 Edit Mode", "SnapDistance", 15f, new ConfigDescription("Distance in screen pixels between the Aura's center and the center of its vanilla slot at which it snaps on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 60f), System.Array.Empty<object>()));
			EditModeSnapMatchSize = cfg.Bind<bool>("1.1 Edit Mode", "SnapMatchSize", true, "On: when an Aura snaps onto its vanilla slot, its Scale is set to the slot's size and its CustomScale is switched on (both in com.zeeCameLsnake.VampireAuras.Layout.cfg). Off: only the position snaps.");
			EditModeShowHelp = cfg.Bind<bool>("1.1 Edit Mode", "ShowHelp", true, "Show a short help line at the top of the screen while the edit mode is active.");
			EditModeShowLabels = cfg.Bind<bool>("1.1 Edit Mode", "ShowLabels", true, "Show the slot name (e.g. Weapon1) above each Aura while the edit mode is active.");
			GlobalScale = cfg.Bind<float>("2. Appearance", "GlobalScale", 0.7f, new ConfigDescription("Size of all Auras. A slot with CustomScale on uses its own Scale instead (both in com.zeeCameLsnake.VampireAuras.Layout.cfg, set by the mouse wheel in the edit mode).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.4f, 3f), System.Array.Empty<object>()));
			ActiveOpacity = cfg.Bind<float>("2. Appearance", "ActiveOpacity", 0.9f, new ConfigDescription("Opacity while an ability is being cast, on cooldown or recharging (0 = invisible, 1 = fully opaque).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), System.Array.Empty<object>()));
			IdleOpacity = cfg.Bind<float>("2. Appearance", "IdleOpacity", 0f, new ConfigDescription("Opacity after the fade-out, once an ability is completely ready (0 = hidden, e.g. 0.25 = faint). A slot with CustomIdleOpacity on uses its own value. Only with FadeWhenReady on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), System.Array.Empty<object>()));
			IdleSizePercent = cfg.Bind<int>("2. Appearance", "IdleSizePercent", 100, new ConfigDescription("Size after the fade-out, in percent of the Aura's normal size. The normal size is GlobalScale, or the slot's own Scale if its CustomScale is on (both in com.zeeCameLsnake.VampireAuras.Layout.cfg). Example: GlobalScale 0.7 with 100 % and GlobalScale 1.0 with 70 % both end at size 0.7 for the idle size (while on cooldown they are shown at 0.7 and 1.0). 100 = unchanged, e.g. 60 = smaller reminder. A slot with CustomIdleSize on uses its own value. Only with FadeWhenReady on.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(30, 150), System.Array.Empty<object>()));
			ShowKeybind = cfg.Bind<bool>("2. Appearance", "ShowKeybind", true, "Show the keybind label on the Auras.");
			ShowCooldownNumber = cfg.Bind<bool>("2. Appearance", "ShowCooldownNumber", true, "Show the cooldown countdown number.");
			ShowCooldownSweep = cfg.Bind<bool>("2. Appearance", "ShowCooldownSweep", true, "Show the dark cooldown fill overlay.");
			ShowChargesText = cfg.Bind<bool>("2. Appearance", "ShowChargesText", true, "Show the charge count of abilities with charges.");
			FadeWhenReady = cfg.Bind<bool>("3. Ready Effect & Fade", "FadeWhenReady", true, "On: once an ability is completely ready (all charges full), its Aura fades to IdleOpacity and IdleSizePercent after the ready effects. Off: Auras stay at ActiveOpacity and normal size, also when ready.");
			FadeOutDuration = cfg.Bind<float>("3. Ready Effect & Fade", "FadeOutDuration", 1.5f, new ConfigDescription("Duration of the fade-out in seconds. It starts after the ready pulse.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 30f), System.Array.Empty<object>()));
			EnableReadyPulse = cfg.Bind<bool>("3. Ready Effect & Fade", "EnableReadyPulse", true, "Briefly enlarge an Aura when its cooldown ends or a charge is restored.");
			PulseScaleMultiplier = cfg.Bind<float>("3. Ready Effect & Fade", "PulseScaleMultiplier", 1.35f, new ConfigDescription("Peak size of the ready pulse relative to the Aura's normal size (e.g. 1.35 = 35 % bigger at the peak).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2.5f), System.Array.Empty<object>()));
			PulseDuration = cfg.Bind<float>("3. Ready Effect & Fade", "PulseDuration", 0.65f, new ConfigDescription("Duration of the ready pulse and glow in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), System.Array.Empty<object>()));
			ReadyGlow = BindGlow(cfg, "3.1 Ready Glow", "Ready glow", "Glow when an ability is completely ready (cooldown over, all charges full).", "#FFCC33", new Color(1f, 0.8f, 0.2f, 1f), 2.5f, GlowShape.Round);
			ChargeGlow = BindGlow(cfg, "3.2 Charge Glow", "Charge glow", "Glow when one charge is back while more charges are still recharging.", "#33CCFF", new Color(0.2f, 0.8f, 1f, 1f), 1.7f, GlowShape.Square);
			FlashEnabled = cfg.Bind<bool>("3.3 Ready Flash", "Enabled", true, "Short flash on top of an Aura when its ability becomes ready.");
			FlashOnChargeReady = cfg.Bind<bool>("3.3 Ready Flash", "OnChargeReady", true, "Also flash when one charge is back while more charges are still recharging.");
			FlashColor = cfg.Bind<string>("3.3 Ready Flash", "Color", "#FFFFFF", "Color of the flash (#RRGGBB).");
			FlashOpacity = cfg.Bind<float>("3.3 Ready Flash", "Opacity", 1f, new ConfigDescription("Peak opacity of the flash (1 = fully opaque at its peak).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), System.Array.Empty<object>()));
			FlashDuration = cfg.Bind<float>("3.3 Ready Flash", "Duration", 0.3f, new ConfigDescription("Duration of the flash in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), System.Array.Empty<object>()));
			FlashShapeSetting = cfg.Bind<FlashShape>("3.3 Ready Flash", "Shape", FlashShape.Star, "Shape of the flash: Star (8 points, long and short alternating, reaching beyond the Aura) or Square (covers the Aura).");
			FlashStarSize = cfg.Bind<float>("3.3 Ready Flash", "StarSize", 3f, new ConfigDescription("Length of the long star points in Aura widths (e.g. 3 = three times as wide as the Aura). Only for Shape = Star.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 4f), System.Array.Empty<object>()));
			FlashStarShortPoints = cfg.Bind<float>("3.3 Ready Flash", "StarShortPoints", 0.7f, new ConfigDescription("Length of the short star points relative to the long ones (only for Shape = Star).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), System.Array.Empty<object>()));
			FlashStarPointWidth = cfg.Bind<float>("3.3 Ready Flash", "StarPointWidth", 0.1f, new ConfigDescription("Width of the star points relative to their length (only for Shape = Star).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.3f), System.Array.Empty<object>()));
			SoundEnabled = cfg.Bind<bool>("3.4 Ready Sound", "Enabled", true, "Play one of the game's own sounds when an ability becomes ready. Master switch for all slots.");
			SoundChoiceSetting = cfg.Bind<SoundChoice>("3.4 Ready Sound", "Sound", SoundChoice.T04_ImportantSelect, "Default ready sound for all slots (each slot can pick its own below). Use the sound check key to listen to all sounds in-game. _MPCaution sounds: in online games the game also plays them for whisper and clan messages, so they can be confused there.");
			SoundVolume = cfg.Bind<float>("3.4 Ready Sound", "Volume", 0.4f, new ConfigDescription("Master volume of the ready sounds (0 = silent, 1 = full). Multiplied with each slot's volume below.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), System.Array.Empty<object>()));
			SoundOnChargeReady = cfg.Bind<bool>("3.4 Ready Sound", "OnChargeReady", true, "Also play the sound when one charge is back while more charges are still recharging.");
			SoundCustomEvent = cfg.Bind<string>("3.4 Ready Sound", "CustomEvent", "", "For tinkerers: any FMOD event path of the game (event:/UI/...), used where a dropdown is set to Custom. Sounds from the SFX banks usually stay silent.");
			SoundCheckKey = Hotkey.Bind(cfg, "3.4 Ready Sound", "SoundCheckKey", HotkeyKey.PageUp, "Sound check: plays the next sound of the dropdown list in-game and shows its name.");
			SoundCheckPreviousKey = Hotkey.Bind(cfg, "3.4 Ready Sound", "SoundCheckPreviousKey", HotkeyKey.PageDown, "Sound check backwards: plays the previous sound of the dropdown list.");
			LogAbilityData = cfg.Bind<bool>("5. Debug", "LogAbilityData", false, "Write ability data changes and ready-pulse triggers to the BepInEx log. Only needed for bug reports.");
			EditModeInputDetour = cfg.Bind<bool>("5. Debug", "EditModeInputDetour", true, "Block game input (attacks, camera zoom) while the edit mode is active, the same way the inventory window does. Switch off only if the game misbehaves; takes effect after a game restart.");
			DumpSoundEvents = cfg.Bind<bool>("5. Debug", "DumpSoundEvents", false, "Write the paths of all game sounds to BepInEx/VampireAuras_SoundEvents.txt once per game start. Only needed to pick a ready sound.");
			Slots = new SlotConfig[6]
			{
				BindSlot(cfg, "4.1", "Weapon1", 2, "AbilityBarEntry_WeaponSkill1", 0.38f, "Weapon1 is the first weapon skill, the 2nd slot of the vanilla ability bar. The 1st slot (primary attack) has no cooldown apart from a minimal global cooldown, so it gets no Aura."),
				BindSlot(cfg, "4.2", "Weapon2", 3, "AbilityBarEntry_WeaponSkill2", 0.428f, "Weapon2 is the second weapon skill, the 3rd slot of the vanilla ability bar. The 1st slot (primary attack) has no cooldown apart from a minimal global cooldown, so it gets no Aura."),
				BindSlot(cfg, "4.3", "Dash", 4, "AbilityBarEntry_Travel", 0.476f),
				BindSlot(cfg, "4.4", "Spell1", 5, "AbilityBarEntry_Spell1", 0.524f),
				BindSlot(cfg, "4.5", "Spell2", 6, "AbilityBarEntry_Spell2", 0.572f),
				BindSlot(cfg, "4.6", "Ultimate", 7, "AbilityBarEntry_Ultimate", 0.62f)
			};
		}

		private static GlowConfig BindGlow(ConfigFile cfg, string section, string name, string purpose, string defaultColor, Color fallbackColor, float defaultSize, GlowShape defaultShape)
		{
			//IL_000e: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			return new GlowConfig
			{
				Name = name,
				FallbackColor = fallbackColor,
				Enabled = cfg.Bind<bool>(section, "Enabled", true, purpose ?? ""),
				ColorHex = cfg.Bind<string>(section, "Color", defaultColor, "Color of the " + name.ToLowerInvariant() + " (#RRGGBB)."),
				Size = cfg.Bind<float>(section, "Size", defaultSize, new ConfigDescription("Size of the " + name.ToLowerInvariant() + " in Aura widths (e.g. 2.5 = two and a half times as wide as the Aura).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1.2f, 3f), System.Array.Empty<object>())),
				Shape = cfg.Bind<GlowShape>(section, "Shape", defaultShape, "Shape of the " + name.ToLowerInvariant() + ": Round, or Square like the Aura.")
			};
		}

		private static SlotConfig BindSlot(ConfigFile cfg, string number, string key, int barSlot, string entryName, float defaultX, string note = null)
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Expected O, but got Unknown
			string text = $"{number} Slot: {key} (bar slot {barSlot})";
			ConfigFile layoutFile = LayoutFile;
			layoutFile.Bind<bool>(text, "ATTENTION, read description before editing! This file is written by the in-game edit mode. Mod managers like Gale do not notice that and keep the old values. If you change anything here after using the edit mode without restarting the mod manager first, your in-game changes are reset to the old values. Easiest: use the in-game edit mode instead. This switch itself does nothing.", true, "Only a warning, see the name of this entry. It has no function.");
			return new SlotConfig
			{
				Key = key,
				EntryName = entryName,
				Enabled = cfg.Bind<bool>(text, "Enabled", true, "Show an Aura for the " + key + " slot." + ((note != null) ? (" " + note) : "")),
				PosX = layoutFile.Bind<float>(text, "PosX", defaultX, new ConfigDescription("Horizontal position (0 = left edge, 0.5 = center, 1 = right edge). Easier: drag the Aura in the edit mode.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), System.Array.Empty<object>())),
				PosY = layoutFile.Bind<float>(text, "PosY", 0.38f, new ConfigDescription("Vertical position (0 = bottom edge, 0.5 = center, 1 = top edge). Easier: drag the Aura in the edit mode.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), System.Array.Empty<object>())),
				CustomScale = layoutFile.Bind<bool>(text, "CustomScale", false, "On: this Aura uses its own Scale below. Off: [2. Appearance] GlobalScale of the main config applies. The mouse wheel in the edit mode switches it on, a middle click off."),
				Scale = layoutFile.Bind<float>(text, "Scale", 0.7f, new ConfigDescription("Own size of this Aura (only with CustomScale on).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.4f, 3f), System.Array.Empty<object>())),
				CustomIdleOpacity = cfg.Bind<bool>(text, "CustomIdleOpacity", false, "On: this Aura uses its own IdleOpacity below. Off: [2. Appearance] IdleOpacity applies. Useful to keep e.g. the Ultimate always in sight."),
				IdleOpacity = cfg.Bind<float>(text, "IdleOpacity", 0f, new ConfigDescription("Own opacity of this Aura once its ability is ready and faded out (only with CustomIdleOpacity on).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), System.Array.Empty<object>())),
				CustomIdleSize = cfg.Bind<bool>(text, "CustomIdleSize", false, "On: this Aura uses its own IdleSizePercent below. Off: [2. Appearance] IdleSizePercent applies."),
				IdleSizePercent = cfg.Bind<int>(text, "IdleSizePercent", 100, new ConfigDescription("Own size of this Aura once its ability is ready and faded out, in percent of its normal size (GlobalScale, or the slot's Scale in com.zeeCameLsnake.VampireAuras.Layout.cfg if its CustomScale is on). Only with CustomIdleSize on. Example: normal size 1.0 and 70 % = idle size 0.7 (on cooldown it stays 1.0).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(30, 150), System.Array.Empty<object>())),
				ReadySound = cfg.Bind<SlotSoundChoice>("3.4 Ready Sound", key + "Sound", SlotSoundChoice.Default, $"Ready sound of the {key} slot (bar slot {barSlot}). Default = the Sound above, Off = no sound for this slot."),
				ReadySoundVolume = cfg.Bind<float>("3.4 Ready Sound", key + "Volume", 1f, new ConfigDescription("Volume of the " + key + " ready sound (0 to 1), multiplied with Volume above.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), System.Array.Empty<object>()))
			};
		}

		internal static string SoundPath(SoundChoice choice)
		{
			return choice switch
			{
				SoundChoice.T01_SpellUnlocked => "event:/UI/Spellbook/UI_Spellbook_Unlock_Spell_Unlocked_CS_OPTIMIZED_STEREO", 
				SoundChoice.T02_JewelEquip => "event:/UI/Spell_Jewel/UI_Spell_Jewel_Equip_OPTIMIZED", 
				SoundChoice.T03_ChargeTick => "event:/UI/Workstation_Lightning_Mega_Rod_Electric/UI_Workstation_Lightning_Mega_Rod_Charging_Light_Increment", 
				SoundChoice.T04_ImportantSelect => "event:/UI/Generic/UI_Generic_Important_Select", 
				SoundChoice.T05_TraderPurchase => "event:/UI/Trader/UI_Trader_Purchase", 
				SoundChoice.T06_JewelcraftDone => "event:/UI/Workstation_Jewelcrafting_Table/UI_Workstation_Jewelcrafting_Table_Crafting_Complete_Receive", 
				SoundChoice.T07_FusionForgeDone => "event:/UI/Workstation_Fusion_Forge/UI_Workstation_Fusion_Forge_Complete_Button", 
				SoundChoice.T08_JewelUnequip => "event:/UI/Spell_Jewel/UI_Spell_Jewel_Unequip_OPTIMIZED", 
				SoundChoice.T09_Whisper_MPCaution => "event:/UI/Social/UI_Social_Message_Private_Whisper", 
				SoundChoice.T10_ClanOnline_MPCaution => "event:/UI/Social/UI_Social_Clan_Member_Comes_Online", 
				SoundChoice.Custom => SoundCustomEvent.Value, 
				_ => null, 
			};
		}

		internal static bool TryGetGlobalSound(out string path, out float volume)
		{
			path = (SoundEnabled.Value ? SoundPath(SoundChoiceSetting.Value) : null);
			volume = SoundVolume.Value;
			return !string.IsNullOrWhiteSpace(path);
		}

		internal static bool TryGetSlotSound(SlotConfig slot, out string path, out float volume)
		{
			path = null;
			volume = SoundVolume.Value * slot.ReadySoundVolume.Value;
			if (!SoundEnabled.Value)
			{
				return false;
			}
			switch (slot.ReadySound.Value)
			{
			case SlotSoundChoice.Off:
				return false;
			case SlotSoundChoice.Default:
				path = SoundPath(SoundChoiceSetting.Value);
				break;
			default:
			{
				SoundChoice choice = default(SoundChoice);
				if (System.Enum.TryParse<SoundChoice>(((object)slot.ReadySound.Value/*cast due to .constrained prefix*/).ToString(), ref choice))
				{
					path = SoundPath(choice);
					break;
				}
				AuraManager.LogWarningOnce("slotsound:" + ((object)slot.ReadySound.Value/*cast due to .constrained prefix*/).ToString(), $"Ready sound '{slot.ReadySound.Value}' of slot {slot.Key} has no sound path.");
				break;
			}
			}
			return !string.IsNullOrWhiteSpace(path);
		}
	}
	internal class AuraSlotController
	{
		internal readonly SlotConfig Slot;

		internal readonly int SourceIndex;

		internal bool EditHighlighted;

		internal bool EditSnapped;

		internal const int MaxConsecutiveErrors = 3;

		private int _consecutiveErrors;

		private readonly AbilityBarEntry _source;

		private readonly AbilityBarEntry _clone;

		private readonly RectTransform _rt;

		private readonly RectTransform _srcRt;

		private readonly AuraMirror _mirror;

		private readonly ReadyStateMachine _ready;

		private AuraEffects _effects;

		private Vector2 _baseSize;

		private bool _visible;

		[field: CompilerGenerated]
		[field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)]
		internal bool Dead
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			private set;
		}

		private AuraSlotController(SlotConfig slot, int sourceIndex, AbilityBarEntry source, AbilityBarEntry clone)
		{
			Slot = slot;
			SourceIndex = sourceIndex;
			_source = source;
			_clone = clone;
			_rt = ((Component)clone).GetComponent<RectTransform>();
			_srcRt = ((Component)source).GetComponent<RectTransform>();
			_mirror = new AuraMirror(source, clone);
			_ready = new ReadyStateMachine(slot.Key);
		}

		internal static AuraSlotController Create(SlotConfig slot, int sourceIndex, AbilityBarEntry source, Transform container, out string error)
		{
			//IL_0096: 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_00cc: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, container, false);
			((Object)val).name = "VampireAura_" + slot.Key;
			AbilityBarEntry component = val.GetComponent<AbilityBarEntry>();
			if ((Object)(object)component == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				error = "clone has no AbilityBarEntry component";
				return null;
			}
			AuraSlotController auraSlotController = new AuraSlotController(slot, sourceIndex, source, component);
			if (!auraSlotController._mirror.HierarchiesMatch())
			{
				Object.Destroy((Object)(object)val);
				error = "source and clone hierarchies differ";
				return null;
			}
			auraSlotController._rt.anchorMin = new Vector2(0.5f, 0.5f);
			auraSlotController._rt.anchorMax = new Vector2(0.5f, 0.5f);
			auraSlotController._rt.pivot = new Vector2(0.5f, 0.5f);
			System.Collections.Generic.IEnumerator<Graphic> enumerator = val.GetComponentsInChildren<Graphic>(true).GetEnumerator();
			try
			{
				while (((System.Collections.IEnumerator)enumerator).MoveNext())
				{
					Graphic current = enumerator.Current;
					current.raycastTarget = false;
				}
			}
			finally
			{
				((System.IDisposable)enumerator)?.Dispose();
			}
			if ((Object)(object)component.Alpha != (Object)null)
			{
				component.Alpha.interactable = false;
				component.Alpha.blocksRaycasts = false;
				component.Alpha.alpha = 0f;
			}
			Rect rect = auraSlotController._rt.rect;
			auraSlotController._baseSize = ((Rect)(ref rect)).size;
			if (auraSlotController._baseSize.x <= 0f || auraSlotController._baseSize.y <= 0f)
			{
				auraSlotController._baseSize = new Vector2(50f, 50f);
			}
			auraSlotController._effects = new AuraEffects(slot, component, auraSlotController._baseSize);
			auraSlotController.RefreshSettings();
			error = null;
			return auraSlotController;
		}

		internal void RefreshSettings()
		{
			_effects.RefreshSettings();
			_mirror.RefreshVisibilityFlags();
		}

		internal void Update(Data data, RectTransform containerRt, float dt)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAlive())
			{
				return;
			}
			int num;
			if (data != null)
			{
				PrefabGUID abilityId = data.AbilityId;
				num = ((((PrefabGUID)(ref abilityId)).GuidHash != 0) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			bool flag = (byte)num != 0;
			ReadyEvent readyEvent = _ready.Step(data, flag);
			_effects.OnReadyEvent(readyEvent);
			_effects.Tick((readyEvent == ReadyEvent.Reset) ? 0f : dt, _ready.Busy);
			bool active = EditMode.Active;
			float num2 = ((!AuraConfig.Enabled.Value || !Slot.Enabled.Value || !(flag || active) || !((Component)_source).gameObject.activeSelf) ? 0f : (active ? 1f : CurrentOpacity()));
			CanvasGroup alpha = _clone.Alpha;
			_visible = num2 > 0.001f;
			if (!_visible)
			{
				if ((Object)(object)alpha != (Object)null && alpha.alpha != 0f)
				{
					alpha.alpha = 0f;
				}
				return;
			}
			_mirror.Copy();
			if ((Object)(object)alpha != (Object)null)
			{
				float num3 = (((Object)(object)_source.Alpha != (Object)null) ? _source.Alpha.alpha : 1f);
				alpha.alpha = num3 * num2;
			}
			_effects.Render(active, active && EditHighlighted, EditSnapped);
			Place(containerRt, _effects.PulseScale());
		}

		private float CurrentOpacity()
		{
			return Mathf.Lerp(AuraConfig.ActiveOpacity.Value, Slot.EffectiveIdleOpacity, _effects.FadeProgress());
		}

		private float CurrentIdleSizeFactor()
		{
			if (EditMode.Active)
			{
				return 1f;
			}
			return Mathf.Lerp(1f, Slot.EffectiveIdleSizeFactor, _effects.FadeProgress());
		}

		private void Place(RectTransform containerRt, float pulseScale)
		{
			//IL_0058: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_rt == (Object)null) && !((Object)(object)containerRt == (Object)null))
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor((float)Screen.width * Slot.PosX.Value, (float)Screen.height * Slot.PosY.Value);
				Vector3 position = default(Vector3);
				if (RectTransformUtility.ScreenPointToWorldPointInRectangle(containerRt, val, (Camera)null, ref position))
				{
					((Transform)_rt).position = position;
				}
				float num = Mathf.Clamp(Slot.EffectiveScale, 0.4f, 3f) * pulseScale * CurrentIdleSizeFactor();
				((Transform)_rt).localScale = new Vector3(num, num, 1f);
			}
		}

		internal bool ContainsScreenPoint(Vector2 screenPoint)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (!_visible || (Object)(object)_rt == (Object)null || ((Il2CppObjectBase)_rt).Pointer == System.IntPtr.Zero)
			{
				return false;
			}
			return RectTransformUtility.RectangleContainsScreenPoint(_rt, screenPoint, (Camera)null);
		}

		internal Vector2 ScreenCenter()
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Transform)_rt).position;
			return new Vector2(position.x, position.y);
		}

		internal bool TryGetSourceScreenCenter(out Vector2 center)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0080: 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)
			center = Vector2.zero;
			if ((Object)(object)_srcRt == (Object)null || ((Il2CppObjectBase)_srcRt).Pointer == System.IntPtr.Zero || !((Component)_source).gameObject.activeInHierarchy)
			{
				return false;
			}
			RectTransform srcRt = _srcRt;
			Rect rect = _srcRt.rect;
			Vector3 val = ((Transform)srcRt).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center));
			center = new Vector2(val.x, val.y);
			return true;
		}

		internal float ScaleMatchingSource()
		{
			//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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_srcRt == (Object)null || (Object)(object)_rt == (Object)null || (Object)(object)((Transform)_rt).parent == (Object)null)
			{
				return Slot.EffectiveScale;
			}
			Rect rect = _srcRt.rect;
			float num = ((Rect)(ref rect)).width * ((Transform)_srcRt).lossyScale.x;
			float num2 = _baseSize.x * ((Transform)_rt).parent.lossyScale.x;
			return (num2 > 0f) ? (num / num2) : Slot.EffectiveScale;
		}

		internal void RecordSuccess()
		{
			_consecutiveErrors = 0;
		}

		internal bool RecordError()
		{
			if (Dead || ++_consecutiveErrors < 3)
			{
				return false;
			}
			Dead = true;
			_visible = false;
			try
			{
				if ((Object)(object)_clone != (Object)null && ((Il2CppObjectBase)_clone).Pointer != System.IntPtr.Zero)
				{
					((Component)_clone).gameObject.SetActive(false);
				}
			}
			catch
			{
			}
			return true;
		}

		internal bool IsAlive()
		{
			return (Object)(object)_clone != (Object)null && ((Il2CppObjectBase)_clone).Pointer != System.IntPtr.Zero && (Object)(object)_source != (Object)null && ((Il2CppObjectBase)_source).Pointer != System.IntPtr.Zero;
		}
	}
	internal class AuraMirror
	{
		private readonly AbilityBarEntry _clone;

		private readonly Transform[] _srcTransforms;

		private readonly Transform[] _dstTransforms;

		private readonly Image[] _srcImages;

		private readonly Image[] _dstImages;

		private readonly TextMeshProUGUI[] _srcTexts;

		private readonly TextMeshProUGUI[] _dstTexts;

		private readonly CanvasGroup[] _srcGroups;

		private readonly CanvasGroup[] _dstGroups;

		private readonly bool[] _imageHidden;

		private readonly bool[] _textHidden;

		internal AuraMirror(AbilityBarEntry source, AbilityBarEntry clone)
		{
			_clone = clone;
			_srcTransforms = ToArray<Transform>(((Component)source).GetComponentsInChildren<Transform>(true));
			_dstTransforms = ToArray<Transform>(((Component)clone).GetComponentsInChildren<Transform>(true));
			_srcImages = ToArray<Image>(((Component)source).GetComponentsInChildren<Image>(true));
			_dstImages = ToArray<Image>(((Component)clone).GetComponentsInChildren<Image>(true));
			_srcTexts = ToArray<TextMeshProUGUI>(((Component)source).GetComponentsInChildren<TextMeshProUGUI>(true));
			_dstTexts = ToArray<TextMeshProUGUI>(((Component)clone).GetComponentsInChildren<TextMeshProUGUI>(true));
			_srcGroups = ToArray<CanvasGroup>(((Component)source).GetComponentsInChildren<CanvasGroup>(true));
			_dstGroups = ToArray<CanvasGroup>(((Component)clone).GetComponentsInChildren<CanvasGroup>(true));
			_imageHidden = new bool[_dstImages.Length];
			_textHidden = new bool[_dstTexts.Length];
		}

		internal bool HierarchiesMatch()
		{
			if (_srcTransforms.Length != _dstTransforms.Length || _srcImages.Length != _dstImages.Length || _srcTexts.Length != _dstTexts.Length || _srcGroups.Length != _dstGroups.Length)
			{
				return false;
			}
			for (int i = 1; i < _srcTransforms.Length; i++)
			{
				if (((Object)_srcTransforms[i]).name != ((Object)_dstTransforms[i]).name)
				{
					return false;
				}
			}
			return true;
		}

		internal void RefreshVisibilityFlags()
		{
			bool flag = !AuraConfig.ShowKeybind.Value;
			bool flag2 = !AuraConfig.ShowCooldownNumber.Value;
			bool flag3 = !AuraConfig.ShowCooldownSweep.Value;
			bool flag4 = !AuraConfig.ShowChargesText.Value;
			for (int i = 0; i < _dstImages.Length; i++)
			{
				Image val = _dstImages[i];
				_imageHidden[i] = (flag3 && Same((Il2CppObjectBase)(object)val, (Il2CppObjectBase)(object)_clone.CooldownFillImage)) || (flag && (Same((Il2CppObjectBase)(object)val, (Il2CppObjectBase)(object)_clone.KeybindImage) || Same((Il2CppObjectBase)(object)val, (Il2CppObjectBase)(object)_clone.KeybindModifierImage) || ((Object)val).name == "KeybindBackground"));
			}
			for (int j = 0; j < _dstTexts.Length; j++)
			{
				TextMeshProUGUI a = _dstTexts[j];
				_textHidden[j] = (flag2 && Same((Il2CppObjectBase)(object)a, (Il2CppObjectBase)(object)_clone.CooldownText)) || (flag4 && Same((Il2CppObjectBase)(object)a, (Il2CppObjectBase)(object)_clone.ChargesText)) || (flag && (Same((Il2CppObjectBase)(object)a, (Il2CppObjectBase)(object)_clone.KeybindText) || Same((Il2CppObjectBase)(object)a, (Il2CppObjectBase)(object)_clone.KeybindComboText)));
			}
		}

		internal void Copy()
		{
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 1; i < _srcTransforms.Length; i++)
			{
				bool activeSelf = ((Component)_srcTransforms[i]).gameObject.activeSelf;
				GameObject gameObject = ((Component)_dstTransforms[i]).gameObject;
				if (gameObject.activeSelf != activeSelf)
				{
					gameObject.SetActive(activeSelf);
				}
			}
			for (int j = 0; j < _srcImages.Length; j++)
			{
				Image val = _srcImages[j];
				Image val2 = _dstImages[j];
				bool flag = ((Behaviour)val).enabled && !_imageHidden[j];
				if (((Behaviour)val2).enabled != flag)
				{
					((Behaviour)val2).enabled = flag;
				}
				if (flag)
				{
					Sprite sprite = val.sprite;
					if ((Object)(object)val2.sprite != (Object)(object)sprite)
					{
						val2.sprite = sprite;
					}
					Material material = ((Graphic)val).material;
					if ((Object)(object)((Graphic)val2).material != (Object)(object)material)
					{
						((Graphic)val2).material = material;
					}
					val2.fillAmount = val.fillAmount;
					((Graphic)val2).color = ((Graphic)val).color;
				}
			}
			for (int k = 0; k < _srcTexts.Length; k++)
			{
				TextMeshProUGUI val3 = _srcTexts[k];
				TextMeshProUGUI val4 = _dstTexts[k];
				bool flag2 = ((Behaviour)val3).enabled && !_textHidden[k];
				if (((Behaviour)val4).enabled != flag2)
				{
					((Behaviour)val4).enabled = flag2;
				}
				if (flag2)
				{
					string text = ((TMP_Text)val3).text;
					if (((TMP_Text)val4).text != text)
					{
						((TMP_Text)val4).text = text;
					}
					((Graphic)val4).color = ((Graphic)val3).color;
				}
			}
			for (int l = 0; l < _srcGroups.Length; l++)
			{
				if (!Same((Il2CppObjectBase)(object)_dstGroups[l], (Il2CppObjectBase)(object)_clone.Alpha))
				{
					_dstGroups[l].alpha = _srcGroups[l].alpha;
				}
			}
		}

		private static bool Same(Il2CppObjectBase a, Il2CppObjectBase b)
		{
			return a != null && b != null && a.Pointer == b.Pointer;
		}

		private static T[] ToArray<T>(Il2CppArrayBase<T> arr) where T : Il2CppObjectBase
		{
			T[] array = new T[arr.Length];
			for (int i = 0; i < arr.Length; i++)
			{
				array[i] = arr[i];
			}
			return array;
		}
	}
	internal enum ReadyEvent
	{
		None,
		Reset,
		ChargeRestored,
		CompletelyReady,
		UpgradedToCompletelyReady
	}
	internal class ReadyStateMachine
	{
		private const float DebugTraceInterval = 0.5f;

		private const float DebounceWindow = 0.15f;

		private readonly string _slotKey;

		private bool _initialized;

		private int _prevHash;

		private float _prevCD;

		private bool _usesCharges;

		private int _prevCharges;

		private bool _prevRawHasCharges;

		private bool _prevFillHasValue;

		private bool _realCooldownSeen;

		private float _lastTriggerTime = -100f;

		private bool _lastTriggerComplete;

		private float _nextTraceTime;

		[field: CompilerGenerated]
		[field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)]
		internal bool Busy
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			private set;
		}

		internal ReadyStateMachine(string slotKey)
		{
			_slotKey = slotKey;
		}

		internal ReadyEvent Step(Data data, bool hasAbility)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			bool value = AuraConfig.LogAbilityData.Value;
			if (!hasAbility)
			{
				if (value && _initialized && _prevHash != 0)
				{
					Log($"ability removed (was {_prevHash})");
				}
				_initialized = true;
				_prevHash = 0;
				_prevCD = 0f;
				_usesCharges = false;
				_prevCharges = 0;
				_prevRawHasCharges = false;
				_prevFillHasValue = false;
				Busy = false;
				_realCooldownSeen = false;
				return ReadyEvent.Reset;
			}
			PrefabGUID abilityId = data.AbilityId;
			int guidHash = ((PrefabGUID)(ref abilityId)).GuidHash;
			float remainingCooldown = data.RemainingCooldown;
			float maxCooldown = data.MaxCooldown;
			bool hasValue = data.Charges.HasValue;
			int num = (hasValue ? data.Charges.Value : 0);
			bool hasValue2 = data.ChargeTimeFill.HasValue;
			float num2 = (hasValue2 ? data.ChargeTimeFill.Value : 0f);
			bool flag = remainingCooldown > 0f || (hasValue2 && num2 > 0.001f && num2 < 0.999f);
			if (!_initialized || guidHash != _prevHash)
			{
				if (value)
				{
					Log($"ability changed {_prevHash} -> {guidHash}: {DescribeData(data)}");
				}
				_initialized = true;
				_usesCharges = hasValue;
				Busy = flag;
				_realCooldownSeen = remainingCooldown > 0f && maxCooldown > 1.01f;
				StorePrevious(guidHash, remainingCooldown, num, hasValue, hasValue2);
				return ReadyEvent.Reset;
			}
			if (hasValue)
			{
				_usesCharges = true;
			}
			if (remainingCooldown > 0f && maxCooldown > 1.01f)
			{
				_realCooldownSeen = true;
			}
			string text = null;
			if (_prevCD > 0f && remainingCooldown <= 0f && _realCooldownSeen)
			{
				text = "cooldown ended";
			}
			if (_usesCharges && num > _prevCharges)
			{
				text = ((text != null) ? (text + ", ") : "") + $"charge restored {_prevCharges} -> {num}";
			}
			ReadyEvent readyEvent = ReadyEvent.None;
			if (text != null)
			{
				bool flag2 = !flag;
				readyEvent = Trigger(flag2);
				if (value)
				{
					Log($"READY ({text}) {(flag2 ? "completely ready" : "still recharging")}: {((readyEvent == ReadyEvent.None) ? "debounced" : ((object)readyEvent/*cast due to .constrained prefix*/).ToString())}: {DescribeData(data)}");
				}
			}
			if (value)
			{
				if (!Busy && flag)
				{
					Log("busy START: " + DescribeData(data));
				}
				if (Busy && !flag)
				{
					Log("busy END: " + DescribeData(data));
				}
				if (_prevCD <= 0f && remainingCooldown > 0f)
				{
					Log("cooldown START: " + DescribeData(data));
				}
				if (_prevCD > 0f && remainingCooldown <= 0f)
				{
					Log($"cooldown END (realCooldownSeen={_realCooldownSeen}): {DescribeData(data)}");
				}
				if (hasValue != _prevRawHasCharges || num != _prevCharges)
				{
					Log($"charges {(_prevRawHasCharges ? _prevCharges.ToString() : "none")} -> {(hasValue ? num.ToString() : "none")}: {DescribeData(data)}");
				}
				if (hasValue2 != _prevFillHasValue)
				{
					Log($"ChargeTimeFill HasValue {_prevFillHasValue} -> {hasValue2}: {DescribeData(data)}");
				}
				float unscaledTime = Time.unscaledTime;
				if (flag && (_usesCharges || hasValue2) && unscaledTime >= _nextTraceTime)
				{
					_nextTraceTime = unscaledTime + 0.5f;
					Log($"trace t={unscaledTime:F2}: {DescribeData(data)}");
				}
			}
			if (Busy && !flag)
			{
				_realCooldownSeen = false;
			}
			Busy = flag;
			StorePrevious(guidHash, remainingCooldown, num, hasValue, hasValue2);
			return readyEvent;
		}

		private ReadyEvent Trigger(bool completelyReady)
		{
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime - _lastTriggerTime < 0.15f)
			{
				if (!completelyReady || _lastTriggerComplete)
				{
					return ReadyEvent.None;
				}
				_lastTriggerComplete = true;
				return ReadyEvent.UpgradedToCompletelyReady;
			}
			_lastTriggerTime = unscaledTime;
			_lastTriggerComplete = completelyReady;
			return completelyReady ? ReadyEvent.CompletelyReady : ReadyEvent.ChargeRestored;
		}

		private void StorePrevious(int hash, float cd, int charges, bool rawHasCharges, bool fillHas)
		{
			_prevHash = hash;
			_prevCD = cd;
			_prevCharges = charges;
			_prevRawHasCharges = rawHasCharges;
			_prevFillHasValue = fillHas;
		}

		private void Log(string message)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			ManualLogSource log = VampireAurasPlugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(3, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_slotKey);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
			}
			log.LogInfo(val);
		}

		private static string DescribeData(Data d)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			string text = (d.Charges.HasValue ? d.Charges.Value.ToString() : "none");
			string text2 = (d.ChargeTimeFill.HasValue ? d.ChargeTimeFill.Value.ToString("F3") : "none");
			System.Runtime.CompilerServices.DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new System.Runtime.CompilerServices.DefaultInterpolatedStringHandler(40, 5);
			defaultInterpolatedStringHandler.AppendLiteral("AbilityId=");
			PrefabGUID abilityId = d.AbilityId;
			defaultInterpolatedStringHandler.AppendFormatted<int>(((PrefabGUID)(ref abilityId)).GuidHash);
			defaultInterpolatedStringHandler.AppendLiteral(" CD=");
			defaultInterpolatedStringHandler.AppendFormatted<float>(d.RemainingCooldown, "F3");
			defaultInterpolatedStringHandler.AppendLiteral("/");
			defaultInterpolatedStringHandler.AppendFormatted<float>(d.MaxCooldown, "F3");
			defaultInterpolatedStringHandler.AppendLiteral(" Charges=");
			defaultInterpolatedStringHandler.AppendFormatted(text);
			defaultInterpolatedStringHandler.AppendLiteral(" ChargeTimeFill=");
			defaultInterpolatedStringHandler.AppendFormatted(text2);
			return defaultInterpolatedStringHandler.ToStringAndClear();
		}
	}
	internal class AuraEffects
	{
		private const float EditHighlightAlpha = 0.6f;

		private const float EditOverlayAlpha = 0.12f;

		private const float EditOverlaySnappedAlpha = 0.25f;

		private readonly SlotConfig _slot;

		private readonly AbilityBarEntry _clone;

		private readonly Vector2 _baseSize;

		private readonly Image _glow;

		private readonly RectTransform _glowRt;

		private readonly Image _flash;

		private readonly Image[] _starRays = (Image[])(object)new Image[4];

		private readonly RectTransform[] _starRayRts = (RectTransform[])(object)new RectTransform[4];

		private readonly Image _editOverlay;

		private readonly GameObject _labelGo;

		private bool _flashIsStar;

		private Color _readyGlowColor;

		private Color _chargeGlowColor;

		private Color _flashColor;

		private Color _activeGlowColor;

		private bool _busy;

		private float _effectTimer = -1f;

		private bool _effectPulse;

		private bool _effectGlow;

		private bool _effectCompletelyReady;

		private float _flashTimer = -1f;

		private float _fadeTimer;

		internal AuraEffects(SlotConfig slot, AbilityBarEntry clone, Vector2 baseSize)
		{
			//IL_0045: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			_slot = slot;
			_clone = clone;
			_baseSize = baseSize;
			_glow = CreateEffectImage("VampireAura_Glow", GlowSprite.Get(GlowShape.Round), out _glowRt);
			((Transform)_glowRt).SetAsFirstSibling();
			_flash = CreateEffectImage("VampireAura_Flash", GlowSprite.GetFlash(), out var rt);
			((Transform)rt).SetAsLastSibling();
			rt.sizeDelta = _baseSize;
			RectTransform rt2;
			GameObject val = UiUtil.CreateChild("VampireAura_FlashStar", ((Component)_clone).transform, out rt2);
			rt2.sizeDelta = Vector2.zero;
			((Transform)rt2).SetAsLastSibling();
			float[] array = new float[4];
			RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			float[] array2 = array;
			for (int i = 0; i < 4; i++)
			{
				_starRays[i] = CreateEffectImage("Ray" + i, GlowSprite.Get(GlowShape.Round), out _starRayRts[i], val.transform);
				((Transform)_starRayRts[i]).localEulerAngles = new Vector3(0f, 0f, array2[i]);
			}
			_editOverlay = CreateEffectImage("VampireAura_EditOverlay", null, out var rt3);
			rt3.sizeDelta = _baseSize;
			((Transform)rt3).SetAsLastSibling();
			_labelGo = CreateLabel();
		}

		private GameObject CreateLabel()
		{
			//IL_004c: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				TMP_FontAsset font = (((Object)(object)_clone.KeybindText != (Object)null) ? ((TMP_Text)_clone.KeybindText).font : null);
				RectTransform rt;
				GameObject val = UiUtil.CreateChild("VampireAura_Label", ((Component)_clone).transform, out rt);
				rt.pivot = new Vector2(0.5f, 0f);
				rt.anchoredPosition = new Vector2(0f, _baseSize.y * 0.5f + 4f);
				rt.sizeDelta = new Vector2(_baseSize.x * 3f, 22f);
				UiUtil.AddText(val, font, _slot.Key, 16f, (TextAlignmentOptions)1026);
				val.SetActive(false);
				return val;
			}
			catch (System.Exception ex)
			{
				AuraManager.LogExceptionOnce("CreateLabel", ex);
				return null;
			}
		}

		private Image CreateEffectImage(string name, Sprite sprite, out RectTransform rt, Transform parent = null)
		{
			GameObject val = UiUtil.CreateChild(name, parent ?? ((Component)_clone).transform, out rt);
			Image val2 = val.AddComponent<Image>();
			val2.sprite = sprite;
			((Graphic)val2).raycastTarget = false;
			((Behaviour)val2).enabled = false;
			return val2;
		}

		internal void RefreshSettings()
		{
			//IL_0011: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			_readyGlowColor = ParseColor(AuraConfig.ReadyGlow.ColorHex, AuraConfig.ReadyGlow.FallbackColor);
			_chargeGlowColor = ParseColor(AuraConfig.ChargeGlow.ColorHex, AuraConfig.ChargeGlow.FallbackColor);
			_flashColor = ParseColor(AuraConfig.FlashColor, Color.white);
			if (_effectTimer >= 0f && _effectGlow)
			{
				ApplyGlowStyle(_effectCompletelyReady ? AuraConfig.ReadyGlow : AuraConfig.ChargeGlow);
			}
			ApplyFlashStyle();
		}

		private void ApplyFlashStyle()
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			_flashIsStar = AuraConfig.FlashShapeSetting.Value == FlashShape.Star;
			float num = Mathf.Max(_baseSize.x, _baseSize.y);
			float num2 = num * Mathf.Clamp(AuraConfig.FlashStarSize.Value, 1f, 4f);
			float num3 = num2 * Mathf.Clamp(AuraConfig.FlashStarShortPoints.Value, 0.2f, 1f);
			float num4 = num2 * Mathf.Clamp(AuraConfig.FlashStarPointWidth.Value, 0.05f, 0.3f);
			for (int i = 0; i < 4; i++)
			{
				if (!((Object)(object)_starRayRts[i] == (Object)null) && !(((Il2CppObjectBase)_starRayRts[i]).Pointer == System.IntPtr.Zero))
				{
					_starRayRts[i].sizeDelta = new Vector2((i < 2) ? num2 : num3, num4);
				}
			}
		}

		private static Color ParseColor(ConfigEntry<string> entry, Color fallback)
		{
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			if (GlowSprite.TryParseHex(entry.Value, out var color))
			{
				return color;
			}
			AuraManager.LogWarningOnce($"color:{((ConfigEntryBase)entry).Definition.Section}:{((ConfigEntryBase)entry).Definition.Key}:{entry.Value}", $"[{((ConfigEntryBase)entry).Definition.Section}] {((ConfigEntryBase)entry).Definition.Key} = '{entry.Value}' is not a valid #RRGGBB color, using the default.");
			return fallback;
		}

		private void ApplyGlowStyle(GlowConfig glow)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_glow == (Object)null) && !(((Il2CppObjectBase)_glow).Pointer == System.IntPtr.Zero))
			{
				_glow.sprite = GlowSprite.Get(glow.Shape.Value);
				_glowRt.sizeDelta = _baseSize * Mathf.Clamp(glow.Size.Value, 1.2f, 3f);
				_activeGlowColor = ((glow == AuraConfig.ReadyGlow) ? _readyGlowColor : _chargeGlowColor);
			}
		}

		internal void OnReadyEvent(ReadyEvent ev)
		{
			switch (ev)
			{
			case ReadyEvent.Reset:
				_effectTimer = -1f;
				_flashTimer = -1f;
				_fadeTimer = 0f;
				break;
			case ReadyEvent.ChargeRestored:
				StartReadyEffect(completelyReady: false);
				break;
			case ReadyEvent.CompletelyReady:
				StartReadyEffect(completelyReady: true);
				break;
			case ReadyEvent.UpgradedToCompletelyReady:
				UpgradeToCompletelyReady();
				break;
			}
		}

		private void StartReadyEffect(bool completelyReady)
		{
			_effectCompletelyReady = completelyReady;
			GlowConfig glowConfig = (completelyReady ? AuraConfig.ReadyGlow : AuraConfig.ChargeGlow);
			_effectPulse = AuraConfig.EnableReadyPulse.Value;
			_effectGlow = glowConfig.Enabled.Value;
			if (_effectGlow)
			{
				ApplyGlowStyle(glowConfig);
			}
			_effectTimer = ((_effectPulse || _effectGlow) ? 0f : (-1f));
			if (AuraConfig.FlashEnabled.Value && (completelyReady || AuraConfig.FlashOnChargeReady.Value))
			{
				_flashTimer = 0f;
			}
			if (completelyReady || AuraConfig.SoundOnChargeReady.Value)
			{
				PlayReadySound();
			}
		}

		private void UpgradeToCompletelyReady()
		{
			_effectCompletelyReady = true;
			_effectGlow = AuraConfig.ReadyGlow.Enabled.Value;
			if (_effectGlow)
			{
				ApplyGlowStyle(AuraConfig.ReadyGlow);
			}
			if (_effectTimer < 0f && (_effectPulse || _effectGlow))
			{
				_effectTimer = 0f;
			}
			if (_flashTimer < 0f && AuraConfig.FlashEnabled.Value && !AuraConfig.FlashOnChargeReady.Value)
			{
				_flashTimer = 0f;
			}
			if (!AuraConfig.SoundOnChargeReady.Value)
			{
				PlayReadySound();
			}
		}

		private void PlayReadySound()
		{
			if (AuraConfig.Enabled.Value && _slot.Enabled.Value && AuraConfig.TryGetSlotSound(_slot, out var path, out var volume))
			{
				ReadySound.Play(path, volume);
			}
		}

		internal void Tick(float dt, bool busy)
		{
			_busy = busy;
			if (busy)
			{
				_fadeTimer = 0f;
			}
			if (_effectTimer >= 0f)
			{
				_effectTimer += dt;
				if (_effectTimer >= AuraConfig.PulseDuration.Value)
				{
					_effectTimer = -1f;
				}
			}
			if (_flashTimer >= 0f)
			{
				_flashTimer += dt;
				if (_flashTimer >= AuraConfig.FlashDuration.Value)
				{
					_flashTimer = -1f;
				}
			}
			if (!busy && _effectTimer < 0f)
			{
				_fadeTimer += dt;
			}
		}

		internal float FadeProgress()
		{
			if (_busy || _effectTimer >= 0f || !AuraConfig.FadeWhenReady.Value)
			{
				return 0f;
			}
			float num = Mathf.Clamp01(_fadeTimer / Mathf.Max(0.01f, AuraConfig.FadeOutDuration.Value));
			return Mathf.SmoothStep(0f, 1f, num);
		}

		internal float PulseScale()
		{
			if (!_effectPulse)
			{
				return 1f;
			}
			return Mathf.Lerp(1f, AuraConfig.PulseScaleMultiplier.Value, EffectEnvelope());
		}

		private float EffectEnvelope()
		{
			if (_effectTimer < 0f)
			{
				return 0f;
			}
			float num = Mathf.Clamp01(_effectTimer / Mathf.Max(0.01f, AuraConfig.PulseDuration.Value));
			if (num < 0.3f)
			{
				return Mathf.SmoothStep(0f, 1f, num / 0.3f);
			}
			return 1f - Mathf.SmoothStep(0f, 1f, (num - 0.3f) / 0.7f);
		}

		private float GlowAlpha()
		{
			return _effectGlow ? EffectEnvelope() : 0f;
		}

		private float FlashAlpha()
		{
			if (_flashTimer < 0f)
			{
				return 0f;
			}
			float num = Mathf.Clamp01(_flashTimer / Mathf.Max(0.01f, AuraConfig.FlashDuration.Value));
			float num2 = ((num < 0.2f) ? (num / 0.2f) : (1f - Mathf.SmoothStep(0f, 1f, (num - 0.2f) / 0.8f)));
			return num2 * AuraConfig.FlashOpacity.Value;
		}

		internal void Render(bool editing, bool highlighted, bool snapped)
		{
			//IL_0065: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			EditHighlight value = AuraConfig.EditModeHighlight.Value;
			float num = GlowAlpha();
			if (highlighted && value == EditHighlight.Glow && num < 0.6f)
			{
				if (!(_effectTimer >= 0f) || !_effectGlow)
				{
					ApplyGlowStyle(AuraConfig.ReadyGlow);
				}
				num = 0.6f;
			}
			UpdateEffectImage(_glow, _activeGlowColor, num);
			float alpha = ((!highlighted || value != EditHighlight.Overlay) ? 0f : (snapped ? 0.25f : 0.12f));
			UpdateEffectImage(_editOverlay, Color.white, alpha);
			bool flag = editing && AuraConfig.EditModeShowLabels.Value;
			if ((Object)(object)_labelGo != (Object)null && _labelGo.activeSelf != flag)
			{
				_labelGo.SetActive(flag);
			}
			float num2 = FlashAlpha();
			UpdateEffectImage(_flash, _flashColor, _flashIsStar ? 0f : num2);
			for (int i = 0; i < 4; i++)
			{
				UpdateEffectImage(_starRays[i], _flashColor, _flashIsStar ? num2 : 0f);
			}
		}

		private static void UpdateEffectImage(Image img, Color color, float alpha)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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)
			if (!((Object)(object)img == (Object)null) && !(((Il2CppObjectBase)img).Pointer == System.IntPtr.Zero))
			{
				bool flag = alpha > 0.001f;
				if (((Behaviour)img).enabled != flag)
				{
					((Behaviour)img).enabled = flag;
				}
				if (flag)
				{
					((Graphic)img).color = new Color(color.r, color.g, color.b, color.a * alpha);
				}
			}
		}
	}
	internal static class AuraManager
	{
		private const float HelpPanelHeight = 0.86f;

		private const float SoundCheckShowSeconds = 3f;

		private static System.IntPtr _parentPtr = System.IntPtr.Zero;

		private static GameObject _container;

		private static RectTransform _containerRt;

		private static readonly List<AuraSlotController> Controllers = new List<AuraSlotController>();

		private static bool _created;

		private static bool _settingsDirty;

		private static bool _soundEventsDumped;

		private static readonly Dictionary<string, string> LastSoundKeys = new Dictionary<string, string>();

		private static GameObject _helpPanel;

		private static RectTransform _helpPanelRt;

		private static TextMeshProUGUI _helpText;

		private static int _soundCheckIndex = -1;

		private static float _soundCheckUntil;

		private static string _soundCheckText;

		private static readonly HashSet<string> LoggedOnce = new HashSet<string>();

		private const float LiveReloadPollSeconds = 0.5f;

		private static float _nextLiveReloadPoll;

		private static System.DateTime _loadedWriteTime;

		private static System.DateTime _pendingWriteTime;

		private static ManualLogSource Log => VampireAurasPlugin.Log;

		private static string HelpText => $"VampireAuras edit mode   |   {AuraConfig.EditModeKey} / ESC: done\n" + "Drag: move   |   Mouse wheel: size   |   Middle click: reset size\nSnaps onto its bar slot   |   " + SoundCheckKeysText() + ": sound check";

		internal static void Init()
		{
			AuraConfig.File.SettingChanged += delegate
			{
				_settingsDirty = true;
			};
			InitSoundPreviewKeys();
			_loadedWriteTime = MainConfigWriteTime();
			_pendingWriteTime = _loadedWriteTime;
		}

		internal static void LogExceptionOnce(string where, System.Exception ex)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			if (LoggedOnce.Add(string.Concat(new string[6]
			{
				"ex:",
				where,
				":",
				((MemberInfo)ex.GetType()).Name,
				":",
				ex.Message
			})))
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(3, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(where);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<System.Exception>(ex);
				}
				log.LogError(val);
			}
		}

		internal static void LogWarningOnce(string key, string message)
		{
			if (LoggedOnce.Add("warn:" + key))
			{
				Log.LogWarning((object)message);
			}
		}

		internal static void Teardown(string reason)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			EditMode.Exit(reason);
			if ((Object)(object)_container != (Object)null)
			{
				Object.Destroy((Object)(object)_container);
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Auras removed (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(reason);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
				}
				log.LogInfo(val);
			}
			_container = null;
			_containerRt = null;
			_helpPanel = null;
			_helpPanelRt = null;
			_helpText = null;
			Controllers.Clear();
			_created = false;
			_parentPtr = System.IntPtr.Zero;
		}

		internal static void OnAbilityBarUpdate(AbilityBarParentMapper mapper)
		{
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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)
			AbilityBarParent abilityBarParent = mapper._AbilityBarParent;
			if ((Object)(object)abilityBarParent == (Object)null)
			{
				return;
			}
			if (_parentPtr != ((Il2CppObjectBase)abilityBarParent).Pointer)
			{
				Teardown("new ability bar");
				_parentPtr = ((Il2CppObjectBase)abilityBarParent).Pointer;
			}
			if (AuraConfig.ReloadKey.IsDown())
			{
				ReloadConfig();
			}
			else
			{
				PollLiveReload();
			}
			if (!AuraConfig.Enabled.Value)
			{
				if (_created || (Object)(object)_container != (Object)null)
				{
					Teardown("disabled in config");
				}
				return;
			}
			AbilityBarParentBinderSystem abilityBarParentBinderSystem = mapper._AbilityBarParentBinderSystem;
			List<Data> val = ((abilityBarParentBinderSystem != null) ? abilityBarParentBinderSystem.Entries : null);
			if (val == null || val.Count == 0)
			{
				return;
			}
			if (!_created)
			{
				Create(abilityBarParent);
			}
			if (!_soundEventsDumped)
			{
				_soundEventsDumped = ReadySound.TryDumpEvents();
			}
			HandleSoundCheck();
			if (_settingsDirty)
			{
				_settingsDirty = false;
				Enumerator<AuraSlotController> enumerator = Controllers.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						AuraSlotController current = enumerator.Current;
						if (!current.Dead)
						{
							current.RefreshSettings();
						}
					}
				}
				finally
				{
					((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
				}
			}
			UpdateEditMode();
			UpdateHelpPanel();
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			Enumerator<AuraSlotController> enumerator2 = Controllers.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					AuraSlotController current2 = enumerator2.Current;
					if (current2.Dead)
					{
						continue;
					}
					try
					{
						Data data = ((current2.SourceIndex < val.Count) ? val[current2.SourceIndex] : null);
						current2.Update(data, _containerRt, unscaledDeltaTime);
						current2.RecordSuccess();
					}
					catch (System.Exception ex)
					{
						LogExceptionOnce("Aura " + current2.Slot.Key, ex);
						if (current2.RecordError())
						{
							Log.LogWarning((object)($"Aura {current2.Slot.Key} is switched off after {3} errors in a row. " + "It comes back when the Auras are rebuilt (re-entering the world, or Enabled off and on)."));
						}
					}
				}
			}
			finally
			{
				((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private static void UpdateEditMode()
		{
			bool flag = (Object)(object)_container != (Object)null && _container.activeInHierarchy;
			if (EditMode.Active)
			{
				if (!flag)
				{
					EditMode.Exit("HUD hidden");
					return;
				}
				if (Input.GetKeyDown((KeyCode)27))
				{
					EditMode.Exit("ESC");
					return;
				}
			}
			if (AuraConfig.EditModeKey.IsDown())
			{
				if (!EditMode.Active && !flag)
				{
					Log.LogInfo((object)"Edit mode is only available while the HUD is visible.");
				}
				else
				{
					EditMode.Toggle();
				}
			}
			if (EditMode.Active)
			{
				EditMode.Update(Controllers);
			}
		}

		private static void Create(AbilityBarParent parent)
		{
			//IL_0045: 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_01c9: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			List<AbilityBarEntry> entries = parent.Entries;
			if (entries == null || entries.Count == 0)
			{
				return;
			}
			_created = true;
			_container = UiUtil.CreateChild("VampireAuras_Container", ((Component)parent).transform, out _containerRt);
			_containerRt.sizeDelta = Vector2.zero;
			_container.AddComponent<LayoutElement>().ignoreLayout = true;
			int num = 0;
			SlotConfig[] slots = AuraConfig.Slots;
			bool flag = default(bool);
			foreach (SlotConfig slotConfig in slots)
			{
				int num2 = FindEntryIndex(entries, slotConfig.EntryName);
				if (num2 < 0)
				{
					ManualLogSource log = Log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(57, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Slot ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(slotConfig.Key);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": vanilla entry '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(slotConfig.EntryName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found, no Aura for this slot.");
					}
					log.LogWarning(val);
					continue;
				}
				string error;
				AuraSlotController auraSlotController = AuraSlotController.Create(slotConfig, num2, entries[num2], _container.transform, out error);
				if (auraSlotController == null)
				{
					ManualLogSource log2 = Log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Slot ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(slotConfig.Key);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Aura not created (");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(error);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
					}
					log2.LogWarning(val);
				}
				else
				{
					Controllers.Add(auraSlotController);
					num++;
				}
			}
			CreateHelpPanel(entries);
			ManualLogSource log3 = Log;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(19, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" of ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(AuraConfig.Slots.Length);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Auras created.");
			}
			log3.LogInfo(val2);
		}

		private static int FindEntryIndex(List<AbilityBarEntry> entries, string name)
		{
			for (int i = 0; i < entries.Count; i++)
			{
				AbilityBarEntry val = entries[i];
				if ((Object)(object)val != (Object)null && ((Object)val).name == name)
				{
					return i;
				}
			}
			return -1;
		}

		private static string SoundCheckKeysText()
		{
			bool isBound = AuraConfig.SoundCheckKey.IsBound;
			bool isBound2 = AuraConfig.SoundCheckPreviousKey.IsBound;
			if (isBound && isBound2)
			{
				return $"{AuraConfig.SoundCheckKey} / {AuraConfig.SoundCheckPreviousKey}";
			}
			if (isBound)
			{
				return ((object)AuraConfig.SoundCheckKey).ToString();
			}
			if (isBound2)
			{
				return ((object)AuraConfig.SoundCheckPreviousKey).ToString();
			}
			return "no key";
		}

		private static void CreateHelpPanel(List<AbilityBarEntry> entries)
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				TMP_FontAsset val = null;
				for (int i = 0; i < entries.Count; i++)
				{
					if (!((Object)(object)val == (Object)null))
					{
						break;
					}
					if ((Object)(object)entries[i] != (Object)null && (Object)(object)entries[i].KeybindText != (Object)null)
					{
						val = ((TMP_Text)entries[i].KeybindText).font;
					}
				}
				_helpPanel = UiUtil.CreateChild("VampireAuras_EditHelp", _container.transform, out _helpPanelRt);
				Image val2 = _helpPanel.AddComponent<Image>();
				((Graphic)val2).color = new Color(0f, 0f, 0f, 0.6f);
				((Graphic)val2).raycastTarget = false;
				RectTransform rt;
				GameObject go = UiUtil.CreateChild("Text", _helpPanel.transform, out rt);
				rt.anchorMin = Vector2.zero;
				rt.anchorMax = Vector2.one;
				rt.offsetMin = Vector2.zero;
				rt.offsetMax = Vector2.zero;
				_helpText = UiUtil.AddText(go, val, HelpText, 18f, (TextAlignmentOptions)514);
				FitHelpPanel();
				_helpPanel.SetActive(false);
			}
			catch (System.Exception ex)
			{
				LogExceptionOnce("CreateHelpPanel", ex);
				_helpPanel = null;
				_helpPanelRt = null;
				_helpText = null;
			}
		}

		private static void UpdateHelpPanel()
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_helpPanel == (Object)null)
			{
				return;
			}
			bool flag = Time.unscaledTime < _soundCheckUntil;
			if (!flag && (!EditMode.Active || !AuraConfig.EditModeShowHelp.Value))
			{
				if (_helpPanel.activeSelf)
				{
					_helpPanel.SetActive(false);
				}
				return;
			}
			string text = (flag ? _soundCheckText : HelpText);
			if ((Object)(object)_helpText != (Object)null && ((TMP_Text)_helpText).text != text)
			{
				((TMP_Text)_helpText).text = text;
				FitHelpPanel();
			}
			if (!_helpPanel.activeSelf)
			{
				_helpPanel.SetActive(true);
			}
			if ((Object)(object)_helpPanelRt != (Object)null && (Object)(object)_containerRt != (Object)null)
			{
				((Transform)_helpPanelRt).position = new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.86f, ((Transform)_containerRt).position.z);
			}
		}

		private static void FitHelpPanel()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_helpText == (Object)null) && !((Object)(object)_helpPanelRt == (Object)null))
			{
				float num = ((TMP_Text)_helpText).preferredWidth;
				float num2 = ((TMP_Text)_helpText).preferredHeight;
				if (num <= 0f || num > 4000f)
				{
					num = 900f;
				}
				if (num2 <= 0f || num2 > 1000f)
				{
					num2 = 80f;
				}
				_helpPanelRt.sizeDelta = new Vector2(num + 40f, num2 + 14f);
			}
		}

		private static void HandleSoundCheck()
		{
			bool flag = AuraConfig.SoundCheckKey.IsDown();
			bool flag2 = !flag && AuraConfig.SoundCheckPreviousKey.IsDown();
			if (!flag && !flag2)
			{
				return;
			}
			List<SoundChoice> val = new List<SoundChoice>();
			foreach (SoundChoice value in System.Enum.GetValues(typeof(SoundChoice)))
			{
				if (value != SoundChoice.Custom)
				{
					val.Add(value);
				}
			}
			if (val.Count != 0)
			{
				if (_soundCheckIndex < 0)
				{
					_soundCheckIndex = (flag2 ? (val.Count - 1) : 0);
				}
				else
				{
					_soundCheckIndex = (_soundCheckIndex + ((!flag2) ? 1 : (-1)) + val.Count) % val.Count;
				}
				SoundChoice soundChoice2 = val[_soundCheckIndex];
				bool flag3 = ReadySound.Play(AuraConfig.SoundPath(soundChoice2), AuraConfig.SoundVolume.Value);
				string text = (AuraConfig.SoundCheckPreviousKey.IsBound ? $"{AuraConfig.SoundCheckKey}: next, {AuraConfig.SoundCheckPreviousKey}: previous" : $"{AuraConfig.SoundCheckKey}: next");
				_soundCheckText = $"Sound check {_soundCheckIndex + 1}/{val.Count}: {soundChoice2}{(flag3 ? "" : " (could not be played)")}   |   {text}";
				_soundCheckUntil = Time.unscaledTime + 3f;
				Log.LogInfo((object)_soundCheckText);
			}
		}

		private static string GlobalSoundKey()
		{
			return $"{AuraConfig.SoundEnabled.Value}|{AuraConfig.SoundChoiceSetting.Value}|{AuraConfig.SoundVolume.Value}|{AuraConfig.SoundCustomEvent.Value}";
		}

		private static string SlotSoundKey(SlotConfig slot)
		{
			return $"{slot.ReadySound.Value}|{slot.ReadySoundVolume.Value}";
		}

		private static void InitSoundPreviewKeys()
		{
			LastSoundKeys["*"] = GlobalSoundKey();
			SlotConfig[] slots = AuraConfig.Slots;
			foreach (SlotConfig slotConfig in slots)
			{
				LastSoundKeys[slotConfig.Key] = SlotSoundKey(slotConfig);
			}
		}

		private static void PreviewChangedSounds()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			bool value = AuraConfig.Enabled.Value;
			string text = GlobalSoundKey();
			string text2 = default(string);
			LastSoundKeys.TryGetValue("*", ref text2);
			bool flag = default(bool);
			if (text != text2)
			{
				LastSoundKeys["*"] = text;
				if (value && AuraConfig.TryGetGlobalSound(out var path, out var volume) && ReadySound.Play(path, volume))
				{
					ManualLogSource log = Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Ready sound preview (global): ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<SoundChoice>(AuraConfig.SoundChoiceSetting.Value);
					}
					log.LogInfo(val);
				}
			}
			SlotConfig[] slots = AuraConfig.Slots;
			string text4 = default(string);
			foreach (SlotConfig slotConfig in slots)
			{
				string text3 = SlotSoundKey(slotConfig);
				LastSoundKeys.TryGetValue(slotConfig.Key, ref text4);
				if (text3 == text4)
				{
					continue;
				}
				LastSoundKeys[slotConfig.Key] = text3;
				if (value && AuraConfig.TryGetSlotSound(slotConfig, out var path2, out var volume2) && ReadySound.Play(path2, volume2))
				{
					ManualLogSource log2 = Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Ready sound preview (");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(slotConfig.Key);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("): ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<SlotSoundChoice>(slotConfig.ReadySound.Value);
					}
					log2.LogInfo(val);
				}
			}
		}

		private static void ReloadConfig()
		{
			try
			{
				ReloadMainConfig();
				if (EditMode.Active)
				{
					Log.LogInfo((object)"Config reloaded. The layout file is not re-read while the edit mode is active.");
				}
				else
				{
					AuraConfig.LayoutFile.Reload();
					Log.LogInfo((object)"Config reloaded.");
				}
				PreviewChangedSounds();
			}
			catch (System.Exception ex)
			{
				LogExceptionOnce("ReloadConfig", ex);
			}
		}

		private static void ReloadMainConfig()
		{
			bool saveOnConfigSet = AuraConfig.File.SaveOnConfigSet;
			AuraConfig.File.SaveOnConfigSet = false;
			try
			{
				AuraConfig.File.Reload();
			}
			finally
			{
				AuraConfig.File.SaveOnConfigSet = saveOnConfigSet;
			}
			_settingsDirty = true;
			_loadedWriteTime = MainConfigWriteTime();
			_pendingWriteTime = _loadedWriteTime;
		}

		private static System.DateTime MainConfigWriteTime()
		{
			try
			{
				string configFilePath = AuraConfig.File.ConfigFilePath;
				return File.Exists(configFilePath) ? File.GetLastWriteTimeUtc(configFilePath) : System.DateTime.MinValue;
			}
			catch (System.Exception)
			{
				return System.DateTime.MinValue;
			}
		}

		private static void PollLiveReload()
		{
			if (!AuraConfig.LiveReload.Value)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime < _nextLiveReloadPoll)
			{
				return;
			}
			_nextLiveReloadPoll = unscaledTime + 0.5f;
			System.DateTime dateTime = MainConfigWriteTime();
			if (dateTime == System.DateTime.MinValue || dateTime == _loadedWriteTime)
			{
				return;
			}
			if (dateTime != _pendingWriteTime)
			{
				_pendingWriteTime = dateTime;
				return;
			}
			try
			{
				ReloadMainConfig();
				Log.LogInfo((object)"Config file changed, reloaded (LiveReload).");
				PreviewChangedSounds();
			}
			catch (System.Exception ex)
			{
				LogExceptionOnce("LiveReload", ex);
			}
		}
	}
	public enum GlowShape
	{
		Round,
		Square
	}
	public enum FlashShape
	{
		Star,
		Square
	}
	internal static class GlowSprite
	{
		private class Entry
		{
			public Texture2D Texture;

			public Sprite Sprite;

			public bool IsAlive => (Object)(object)Sprite != (Object)null && ((Il2CppObjectBase)Sprite).Pointer != System.IntPtr.Zero && (Object)(object)Texture != (Object)null && ((Il2CppObjectBase)Texture).Pointer != System.IntPtr.Zero;
		}

		private const int Size = 64;

		private static Entry _round;

		private static Entry _square;

		private static Entry _flash;

		internal static Sprite Get(GlowShape shape)
		{
			return (shape == GlowShape.Square) ? GetOrBuild(ref _square, "VampireAuras_GlowSquare", 8f, 0.55f) : GetOrBuild(ref _round, "VampireAuras_GlowRound", 2f, 0.55f);
		}

		internal static Sprite GetFlash()
		{
			return GetOrBuild(ref _flash, "VampireAuras_Flash", 8f, 0.85f);
		}

		private static Entry BuildEntry(string name, int size, Color32[] pixels)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_004f: 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)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			((Object)val).name = name;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			val.SetPixels32(new Il2CppStructArray<Color32>(pixels));
			val.Apply();
			((Object)val).hideFlags = (HideFlags)32;
			Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f));
			((Object)val2).name = name;
			((Object)val2).hideFlags = (HideFlags)32;
			return new Entry
			{
				Texture = val,
				Sprite = val2
			};
		}

		private static Sprite GetOrBuild(ref Entry entry, string name, float exponent, float innerRadius)
		{
			//IL_00c8: 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)
			if (entry != null && entry.IsAlive)
			{
				return entry.Sprite;
			}
			Color32[] array = (Color32[])(object)new Color32[4096];
			float num = 31.5f;
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num2 = Mathf.Abs(((float)j - num) / num);
					float num3 = Mathf.Abs(((float)i - num) / num);
					float num4 = Mathf.Pow(Mathf.Pow(num2, exponent) + Mathf.Pow(num3, exponent), 1f / exponent);
					float num5 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(innerRadius, 1f, num4));
					array[i * 64 + j] = new Color32((byte)255, (byte)255, (byte)255, (byte)Mathf.RoundToInt(num5 * 255f));
				}
			}
			entry = BuildEntry(name, 64, array);
			return entry.Sprite;
		}

		internal static bool TryParseHex(string hex, out Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			color = Color.white;
			if (string.IsNullOrWhiteSpace(hex))
			{
				return false;
			}
			string text = hex.Trim().TrimStart('#');
			if (text.Length != 6 && text.Length != 8)
			{
				return false;
			}
			try
			{
				byte b = Convert.ToByte(text.Substring(0, 2), 16);
				byte b2 = Convert.ToByte(text.Substring(2, 2), 16);
				byte b3 = Convert.ToByte(text.Substring(4, 2), 16);
				byte b4 = (byte)((text.Length == 8) ? Convert.ToByte(text.Substring(6, 2), 16) : 255);
				color = new Color((float)(int)b / 255f, (float)(int)b2 / 255f, (float)(int)b3 / 255f, (float)(int)b4 / 255f);
				return true;
			}
			catch (FormatException)
			{
				return false;
			}
		}
	}
	internal static class EditMode
	{
		private const float ScaleStep = 0.05f;

		private static bool _savedSaveOnConfigSet;

		private static AuraSlotController _dragged;

		private static Vector2 _dragOffset;

		[field: CompilerGenerated]
		[field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)]
		internal static bool Active
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			private set;
		}

		internal static void Toggle()
		{
			if (Active)
			{
				Exit("edit mode key");
			}
			else
			{
				Enter();
			}
		}

		internal static void Enter()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			if (!Active)
			{
				Active = true;
				_dragged = null;
				ConsumedInputsDetour.ResetLog();
				_savedSaveOnConfigSet = AuraConfig.LayoutFile.SaveOnConfigSet;
				AuraConfig.LayoutFile.SaveOnConfigSet = false;
				ManualLogSource log = VampireAurasPlugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(120, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Edit mode ON. Drag with the left mouse button, mouse wheel = size, middle click = back to GlobalScale, ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Hotkey>(AuraConfig.EditModeKey);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" or ESC = finish.");
				}
				log.LogInfo(val);
				if (IsRetroCameraLoaded())
				{
					VampireAurasPlugin.Log.LogInfo((object)"RetroCamera is loaded. Editing works in its action mode too, but the cursor flickers; turn the action mode off with its hotkey to stop that.");
				}
			}
		}

		internal static void Exit(string reason)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (!Active)
			{
				return;
			}
			Active = false;
			_dragged = null;
			bool flag = default(bool);
			try
			{
				AuraConfig.LayoutFile.Save();
				ManualLogSource log = VampireAurasPlugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(48, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Edit mode OFF (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(reason);
					((BepInExLogInterpolate