Decompiled source of BladeAlpha v0.2.1

plugins/BladeAlpha/BladeAlpha.dll

Decompiled 8 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using EasyCharacterMovement;
using FishNet;
using FishNet.Managing;
using FishNet.Managing.Object;
using FishNet.Object;
using Gatekeeper.CameraScripts;
using Gatekeeper.CameraScripts.HUD.EvolutionPanel.EvolutionStatSelector;
using Gatekeeper.CameraScripts.HUD.SkillPanelStuff;
using Gatekeeper.CameraScripts.HUD.StatisticPanel;
using Gatekeeper.Char_Scripts.Base;
using Gatekeeper.Char_Scripts.General;
using Gatekeeper.Char_Scripts.General.CharData;
using Gatekeeper.Char_Scripts.General.CharacterController;
using Gatekeeper.Char_Scripts.Hybrid;
using Gatekeeper.Enemy.Base;
using Gatekeeper.Enemy.Base.StatusEffects;
using Gatekeeper.Enemy.Base.StatusEffects.Bleeding;
using Gatekeeper.EnvironmentStuff.OmniStatue;
using Gatekeeper.EnvironmentStuff.Scene;
using Gatekeeper.EnvironmentStuff.Spectris;
using Gatekeeper.General.InputSystem;
using Gatekeeper.General.InputSystem.Enums;
using Gatekeeper.General.SaveLoad;
using Gatekeeper.Infrastructure.Providers.InfoProviders;
using Gatekeeper.Interfaces;
using Gatekeeper.MainMenuScripts.Database;
using Gatekeeper.MainMenuScripts.MainMenu.CharacterSelectPanel;
using Gatekeeper.MainMenuScripts.MainMenu.CharacterSelectPanel.CharacterSelectorPanel;
using Gatekeeper.MainMenuScripts.MainMenu.CharacterSelectPanel.Characters;
using Gatekeeper.MainMenuScripts.MainMenu.CharacterSelectPanel.PanelCharacterInfo;
using Gatekeeper.NPC;
using Gatekeeper.Network.GameLobby;
using Gatekeeper.Network.Team;
using Gatekeeper.StatusEffects;
using Gatekeeper.Utility;
using HarmonyLib;
using I2.Loc;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("BladeDevTools")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BladeAlpha")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BladeAlpha")]
[assembly: AssemblyTitle("BladeAlpha")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BladeAlpha
{
	[BepInPlugin("naccel_inc.blade.alpha", "Blade Alpha", "0.2.1")]
	public sealed class Plugin : BasePlugin
	{
		private struct BasicLungeStep
		{
			public BladeFighter Fighter;

			public Vector3 NativeVelocity;
		}

		private struct UltimateMoveStep
		{
			internal BladeFighter Fighter;

			internal Vector3 From;
		}

		private sealed class LobbyVisual
		{
			private readonly BladeRig.BladeVisual visual;

			private readonly Transform anchor;

			private readonly Dictionary<int, (Renderer Mesh, bool Enabled, bool ForceOff)> replaced = new Dictionary<int, (Renderer, bool, bool)>();

			internal bool Alive
			{
				get
				{
					if (Object.op_Implicit((Object)(object)anchor))
					{
						return Object.op_Implicit((Object)(object)visual.Root);
					}
					return false;
				}
			}

			internal LobbyVisual(BladeRig.BladeVisual visual, Transform anchor)
			{
				this.visual = visual;
				this.anchor = anchor;
			}

			internal void HideNativeMeshes()
			{
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Expected O, but got Unknown
				if (!Alive)
				{
					return;
				}
				bool flag = default(bool);
				foreach (Renderer item in MeshRenderers(anchor))
				{
					if (((Component)item).transform.IsChildOf(visual.Root))
					{
						continue;
					}
					int instanceID = ((Object)item).GetInstanceID();
					if (!replaced.ContainsKey(instanceID))
					{
						replaced.Add(instanceID, (item, item.enabled, item.forceRenderingOff));
						ManualLogSource log = Plugin.log;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade lobby isolated native mesh ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)item).name);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" from slot ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)anchor).name);
						}
						log.LogInfo(val);
					}
					item.enabled = false;
					item.forceRenderingOff = true;
				}
			}

			internal void Restore()
			{
				if (Object.op_Implicit((Object)(object)visual.Root))
				{
					((Component)visual.Root).gameObject.SetActive(false);
					Object.Destroy((Object)(object)((Component)visual.Root).gameObject);
				}
				foreach (var (_, tuple2) in replaced)
				{
					if (Object.op_Implicit((Object)(object)tuple2.Item1))
					{
						tuple2.Item1.enabled = tuple2.Item2;
						tuple2.Item1.forceRenderingOff = tuple2.Item3;
					}
				}
				replaced.Clear();
			}
		}

		private static ConfigEntry<float>[] cooldown;

		private static ConfigEntry<float> dashDistance;

		private static ConfigEntry<float> shieldDuration;

		private static ConfigEntry<float> ghostDuration;

		private static ConfigEntry<bool> traceCombat;

		private static ConfigEntry<float> ultimateDashDistance;

		private const CharacterType BladeType = (CharacterType)77;

		private const ushort BladeCollection = 48077;

		private const string BladePrefabName = "Blade_Alpha_Network";

		private static GameObject stagingRoot;

		private static GameObject temporaryNetworkPrefab;

		private static readonly Dictionary<int, LobbyVisual> lobbySlots = new Dictionary<int, LobbyVisual>();

		private const string BladeId = "BLADE_ALPHA";

		private const string NameKey = "blade.name";

		private const string DescKey = "blade.hero.description";

		internal static ManualLogSource log;

		private static BladeContent content;

		private static BladeRig rig;

		private static bool cardMounting;

		private static OmniStatueInfo temporaryOmni;

		private static float nextLobbyCheck;

		internal static float GhostDashDistance => Mathf.Clamp(dashDistance.Value, 0f, 14f);

		internal static float GhostDuration => Mathf.Clamp(ghostDuration.Value, 0f, 10f);

		internal static float ShieldDuration => Mathf.Clamp(shieldDuration.Value, 0.1f, 10f);

		internal static float UltimateDashDistance => Mathf.Clamp(ultimateDashDistance.Value, 1f, 30f);

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayableCharacterMain), "ClientHandleOnStartAppear")]
		private static void BeforeBladeAppearStart(PlayableCharacterMain __instance)
		{
			CharManager player = __instance.Manager;
			if (IsBlade(player))
			{
				Attempt("arrival visual", delegate
				{
					BladeTick.Get(player)?.BeginArrival();
				});
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HybridParticles), "ClientPlayAppearPs")]
		private static bool BeforeBladeAppearParticles(HybridParticles __instance)
		{
			return KeepNativeArrival((PlayableCharacterParticles)(object)__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayableCharacterParticles), "ClientPlayAppearPs")]
		private static bool BeforeBaseAppearParticles(PlayableCharacterParticles __instance)
		{
			return KeepNativeArrival(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharManager), "ClientHandleDeath")]
		private static void AfterBladeDeath(CharManager __instance)
		{
			if (IsBlade(__instance))
			{
				BladeTick.Get(__instance)?.StopArrival();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CameraManager), "OwnerHandleOnEndAppearOrResurrect")]
		private static void AfterNativeArrivalHandoff(CameraManager __instance)
		{
			CharManager charManager = __instance._charManager;
			if (IsBlade(charManager))
			{
				BladeTick.Get(charManager)?.SignalArrivalHandoff();
			}
		}

		private static bool KeepNativeArrival(PlayableCharacterParticles particles)
		{
			CharManager charManager = particles.CharManager;
			if (!IsBlade(charManager))
			{
				return true;
			}
			BladeFighter fighter = BladeTick.Get(charManager);
			if (fighter == null)
			{
				return true;
			}
			if (!fighter.HasAttemptedArrival)
			{
				Attempt("arrival particles", delegate
				{
					fighter.BeginArrival();
				});
			}
			return !fighter.SuppressNativeArrival;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GatekeeperCharacterMovement), "Move", new Type[]
		{
			typeof(Vector3),
			typeof(float)
		})]
		private static void ApplyBasicLunge(GatekeeperCharacterMovement __instance, ref Vector3 __0, float __1, out BasicLungeStep __state)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			__state = default(BasicLungeStep);
			if (BladeFighter.BasicLungeMovers.TryGetValue(((Object)__instance).GetInstanceID(), out var value))
			{
				Vector3 val = value.StepBasicLunge((__1 > 0f) ? __1 : Time.deltaTime);
				if (!(((Vector3)(ref val)).sqrMagnitude <= 0f))
				{
					__state = new BasicLungeStep
					{
						Fighter = value,
						NativeVelocity = __0
					};
					__0 += val;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GatekeeperCharacterMovement), "Move", new Type[]
		{
			typeof(Vector3),
			typeof(float)
		})]
		private static void FinishBasicLungeStep(GatekeeperCharacterMovement __instance, BasicLungeStep __state)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (__state.Fighter != null)
			{
				Vector3 nativeVelocity = __state.NativeVelocity;
				nativeVelocity.y = __instance.velocity.y;
				__instance.velocity = nativeVelocity;
				__state.Fighter.SampleBasicLunge(__instance.GetPosition());
			}
		}

		private void BindCombatSettings()
		{
			string[] array = new string[4] { "FanSlash", "HolographicCounter", "GhostStep", "TripleDash" };
			float[] array2 = new float[4] { 0f, 7f, 6f, 19f };
			cooldown = new ConfigEntry<float>[4];
			for (int i = 0; i < 4; i++)
			{
				cooldown[i] = ((BasePlugin)this).Config.Bind<float>(array[i], "Cooldown", array2[i], "Temporary cooldown in seconds.");
			}
			dashDistance = ((BasePlugin)this).Config.Bind<float>("GhostStep", "DashDistance", 8.5f, "Target backward retreat distance on open ground.");
			ultimateDashDistance = ((BasePlugin)this).Config.Bind<float>("TripleDash", "DashDistance", 17.5f, "Target distance per dash on open ground.");
			shieldDuration = ((BasePlugin)this).Config.Bind<float>("HolographicCounter", "ShieldDuration", 1.6f, "Front guard duration in seconds.");
			ghostDuration = ((BasePlugin)this).Config.Bind<float>("GhostStep", "GhostDuration", 1.65f, "Intangible duration after the retreat.");
			traceCombat = ((BasePlugin)this).Config.Bind<bool>("Diagnostics", "LogCombat", false, "Log skill events and confirmed damage.");
		}

		internal static float CooldownFor(int i)
		{
			return Mathf.Max(0f, cooldown[i - 1].Value);
		}

		internal static void Trace(string info)
		{
			if (traceCombat.Value)
			{
				log.LogInfo((object)info);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharManager), "OnOwnerUpdate")]
		public static void UseNativeFacingForBlade(CharManager __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner)
			{
				BladeTick.Get(__instance)?.UseNativeLocomotionFacing();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharManager), "OwnerSetAttack")]
		public static bool OverrideAttackInput(CharManager __instance)
		{
			return !IsBlade(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HybridSkills), "OwnerFirstSkillUpdate")]
		public static bool SuppressTemplatePrimary(HybridSkills __instance)
		{
			return !IsBlade(((PlayableCharacterSkills)__instance).CharManager);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayableCharacterSkills), "UseFirstSkill")]
		public static bool DoFirst(PlayableCharacterSkills __instance)
		{
			return Intercept(__instance, 1);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayableCharacterSkills), "UseSecondSkill")]
		public static bool DoSecond(PlayableCharacterSkills __instance)
		{
			return Intercept(__instance, 2);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayableCharacterSkills), "UseThirdSkill")]
		public static bool DoThird(PlayableCharacterSkills __instance)
		{
			return Intercept(__instance, 3);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayableCharacterSkills), "UseFourthSkill")]
		public static bool DoFourth(PlayableCharacterSkills __instance)
		{
			return Intercept(__instance, 4);
		}

		private static bool Intercept(PlayableCharacterSkills skill, int index)
		{
			CharManager charManager = skill.CharManager;
			if (!IsBlade(charManager))
			{
				return true;
			}
			if (((NetworkBehaviour)charManager).IsOwner)
			{
				BladeTick.Get(charManager)?.Request(index);
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharManager), "TakeDamage")]
		public static bool InterceptDamage(CharManager __instance, IDamageSource __0, float __1, DamageType __2, bool __3, bool __5)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (!IsBlade(__instance) || __1 <= 0f || __3 || __5 || __0 == null)
			{
				return true;
			}
			return BladeTick.Get(__instance)?.ShouldTakeDamage(__0, __2, __1) ?? true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharDataMoveSpeed), "ClientGetMoveSpeed")]
		private static void ApplyBeyondReality(CharDataMoveSpeed __instance, ref float __result)
		{
			CharData charData = __instance.charData;
			if (Object.op_Implicit((Object)(object)charData) && Object.op_Implicit((Object)(object)charData.CharManager))
			{
				BladeFighter bladeFighter = BladeTick.Get(charData.CharManager);
				if (bladeFighter != null && bladeFighter.BeyondRealityActive)
				{
					__result *= 1.35f;
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayableCharacterMain), "ServerSetCanTakeDamage")]
		public static void PreserveBladePhase(PlayableCharacterMain __instance, ref bool __0)
		{
			CharManager manager = __instance.Manager;
			if (manager != null && Object.op_Implicit((Object)(object)manager))
			{
				BladeTick.Get(manager)?.PreservePhaseDamageLock(ref __0);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GatekeeperCharacterMovement), "Move", new Type[]
		{
			typeof(Vector3),
			typeof(float)
		})]
		public static void ApplyBladeGhostVelocity(GatekeeperCharacterMovement __instance, ref Vector3 __0, float __1)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (BladeFighter.GhostMovers.TryGetValue(((Object)__instance).GetInstanceID(), out var value))
			{
				__0 = value.GhostVelocity(__0, (__1 > 0f) ? __1 : Time.deltaTime);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharManager), "TakeDamage")]
		public static void BeforeGhostDamage(CharManager __instance, IDamageSource __0, float __1, out float __state)
		{
			__state = -1f;
			if (__1 > 0f && __0 != null)
			{
				BladeFighter bladeFighter = BladeTick.Get(__instance);
				if (bladeFighter != null && (bladeFighter.TracingGhostDamage || bladeFighter.TracingUltimateDamage))
				{
					__state = __instance.Data.HealthData.CurrentHealth;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharManager), "TakeDamage")]
		public static void AfterGhostDamage(CharManager __instance, IDamageSource __0, float __1, float __state)
		{
			if (__state < 0f || !Object.op_Implicit((Object)(object)__instance))
			{
				return;
			}
			BladeFighter bladeFighter = BladeTick.Get(__instance);
			if (bladeFighter != null)
			{
				if (bladeFighter.TracingGhostDamage)
				{
					bladeFighter.LogGhostDamage(__0, __1, __state);
				}
				if (bladeFighter.TracingUltimateDamage)
				{
					bladeFighter.LogUltimateDamage(__1, __state);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static bool UseNativeHybridDeathPassive(HybridMain __instance, ref bool __result)
		{
			if (!IsBlade(((PlayableCharacterMain)__instance).Manager))
			{
				return true;
			}
			__result = false;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(StatisticPanelView), "FillCharacterName")]
		public static bool FillNativeResultName(StatisticPanelView __instance)
		{
			CharManager selectedCharacter = __instance._selectedCharacter;
			if (!IsBlade(selectedCharacter))
			{
				return true;
			}
			string translation = LocalizationManager.GetTranslation(selectedCharacter.PlayableCharacterInfo.characterNameKey, true, 0, true, false, (GameObject)null, (string)null, true);
			if (Object.op_Implicit((Object)(object)__instance.characterNameText))
			{
				__instance.characterNameText.text = (string.IsNullOrEmpty(translation) ? "Blade" : translation).ToUpperInvariant();
			}
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StatisticPanelView), "FillInfo")]
		public static void FillBladeResultPortrait(StatisticPanelView __instance)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			CharManager selectedCharacter = __instance._selectedCharacter;
			if (IsBlade(selectedCharacter))
			{
				if (Object.op_Implicit((Object)(object)__instance.characterPortrait))
				{
					__instance.characterPortrait.sprite = selectedCharacter.PlayableCharacterInfo.characterMiniPortraitSprite;
				}
				ManualLogSource obj = log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade result panel filled: character=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<CharacterType>(selectedCharacter.CharacterType);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", name=");
					TMP_Text characterNameText = __instance.characterNameText;
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((characterNameText != null) ? characterNameText.text : null);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", statistics=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int?>(__instance._statisticListItems?.Count);
				}
				obj.LogInfo(val);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharManager), "ClientHandleLevelLoadStarted")]
		public static void StopBladeUltimateForLevelLoad(CharManager __instance)
		{
			StopBladeForTransition(__instance, "level-load");
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharManager), "OwnerHandleOnGameOver")]
		public static void StopBladeUltimateForGameOver(CharManager __instance)
		{
			StopBladeForTransition(__instance, "run-ended");
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharManager), "OnDisable")]
		public static void StopBladeUltimateForDisable(CharManager __instance)
		{
			StopBladeForTransition(__instance, "disabled");
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharManager), "OnStopServer")]
		public static void StopBladeUltimateForNetworkStop(CharManager __instance)
		{
			StopBladeForTransition(__instance, "server-stopped");
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharManager), "OnDestroy")]
		public static void StopBladeUltimateForDestroy(CharManager __instance)
		{
			StopBladeForTransition(__instance, "destroyed");
		}

		private static void StopBladeForTransition(CharManager player, string reason)
		{
			BladeFighter bladeFighter = BladeTick.Get(player);
			bladeFighter?.StopArrival();
			bladeFighter?.ClearEvolutionTransient();
			bladeFighter?.CancelUltimate(reason);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GatekeeperCharacterMovement), "Move", new Type[]
		{
			typeof(Vector3),
			typeof(float)
		})]
		private static void ApplyBladeUltimateVelocity(GatekeeperCharacterMovement __instance, ref Vector3 __0, float __1, out UltimateMoveStep __state)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			__state = default(UltimateMoveStep);
			if (BladeFighter.UltimateMovers.TryGetValue(((Object)__instance).GetInstanceID(), out var value))
			{
				if (value.CollectingUltimatePath)
				{
					__state = new UltimateMoveStep
					{
						Fighter = value,
						From = __instance.GetPosition()
					};
				}
				__0 = value.UltimateVelocity(__0, (__1 > 0f) ? __1 : Time.deltaTime);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GatekeeperCharacterMovement), "Move", new Type[]
		{
			typeof(Vector3),
			typeof(float)
		})]
		private static void RecordBladeUltimateMovement(GatekeeperCharacterMovement __instance, UltimateMoveStep __state)
		{
			//IL_000c: 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)
			__state.Fighter?.RecordUltimateMovement(__state.From, __instance.GetPosition());
		}

		public override void Load()
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			if (Application.version != "1.2.0.30")
			{
				ManualLogSource obj = log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(73, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade expects Gatekeeper 1.2.0.30, running ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Application.version);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". The hero was not registered.");
				}
				obj.LogWarning(val);
				return;
			}
			string? directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location);
			content = new BladeContent(Path.Combine(directoryName, "assets"));
			rig = new BladeRig(Path.Combine(directoryName, "assets", "blade.rig"));
			BindCombatSettings();
			((BasePlugin)this).AddComponent<BladeTick>();
			new Harmony("naccel_inc.blade.alpha").PatchAll(typeof(Plugin));
			ManualLogSource obj2 = log;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(43, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Blade loaded: app=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Application.version);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" unity=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Application.unityVersion);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", enum ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(77);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", asset id ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("BLADE_ALPHA");
			}
			obj2.LogInfo(val2);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(DatabaseInfoProvider), "Setup")]
		public static void AfterDatabaseSetup()
		{
			Attempt("DatabaseInfoProvider.Setup", delegate
			{
				Register();
			});
		}

		private static PlayableCharacterInfo Register()
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			GatekeepersInfoProvider gatekeepers = DatabaseInfoProvider.Gatekeepers;
			Dictionary<CharacterType, PlayableCharacterInfo> val = ((gatekeepers != null) ? gatekeepers.PlayableCharacterInfos : null);
			if (val == null)
			{
				return null;
			}
			PlayableCharacterInfo val2 = default(PlayableCharacterInfo);
			if (val.TryGetValue((CharacterType)77, ref val2))
			{
				if (((BaseDatabaseInfo)val2).Id != "BLADE_ALPHA")
				{
					throw new InvalidOperationException($"Type {77} already belongs to {((BaseDatabaseInfo)val2).Id}");
				}
				return val2;
			}
			PlayableCharacterInfo characterByType = gatekeepers.GetCharacterByType((CharacterType)1);
			int count = val.Count;
			val2 = Object.Instantiate<PlayableCharacterInfo>(characterByType);
			((Object)val2).name = "Blade";
			((BaseDatabaseInfo)val2)._Id_k__BackingField = "BLADE_ALPHA";
			val2.type = (CharacterType)77;
			((BaseDatabaseInfo)val2).unlocked = true;
			val2.characterNameKey = "blade.name";
			val2.characterDescriptionKey = "blade.hero.description";
			content.SetupCharacter(val2, characterByType);
			EnsureStagingRoot();
			PlayableMenuCharacter val3 = Object.Instantiate<PlayableMenuCharacter>(characterByType.menuPrefab, stagingRoot.transform, false);
			((Object)val3).name = "Blade lobby template";
			HideTemplateMeshes(((Component)val3).transform);
			val2.menuPrefab = val3;
			val.Add((CharacterType)77, val2);
			ManualLogSource obj = log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(92, 7, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Blade registry: ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(count);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" -> ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(val.Count);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("; lookup by type=");
				PlayableCharacterInfo characterByType2 = gatekeepers.GetCharacterByType((CharacterType)77);
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>((characterByType2 != null) ? ((BaseDatabaseInfo)characterByType2).Id : null);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", by id=");
				PlayableCharacterInfo characterById = gatekeepers.GetCharacterById("BLADE_ALPHA");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>((characterById != null) ? ((BaseDatabaseInfo)characterById).Id : null);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("; original Hybrid id=");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((BaseDatabaseInfo)characterByType).Id);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("; menu=");
				PlayableMenuCharacter menuPrefab = val2.menuPrefab;
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>((menuPrefab != null) ? ((Object)menuPrefab).name : null);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" and playable base=");
				GameObject characterPrefab = val2.characterPrefab;
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>((characterPrefab != null) ? ((Object)characterPrefab).name : null);
			}
			obj.LogInfo(val4);
			return val2;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GatekeepersInfoProvider), "IsUnlocked")]
		public static bool UnlockOnlyBlade(BaseDatabaseInfo __0, ref bool __result)
		{
			if (((__0 != null) ? __0.Id : null) != "BLADE_ALPHA")
			{
				return true;
			}
			__result = true;
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharacterSelectorPanel), "Awake")]
		public static void AfterPanelAwake(CharacterSelectorPanel __instance)
		{
			MountCard(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharacterSelectorPanel), "OnEnable")]
		public static void BeforePanelEnable(CharacterSelectorPanel __instance)
		{
			MountCard(__instance);
		}

		private static void MountCard(CharacterSelectorPanel selector)
		{
			if (cardMounting)
			{
				return;
			}
			Attempt("MountCard", delegate
			{
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Expected O, but got Unknown
				//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b0: Expected O, but got Unknown
				//IL_016d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				//IL_018e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Invalid comparison between Unknown and I4
				List<CharacterSelectorCard> characterSelectorCards = selector.CharacterSelectorCards;
				PlayableCharacterInfo val = Register();
				if (!((Object)(object)val == (Object)null) && characterSelectorCards != null)
				{
					content.Localize();
					CharacterSelectorCard val2 = null;
					int num = 0;
					Enumerator<CharacterSelectorCard> enumerator = characterSelectorCards.GetEnumerator();
					while (enumerator.MoveNext())
					{
						CharacterSelectorCard current = enumerator.Current;
						PlayableCharacterInfo val3 = ((current != null) ? current.CharacterInfo : null);
						if (((val3 != null) ? ((BaseDatabaseInfo)val3).Id : null) == "BLADE_ALPHA")
						{
							return;
						}
						if (val3 != null && (int)val3.type == 1)
						{
							val2 = current;
						}
						if (Object.op_Implicit((Object)(object)current))
						{
							num = Math.Max(num, ((Component)current).transform.GetSiblingIndex());
						}
					}
					bool flag = default(bool);
					if (Object.op_Implicit((Object)(object)val2))
					{
						cardMounting = true;
						try
						{
							CharacterSelectorCard val4 = Object.Instantiate<CharacterSelectorCard>(val2, ((Component)val2).transform.parent, false);
							((Object)val4).name = "Blade";
							((Component)val4).transform.SetSiblingIndex(num + 1);
							val4._CharacterInfo_k__BackingField = val;
							val4.selectorPanel = selector;
							characterSelectorCards.Add(val4);
							val4.UpdateInfo();
							val4.CheckUnlockCard();
							SetCardPortrait(val4);
							if (Object.op_Implicit((Object)(object)val4.characterIcon))
							{
								RectTransform rectTransform = ((Graphic)val4.characterIcon).rectTransform;
								Vector3 localScale = ((Transform)rectTransform).localScale;
								((Transform)rectTransform).localScale = new Vector3(localScale.x * 0.6f, localScale.y * 0.6f, localScale.z);
							}
							ManualLogSource obj = log;
							BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(70, 4, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Blade native selector card added: list index ");
								((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(characterSelectorCards.Count - 1);
								((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", unlocked=");
								((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<bool>(val4.IsUnlocked);
								((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", id=");
								((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((BaseDatabaseInfo)val4.CharacterInfo).Id);
								((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", object=");
								((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)val4).name);
							}
							obj.LogInfo(val5);
							return;
						}
						finally
						{
							cardMounting = false;
						}
					}
					ManualLogSource obj2 = log;
					BepInExWarningLogInterpolatedStringHandler val6 = new BepInExWarningLogInterpolatedStringHandler(51, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Blade cannot locate native Hybrid card among ");
						((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<int>(characterSelectorCards.Count);
						((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" cards");
					}
					obj2.LogWarning(val6);
				}
			});
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharacterSelectorPanel), "Select")]
		public static void BeforeSelection(CharacterSelectorCard __0, ref bool __state)
		{
			object obj;
			if (__0 == null)
			{
				obj = null;
			}
			else
			{
				PlayableCharacterInfo characterInfo = __0.CharacterInfo;
				obj = ((characterInfo != null) ? ((BaseDatabaseInfo)characterInfo).Id : null);
			}
			if (!((string?)obj != "BLADE_ALPHA"))
			{
				SaveData dataSave = SaveLoadManager.DataSave;
				Dictionary<CharacterType, CharSkinType> val = ((dataSave != null) ? dataSave.SelectedSkins : null);
				if (val != null && !val.ContainsKey((CharacterType)77))
				{
					val.Add((CharacterType)77, (CharSkinType)0);
					__state = true;
					log.LogInfo((object)"Blade supplied native default skin lookup for enum 77 (only during Select)");
				}
			}
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(CharacterSelectorPanel), "Select")]
		public static Exception AfterSelectionCleanup(bool __state, Exception __exception)
		{
			if (__state)
			{
				SaveData dataSave = SaveLoadManager.DataSave;
				if (dataSave != null)
				{
					dataSave.SelectedSkins?.Remove((CharacterType)77);
				}
			}
			return __exception;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PanelCharacterInfo), "FillInfo")]
		public static void BeforeFillInfo(PlayableCharacterInfo __0, ref int __state)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			if (((__0 != null) ? ((BaseDatabaseInfo)__0).Id : null) != "BLADE_ALPHA")
			{
				return;
			}
			SaveData dataSave = SaveLoadManager.DataSave;
			Dictionary<CharacterType, CharSkinType> val = ((dataSave != null) ? dataSave.SelectedSkins : null);
			if (val != null && !val.ContainsKey((CharacterType)77))
			{
				val.Add((CharacterType)77, (CharSkinType)0);
				__state |= 1;
			}
			OmniStatuesInfoProvider omniStatues = DatabaseInfoProvider.OmniStatues;
			Dictionary<CharacterType, OmniStatueInfo> val2 = ((omniStatues != null) ? omniStatues.StatueInfos : null);
			if (val2 != null && !val2.ContainsKey((CharacterType)77))
			{
				if (!Object.op_Implicit((Object)(object)temporaryOmni))
				{
					temporaryOmni = Object.Instantiate<OmniStatueInfo>(val2[(CharacterType)1]);
					temporaryOmni._CharacterType_k__BackingField = (CharacterType)77;
				}
				val2.Add((CharacterType)77, temporaryOmni);
				__state |= 2;
			}
			ManualLogSource obj = log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(57, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Blade native detail panel supplied dependency flags ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(__state);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" for ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("BLADE_ALPHA");
			}
			obj.LogInfo(val3);
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(PanelCharacterInfo), "FillInfo")]
		public static Exception AfterFillInfo(int __state, Exception __exception)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			if ((__state & 1) != 0)
			{
				SaveData dataSave = SaveLoadManager.DataSave;
				if (dataSave != null)
				{
					dataSave.SelectedSkins?.Remove((CharacterType)77);
				}
			}
			if ((__state & 2) != 0)
			{
				OmniStatuesInfoProvider omniStatues = DatabaseInfoProvider.OmniStatues;
				if (omniStatues != null)
				{
					omniStatues.StatueInfos?.Remove((CharacterType)77);
				}
			}
			if (__state != 0 && __exception == null)
			{
				ManualLogSource obj = log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade native detail panel filled ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BLADE_ALPHA");
				}
				obj.LogInfo(val);
			}
			return __exception;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharactersMenuController), "SetupMenu")]
		public static void AfterSetupMenu()
		{
			Attempt("distinct prefab registration", delegate
			{
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_012f: Expected O, but got Unknown
				//IL_026c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0273: Expected O, but got Unknown
				PlayableCharacterInfo val = Register();
				NetworkManager networkManager = InstanceFinder.NetworkManager;
				if (!Object.op_Implicit((Object)(object)networkManager) || !Object.op_Implicit((Object)(object)val))
				{
					throw new InvalidOperationException("No FishNet NetworkManager or Blade database info at SetupMenu");
				}
				PrefabObjects prefabObjects = networkManager.GetPrefabObjects<SinglePrefabObjects>((ushort)48077, true);
				if (!Object.op_Implicit((Object)(object)prefabObjects))
				{
					throw new InvalidOperationException("FishNet did not create the Blade prefab collection");
				}
				if (prefabObjects.GetObjectCount() > 0)
				{
					NetworkObject val2 = prefabObjects.GetObject(true, 0);
					if (!Object.op_Implicit((Object)(object)val2) || ((Object)val2).name != "Blade_Alpha_Network" || !Object.op_Implicit((Object)(object)temporaryNetworkPrefab))
					{
						throw new InvalidOperationException($"FishNet collection {48077} already in use");
					}
					val.characterPrefab = temporaryNetworkPrefab;
				}
				else
				{
					EnsureStagingRoot();
					PlayableCharacterInfo characterByType = DatabaseInfoProvider.Gatekeepers.GetCharacterByType((CharacterType)1);
					GameObject val3 = Object.Instantiate<GameObject>(characterByType.characterPrefab, stagingRoot.transform, false);
					((Object)val3).name = "Blade_Alpha_Network";
					CharManager componentInChildren = val3.GetComponentInChildren<CharManager>(true);
					NetworkObject val4 = ((componentInChildren != null) ? ((Component)componentInChildren).GetComponent<NetworkObject>() : null) ?? val3.GetComponentInChildren<NetworkObject>(true);
					ManualLogSource obj = log;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(59, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Blade cloned container=");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)val3).name);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", native player node=");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>((componentInChildren != null) ? ((Object)componentInChildren).name : null);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", network node=");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>((val4 != null) ? ((Object)val4).name : null);
					}
					obj.LogInfo(val5);
					if (!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)val4))
					{
						throw new InvalidOperationException("Base controller lacks native CharManager or NetworkObject");
					}
					((Object)componentInChildren).name = "Blade_Alpha_Network";
					((Object)val4).name = "Blade_Alpha_Network";
					componentInChildren.PlayableCharacterInfo = val;
					val4.SetSceneId(0uL);
					prefabObjects.AddObject(val4, true, true);
					if (val4.SpawnableCollectionId != 48077 || (Object)(object)prefabObjects.GetObject(true, (int)val4.PrefabId) != (Object)(object)val4)
					{
						throw new InvalidOperationException($"FishNet registered inconsistent collection={val4.SpawnableCollectionId} / prefab={val4.PrefabId}");
					}
					temporaryNetworkPrefab = val3;
					val.characterPrefab = val3;
					ManualLogSource obj2 = log;
					val5 = new BepInExInfoLogInterpolatedStringHandler(88, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Blade distinct FishNet prefab registered: collection=");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<ushort>(val4.SpawnableCollectionId);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", prefab=");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<ushort>(val4.PrefabId);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", name=");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)val3).name);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", template remains=");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)characterByType.characterPrefab).name);
					}
					obj2.LogInfo(val5);
				}
			});
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(TeamManager), "TryAddMember")]
		public static void AfterTeamMemberRegistered(TeammateData __1, bool __result)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected I4, but got Unknown
			if (__result && (int)__1.SelectedCharacter == 77)
			{
				ManualLogSource obj = log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(68, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade server registered team member with independent character type ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>((int)__1.SelectedCharacter);
				}
				obj.LogInfo(val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharManager), "Awake")]
		public static void AfterCharacterAwake(CharManager __instance)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected I4, but got Unknown
			if (((Object)__instance).name.StartsWith("Blade_Alpha_Network", StringComparison.Ordinal))
			{
				__instance.PlayableCharacterInfo = Register();
				ManualLogSource obj = log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(41, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade Blade CharManager.Awake: id=");
					PlayableCharacterInfo playableCharacterInfo = __instance.PlayableCharacterInfo;
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((playableCharacterInfo != null) ? ((BaseDatabaseInfo)playableCharacterInfo).Id : null);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", enum=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>((int)__instance.CharacterType);
				}
				obj.LogInfo(val);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SceneInitializer), "TryServerSpawnCharacters")]
		public static void BeforeLevelSpawn()
		{
			log.LogInfo((object)"Blade SceneInitializer.TryServerSpawnCharacters");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharacterSelectorPanel), "Select")]
		public static void AfterSelection(CharacterSelectorCard __0)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected I4, but got Unknown
			object obj;
			if (__0 == null)
			{
				obj = null;
			}
			else
			{
				PlayableCharacterInfo characterInfo = __0.CharacterInfo;
				obj = ((characterInfo != null) ? ((BaseDatabaseInfo)characterInfo).Id : null);
			}
			if ((string?)obj == "BLADE_ALPHA")
			{
				ManualLogSource obj2 = log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade native selector selected ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((BaseDatabaseInfo)__0.CharacterInfo).Id);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; enum=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>((int)__0.CharacterInfo.type);
				}
				obj2.LogInfo(val);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(MenuCharacterSpawner), "SpawnCharacter")]
		public static void BeforeMenuSpawn(int __0, CharacterType __1, bool __2)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected I4, but got Unknown
			if ((int)__1 == 77)
			{
				ManualLogSource obj = log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(55, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade native menu spawner accepted enum ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>((int)__1);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", slot ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(__0);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", local=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(__2);
				}
				obj.LogInfo(val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharactersMenuController), "UpdatePlayerAndCharacterInfo")]
		public static void AfterLobbyUpdate(NetworkLobbyPlayerData __0, bool __1)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			if (__1)
			{
				ManualLogSource obj = log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade local lobby data: slot ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(__0.PlayerPanelIndex);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", char index ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(__0.CharacterIndex);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", random index ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(__0.RandomCharacterIndex);
				}
				obj.LogInfo(val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharManager), "OnStartClient")]
		public static void AfterCharacterSpawn(CharManager __instance)
		{
			Attempt("CharManager.OnStartClient", delegate
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Expected I4, but got Unknown
				ManualLogSource obj = log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade gameplay spawn: object=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)__instance).name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", enum=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>((int)__instance.CharacterType);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", id=");
					PlayableCharacterInfo playableCharacterInfo = __instance.PlayableCharacterInfo;
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((playableCharacterInfo != null) ? ((BaseDatabaseInfo)playableCharacterInfo).Id : null);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", owner=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(((NetworkBehaviour)__instance).IsOwner);
				}
				obj.LogInfo(val);
			});
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharacterSelectorCard), "UpdateInfo")]
		public static void SetCardPortrait(CharacterSelectorCard __instance)
		{
			PlayableCharacterInfo characterInfo = __instance.CharacterInfo;
			if (((characterInfo != null) ? ((BaseDatabaseInfo)characterInfo).Id : null) == "BLADE_ALPHA" && Object.op_Implicit((Object)(object)__instance.characterIcon))
			{
				__instance.characterIcon.sprite = __instance.CharacterInfo.characterMiniPortraitSprite;
			}
		}

		private static void EnsureStagingRoot()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)stagingRoot))
			{
				stagingRoot = new GameObject("Blade template storage");
				stagingRoot.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)stagingRoot);
			}
		}

		private static IEnumerable<Renderer> MeshRenderers(Transform root)
		{
			foreach (SkinnedMeshRenderer componentsInChild in ((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(true))
			{
				if (Object.op_Implicit((Object)(object)componentsInChild))
				{
					yield return (Renderer)(object)componentsInChild;
				}
			}
			foreach (MeshRenderer componentsInChild2 in ((Component)root).GetComponentsInChildren<MeshRenderer>(true))
			{
				if (Object.op_Implicit((Object)(object)componentsInChild2))
				{
					yield return (Renderer)(object)componentsInChild2;
				}
			}
		}

		private static void HideTemplateMeshes(Transform root)
		{
			foreach (Renderer item in MeshRenderers(root))
			{
				item.enabled = false;
				item.forceRenderingOff = true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(MenuCharacterSpawner), "SpawnCharacter")]
		public static void AfterMenuSpawn(MenuCharacterSpawner __instance, int __0, CharacterType __1)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Attempt("native lobby slot visual", delegate
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Invalid comparison between Unknown and I4
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Expected O, but got Unknown
				//IL_0152: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Expected O, but got Unknown
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				List<Transform> spawnPoints = __instance.spawnPoints;
				if (spawnPoints != null && __0 >= 0 && __0 < spawnPoints.Count)
				{
					Transform val = spawnPoints[__0];
					if (Object.op_Implicit((Object)(object)val))
					{
						int instanceID = ((Object)val).GetInstanceID();
						bool flag = default(bool);
						if ((int)__1 != 77)
						{
							if (lobbySlots.Remove(instanceID, out var value))
							{
								value.Restore();
								ManualLogSource obj = log;
								BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(31, 2, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Blade lobby slot ");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(__0);
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" restored for ");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<CharacterType>(__1);
								}
								obj.LogInfo(val2);
							}
						}
						else
						{
							if (!lobbySlots.TryGetValue(instanceID, out var value2))
							{
								PlayableMenuCharacter componentInChildren = ((Component)val).GetComponentInChildren<PlayableMenuCharacter>(false);
								BladeRig.BladeVisual bladeVisual = rig.Attach(val, lobby: true, ((Component)val).gameObject.layer, 4f);
								if (Object.op_Implicit((Object)(object)componentInChildren))
								{
									bladeVisual.Root.SetPositionAndRotation(((Component)componentInChildren).transform.position, ((Component)componentInChildren).transform.rotation);
								}
								bladeVisual.Play("LobbySelect");
								value2 = new LobbyVisual(bladeVisual, val);
								lobbySlots.Add(instanceID, value2);
								BladeTick.Add(bladeVisual, null);
								ManualLogSource obj2 = log;
								BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(45, 3, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Blade D12 intro started slot=");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(__0);
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" anchor=");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" meshes=");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(bladeVisual.Renderers.Length);
								}
								obj2.LogInfo(val2);
							}
							value2.HideNativeMeshes();
						}
					}
				}
			});
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(MenuCharacterSpawner), "RemoveCharacter")]
		public static void ReleaseLobbySlot(MenuCharacterSpawner __instance, int __0)
		{
			List<Transform> spawnPoints = __instance.spawnPoints;
			if (spawnPoints != null && __0 >= 0 && __0 < spawnPoints.Count && Object.op_Implicit((Object)(object)spawnPoints[__0]))
			{
				int instanceID = ((Object)spawnPoints[__0]).GetInstanceID();
				if (lobbySlots.Remove(instanceID, out var value))
				{
					value.Restore();
				}
			}
		}

		internal static void MaintainLobby()
		{
			if (lobbySlots.Count == 0 || Time.unscaledTime < nextLobbyCheck)
			{
				return;
			}
			nextLobbyCheck = Time.unscaledTime + 0.17f;
			List<int> list = new List<int>();
			foreach (var (item, lobbyVisual2) in lobbySlots)
			{
				if (!lobbyVisual2.Alive)
				{
					list.Add(item);
				}
				else
				{
					lobbyVisual2.HideNativeMeshes();
				}
			}
			foreach (int item2 in list)
			{
				lobbySlots.Remove(item2);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayableCharacterMain), "ClientInit")]
		public static void AfterPlayableInit(PlayableCharacterMain __instance)
		{
			CharManager player = __instance.Manager;
			if (IsBlade(player))
			{
				Attempt("game visual", delegate
				{
					Transform transform = ((Component)player).transform;
					Transform nativeMeshRoot = (Object.op_Implicit((Object)(object)player.charRig) ? player.charRig : ((Component)player).transform);
					AttachGameplayVisual(transform, nativeMeshRoot, player);
				});
			}
		}

		private static bool IsBlade(CharManager player)
		{
			if (Object.op_Implicit((Object)(object)player))
			{
				PlayableCharacterInfo playableCharacterInfo = player.PlayableCharacterInfo;
				return ((playableCharacterInfo != null) ? ((BaseDatabaseInfo)playableCharacterInfo).Id : null) == "BLADE_ALPHA";
			}
			return false;
		}

		private static void AttachGameplayVisual(Transform anchor, Transform nativeMeshRoot, CharManager player)
		{
			//IL_0092: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			if (BladeTick.Get(player) != null)
			{
				return;
			}
			List<Renderer> list = new List<Renderer>(MeshRenderers(nativeMeshRoot));
			int num = (((Object)(object)player != (Object)null && Object.op_Implicit((Object)(object)player.CharMesh)) ? ((Component)player.CharMesh).gameObject.layer : ((list.Count > 0) ? ((Component)list[0]).gameObject.layer : ((Component)anchor).gameObject.layer));
			float num2;
			Bounds bounds;
			if (!((Object)(object)player != (Object)null) || !Object.op_Implicit((Object)(object)player.CharMesh))
			{
				if (list.Count <= 0)
				{
					num2 = 0f;
				}
				else
				{
					bounds = list[0].bounds;
					num2 = ((Bounds)(ref bounds)).size.y;
				}
			}
			else
			{
				bounds = player.CharMesh.bounds;
				num2 = ((Bounds)(ref bounds)).size.y;
			}
			float num3 = num2;
			BladeRig.BladeVisual bladeVisual = rig.Attach(anchor, lobby: false, num, num3);
			bladeVisual.Root.SetParent((Transform)null, true);
			((Object)bladeVisual.Root).name = "Blade gameplay visual";
			foreach (Renderer item in list)
			{
				item.enabled = false;
				item.forceRenderingOff = true;
			}
			if ((Object)(object)player != (Object)null && Object.op_Implicit((Object)(object)player.CharMesh))
			{
				player.CharMesh.forceRenderingOff = true;
			}
			BladeTick.Add(bladeVisual, player);
			ManualLogSource obj = log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(102, 6, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade assets attached in gameplay, native height=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num3, "F2");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", layer=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", anchor=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)anchor).name);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(anchor.position);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", hidden native meshes=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(list.Count);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", renderers=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(bladeVisual.Renderers.Length);
			}
			obj.LogInfo(val);
		}

		private static void Attempt(string stage, Action action)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			try
			{
				action();
			}
			catch (Exception ex)
			{
				ManualLogSource obj = log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(8, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(stage);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				obj.LogError(val);
			}
		}
	}
	internal sealed class BladeFighter
	{
		private sealed class Bleed
		{
			public NpcCharacter Enemy;

			public readonly List<float> Until = new List<float>();

			public float NextTick;

			public float BasicUntil;

			public float BasicConfirmBy;

			public int BasicStacksBefore;
		}

		[Flags]
		private enum PhaseDamageOwner
		{
			None = 0,
			GhostStep = 1,
			Ultimate = 2
		}

		private BladeFx.Arrival arrival;

		private bool arrivalMaySetPose;

		private bool arrivalMeshesHidden;

		private float arrivalOpacity;

		internal static readonly Dictionary<int, BladeFighter> BasicLungeMovers = new Dictionary<int, BladeFighter>();

		private const float BasicLungeDistance = 0.92f;

		private const float BasicLungeDuration = 0.15f;

		private int basicLungeMover;

		private int basicLungeSwing;

		private Vector3 basicLungeHeading;

		private Vector3 basicLungeOrigin;

		private float basicLungeRemaining;

		private readonly CharManager player;

		private readonly BladeRig.BladeVisual visual;

		private readonly Transform root;

		private readonly BladeFx fx;

		private readonly float[] next = new float[5];

		private readonly HashSet<int> ultTargets = new HashSet<int>();

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

		private readonly HashSet<int> castVictims = new HashSet<int>();

		private readonly HashSet<int> castSpectris = new HashSet<int>();

		private const float BasicRadius = 4.7f;

		private const float BasicHalfAngle = 130f;

		private bool attackHeld;

		private bool landed;

		private bool moving;

		private bool warnedRemote;

		private bool deathPlaying;

		private int basicSwing;

		private float basicStartedAt;

		private float basicLastStrikeAt;

		private int skill;

		private float guardStart;

		private float movementSpeed;

		private Vector3 travelDirection;

		private Vector3 heading;

		private RotationMode? previousRotationMode;

		internal readonly int Instance;

		private float nextRenderCheck;

		private int renderReports;

		private Vector3 oldPosition;

		private static readonly string[] SprintClips = new string[8] { "Sprint0", "Sprint1", "Sprint2", "Sprint3", "Sprint4", "Sprint5", "Sprint6", "Sprint7" };

		private float danceBonus;

		private float counterFullCooldown;

		private int windSwings;

		private int phantomScene;

		private int phantomCreated;

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

		private readonly Queue<(Vector3 Position, float Due)> phantomEchoes = new Queue<(Vector3, float)>();

		private PhaseDamageOwner phaseDamageOwners;

		private bool restoreCanTakeDamage;

		private bool writingPhaseDamage;

		private float ghostOpacity;

		private float ultimateOpacity;

		internal static readonly Dictionary<int, BladeFighter> GhostMovers = new Dictionary<int, BladeFighter>();

		private const float GhostDashTime = 0.44f;

		private const float GhostCutStart = 30f;

		private const int GhostHitFrame = 32;

		private const float GhostCutEnd = 39f;

		private const int GhostRetreatFrame = 47;

		private const float GhostRadius = 4.25f;

		private const float GhostSector = 153f;

		private int ghostCast;

		private int ghostMover;

		private int ghostAfterimages;

		private Vector3 ghostDirection;

		private Vector3 ghostOrigin;

		private Vector3 ghostLastWake;

		private Vector3 ghostRunOrigin;

		private float ghostStartedAt;

		private float ghostDashEndedAt;

		private float ghostUntil;

		private float ghostElapsed;

		private float ghostDistance;

		private float ghostLastCollision;

		private float ghostTraceEnd;

		private bool ghostPhased;

		private bool ghostRunReported;

		private RotationMode? ghostPreviousRotation;

		internal static readonly Dictionary<int, BladeFighter> UltimateMovers = new Dictionary<int, BladeFighter>();

		private const float UltimateDashDuration = 0.34f;

		private int ultMover;

		private int ultCast;

		private int ultLeg;

		private RotationMode? ultPreviousRotation;

		private Vector3 ultDashOrigin;

		private Vector3 ultLastWake;

		private float ultRemaining;

		private float ultSpeed;

		private float ultStartedAt;

		private float ultimatePhaseStart;

		private float ultimateTraceUntil;

		private int ultimateScene;

		private bool ultDashActive;

		private bool ultimatePhased;

		private GatekeeperCharacterMovement ultimateFilteredMover;

		private ColliderFilterCallback previousUltimateFilter;

		private ColliderFilterCallback ultimateFilter;

		private readonly List<(Vector3 From, Vector3 To)> ultimatePath = new List<(Vector3, Vector3)>();

		private int ultimateIgnoredContacts;

		internal bool SuppressNativeArrival { get; private set; }

		internal bool HasAttemptedArrival { get; private set; }

		internal bool HasPlayer => Object.op_Implicit((Object)(object)player);

		internal bool DevInputBlocked { get; private set; }

		internal bool DevCooldownBypassed { get; private set; }

		internal Action<string> DevJournal { get; set; }

		internal float DevDance => danceBonus;

		internal bool DevIsPhased
		{
			get
			{
				if (!ghostPhased)
				{
					return ultimatePhased;
				}
				return true;
			}
		}

		internal bool DevIsCasting => skill != 0;

		internal float DevLastDamage { get; private set; }

		internal float DevLastHeal { get; private set; }

		internal float DevLastAbsorbed { get; private set; }

		internal float DevLastRefund { get; private set; }

		internal bool DevLastWound { get; private set; }

		internal string DevLastSource { get; private set; } = "";

		private float CurrentDamage => Mathf.Max(0f, player.Data.DamageData.FinalDamage);

		internal bool BeyondRealityActive
		{
			get
			{
				if (Object.op_Implicit((Object)(object)player) && ((NetworkBehaviour)player).IsOwner && player.IsActiveAndAlive && ghostPhased && ghostMover == 0 && Time.time < ghostUntil)
				{
					return HasEvolution(3, 2);
				}
				return false;
			}
		}

		internal bool TracingGhostDamage
		{
			get
			{
				if (ghostCast > 0)
				{
					return Time.time < ghostTraceEnd;
				}
				return false;
			}
		}

		internal bool TracingUltimateDamage
		{
			get
			{
				if (!ultimatePhased)
				{
					return Time.time < ultimateTraceUntil;
				}
				return true;
			}
		}

		internal bool CollectingUltimatePath
		{
			get
			{
				if (ultDashActive && skill == 4 && Object.op_Implicit((Object)(object)player))
				{
					return player.IsActiveAndAlive;
				}
				return false;
			}
		}

		internal void BeginArrival()
		{
			//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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			if (HasAttemptedArrival)
			{
				if (arrival == null)
				{
					SuppressNativeArrival = false;
				}
			}
			else if (Object.op_Implicit((Object)(object)root) && Object.op_Implicit((Object)(object)visual.Root))
			{
				HasAttemptedArrival = true;
				Vector3 spawnPosition = player.SpawnPosition;
				arrival = fx.BeginArrival(spawnPosition, Object.op_Implicit((Object)(object)player.Controller) ? player.Controller.GetRotation() : root.rotation);
				SuppressNativeArrival = true;
				arrivalMaySetPose = true;
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade D16 arrival started at ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(spawnPosition);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (visual only)");
				}
				log.LogInfo(val);
			}
		}

		internal void SignalArrivalHandoff()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			BladeFx.Arrival obj = arrival;
			if (obj != null && obj.SignalHandoff())
			{
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade D16 arrival camera handoff t=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(arrival.Age, "F2");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s");
				}
				log.LogInfo(val);
			}
		}

		internal void UpdateArrival()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if (arrival == null)
			{
				return;
			}
			try
			{
				DrawArrival();
			}
			catch (Exception ex)
			{
				StopArrival();
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade D16 arrival renderer stopped: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private void DrawArrival()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			if (!arrival.InScene || !Object.op_Implicit((Object)(object)player) || !((Behaviour)player).isActiveAndEnabled)
			{
				StopArrival();
				return;
			}
			float choreographyTime = arrival.ChoreographyTime;
			if (arrival.Finished)
			{
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(67, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blade D16 arrival ended t=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(arrival.Age, "F2");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s cue=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(arrival.UsedNativeHandoff ? "camera" : "fallback");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; effects and ghost meshes released");
				}
				log.LogInfo(val);
				EndArrivalVisual();
			}
			else
			{
				if (skill != 0 || moving)
				{
					arrivalMaySetPose = false;
				}
				if (arrivalMaySetPose)
				{
					visual.BlendArrivalStance(1f - Mathf.SmoothStep(0f, 1f, (choreographyTime - 0.44f) / 0.25f));
				}
				SetArrivalHidden(arrivalMaySetPose && choreographyTime < 0.24f);
				UpdateArrivalOpacity(arrivalMaySetPose ? (1f - Mathf.SmoothStep(0f, 1f, (choreographyTime - 0.24f) / 0.32f)) : 0f);
				arrival.Draw(choreographyTime);
			}
		}

		internal void StopArrival()
		{
			SuppressNativeArrival = false;
			EndArrivalVisual();
		}

		private void EndArrivalVisual()
		{
			if (arrival != null)
			{
				arrival.Dispose();
				arrival = null;
				SetArrivalHidden(hide: false);
				UpdateArrivalOpacity(0f);
			}
		}

		private void SetArrivalHidden(bool hide)
		{
			if (!hide && !arrivalMeshesHidden)
			{
				return;
			}
			Renderer[] renderers = visual.Renderers;
			foreach (Renderer val in renderers)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					val.forceRenderingOff = hide;
				}
			}
			arrivalMeshesHidden = hide;
		}

		private void UpdateArrivalOpacity(float opacity)
		{
			if (arrivalOpacity != opacity)
			{
				arrivalOpacity = opacity;
				RefreshPhaseOpacity();
			}
		}

		private void BeginBasicLunge()
		{
			//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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			StopBasicLunge();
			GatekeeperCharacter controller = player.Controller;
			GatekeeperCharacterMovement val = (Object.op_Implicit((Object)(object)controller) ? controller.GetCharacterMovement() : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				basicLungeMover = ((Object)val).GetInstanceID();
				basicLungeSwing = basicSwing;
				basicLungeHeading = heading;
				basicLungeOrigin = val.GetPosition();
				basicLungeRemaining = 0.92f;
				BasicLungeMovers[basicLungeMover] = this;
				Plugin.Trace($"Blade D5 lunge swing={basicSwing}, target={0.92f:F2}, aim=({heading.x:F3},{heading.z:F3})");
			}
		}

		internal Vector3 StepBasicLunge(float deltaTime)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if (deltaTime <= 0f || !Object.op_Implicit((Object)(object)player) || !player.IsActiveAndAlive || skill != 1)
			{
				return Vector3.zero;
			}
			float num = Mathf.Min(basicLungeRemaining, deltaTime * 6.133333f);
			basicLungeRemaining -= num;
			return basicLungeHeading * (num / deltaTime);
		}

		internal void SampleBasicLunge(Vector3 position)
		{
			//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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (!(basicLungeRemaining > 0.0001f))
			{
				Vector3 val = Flat(position - basicLungeOrigin);
				Plugin.Trace($"Blade D5 lunge complete swing={basicLungeSwing}, actual={((Vector3)(ref val)).magnitude:F3}, forward={Vector3.Dot(val, basicLungeHeading):F3}");
				StopBasicLunge();
			}
		}

		internal void StopBasicLunge()
		{
			if (basicLungeMover != 0)
			{
				BasicLungeMovers.Remove(basicLungeMover);
				basicLungeMover = 0;
				basicLungeRemaining = 0f;
			}
		}

		public BladeFighter(CharManager player, BladeRig.BladeVisual visual)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			this.player = player;
			this.visual = visual;
			root = ((Component)player).transform;
			Instance = ((Object)player).GetInstanceID();
			oldPosition = root.position;
			fx = new BladeFx(visual);
			heading = Aim();
		}

		public void Request(int slot)
		{
			if (!((NetworkBehaviour)player).IsOwner || !player.IsActiveAndAlive)
			{
				return;
			}
			if (!InstanceFinder.IsServerStarted || !TeamManager.IsSoloPlayer)
			{
				if (!warnedRemote)
				{
					Plugin.log.LogWarning((object)"Blade 0.1 active skills are enabled only in verified local-host solo runs.");
				}
				warnedRemote = true;
			}
			else
			{
				if (DevInputBlocked || skill != 0 || (!DevCooldownBypassed && Time.time < next[slot]))
				{
					return;
				}
				if (slot != 1)
				{
					RestoreNativeRotationMode();
				}
				skill = slot;
				next[slot] = Time.time + Plugin.CooldownFor(slot);
				switch (slot)
				{
				case 1:
					basicSwing = 0;
					basicStartedAt = Time.time;
					basicLastStrikeAt = 0f;
					Play("Draw", 4f);
					break;
				case 2:
					counterFullCooldown = (HasEvolution(2, 3) ? player.playableCharacterMain.Skills.GetSkillCooldown((SkillType)2) : 0f);
					Play("CounterMiss");
					break;
				case 3:
					StartGhostStep();
					break;
				case 4:
					ultTargets.Clear();
					StartUltimateMotion();
					Play("UltIn");
					break;
				}
				if (slot > 1)
				{
					try
					{
						if (slot == 4)
						{
							BeginUltimatePhase();
						}
						if (!DevCooldownBypassed)
						{
							player.playableCharacterMain.Skills.SpendSkillCharge((SkillType)slot);
						}
					}
					catch when (slot == 4)
					{
						CancelUltimate("activation-failed");
						throw;
					}
				}
				Plugin.Trace($"Blade cast {slot}: {visual.Clip}");
			}
		}

		public bool ShouldTakeDamage(IDamageSource source, DamageType kind, float incoming)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			Component damageSourceComponent = source.DamageSourceComponent;
			if (!Object.op_Implicit((Object)(object)damageSourceComponent))
			{
				return true;
			}
			Vector3 val = Flat(damageSourceComponent.transform.position - root.position);
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f || (int)kind == 6)
			{
				return true;
			}
			if (skill != 2 || guardStart <= 0f || Vector3.Dot(((Vector3)(ref val)).normalized, heading) < 0.01f)
			{
				return true;
			}
			guardStart = 0f;
			fx.ClearGuard();
			Play("CounterHit", 61f);
			float num = (player.Data.CanTakeDamage ? incoming : 0f);
			DevRecordAbsorption(num);
			float value = (HasEvolution(2, 1) ? BladeBalance.CounterDamage(CurrentDamage, num) : SkillDamage(2));
			Plugin.Trace($"Blade D14 counter absorbed={num:F2} input={incoming:F2} wave={value:F2}");
			Hit(2, 5.1f, 360f, knockback: true, value);
			if (HasEvolution(2, 2))
			{
				fx.ShatterWave(root.position, heading);
			}
			fx.Impact(root.position, heading, 5.1f, ((Vector3)(ref val)).normalized);
			Plugin.Trace("Blade Counter confirmed an incoming frontal hit and fired its radial wave");
			return false;
		}

		public void Update(float dt)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)player))
			{
				return;
			}
			visual.Root.position = root.position;
			if (Time.time >= nextRenderCheck)
			{
				nextRenderCheck = Time.time + 0.3f;
				Renderer[] renderers = visual.Renderers;
				foreach (Renderer val in renderers)
				{
					if (Object.op_Implicit((Object)(object)val))
					{
						val.enabled = true;
						val.forceRenderingOff = false;
					}
				}
				if (Object.op_Implicit((Object)(object)player.CharMesh))
				{
					player.CharMesh.forceRenderingOff = true;
				}
				if (player.IsActiveAndAlive && renderReports++ < 2)
				{
					Renderer val2 = visual.Renderers[0];
					Material sharedMaterial = val2.sharedMaterial;
					SkinnedMeshRenderer val3 = ((Il2CppObjectBase)val2).TryCast<SkinnedMeshRenderer>();
					DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(88, 8);
					defaultInterpolatedStringHandler.AppendLiteral("Blade runtime render: actor=");
					defaultInterpolatedStringHandler.AppendFormatted<Vector3>(root.position);
					defaultInterpolatedStringHandler.AppendLiteral(", visual=");
					defaultInterpolatedStringHandler.AppendFormatted<Vector3>(visual.Root.position);
					defaultInterpolatedStringHandler.AppendLiteral(", scale=");
					defaultInterpolatedStringHandler.AppendFormatted<Vector3>(visual.Root.lossyScale);
					defaultInterpolatedStringHandler.AppendLiteral(", bounds=");
					Bounds bounds = val2.bounds;
					defaultInterpolatedStringHandler.AppendFormatted<Vector3>(((Bounds)(ref bounds)).center);
					defaultInterpolatedStringHandler.AppendLiteral(", layer=");
					defaultInterpolatedStringHandler.AppendFormatted(((Component)val2).gameObject.layer);
					defaultInterpolatedStringHandler.AppendLiteral(", mesh=");
					defaultInterpolatedStringHandler.AppendFormatted((Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val3.sharedMesh)) ? val3.sharedMesh.vertexCount : 0);
					defaultInterpolatedStringHandler.AppendLiteral(", shader=");
					defaultInterpolatedStringHandler.AppendFormatted((Object.op_Implicit((Object)(object)sharedMaterial) && Object.op_Implicit((Object)(object)sharedMaterial.shader)) ? ((Object)sharedMaterial.shader).name : "missing");
					defaultInterpolatedStringHandler.AppendLiteral(", visible=");
					defaultInterpolatedStringHandler.AppendFormatted(val2.isVisible);
					Plugin.Trace(defaultInterpolatedStringHandler.ToStringAndClear());
				}
			}
			if (!player.IsActiveAndAlive)
			{
				if (!deathPlaying)
				{
					deathPlaying = true;
					ClearEvolutionTransient();
					StopBasicLunge();
					StopUltimateMotion("inactive");
					ResetGhostStep();
					fx.ClearGuard();
					visual.Play("Death");
				}
				visual.Tick(dt);
				return;
			}
			if (deathPlaying)
			{
				deathPlaying = false;
				Finish();
			}
			if (((NetworkBehaviour)player).IsOwner)
			{
				TickWounds();
				attackHeld = !DevInputBlocked && GameplayInputManager.ButtonIsPressed((ActionName)1);
				UpdateDance(dt);
				UpdatePhantomEchoes();
				fx.SwordTrail(active: false, 0.18f);
				UpdateGhostPhase();
			}
			Vector3 val4 = Flat(root.position - oldPosition);
			moving = ((Vector3)(ref val4)).sqrMagnitude > 7E-06f;
			if (moving)
			{
				travelDirection = ((Vector3)(ref val4)).normalized;
			}
			movementSpeed = ((Vector3)(ref val4)).magnitude / dt;
			oldPosition = root.position;
			if (skill == 0)
			{
				if (!DevInputBlocked && ((NetworkBehaviour)player).IsOwner && player.playableCharacterMain.Skills.CanUseSkills && (attackHeld || GameplayInputManager.ButtonWasPressed((ActionName)1)))
				{
					Request(1);
				}
				if (skill == 0)
				{
					UpdateLocomotion(dt);
					return;
				}
			}
			if (skill == 1)
			{
				UpdateBasic(dt);
				return;
			}
			if (skill == 4)
			{
				UpdateUltimate(dt);
				return;
			}
			if (skill == 3)
			{
				UpdateGhostAttack(dt);
				return;
			}
			string clip = visual.Clip;
			Face();
			float frame = visual.Frame;
			if (clip == "CounterMiss" && guardStart > 0f)
			{
				fx.Guard(root.position, heading, Time.time - guardStart);
				if (Time.time - guardStart < Plugin.ShieldDuration)
				{
					return;
				}
				guardStart = 0f;
				visual.HoldAt(86f);
				fx.ClearGuard();
				RefundCounterCooldown();
				Plugin.Trace("Blade Counter expired without impact. No counter was fired.");
			}
			visual.Tick(dt, SpeedFor(clip));
			float frame2 = visual.Frame;
			if (clip == "CounterMiss" && Crossed(frame, frame2, 49))
			{
				guardStart = Time.time;
				visual.HoldAt(49f);
				fx.Guard(root.position, heading, 0f);
				Plugin.Trace("Blade Counter frontal guard open");
			}
			if (visual.Finished)
			{
				Finish();
			}
		}

		private void UpdateBasic(float dt)
		{
			//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)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: 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)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			string clip = visual.Clip;
			float frame = visual.Frame;
			bool flag = ((clip == "BasicRight" || clip == "BasicLeft") ? true : false);
			bool flag2 = flag;
			float num;
			switch (clip)
			{
			case "Draw":
				num = 9.4f;
				break;
			case "BasicIn":
				num = 7f;
				break;
			case "BasicRight":
			case "BasicLeft":
				num = ((frame < 9f && basicSwing == 1) ? 3.2f : 2.55f);
				break;
			case "BasicOutLeft":
			case "BasicOutRight":
				num = 2.9f;
				break;
			default:
				num = 3.8f;
				break;
			}
			float num2 = num;
			visual.Tick(dt, HasEvolution(1, 2) ? (num2 * (1f + danceBonus)) : num2);
			float frame2 = visual.Frame;
			if (flag2)
			{
				if (Crossed(frame, frame2, 9))
				{
					Vector3 val = Flat(player.PlaneRay.LookDirection());
					Vector3 normalized;
					if (!(((Vector3)(ref val)).sqrMagnitude > 0.001f))
					{
						Vector3 val2 = Flat(player.Controller.GetRotation() * Vector3.forward);
						normalized = ((Vector3)(ref val2)).normalized;
					}
					else
					{
						normalized = ((Vector3)(ref val)).normalized;
					}
					heading = normalized;
					visual.Root.rotation = Quaternion.LookRotation(heading, Vector3.up);
					Vector3 position = root.position;
					fx.FanSlash(position, heading, 4.7f, 130f);
					HitBasic(position, heading);
					TrySeveringWind(position, heading);
				}
				if (Crossed(frame, frame2, 18))
				{
					BeginBasicLunge();
				}
				SwordTrail(frame2 >= 4f && frame2 <= 17f, 0.22f);
			}
			if (!visual.Finished)
			{
				return;
			}
			switch (clip)
			{
			case "Draw":
				Play("BasicIn");
				break;
			case "BasicIn":
				StartBasicSwing(clockwise: true);
				break;
			case "BasicRight":
			case "BasicLeft":
				if (HasEvolution(1, 2))
				{
					danceBonus = BladeBalance.AddDance(danceBonus);
				}
				if (attackHeld)
				{
					StartBasicSwing(clip == "BasicLeft");
					break;
				}
				Plugin.Trace($"Blade D5 release after swing={basicSwing}");
				Play((clip == "BasicRight") ? "BasicOutLeft" : "BasicOutRight");
				break;
			case "BasicOutLeft":
			case "BasicOutRight":
				Play("Sheathe");
				break;
			default:
				Plugin.Trace($"Blade D5 fully sheathed after swing={basicSwing}");
				Finish();
				break;
			}
		}

		private void StartBasicSwing(bool clockwise)
		{
			basicSwing++;
			Play(clockwise ? "BasicRight" : "BasicLeft");
		}

		private void HitBasic(Vector3 origin, Vector3 direction)
		{
			//IL_004c: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			float value = Time.time - ((basicSwing == 1) ? basicStartedAt : basicLastStrikeAt);
			basicLastStrikeAt = Time.time;
			float num = Mathf.Cos((float)Math.PI * 13f / 18f);
			castVictims.Clear();
			castSpectris.Clear();
			int num2 = 0;
			foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(origin + Vector3.up * 0.55f, 5.7f, -1, (QueryTriggerInteraction)2))
			{
				if (!Object.op_Implicit((Object)(object)item))
				{
					continue;
				}
				NpcCharacter componentInParent = ((Component)item).GetComponentInParent<NpcCharacter>();
				if (!Object.op_Implicit((Object)(object)componentInParent))
				{
					HitSpectris(item, origin, direction, 4.7f, 260f, SkillDamage(1), castSpectris, checkRadius: true, checkHeight: true, "S1");
				}
				else
				{
					if (!componentInParent.IsActiveAndAlive || !componentInParent.CanTakeDamage || ((Il2CppObjectBase)componentInParent).TryCast<IEnemy>() == null)
					{
						continue;
					}
					int instanceID = ((Object)componentInParent).GetInstanceID();
					if (!castVictims.Add(instanceID))
					{
						continue;
					}
					Vector3 val = ((Component)componentInParent).transform.position - origin;
					Vector3 val2 = Flat(val);
					float magnitude = ((Vector3)(ref val2)).magnitude;
					float num3 = ((magnitude > 0.001f) ? Vector3.Dot(direction, val2 / magnitude) : 1f);
					float value2 = Mathf.Acos(Mathf.Clamp(num3, -1f, 1f)) * 57.29578f;
					if (magnitude > 4.7f || num3 < num || Mathf.Abs(val.y) > 1.6f)
					{
						Plugin.Trace($"Blade D5 miss swing={basicSwing}, target={instanceID}, angle={value2:F1}, range={magnitude:F2}, height={val.y:F2}");
						continue;
					}
					var (num4, num5, flag) = HitWithKatana(componentInParent, instanceID, 1);
					if (num5 >= num4)
					{
						Plugin.Trace($"Blade D5 no damage swing={basicSwing}, target={instanceID}, angle={value2:F1}, range={magnitude:F2}, hp={num4:F1}");
					}
					else
					{
						fx.BasicImpact(origin + val, direction);
						num2++;
						float value3 = Random.value;
						bool value4 = flag && value3 < (HasEvolution(1, 1) ? 0.15f : 0.05f) && ApplyBasicBleed(instanceID, componentInParent);
						Plugin.Trace($"Blade D5 hit swing={basicSwing}, target={instanceID}, angle={value2:F1}, range={magnitude:F2}, hp={num4:F1}->{num5:F1}, roll={value3:F4}, bleedRequested={value4}");
					}
				}
			}
			Plugin.Trace($"Blade D5 strike swing={basicSwing}, clip={visual.Clip}, held={attackHeld}, moving={moving}, origin={origin}, aim=({direction.x:F3},{direction.z:F3}), radius={4.7f:F2}, sector={260f:F0}, hits={num2}, interval={value:F3}s, t={Time.time:F3}");
		}

		private bool ApplyBasicBleed(int id, NpcCharacter enemy)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			IStatusEffectsHolder statusEffectsHolder = enemy.StatusEffectsHolder;
			EnemyStatusEffectsHolder val = ((statusEffectsHolder != null) ? ((Il2CppObjectBase)statusEffectsHolder).TryCast<EnemyStatusEffectsHolder>() : null);
			if (!Object.op_Implicit((Object)(object)val) || !((StatusEffectsHolder)val).CanReceiveEffect((StatusEffectType)5))
			{
				return false;
			}
			int stacksQuantity = ((StatusEffectsHolder)val).GetStacksQuantity((StatusEffectType)5, false);
			EnemyBleedingEffect val2 = new EnemyBleedingEffect(player, 6f);
			((StatusEffectsHolder)val).ClientAddEffect(((Il2CppObjectBase)val2).Cast<IStatusEffect>(), true, false);
			if (!wounds.TryGetValue(id, out var value))
			{
				value = new Bleed
				{
					Enemy = enemy,
					NextTick = Time.time + 1f
				};
				wounds.Add(id, value);
			}
			value.BasicStacksBefore = stacksQuantity;
			value.BasicConfirmBy = Time.time + 0.55f;
			ConfirmBasicBleed(id, value);
			return true;
		}

		private static void ConfirmBasicBleed(int id, Bleed wound)
		{
			if (!(wound.BasicConfirmBy <= 0f))
			{
				int stacksQuantity = wound.Enemy.StatusEffectsHolder.GetStacksQuantity((StatusEffectType)5, false);
				if (stacksQuantity > wound.BasicStacksBefore)
				{
					Plugin.Trace($"Blade D5 native bleed confirmed target={id}, stacks={wound.BasicStacksBefore}->{stacksQuantity}, duration={6f:F1}");
					wound.BasicUntil = Time.time + 6f;
					wound.BasicConfirmBy = 0f;
				}
				else if (Time.time >= wound.BasicConfirmBy)
				{
					Plugin.Trace($"Blade D5 native bleed unconfirmed target={id}, stacks={stacksQuantity}");
					wound.BasicConfirmBy = 0f;
				}
			}
		}

		private (float Before, float After, bool Alive) HitWithKatana(NpcCharacter enemy, int id, int slot)
		{
			//IL_0045: 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)
			float currentHealth = enemy.CurrentHealth;
			float num = KatanaDamage(enemy, id, slot);
			if (num <= 0f)
			{
				return (Before: currentHealth, After: currentHealth, Alive: true);
			}
			bool flag = BleedStacks(enemy, id) > 0 && Random.value < 0.25f;
			PlayableCharacterHitType val = (PlayableCharacterHitType)(slot != 1);
			DamageDealer.PlayerDealDamage(player, val, ((Component)enemy).gameObject, num, false, (HitPointInfo)null, (DamageType)1, true, flag, true, flag, false, false);
			bool flag2 = Object.op_Implicit((Object)(object)enemy) && enemy.IsActiveAndAlive;
			float num2 = (flag2 ? enemy.CurrentHealth : 0f);
			if (slot == 4 && num2 < currentHealth && HasEvolution(4, 1))
			{
				relentlessHits.TryGetValue(id, out var value);
				relentlessHits[id] = value + 1;
			}
			float heal = 0f;
			if (flag && num2 < currentHealth && Object.op_Implicit((Object)(object)player) && player.IsActiveAndAlive)
			{
				CharDataHealth healthData = player.Data.HealthData;
				float currentHealth2 = healthData.CurrentHealth;
				float num3 = currentHealth2 * 0.04f;
				healthData.ServerTakeHeal(num3, true, true, (HealType)0);
				if (DevJournal != null)
				{
					heal = Mathf.Max(0f, healthData.CurrentHealth - currentHealth2);
				}
				Plugin.Trace($"Blade D13 Open Wound S{slot}/{visual.Clip}: target={id}, enemyHp={currentHealth:F2}->{num2:F2}, bladeHp={currentHealth2:F2}->{healthData.CurrentHealth:F2}, requestedHeal={num3:F2}");
			}
			if (DevJournal != null)
			{
				DevRecordHit($"S{slot}/{visual.Clip}", currentHealth, num2, flag, heal);
			}
			return (Before: currentHealth, After: num2, Alive: flag2);
		}

		internal void UseNativeLocomotionFacing()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result typ