Decompiled source of SparkleEnemiesTweaks v1.0.19

plugins/SparkleEnemiesTweaks.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.BrotherMonster;
using EntityStates.TitanMonster;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.CharacterAI;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("SparkleEnemiesTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.19.0")]
[assembly: AssemblyInformationalVersion("1.0.19")]
[assembly: AssemblyProduct("SparkleEnemiesTweaks")]
[assembly: AssemblyTitle("SparkleEnemiesTweaks")]
[assembly: AssemblyVersion("1.0.19.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SparkleEnemiesTweaks
{
	internal static class MithrixAim
	{
		private const string HarmonyId = "com.sparkletwilight.sparkleenemiestweaks.mithrix";

		private static readonly Type[] NormalStates = new Type[2]
		{
			typeof(WeaponSlam),
			typeof(SprintBash)
		};

		private static readonly Type[] HurtStates = new Type[2]
		{
			typeof(FistSlam),
			typeof(SprintBashHurt)
		};

		private static readonly MethodInfo GetDirection = AccessTools.PropertyGetter(typeof(EntityState), "characterDirection");

		private static readonly MethodInfo GetState = AccessTools.PropertyGetter(typeof(EntityStateMachine), "state");

		private static readonly MethodInfo GetCustomTarget = AccessTools.PropertyGetter(typeof(BaseAI), "customTarget");

		private static readonly FieldInfo BufferedTarget = AccessTools.Field(typeof(BaseAI), "bufferedTarget");

		private static ManualLogSource _log;

		private static ConfigEntry<bool> _enabled;

		private static ConfigEntry<bool> _continuous;

		private static ConfigEntry<bool> _includeHurt;

		private static ConfigEntry<bool> _debug;

		private static ConfigEntry<float> _freezeDelay;

		private static int _errorCount;

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

		private static readonly Dictionary<int, Vector3> _frozen = new Dictionary<int, Vector3>();

		private static bool _tickStopped;

		private static BodyIndex _brotherIndex = (BodyIndex)(-1);

		private static BodyIndex _hurtIndex = (BodyIndex)(-1);

		private static bool _catalogChecked;

		internal static bool Enabled
		{
			get
			{
				if (_enabled != null)
				{
					return _enabled.Value;
				}
				return false;
			}
		}

		internal static bool DebugEnabled
		{
			get
			{
				if (_debug != null)
				{
					return _debug.Value;
				}
				return false;
			}
		}

		internal static void Init(ConfigFile config, ManualLogSource log)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			_log = log;
			_enabled = config.Bind<bool>("General", "Enabled", true, "总开关:关闭后米斯历克斯的挥锤朝向完全保持原版。");
			_continuous = config.Bind<bool>("Mithrix", "ContinuousTracking", true, "开启:技能释放后整个攻击过程中每帧重新对准当前仇恨目标(含蓄力期间目标移动)。\n关闭:只在进入技能状态的那一刻对准一次。");
			_includeHurt = config.Bind<bool>("Mithrix", "IncludeHurtForm", true, "是否同时作用于第四阶段失去锤子后的重砸(FistSlam)与挥击(SprintBashHurt)。");
			_debug = config.Bind<bool>("General", "DebugLog", false, "输出每次对准/无目标的调试日志,排查用。");
			_freezeDelay = config.Bind<float>("Mithrix", "FreezeDelay", 0.6f, "挥锤/重锤释放后允许继续跟随目标调整朝向的时长(秒);超过之后角度冻结,整个释放过程不再转动。设为 0 = 释放瞬间就冻结。ContinuousTracking 关闭时此项无效。");
			Harmony val = new Harmony("com.sparkletwilight.sparkleenemiestweaks.mithrix");
			MethodInfo methodInfo = AccessTools.Method(typeof(MithrixAim), "OnEnterPostfix", (Type[])null, (Type[])null);
			Type[] array = new Type[NormalStates.Length + HurtStates.Length];
			Array.Copy(NormalStates, 0, array, 0, NormalStates.Length);
			Array.Copy(HurtStates, 0, array, NormalStates.Length, HurtStates.Length);
			Type[] array2 = array;
			foreach (Type type in array2)
			{
				try
				{
					MethodInfo methodInfo2 = AccessTools.Method(type, "OnEnter", (Type[])null, (Type[])null);
					if (methodInfo2 == null)
					{
						_log.LogWarning((object)("找不到目标方法:" + type.FullName + ".OnEnter,该状态不会被修正。"));
						continue;
					}
					val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(methodInfo), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					_log.LogInfo((object)("补丁已挂载:" + type.FullName + ".OnEnter"));
				}
				catch (Exception ex)
				{
					_log.LogError((object)("挂载补丁失败:" + type.FullName + ".OnEnter —— " + ex));
				}
			}
		}

		public static void OnEnterPostfix(object __instance)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (!_enabled.Value || !NetworkServer.active || __instance == null)
			{
				return;
			}
			try
			{
				EntityState val = (EntityState)((__instance is EntityState) ? __instance : null);
				if (val == null || !IsTracked(((object)val).GetType()))
				{
					return;
				}
				EntityStateMachine outer = val.outer;
				CharacterBody val2 = (((Object)(object)outer != (Object)null) ? ((Component)outer).GetComponent<CharacterBody>() : null);
				if (!((Object)(object)val2 == (Object)null))
				{
					int instanceID = ((Object)val2).GetInstanceID();
					_castStart[instanceID] = Time.time;
					_frozen.Remove(instanceID);
					ForceFace(val);
					if (_freezeDelay != null && _freezeDelay.Value <= 0f && TryComputeDirection(val2, out var direction))
					{
						_frozen[instanceID] = direction;
					}
				}
			}
			catch (Exception e)
			{
				LogError("技能进入时对准失败", e);
			}
		}

		internal static void Tick()
		{
			if (!_enabled.Value || !_continuous.Value || _tickStopped || !NetworkServer.active)
			{
				return;
			}
			try
			{
				ReadOnlyCollection<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList;
				if (readOnlyInstancesList == null)
				{
					return;
				}
				for (int i = 0; i < readOnlyInstancesList.Count; i++)
				{
					CharacterBody val = readOnlyInstancesList[i];
					if ((Object)(object)val == (Object)null || !IsMithrix(val))
					{
						continue;
					}
					EntityStateMachine[] components = ((Component)val).GetComponents<EntityStateMachine>();
					int instanceID = ((Object)val).GetInstanceID();
					bool flag = false;
					foreach (EntityStateMachine val2 in components)
					{
						if (!((Object)(object)val2 == (Object)null) && !(GetState == null))
						{
							object? obj = GetState.Invoke(val2, null);
							EntityState val3 = (EntityState)((obj is EntityState) ? obj : null);
							if (val3 != null && IsTracked(((object)val3).GetType()))
							{
								flag = true;
								TickState(val, instanceID, val3);
							}
						}
					}
					if (!flag)
					{
						_castStart.Remove(instanceID);
						_frozen.Remove(instanceID);
					}
				}
			}
			catch (Exception ex)
			{
				_tickStopped = true;
				_log.LogError((object)("每帧跟踪出现异常,已停止持续跟踪(技能释放瞬间的对准仍然有效):" + ex));
			}
		}

		private static bool IsTracked(Type type)
		{
			for (int i = 0; i < NormalStates.Length; i++)
			{
				if (type == NormalStates[i])
				{
					return true;
				}
			}
			if (_includeHurt != null && _includeHurt.Value)
			{
				for (int j = 0; j < HurtStates.Length; j++)
				{
					if (type == HurtStates[j])
					{
						return true;
					}
				}
			}
			return false;
		}

		internal static bool IsMithrix(CharacterBody body)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			//IL_003b: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			string name = ((Object)body).name;
			if (!string.IsNullOrEmpty(name) && (name.StartsWith("BrotherBody", StringComparison.Ordinal) || name.StartsWith("BrotherHurtBody", StringComparison.Ordinal)))
			{
				return true;
			}
			EnsureBodyIndexes();
			if ((int)_brotherIndex != -1 && body.bodyIndex == _brotherIndex)
			{
				return true;
			}
			if ((int)_hurtIndex != -1 && body.bodyIndex == _hurtIndex)
			{
				return true;
			}
			return false;
		}

		private static void EnsureBodyIndexes()
		{
			//IL_000e: 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_001d: 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_002d: Invalid comparison between Unknown and I4
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			if (_catalogChecked)
			{
				return;
			}
			try
			{
				_brotherIndex = BodyCatalog.FindBodyIndex("BrotherBody");
				_hurtIndex = BodyCatalog.FindBodyIndex("BrotherHurtBody");
				_catalogChecked = (int)_brotherIndex != -1 || (int)_hurtIndex != -1;
			}
			catch (Exception)
			{
			}
		}

		private static void TickState(CharacterBody body, int key, EntityState state)
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			float num = ((_freezeDelay != null) ? _freezeDelay.Value : 0f);
			if (!_castStart.TryGetValue(key, out var value))
			{
				_castStart[key] = Time.time;
				ForceFace(state);
			}
			else if (num <= 0f || Time.time - value >= num)
			{
				if (!_frozen.TryGetValue(key, out var value2))
				{
					if (!TryComputeDirection(body, out value2))
					{
						ForceFace(state);
						return;
					}
					_frozen[key] = value2;
					if (_debug.Value && _log != null)
					{
						_log.LogInfo((object)("米斯历克斯 " + ((object)state).GetType().Name + " 释放 " + num.ToString("F2") + " 秒,朝向已冻结。"));
					}
				}
				ApplyDirection(state, value2);
			}
			else
			{
				ForceFace(state);
			}
		}

		private static void ForceFace(EntityState state)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			EntityStateMachine outer = state.outer;
			if (!((Object)(object)outer == (Object)null))
			{
				CharacterBody component = ((Component)outer).GetComponent<CharacterBody>();
				if (!((Object)(object)component == (Object)null) && TryComputeDirection(component, out var direction))
				{
					ApplyDirection(state, direction);
				}
			}
		}

		private static bool TryComputeDirection(CharacterBody body, out Vector3 direction)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			direction = Vector3.zero;
			if (!TryGetTargetPosition(body, out var position))
			{
				if (_debug.Value && _log != null)
				{
					_log.LogInfo((object)"米斯历克斯:当前没有仇恨目标,保持原版朝向。");
				}
				return false;
			}
			direction = position - ((Component)body).transform.position;
			direction.y = 0f;
			if (((Vector3)(ref direction)).sqrMagnitude < 0.0001f)
			{
				direction = Vector3.zero;
				return false;
			}
			((Vector3)(ref direction)).Normalize();
			return true;
		}

		private static void ApplyDirection(EntityState state, Vector3 direction)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			EntityStateMachine outer = state.outer;
			if ((Object)(object)outer == (Object)null)
			{
				return;
			}
			CharacterBody component = ((Component)outer).GetComponent<CharacterBody>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			CharacterDirection val = ((Component)outer).GetComponent<CharacterDirection>();
			if ((Object)(object)val == (Object)null && GetDirection != null)
			{
				object? obj = GetDirection.Invoke(state, null);
				val = (CharacterDirection)((obj is CharacterDirection) ? obj : null);
			}
			if (!((Object)(object)val == (Object)null))
			{
				float num = Vector3.Angle(val.forward, direction);
				val.forward = direction;
				val.moveVector = direction;
				if (_debug.Value && _log != null && num > 0.5f)
				{
					string text = (((Object)(object)component.master != (Object)null) ? ((Object)component.master).name : "?");
					_log.LogInfo((object)("米斯历克斯 " + ((object)state).GetType().Name + " 已对准 " + text + " 的目标,修正 " + num.ToString("F1") + " 度。"));
				}
			}
		}

		private static bool TryGetTargetPosition(CharacterBody body, out Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			position = Vector3.zero;
			CharacterMaster master = body.master;
			if ((Object)(object)master == (Object)null)
			{
				return false;
			}
			BaseAI val = ((Component)master).GetComponent<BaseAI>();
			if ((Object)(object)val == (Object)null)
			{
				IList<BaseAI> aiComponents = master.AiComponents;
				if (aiComponents != null && aiComponents.Count > 0)
				{
					val = aiComponents[0];
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			if (TryPosition(val.currentEnemy, out position))
			{
				return true;
			}
			if (GetCustomTarget != null && TryPosition(GetCustomTarget.Invoke(val, null), out position))
			{
				return true;
			}
			if (BufferedTarget != null && TryPosition(BufferedTarget.GetValue(val), out position))
			{
				return true;
			}
			return false;
		}

		private static bool TryPosition(object value, out Vector3 position)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Target val = (Target)((value is Target) ? value : null);
			if (val != null)
			{
				Vector3 val2 = default(Vector3);
				if (val.GetBullseyePosition(ref val2))
				{
					position = val2;
					return true;
				}
				if ((Object)(object)val.gameObject != (Object)null)
				{
					position = val.gameObject.transform.position;
					return true;
				}
			}
			Component val3 = (Component)((value is Component) ? value : null);
			if ((Object)(object)val3 != (Object)null)
			{
				position = val3.transform.position;
				return true;
			}
			GameObject val4 = (GameObject)((value is GameObject) ? value : null);
			if ((Object)(object)val4 != (Object)null)
			{
				position = val4.transform.position;
				return true;
			}
			position = Vector3.zero;
			return false;
		}

		private static void LogError(string context, Exception e)
		{
			if (_errorCount++ < 5 && _log != null)
			{
				_log.LogError((object)(context + ":" + e));
			}
		}
	}
	internal static class MithrixSkillControl
	{
		private struct ShiftPlan
		{
			public float tilt;

			public Vector3 direction;

			public float time;
		}

		private struct HammerRecoveryRecord
		{
			public EntityState state;

			public float start;

			public bool fired;
		}

		private const string HarmonyId = "com.sparkletwilight.sparkleenemiestweaks.skills";

		private const int ReasonSlow = 0;

		private const int ReasonHammerRecovery = 1;

		private const int ReasonDistance = 2;

		private const int ReasonCount = 3;

		private static readonly Type SlideBaseType = typeof(BaseSlideState);

		private static readonly Type SlideIntroType = typeof(SlideIntroState);

		private static readonly Type BashType = typeof(SprintBash);

		private static readonly Type BashHurtType = typeof(SprintBashHurt);

		private static readonly Type SlamType = typeof(WeaponSlam);

		private static readonly Type FistSlamType = typeof(FistSlam);

		private static readonly Type SkyLeapEnterType = typeof(EnterSkyLeap);

		private static readonly Type SkyLeapHoldType = typeof(HoldSkyLeap);

		private static readonly Type UltEnterType = typeof(UltEnterState);

		private static readonly Type MainStateType = typeof(GenericCharacterMain);

		private static readonly Type ShockwaveType = typeof(UltChannelState);

		private static readonly FieldInfo SlideDuration = AccessTools.Field(SlideBaseType, "duration");

		private static readonly FieldInfo SlideRotation = AccessTools.Field(SlideBaseType, "slideRotation");

		private static readonly FieldInfo MeleeTicks = AccessTools.Field(typeof(BasicMeleeAttack), "meleeAttackTicks");

		private static readonly FieldInfo BashPriorityDuration = AccessTools.Field(BashType, "durationBeforePriorityReduces");

		private static readonly MethodInfo GetFixedAge = AccessTools.PropertyGetter(typeof(EntityState), "fixedAge");

		private static readonly MethodInfo GetState = AccessTools.PropertyGetter(typeof(EntityStateMachine), "state");

		private static readonly MethodInfo GetSkillBody = AccessTools.PropertyGetter(typeof(GenericSkill), "characterBody");

		private static readonly FieldInfo JumpInputReceived = AccessTools.Field(MainStateType, "jumpInputReceived");

		private static ConfigEntry<float> _reasonCooldown;

		private static ConfigEntry<float> _distanceMin;

		private static ConfigEntry<float> _distanceMax;

		private static ConfigEntry<float> _tiltRecoveryMin;

		private static ConfigEntry<float> _tiltRecoveryMax;

		private static ConfigEntry<float> _tiltDistanceMin;

		private static ConfigEntry<float> _tiltDistanceMax;

		private static ConfigEntry<float> _recoveryReduction;

		private static ConfigEntry<float> _recoveryShare;

		private static ConfigEntry<float> _slowThreshold;

		private static ConfigEntry<float> _m2MaxDistance;

		private static ConfigEntry<float> _maxHeightAbove;

		private static ConfigEntry<float> _jumpMaxDistance;

		private static ConfigEntry<float> _jumpCooldown;

		private static ConfigEntry<float> _jumpSwingLockout;

		private static ConfigEntry<float> _hammerRecoveryDelay;

		private static ConfigEntry<float> _castLockout;

		private static ManualLogSource _log;

		private static int _errorCount;

		private static bool _tickStopped;

		private static bool _forcing;

		private static GenericSkill _forcingSkill;

		private static readonly Dictionary<int, ShiftPlan> _pending = new Dictionary<int, ShiftPlan>();

		private static readonly Dictionary<int, ShiftPlan> _active = new Dictionary<int, ShiftPlan>();

		private static readonly Dictionary<int, float[]> _lastUsed = new Dictionary<int, float[]>();

		private static readonly Dictionary<int, HammerRecoveryRecord> _recoveries = new Dictionary<int, HammerRecoveryRecord>();

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

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

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

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

		internal static void Init(ConfigFile config, ManualLogSource log)
		{
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Expected O, but got Unknown
			_log = log;
			_reasonCooldown = config.Bind<float>("Shift", "ReasonCooldown", 2f, "同一个理由两次使用之间的最小间隔(秒)。默认 2 秒。");
			_distanceMin = config.Bind<float>("Shift", "DistanceMin", 40f, "「距离仇恨目标」理由的最小距离(米)。");
			_distanceMax = config.Bind<float>("Shift", "DistanceMax", 70f, "「距离仇恨目标」理由的最大距离(米)。");
			_tiltRecoveryMin = config.Bind<float>("Shift", "TiltRecoveryMin", 30f, "挥锤后摇理由的倾斜角下限(度),左右随机。");
			_tiltRecoveryMax = config.Bind<float>("Shift", "TiltRecoveryMax", 60f, "挥锤后摇理由的倾斜角上限(度),左右随机。");
			_tiltDistanceMin = config.Bind<float>("Shift", "TiltDistanceMin", 0f, "距离理由的倾斜角下限(度),左右随机。");
			_tiltDistanceMax = config.Bind<float>("Shift", "TiltDistanceMax", 30f, "距离理由的倾斜角上限(度),左右随机。");
			_recoveryReduction = config.Bind<float>("Shift", "RecoveryReduction", 0.5f, "闪身后摇缩减比例。0.5 = 后摇减半;设为 0 关闭。");
			_recoveryShare = config.Bind<float>("Shift", "RecoveryShare", 0.5f, "后摇占整个滑步状态尾段的比例。0.5 = 状态后半段视为后摇;设 1 则等价于整个状态时长按缩减比例缩短。");
			_slowThreshold = config.Bind<float>("Shift", "SlowSpeedThreshold", 0.02f, "当前移速低于「基础移速×奔跑倍率」多少比例才算「移速低于预期」。");
			_m2MaxDistance = config.Bind<float>("Hammer", "M2MaxDistance", 40f, "M2 挥锤允许使用的最大距离(米)。");
			_maxHeightAbove = config.Bind<float>("Hammer", "MaxHeightAbove", 13f, "挥锤与非奔跑重锤允许的「目标高出自身」最大高度差(米),也是触发普通跳跃的起始高度差:目标高出不超过此值用锤,超过此值且距离足够近时尝试普通跳跃(按空格)。目标比自身低不受限;设为 0 关闭全部高度相关机制。");
			_jumpMaxDistance = config.Bind<float>("Jump", "MaxDistance", 40f, "目标高出自身超过上限时,尝试普通跳跃所需的最大距离(米,3D 直线距离)。注意:这是按空格的普通跳跃,不是 R 飞跃技能。");
			_jumpCooldown = config.Bind<float>("Jump", "Cooldown", 5f, "两次普通跳跃之间的最小间隔(秒)。设为 0 关闭跳跃。");
			_jumpSwingLockout = config.Bind<float>("Jump", "SwingLockout", 2f, "主动跳跃后禁用 M2 挥锤的时长(秒);同一窗口内一旦目标高出自身不超过 MaxHeightAbove,立刻强制使用非奔跑 M1 重锤。设为 0 关闭这套跳跃后续逻辑。");
			_hammerRecoveryDelay = config.Bind<float>("Shift", "HammerRecoveryDelay", 1f, "挥锤后摇开始后,延迟多少秒才允许用闪身取消后摇。默认 1 秒;设为 0 回到 1.0.1 的立即取消。");
			_castLockout = config.Bind<float>("Shift", "PostCastLockout", 3f, "释放 R(飞跃)或 M1 重锤后禁止使用闪身的时长(秒)。默认 3 秒;设为 0 关闭。");
			Harmony harmony = new Harmony("com.sparkletwilight.sparkleenemiestweaks.skills");
			Patch(harmony, typeof(GenericSkill), "CanExecute", "CanExecutePrefix", isPrefix: true);
			Patch(harmony, typeof(GenericSkill), "IsReady", "IsReadyPrefix", isPrefix: true);
			Patch(harmony, typeof(EntityStateMachine), "CanInterruptState", "ForceInterruptPrefix", isPrefix: true);
			Patch(harmony, SlideIntroType, "OnEnter", "SlideIntroPostfix", isPrefix: false);
			Patch(harmony, SlideBaseType, "OnEnter", "SlideEnterPostfix", isPrefix: false);
			Patch(harmony, SlideBaseType, "FixedUpdate", "SlideFixedUpdatePostfix", isPrefix: false);
			Patch(harmony, MainStateType, "ProcessJump", "JumpPulsePrefix", isPrefix: true, new Type[1] { typeof(bool) });
			Patch(harmony, typeof(GenericSkill), "ExecuteIfReady", "SpecialExecutedPostfix", isPrefix: false);
			Patch(harmony, SkyLeapEnterType, "OnEnter", "ProtectedCastPostfix", isPrefix: false);
			Patch(harmony, SkyLeapHoldType, "OnEnter", "ProtectedCastPostfix", isPrefix: false);
			Patch(harmony, UltEnterType, "OnEnter", "ProtectedCastPostfix", isPrefix: false);
			Patch(harmony, SlamType, "OnEnter", "ProtectedCastPostfix", isPrefix: false);
			Patch(harmony, FistSlamType, "OnEnter", "ProtectedCastPostfix", isPrefix: false);
		}

		private static void Patch(Harmony harmony, Type type, string methodName, string patchName, bool isPrefix, Type[] parameters = null)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = ((parameters == null) ? AccessTools.Method(type, methodName, (Type[])null, (Type[])null) : AccessTools.Method(type, methodName, parameters, (Type[])null));
				MethodInfo methodInfo2 = AccessTools.Method(typeof(MithrixSkillControl), patchName, (Type[])null, (Type[])null);
				if (methodInfo == null || methodInfo2 == null)
				{
					_log.LogWarning((object)("找不到补丁目标:" + type.FullName + "." + methodName + " / " + patchName));
					return;
				}
				HarmonyMethod val = new HarmonyMethod(methodInfo2);
				if (isPrefix)
				{
					harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				_log.LogInfo((object)("补丁已挂载:" + type.FullName + "." + methodName + " ← " + patchName));
			}
			catch (Exception ex)
			{
				_log.LogError((object)("挂载补丁失败:" + type.FullName + "." + methodName + " —— " + ex));
			}
		}

		public static bool CanExecutePrefix(GenericSkill __instance, ref bool __result)
		{
			if (!MithrixAim.Enabled || !NetworkServer.active)
			{
				return true;
			}
			if (_forcing && __instance == _forcingSkill)
			{
				CharacterBody body = GetBody(__instance);
				if ((Object)(object)body != (Object)null && IsShiftLocked(body))
				{
					SkillLocator component = ((Component)body).GetComponent<SkillLocator>();
					if ((Object)(object)component != (Object)null && __instance == component.utility)
					{
						__result = false;
						return false;
					}
				}
				return true;
			}
			if (!IsBlocked(__instance))
			{
				return true;
			}
			__result = false;
			return false;
		}

		public static bool IsReadyPrefix(GenericSkill __instance, ref bool __result)
		{
			if (!MithrixAim.Enabled || !NetworkServer.active)
			{
				return true;
			}
			if (_forcing && __instance == _forcingSkill)
			{
				return true;
			}
			if (!IsBlocked(__instance))
			{
				return true;
			}
			__result = false;
			return false;
		}

		private static bool IsBlocked(GenericSkill skill)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)skill == (Object)null)
			{
				return false;
			}
			CharacterBody body = GetBody(skill);
			if ((Object)(object)body == (Object)null || !MithrixAim.IsMithrix(body))
			{
				return false;
			}
			SkillLocator component = ((Component)body).GetComponent<SkillLocator>();
			if ((Object)(object)component == (Object)null)
			{
				return false;
			}
			if (InShockwave(body))
			{
				return true;
			}
			if (skill == component.utility)
			{
				return true;
			}
			Vector3 position;
			float distance;
			bool flag = TryGetTarget(body, out position, out distance);
			float heightAbove = (flag ? (position.y - body.corePosition.y) : 0f);
			if (skill == component.secondary)
			{
				if (JumpSwingLocked(body))
				{
					return true;
				}
				if (!flag)
				{
					return true;
				}
				if (distance > _m2MaxDistance.Value)
				{
					return true;
				}
				if (HeightBlocks(heightAbove))
				{
					return true;
				}
				return false;
			}
			if (skill == component.primary)
			{
				if (body.isSprinting)
				{
					return false;
				}
				if (flag && HeightBlocks(heightAbove))
				{
					return true;
				}
				if (HammerSwingAvailable(component, flag, distance, heightAbove))
				{
					return true;
				}
				return false;
			}
			return false;
		}

		private static bool HeightBlocks(float heightAbove)
		{
			float value = _maxHeightAbove.Value;
			if (value > 0f)
			{
				return heightAbove > value;
			}
			return false;
		}

		private static bool InShockwave(CharacterBody body)
		{
			if ((Object)(object)body == (Object)null || GetState == null)
			{
				return false;
			}
			EntityStateMachine[] components = ((Component)body).GetComponents<EntityStateMachine>();
			foreach (EntityStateMachine val in components)
			{
				if (!((Object)(object)val == (Object)null))
				{
					object? obj = GetState.Invoke(val, null);
					EntityState val2 = (EntityState)((obj is EntityState) ? obj : null);
					if (val2 != null && ShockwaveType.IsInstanceOfType(val2))
					{
						return true;
					}
				}
			}
			return false;
		}

		private static bool HammerSwingAvailable(SkillLocator locator, bool hasTarget, float distance, float heightAbove)
		{
			GenericSkill secondary = locator.secondary;
			if ((Object)(object)secondary == (Object)null || !hasTarget)
			{
				return false;
			}
			if (JumpSwingLocked(((Component)locator).GetComponent<CharacterBody>()))
			{
				return false;
			}
			if (distance > _m2MaxDistance.Value || HeightBlocks(heightAbove))
			{
				return false;
			}
			if (secondary.stock > 0)
			{
				return secondary.cooldownRemaining <= 0.01f;
			}
			return false;
		}

		private static bool JumpSwingLocked(CharacterBody body)
		{
			float value = _jumpSwingLockout.Value;
			if ((Object)(object)body == (Object)null || value <= 0f)
			{
				return false;
			}
			if (_lastJump.TryGetValue(((Object)body).GetInstanceID(), out var value2))
			{
				return Time.time - value2 < value;
			}
			return false;
		}

		private static CharacterBody GetBody(GenericSkill skill)
		{
			CharacterBody component = ((Component)skill).GetComponent<CharacterBody>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
			if (GetSkillBody == null)
			{
				return null;
			}
			try
			{
				object? obj = GetSkillBody.Invoke(skill, null);
				return (CharacterBody)((obj is CharacterBody) ? obj : null);
			}
			catch (Exception)
			{
				return null;
			}
		}

		public static bool ForceInterruptPrefix(EntityStateMachine __instance, EntityState __0, ref bool __result)
		{
			if (!NetworkServer.active)
			{
				return true;
			}
			if (_forcing)
			{
				__result = true;
				return false;
			}
			if ((Object)(object)__instance == (Object)null || __0 == null || GetState == null)
			{
				return true;
			}
			object? obj = GetState.Invoke(__instance, null);
			EntityState val = (EntityState)((obj is EntityState) ? obj : null);
			if (val == null || !ShockwaveType.IsInstanceOfType(val))
			{
				return true;
			}
			if (ShockwaveType.IsInstanceOfType(__0))
			{
				return true;
			}
			__result = false;
			return false;
		}

		public static void JumpPulsePrefix(object __instance)
		{
			if (!MithrixAim.Enabled || !NetworkServer.active || _jumpPending.Count == 0 || JumpInputReceived == null)
			{
				return;
			}
			try
			{
				EntityState val = (EntityState)((__instance is EntityState) ? __instance : null);
				if (val == null || (Object)(object)val.outer == (Object)null)
				{
					return;
				}
				CharacterBody component = ((Component)val.outer).GetComponent<CharacterBody>();
				if ((Object)(object)component == (Object)null || !MithrixAim.IsMithrix(component))
				{
					return;
				}
				int instanceID = ((Object)component).GetInstanceID();
				if (!_jumpPending.TryGetValue(instanceID, out var value))
				{
					return;
				}
				_jumpPending.Remove(instanceID);
				if (!(Time.time - value > 0.5f))
				{
					JumpInputReceived.SetValue(val, true);
					_lastJump[instanceID] = Time.time;
					_jumpHammerPending[instanceID] = Time.time;
					if (MithrixAim.DebugEnabled && _log != null)
					{
						_log.LogInfo((object)"米斯历克斯普通跳跃:已注入一次空格按下(不是 R 飞跃)。");
					}
				}
			}
			catch (Exception e)
			{
				LogError("跳跃脉冲注入失败", e);
			}
		}

		public static void SpecialExecutedPostfix(GenericSkill __instance, bool __result)
		{
			if (!__result || !MithrixAim.Enabled || !NetworkServer.active)
			{
				return;
			}
			try
			{
				CharacterBody body = GetBody(__instance);
				if (!((Object)(object)body == (Object)null) && MithrixAim.IsMithrix(body))
				{
					SkillLocator component = ((Component)body).GetComponent<SkillLocator>();
					if (!((Object)(object)component == (Object)null) && __instance == component.special)
					{
						MarkProtectedCast(body);
					}
				}
			}
			catch (Exception e)
			{
				LogError("R 释放记录失败", e);
			}
		}

		public static void ProtectedCastPostfix(object __instance)
		{
			if (!MithrixAim.Enabled || !NetworkServer.active)
			{
				return;
			}
			try
			{
				EntityState val = (EntityState)((__instance is EntityState) ? __instance : null);
				if (val != null && !((Object)(object)val.outer == (Object)null))
				{
					CharacterBody component = ((Component)val.outer).GetComponent<CharacterBody>();
					if (!((Object)(object)component == (Object)null) && MithrixAim.IsMithrix(component))
					{
						MarkProtectedCast(component);
					}
				}
			}
			catch (Exception e)
			{
				LogError("施法锁定记录失败", e);
			}
		}

		private static void MarkProtectedCast(CharacterBody body)
		{
			int instanceID = ((Object)body).GetInstanceID();
			if (!_lastProtectedCast.TryGetValue(instanceID, out var value) || !(Time.time - value < _castLockout.Value))
			{
				_lastProtectedCast[instanceID] = Time.time;
				if (MithrixAim.DebugEnabled && _log != null)
				{
					_log.LogInfo((object)("米斯历克斯释放 R / 重锤:闪身锁定 " + _castLockout.Value.ToString("F1") + " 秒。"));
				}
			}
		}

		private static bool IsShiftLocked(CharacterBody body)
		{
			if ((Object)(object)body == (Object)null || _castLockout.Value <= 0f)
			{
				return false;
			}
			if (_lastProtectedCast.TryGetValue(((Object)body).GetInstanceID(), out var value))
			{
				return Time.time - value < _castLockout.Value;
			}
			return false;
		}

		public static void SlideIntroPostfix(object __instance)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (!MithrixAim.Enabled || !NetworkServer.active)
			{
				return;
			}
			try
			{
				EntityState val = (EntityState)((__instance is EntityState) ? __instance : null);
				if (val == null || (Object)(object)val.outer == (Object)null)
				{
					return;
				}
				CharacterBody component = ((Component)val.outer).GetComponent<CharacterBody>();
				if ((Object)(object)component == (Object)null || !MithrixAim.IsMithrix(component))
				{
					return;
				}
				int instanceID = ((Object)component).GetInstanceID();
				if (_pending.TryGetValue(instanceID, out var value))
				{
					if (Time.time - value.time > 2f)
					{
						_pending.Remove(instanceID);
						return;
					}
					val.outer.SetNextState((EntityState)new SlideForwardState());
					ApplyDirection(val.outer, value.direction);
				}
			}
			catch (Exception e)
			{
				LogError("闪身前奏处理失败", e);
			}
		}

		public static void SlideEnterPostfix(object __instance)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (!MithrixAim.Enabled || !NetworkServer.active)
			{
				return;
			}
			try
			{
				EntityState val = (EntityState)((__instance is EntityState) ? __instance : null);
				if (val == null || (Object)(object)val.outer == (Object)null)
				{
					return;
				}
				CharacterBody component = ((Component)val.outer).GetComponent<CharacterBody>();
				if ((Object)(object)component == (Object)null || !MithrixAim.IsMithrix(component))
				{
					return;
				}
				int instanceID = ((Object)component).GetInstanceID();
				if (!_pending.TryGetValue(instanceID, out var value))
				{
					return;
				}
				_pending.Remove(instanceID);
				if (!(Time.time - value.time > 2f))
				{
					_active[instanceID] = value;
					ApplyTilt(val, value.tilt);
					ApplyDirection(val.outer, value.direction);
					if (MithrixAim.DebugEnabled)
					{
						_log.LogInfo((object)("米斯历克斯闪身:倾斜 " + value.tilt.ToString("F1") + " 度。"));
					}
				}
			}
			catch (Exception e)
			{
				LogError("滑步进入处理失败", e);
			}
		}

		public static void SlideFixedUpdatePostfix(object __instance)
		{
			if (!MithrixAim.Enabled || !NetworkServer.active)
			{
				return;
			}
			try
			{
				float num = Mathf.Clamp01(_recoveryReduction.Value);
				if (num <= 0f || SlideDuration == null || GetFixedAge == null)
				{
					return;
				}
				float num2 = (float)SlideDuration.GetValue(null);
				if (num2 <= 0f)
				{
					return;
				}
				float num3 = Mathf.Clamp01(_recoveryShare.Value);
				float num4 = 1f - num3 * num;
				if (num4 <= 0f || num4 >= 1f)
				{
					return;
				}
				EntityState val = (EntityState)((__instance is EntityState) ? __instance : null);
				if (val != null && !((Object)(object)val.outer == (Object)null) && !((float)GetFixedAge.Invoke(val, null) < num2 * num4))
				{
					EntityStateMachine outer = val.outer;
					if (!outer.HasPendingState())
					{
						outer.SetNextStateToMain();
					}
				}
			}
			catch (Exception e)
			{
				LogError("闪身后摇处理失败", e);
			}
		}

		private static void ApplyTilt(EntityState state, float tilt)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (!(SlideRotation == null))
			{
				SlideRotation.SetValue(state, Quaternion.AngleAxis(tilt, Vector3.up));
			}
		}

		private static void ApplyDirection(EntityStateMachine machine, Vector3 direction)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)machine == (Object)null) && !(((Vector3)(ref direction)).sqrMagnitude < 0.0001f))
			{
				CharacterDirection component = ((Component)machine).GetComponent<CharacterDirection>();
				if (!((Object)(object)component == (Object)null))
				{
					component.forward = direction;
					component.moveVector = direction;
				}
			}
		}

		internal static void Tick()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			if (!MithrixAim.Enabled || _tickStopped || !NetworkServer.active)
			{
				return;
			}
			try
			{
				ReadOnlyCollection<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList;
				if (readOnlyInstancesList == null)
				{
					return;
				}
				for (int i = 0; i < readOnlyInstancesList.Count; i++)
				{
					CharacterBody val = readOnlyInstancesList[i];
					if ((Object)(object)val == (Object)null || !MithrixAim.IsMithrix(val))
					{
						continue;
					}
					Vector3 position;
					float distance;
					bool flag = TryGetTarget(val, out position, out distance);
					Vector3 direction = (flag ? Horizontal(val.corePosition, position) : Vector3.zero);
					int instanceID = ((Object)val).GetInstanceID();
					if (InShockwave(val))
					{
						_pending.Remove(instanceID);
						_active.Remove(instanceID);
						_jumpPending.Remove(instanceID);
						_jumpHammerPending.Remove(instanceID);
						continue;
					}
					float heightAbove = (flag ? (position.y - val.corePosition.y) : 0f);
					TryConditionalJump(instanceID, flag, distance, heightAbove);
					TryHammerAfterJump(val, instanceID, flag, heightAbove);
					float[] lastUsed = GetLastUsed(instanceID);
					EvaluateHammerRecovery(val, instanceID, lastUsed, out var armed, out var pending);
					bool num = IsShiftLocked(val);
					int num2 = -1;
					float tilt = 0f;
					if (!num)
					{
						bool flag2 = IsSlowed(val);
						if (armed)
						{
							num2 = 1;
							tilt = RandomTilt(_tiltRecoveryMin.Value, _tiltRecoveryMax.Value);
						}
						else if (!pending && flag2 && ReasonReady(lastUsed, 0))
						{
							num2 = 0;
							tilt = 0f;
						}
						else if (!pending && flag && distance >= _distanceMin.Value && distance <= _distanceMax.Value && ReasonReady(lastUsed, 2))
						{
							num2 = 2;
							tilt = RandomTilt(_tiltDistanceMin.Value, _tiltDistanceMax.Value);
						}
					}
					if (num2 >= 0 && ((Vector3)(ref direction)).sqrMagnitude > 0.0001f)
					{
						TryForceShift(val, instanceID, lastUsed, num2, tilt, direction, distance);
					}
					MaintainActiveShift(val, instanceID, direction);
				}
				CleanupStalePlans();
			}
			catch (Exception ex)
			{
				_tickStopped = true;
				if (_log != null)
				{
					_log.LogError((object)("技能条件控制每帧逻辑异常,已停止:" + ex));
				}
			}
		}

		private static void TryConditionalJump(int key, bool hasTarget, float distance, float heightAbove)
		{
			float value = _jumpCooldown.Value;
			float value2 = _maxHeightAbove.Value;
			if (!(value <= 0f) && !(value2 <= 0f) && hasTarget && !(heightAbove <= value2) && !(distance > _jumpMaxDistance.Value) && !_jumpPending.ContainsKey(key) && (!_lastJump.TryGetValue(key, out var value3) || !(Time.time - value3 < value)))
			{
				_jumpPending[key] = Time.time;
				if (MithrixAim.DebugEnabled && _log != null)
				{
					_log.LogInfo((object)("米斯历克斯尝试普通跳跃:目标高出 " + heightAbove.ToString("F1") + "m,距离 " + distance.ToString("F1") + "m,已排队空格按下。"));
				}
			}
		}

		private static void TryHammerAfterJump(CharacterBody body, int key, bool hasTarget, float heightAbove)
		{
			float value = _jumpSwingLockout.Value;
			if (!_jumpHammerPending.TryGetValue(key, out var value2))
			{
				return;
			}
			if (value <= 0f || !hasTarget || Time.time - value2 > value)
			{
				_jumpHammerPending.Remove(key);
			}
			else
			{
				if (HeightBlocks(heightAbove))
				{
					return;
				}
				SkillLocator component = ((Component)body).GetComponent<SkillLocator>();
				if ((Object)(object)component == (Object)null || (Object)(object)component.primary == (Object)null)
				{
					return;
				}
				GenericSkill primary = component.primary;
				if (primary.stock <= 0 || primary.cooldownRemaining > 0.01f)
				{
					return;
				}
				bool isSprinting = body.isSprinting;
				_forcing = true;
				_forcingSkill = primary;
				bool flag;
				try
				{
					body.isSprinting = false;
					flag = primary.ExecuteIfReady();
				}
				finally
				{
					body.isSprinting = isSprinting;
					_forcing = false;
					_forcingSkill = null;
				}
				if (flag)
				{
					_jumpHammerPending.Remove(key);
					if (MithrixAim.DebugEnabled && _log != null)
					{
						_log.LogInfo((object)("跳跃后目标高度已达标,立刻使用重锤:高出 " + heightAbove.ToString("F1") + "m。"));
					}
				}
			}
		}

		private static void TryForceShift(CharacterBody body, int key, float[] used, int reason, float tilt, Vector3 direction, float distance)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if (InShockwave(body) || IsShiftLocked(body))
			{
				return;
			}
			SkillLocator component = ((Component)body).GetComponent<SkillLocator>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.utility == (Object)null)
			{
				return;
			}
			GenericSkill utility = component.utility;
			if (utility.stock <= 0 || utility.cooldownRemaining > 0.01f)
			{
				return;
			}
			_pending[key] = new ShiftPlan
			{
				tilt = tilt,
				direction = direction,
				time = Time.time
			};
			_forcing = true;
			_forcingSkill = utility;
			bool flag;
			try
			{
				flag = utility.ExecuteIfReady();
			}
			finally
			{
				_forcing = false;
				_forcingSkill = null;
			}
			if (!flag)
			{
				_pending.Remove(key);
				return;
			}
			used[reason] = Time.time;
			if (reason == 1)
			{
				MarkRecoveryFired(key);
			}
			if (MithrixAim.DebugEnabled && _log != null)
			{
				string[] array = new string[3]
				{
					"移速低于预期",
					"挥锤后摇",
					"距离 " + _distanceMin.Value.ToString("F0") + "~" + _distanceMax.Value.ToString("F0") + "m"
				};
				_log.LogInfo((object)("米斯历克斯闪身已强制触发:理由「" + array[reason] + "」,距离 " + (float.IsInfinity(distance) ? (-1f) : distance).ToString("F1") + "m,倾斜 " + tilt.ToString("F1") + " 度。"));
			}
		}

		private static void MaintainActiveShift(CharacterBody body, int key, Vector3 direction)
		{
			//IL_007a: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			if (!_active.TryGetValue(key, out var value))
			{
				return;
			}
			bool flag = false;
			EntityStateMachine[] components = ((Component)body).GetComponents<EntityStateMachine>();
			foreach (EntityStateMachine val in components)
			{
				if ((Object)(object)val == (Object)null || GetState == null)
				{
					continue;
				}
				object? obj = GetState.Invoke(val, null);
				EntityState val2 = (EntityState)((obj is EntityState) ? obj : null);
				if (val2 != null && SlideBaseType.IsInstanceOfType(val2))
				{
					flag = true;
					if (((Vector3)(ref direction)).sqrMagnitude > 0.0001f)
					{
						value.direction = direction;
					}
					ApplyDirection(val, value.direction);
					ApplyTilt(val2, value.tilt);
				}
			}
			if (!flag)
			{
				_active.Remove(key);
			}
			else
			{
				_active[key] = value;
			}
		}

		private static void CleanupStalePlans()
		{
			if (_pending.Count > 0)
			{
				List<int> list = new List<int>();
				foreach (KeyValuePair<int, ShiftPlan> item in _pending)
				{
					if (Time.time - item.Value.time > 2f)
					{
						list.Add(item.Key);
					}
				}
				for (int i = 0; i < list.Count; i++)
				{
					_pending.Remove(list[i]);
				}
			}
			if (_active.Count > 0)
			{
				List<int> list2 = new List<int>();
				foreach (KeyValuePair<int, ShiftPlan> item2 in _active)
				{
					if (Time.time - item2.Value.time > 10f)
					{
						list2.Add(item2.Key);
					}
				}
				for (int j = 0; j < list2.Count; j++)
				{
					_active.Remove(list2[j]);
				}
			}
			float num = Mathf.Max(0f, _hammerRecoveryDelay.Value) + Mathf.Max(1f, _reasonCooldown.Value) + 2f;
			if (_recoveries.Count > 0)
			{
				List<int> list3 = new List<int>();
				foreach (KeyValuePair<int, HammerRecoveryRecord> recovery in _recoveries)
				{
					if (Time.time - recovery.Value.start > num)
					{
						list3.Add(recovery.Key);
					}
				}
				for (int k = 0; k < list3.Count; k++)
				{
					_recoveries.Remove(list3[k]);
				}
			}
			if (_lastProtectedCast.Count > 0)
			{
				List<int> list4 = new List<int>();
				foreach (KeyValuePair<int, float> item3 in _lastProtectedCast)
				{
					if (Time.time - item3.Value > Mathf.Max(3f, _castLockout.Value) + 10f)
					{
						list4.Add(item3.Key);
					}
				}
				for (int l = 0; l < list4.Count; l++)
				{
					_lastProtectedCast.Remove(list4[l]);
				}
			}
			if (_lastJump.Count > 0)
			{
				List<int> list5 = new List<int>();
				foreach (KeyValuePair<int, float> item4 in _lastJump)
				{
					if (Time.time - item4.Value > Mathf.Max(5f, _jumpCooldown.Value) + 10f)
					{
						list5.Add(item4.Key);
					}
				}
				for (int m = 0; m < list5.Count; m++)
				{
					_lastJump.Remove(list5[m]);
				}
			}
			if (_jumpPending.Count > 0)
			{
				List<int> list6 = new List<int>();
				foreach (KeyValuePair<int, float> item5 in _jumpPending)
				{
					if (Time.time - item5.Value > 1f)
					{
						list6.Add(item5.Key);
					}
				}
				for (int n = 0; n < list6.Count; n++)
				{
					_jumpPending.Remove(list6[n]);
				}
			}
			if (_jumpHammerPending.Count <= 0)
			{
				return;
			}
			float num2 = Mathf.Max(0f, _jumpSwingLockout.Value) + 2f;
			List<int> list7 = new List<int>();
			foreach (KeyValuePair<int, float> item6 in _jumpHammerPending)
			{
				if (Time.time - item6.Value > num2)
				{
					list7.Add(item6.Key);
				}
			}
			for (int num3 = 0; num3 < list7.Count; num3++)
			{
				_jumpHammerPending.Remove(list7[num3]);
			}
		}

		private static float[] GetLastUsed(int key)
		{
			if (!_lastUsed.TryGetValue(key, out var value))
			{
				value = new float[3];
				for (int i = 0; i < value.Length; i++)
				{
					value[i] = -999f;
				}
				_lastUsed[key] = value;
			}
			return value;
		}

		private static bool ReasonReady(float[] used, int reason)
		{
			return Time.time - used[reason] >= _reasonCooldown.Value;
		}

		private static float RandomTilt(float min, float max)
		{
			float num = Mathf.Min(min, max);
			float num2 = Mathf.Max(min, max);
			float num3 = Random.Range(num, num2);
			if (!(Random.value < 0.5f))
			{
				return num3;
			}
			return 0f - num3;
		}

		private static bool IsSlowed(CharacterBody body)
		{
			float num = (body.isSprinting ? Mathf.Max(1f, body.sprintingSpeedMultiplier) : 1f);
			float num2 = body.baseMoveSpeed * num;
			if (num2 <= 0f)
			{
				return false;
			}
			return body.moveSpeed < num2 * (1f - Mathf.Clamp01(_slowThreshold.Value));
		}

		private static void TrackHammerRecovery(CharacterBody body, int key)
		{
			if (GetState == null)
			{
				return;
			}
			EntityStateMachine[] components = ((Component)body).GetComponents<EntityStateMachine>();
			foreach (EntityStateMachine val in components)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				object? obj = GetState.Invoke(val, null);
				EntityState val2 = (EntityState)((obj is EntityState) ? obj : null);
				if (val2 == null)
				{
					continue;
				}
				Type type = ((object)val2).GetType();
				if (type != BashType && type != BashHurtType)
				{
					continue;
				}
				if (((MeleeTicks != null && (int)MeleeTicks.GetValue(val2) != 0) ? 1 : 0) > (false ? 1 : 0))
				{
					float num = ((GetFixedAge != null) ? ((float)GetFixedAge.Invoke(val2, null)) : 0f);
					float num2 = ((BashPriorityDuration != null) ? ((float)BashPriorityDuration.GetValue(null)) : 0f);
					if (num2 <= 0f)
					{
						num2 = 0.3f;
					}
					if (!(num < num2) && (!_recoveries.TryGetValue(key, out var value) || value.state != val2))
					{
						_recoveries[key] = new HammerRecoveryRecord
						{
							state = val2,
							start = Time.time,
							fired = false
						};
					}
				}
				break;
			}
		}

		private static void EvaluateHammerRecovery(CharacterBody body, int key, float[] used, out bool armed, out bool pending)
		{
			armed = false;
			pending = false;
			TrackHammerRecovery(body, key);
			if (!_recoveries.TryGetValue(key, out var value) || value.fired)
			{
				return;
			}
			float num = Mathf.Max(0f, _hammerRecoveryDelay.Value);
			float num2 = num + Mathf.Max(1f, _reasonCooldown.Value);
			float num3 = Time.time - value.start;
			if (!(num3 > num2))
			{
				pending = true;
				if (num3 >= num && ReasonReady(used, 1))
				{
					armed = true;
				}
			}
		}

		private static void MarkRecoveryFired(int key)
		{
			if (_recoveries.TryGetValue(key, out var value))
			{
				value.fired = true;
				_recoveries[key] = value;
			}
		}

		private static bool TryGetTarget(CharacterBody body, out Vector3 position, out float distance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			position = Vector3.zero;
			distance = float.PositiveInfinity;
			CharacterMaster master = body.master;
			if ((Object)(object)master == (Object)null)
			{
				return false;
			}
			BaseAI val = ((Component)master).GetComponent<BaseAI>();
			if ((Object)(object)val == (Object)null)
			{
				IList<BaseAI> aiComponents = master.AiComponents;
				if (aiComponents != null && aiComponents.Count > 0)
				{
					val = aiComponents[0];
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Target currentEnemy = val.currentEnemy;
			Vector3 val2 = default(Vector3);
			if (currentEnemy != null && currentEnemy.GetBullseyePosition(ref val2))
			{
				position = val2;
			}
			else
			{
				if (currentEnemy == null || !((Object)(object)currentEnemy.gameObject != (Object)null))
				{
					return false;
				}
				position = currentEnemy.gameObject.transform.position;
			}
			distance = Vector3.Distance(body.corePosition, position);
			return true;
		}

		private static Vector3 Horizontal(Vector3 from, Vector3 to)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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)
			Vector3 val = to - from;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				return Vector3.zero;
			}
			return ((Vector3)(ref val)).normalized;
		}

		private static void LogError(string context, Exception e)
		{
			if (_errorCount++ < 5 && _log != null)
			{
				_log.LogError((object)(context + ":" + e));
			}
		}
	}
	[BepInPlugin("com.sparkletwilight.sparkleenemiestweaks", "SparkleEnemiesTweaks", "1.0.19")]
	public class SparkleEnemiesTweaksPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.sparkletwilight.sparkleenemiestweaks";

		public const string PluginName = "SparkleEnemiesTweaks";

		public const string PluginVersion = "1.0.19";

		private void Awake()
		{
			MithrixAim.Init(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger);
			MithrixSkillControl.Init(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger);
			TitanStoneConstructFix.Init(((BaseUnityPlugin)this).Logger);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"SparkleEnemiesTweaks v1.0.19 已加载。");
		}

		private void Update()
		{
			MithrixAim.Tick();
			MithrixSkillControl.Tick();
			TitanStoneConstructFix.Tick();
		}
	}
	internal static class TitanStoneConstructFix
	{
		private static readonly string[] TitanBodyNames = new string[2] { "TitanBody", "TitanGoldBody" };

		private static readonly Type StoneConstructStateType = typeof(RechargeRocks);

		private static readonly FieldInfo MaxHealthFractionField = AccessTools.Field(typeof(AISkillDriver), "maxUserHealthFraction");

		private static readonly FieldInfo MinHealthFractionField = AccessTools.Field(typeof(AISkillDriver), "minUserHealthFraction");

		private static readonly FieldInfo RequiredSkillField = AccessTools.Field(typeof(AISkillDriver), "requiredSkill");

		private static readonly FieldInfo SkillSlotField = AccessTools.Field(typeof(AISkillDriver), "skillSlot");

		private static readonly FieldInfo CustomNameField = AccessTools.Field(typeof(AISkillDriver), "customName");

		private static readonly FieldInfo MinDistanceField = AccessTools.Field(typeof(AISkillDriver), "minDistance");

		private static readonly FieldInfo MaxDistanceField = AccessTools.Field(typeof(AISkillDriver), "maxDistance");

		private static readonly FieldInfo MaxTimesSelectedField = AccessTools.Field(typeof(AISkillDriver), "maxTimesSelected");

		private static readonly FieldInfo SelectionRequiresSkillReadyField = AccessTools.Field(typeof(AISkillDriver), "requireSkillReady");

		private static readonly FieldInfo ActivationStateField = AccessTools.Field(typeof(SkillDef), "activationState");

		private static readonly MethodInfo StateTypeGetter = ((ActivationStateField != null) ? AccessTools.PropertyGetter(ActivationStateField.FieldType, "stateType") : null);

		private static ManualLogSource _log;

		private static readonly HashSet<int> _dumpedBodies = new HashSet<int>();

		internal static void Init(ManualLogSource log)
		{
			_log = log;
		}

		internal static void Tick()
		{
			try
			{
				foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
				{
					if (!((Object)(object)readOnlyInstances == (Object)null) && IsTitanBody(((Object)readOnlyInstances).name))
					{
						CharacterMaster master = readOnlyInstances.master;
						GameObject val = (((Object)(object)master != (Object)null) ? ((Component)master).gameObject : null);
						int num = 0;
						num = ((!((Object)(object)val != (Object)null)) ? (num + ProcessTitan(((Component)readOnlyInstances).gameObject, ((Component)readOnlyInstances).gameObject)) : (num + ProcessTitan(val, ((Component)readOnlyInstances).gameObject)));
						int instanceID = ((Object)readOnlyInstances).GetInstanceID();
						if (_dumpedBodies.Add(instanceID))
						{
							DumpBody(readOnlyInstances, val, num);
						}
					}
				}
			}
			catch (Exception ex)
			{
				if (_log != null)
				{
					_log.LogError((object)("石巨人泰坦处理失败:" + ex));
				}
			}
		}

		private static int ProcessTitan(GameObject aiRoot, GameObject bodyRoot)
		{
			if ((Object)(object)aiRoot == (Object)null)
			{
				return 0;
			}
			AISkillDriver[] drivers = GetDrivers(aiRoot);
			if (drivers == null || drivers.Length == 0)
			{
				return 0;
			}
			bool[] slotIsStone = new bool[8];
			SkillLocator val = (((Object)(object)bodyRoot != (Object)null) ? bodyRoot.GetComponent<SkillLocator>() : null);
			if ((Object)(object)val != (Object)null)
			{
				MarkSlot(slotIsStone, (SkillSlot)0, val.primary);
				MarkSlot(slotIsStone, (SkillSlot)1, val.secondary);
				MarkSlot(slotIsStone, (SkillSlot)2, val.utility);
				MarkSlot(slotIsStone, (SkillSlot)3, val.special);
			}
			int num = 0;
			for (int i = 0; i < drivers.Length; i++)
			{
				AISkillDriver val2 = drivers[i];
				if (!((Object)(object)val2 == (Object)null) && IsStoneConstructDriver(val2, slotIsStone) && Relax(val2, i))
				{
					num++;
				}
			}
			return num;
		}

		private static void MarkSlot(bool[] slotIsStone, SkillSlot slot, GenericSkill skill)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected I4, but got Unknown
			if ((Object)(object)skill == (Object)null)
			{
				return;
			}
			SkillDef skillDef = skill.skillDef;
			if (!((Object)(object)skillDef == (Object)null) && SkillUsesState(skillDef, StoneConstructStateType))
			{
				int num = (int)slot;
				if (num >= 0 && num < slotIsStone.Length)
				{
					slotIsStone[num] = true;
				}
			}
		}

		private static bool IsStoneConstructDriver(AISkillDriver driver, bool[] slotIsStone)
		{
			SkillDef val = (SkillDef)((RequiredSkillField != null) ? /*isinst with value type is only supported in some contexts*/: null);
			if ((Object)(object)val != (Object)null && SkillUsesState(val, StoneConstructStateType))
			{
				return true;
			}
			int num = SlotIndexOf((SkillSlotField != null) ? SkillSlotField.GetValue(driver) : null);
			if (num >= 0 && num < slotIsStone.Length && slotIsStone[num])
			{
				return true;
			}
			string text = ((CustomNameField != null) ? (CustomNameField.GetValue(driver) as string) : null);
			if (!string.IsNullOrEmpty(text) && text.IndexOf("RechargeRocks", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return true;
			}
			return false;
		}

		private static int SlotIndexOf(object slot)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected I4, but got Unknown
			if (slot == null)
			{
				return -1;
			}
			try
			{
				return (int)(SkillSlot)slot;
			}
			catch
			{
			}
			try
			{
				return (int)Enum.Parse(typeof(SkillSlot), slot.ToString());
			}
			catch
			{
				return -1;
			}
		}

		private static bool Relax(AISkillDriver driver, int index)
		{
			if (MaxHealthFractionField == null || MinHealthFractionField == null)
			{
				return false;
			}
			float num = (float)MaxHealthFractionField.GetValue(driver);
			float num2 = (float)MinHealthFractionField.GetValue(driver);
			bool flag = false;
			if (num < 1f)
			{
				MaxHealthFractionField.SetValue(driver, 1f);
				flag = true;
			}
			if (num2 > 0f)
			{
				MinHealthFractionField.SetValue(driver, 0f);
				flag = true;
			}
			if (flag && _log != null)
			{
				_log.LogInfo((object)("石巨人泰坦 Stone Construct:驱动[" + index + "] 自身血量区间 " + num2.ToString("F2") + "~" + num.ToString("F2") + " -> 0.00~1.00"));
			}
			return flag;
		}

		private static void DumpBody(CharacterBody body, GameObject masterObject, int patched)
		{
			if (_log == null)
			{
				return;
			}
			float num = -1f;
			try
			{
				HealthComponent healthComponent = body.healthComponent;
				if ((Object)(object)healthComponent != (Object)null && healthComponent.fullHealth > 0f)
				{
					num = healthComponent.health / healthComponent.fullHealth * 100f;
				}
			}
			catch
			{
			}
			_log.LogInfo((object)("石巨人诊断:body=" + ((Object)body).name + " 血量=" + num.ToString("F1") + "% master=" + (((Object)(object)masterObject != (Object)null) ? ((Object)masterObject).name : "(无)") + " 本次解除驱动=" + patched));
			SkillLocator component = ((Component)body).GetComponent<SkillLocator>();
			if ((Object)(object)component != (Object)null)
			{
				LogSlot("Primary", component.primary);
				LogSlot("Secondary", component.secondary);
				LogSlot("Utility", component.utility);
				LogSlot("Special", component.special);
			}
			if ((Object)(object)masterObject == (Object)null)
			{
				return;
			}
			try
			{
				Component[] components = masterObject.GetComponents<Component>();
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i < components.Length; i++)
				{
					if (!((Object)(object)components[i] == (Object)null))
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(", ");
						}
						stringBuilder.Append(((object)components[i]).GetType().Name);
						if (stringBuilder.Length > 220)
						{
							stringBuilder.Append("...");
							break;
						}
					}
				}
				_log.LogInfo((object)("石巨人 master 组件 = " + stringBuilder));
			}
			catch
			{
			}
			AISkillDriver[] drivers = GetDrivers(masterObject);
			if (drivers == null || drivers.Length == 0)
			{
				_log.LogInfo((object)"石巨人诊断:master 上也没有任何 AISkillDriver。");
				return;
			}
			for (int j = 0; j < drivers.Length; j++)
			{
				AISkillDriver val = drivers[j];
				if (!((Object)(object)val == (Object)null))
				{
					_log.LogInfo((object)("石巨人驱动[" + j + "] " + DescribeDriver(val)));
				}
			}
		}

		private static void LogSlot(string slotName, GenericSkill skill)
		{
			if (_log == null)
			{
				return;
			}
			if ((Object)(object)skill == (Object)null)
			{
				_log.LogInfo((object)("石巨人技能 " + slotName + " = (空)"));
				return;
			}
			SkillDef skillDef = skill.skillDef;
			string text = (((Object)(object)skillDef != (Object)null) ? StateNameOf(skillDef) : "(无 skillDef)");
			float num = (((Object)(object)skillDef != (Object)null) ? skillDef.baseRechargeInterval : 0f);
			string text2 = "?";
			string text3 = "?";
			try
			{
				text2 = skill.cooldownRemaining.ToString("F1") + "/" + num.ToString("F1");
			}
			catch
			{
			}
			try
			{
				text3 = skill.stock.ToString();
			}
			catch
			{
			}
			_log.LogInfo((object)("石巨人技能 " + slotName + " = " + text + " 冷却=" + text2 + " 充能=" + text3));
		}

		private static AISkillDriver[] GetDrivers(GameObject root)
		{
			BaseAI component = root.GetComponent<BaseAI>();
			if ((Object)(object)component != (Object)null && component.skillDrivers != null && component.skillDrivers.Length != 0)
			{
				return component.skillDrivers;
			}
			return root.GetComponentsInChildren<AISkillDriver>(true);
		}

		private static bool IsTitanBody(string prefabName)
		{
			if (string.IsNullOrEmpty(prefabName))
			{
				return false;
			}
			for (int i = 0; i < TitanBodyNames.Length; i++)
			{
				if (prefabName.StartsWith(TitanBodyNames[i], StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
			}
			return false;
		}

		private static string StateNameOf(SkillDef skill)
		{
			Type type = StateTypeOf(skill);
			if (!(type != null))
			{
				return "(未知状态)";
			}
			return type.Name;
		}

		private static Type StateTypeOf(SkillDef skill)
		{
			if ((Object)(object)skill == (Object)null || ActivationStateField == null || StateTypeGetter == null)
			{
				return null;
			}
			object value = ActivationStateField.GetValue(skill);
			if (value == null)
			{
				return null;
			}
			return StateTypeGetter.Invoke(value, null) as Type;
		}

		private static bool SkillUsesState(SkillDef skill, Type stateType)
		{
			if (stateType == null)
			{
				return false;
			}
			Type type = StateTypeOf(skill);
			if (type != null)
			{
				return stateType.IsAssignableFrom(type);
			}
			return false;
		}

		private static string DescribeDriver(AISkillDriver d)
		{
			string text = "?";
			string text2 = "?";
			string text3 = "(空)";
			string text4 = "?";
			string text5 = "?";
			string text6 = "?";
			string text7 = "?";
			try
			{
				object obj = ((CustomNameField != null) ? CustomNameField.GetValue(d) : null);
				text = ((obj != null) ? obj.ToString() : "(无)");
			}
			catch
			{
			}
			try
			{
				object obj3 = ((SkillSlotField != null) ? SkillSlotField.GetValue(d) : null);
				text2 = ((obj3 != null) ? obj3.ToString() : "?");
			}
			catch
			{
			}
			try
			{
				SkillDef val = (SkillDef)((RequiredSkillField != null) ? /*isinst with value type is only supported in some contexts*/: null);
				text3 = (((Object)(object)val != (Object)null) ? StateNameOf(val) : "(未指定)");
			}
			catch
			{
			}
			try
			{
				float num = ((MinHealthFractionField != null) ? ((float)MinHealthFractionField.GetValue(d)) : 0f);
				float num2 = ((MaxHealthFractionField != null) ? ((float)MaxHealthFractionField.GetValue(d)) : 0f);
				text4 = num.ToString("F2") + "~" + num2.ToString("F2");
			}
			catch
			{
			}
			try
			{
				float num3 = ((MinDistanceField != null) ? ((float)MinDistanceField.GetValue(d)) : 0f);
				float num4 = ((MaxDistanceField != null) ? ((float)MaxDistanceField.GetValue(d)) : 0f);
				text5 = num3.ToString("F0") + "~" + num4.ToString("F0");
			}
			catch
			{
			}
			try
			{
				int num5 = ((MaxTimesSelectedField != null) ? ((int)MaxTimesSelectedField.GetValue(d)) : 0);
				text6 = d.timesSelected + "/" + num5;
			}
			catch
			{
			}
			try
			{
				text7 = ((SelectionRequiresSkillReadyField != null && (bool)SelectionRequiresSkillReadyField.GetValue(d)) ? "要求就绪" : "不要求就绪");
			}
			catch
			{
			}
			return "名称=" + text + " 槽=" + text2 + " 技能=" + text3 + " 自身血量=" + text4 + " 距离=" + text5 + " 已选=" + text6 + " " + text7;
		}
	}
}