Decompiled source of StrongerItems v1.73.4

plugins/StrongerItems.dll

Decompiled 13 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Characters;
using Characters.AI;
using Characters.Abilities;
using Characters.Abilities.CharacterStat;
using Characters.Abilities.Customs;
using Characters.Abilities.Essences;
using Characters.Abilities.Items;
using Characters.Abilities.Spirits;
using Characters.Abilities.Statuses;
using Characters.Abilities.Triggers;
using Characters.Abilities.Upgrades;
using Characters.Abilities.Weapons.DavyJones;
using Characters.Abilities.Weapons.Fighter;
using Characters.Abilities.Weapons.Gambler;
using Characters.Abilities.Weapons.GrimReaper;
using Characters.Abilities.Weapons.Hercules;
using Characters.Abilities.Weapons.Minotaurus;
using Characters.Abilities.Weapons.Skeleton_Sword;
using Characters.Abilities.Weapons.Wizard;
using Characters.Actions;
using Characters.Actions.Constraints;
using Characters.Controllers;
using Characters.Cooldowns;
using Characters.Gear;
using Characters.Gear.Items;
using Characters.Gear.Quintessences;
using Characters.Gear.Quintessences.Effects;
using Characters.Gear.Synergy;
using Characters.Gear.Synergy.Inscriptions;
using Characters.Gear.Upgrades;
using Characters.Gear.Weapons;
using Characters.Gear.Weapons.Gauges;
using Characters.Marks;
using Characters.Minions;
using Characters.Movements;
using Characters.Operations;
using Characters.Operations.Attack;
using Characters.Operations.Customs;
using Characters.Operations.Customs.GrimReaper;
using Characters.Operations.Decorator;
using Characters.Operations.Fx;
using Characters.Operations.Gauge;
using Characters.Operations.Movement;
using Characters.Operations.Summon;
using Characters.Player;
using Characters.Projectiles;
using Characters.Projectiles.Movements;
using Data;
using FX;
using GameResources;
using HarmonyLib;
using Level;
using Microsoft.CodeAnalysis;
using Services;
using Singletons;
using TMPro;
using UI;
using UI.Hud;
using UI.Pause;
using UI.Upgrades;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Plugins.Common")]
[assembly: IgnoresAccessChecksTo("Plugins.Singletons")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("StrongerItems")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.73.4.0")]
[assembly: AssemblyInformationalVersion("1.73.4")]
[assembly: AssemblyProduct("StrongerItems")]
[assembly: AssemblyTitle("StrongerItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.73.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[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 StrongerItems
{
	internal static class AbsoluteZeroPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<float> <0>__Tick;

			public static OnTimeDelegate <1>__OnFreezeApplied;

			public static <>A{000000d8}<ITarget, Damage, Damage, double> <2>__OnGaveDamage;
		}

		internal const int Keyword = 20;

		private const double FreezeChance = 0.08;

		private const double BasePerLayer = 0.05;

		private const double PerInscriptionPerLayer = 0.03;

		private const double MaxExtraPerLayer = 0.3;

		private const int MaxStacks = 5;

		private const float Duration = 7f;

		private const float TickInterval = 0.25f;

		private const string NoteFragment = "从地面涌出冰块";

		private const string Note = "取消原版「普攻时每 15 秒结冰」;改为每次造成本体魔法伤害(不含道具伤害)有 8% 概率结冰;每次结冰使魔法攻击力 +5%(每个绝对零度刻印每层再 +3%,这部分最多 +30%),持续 7 秒,最多 5 层,叠层刷新全部层数";

		private static readonly ApplyInfo FreezeInfo = new ApplyInfo((Kind)1);

		private static Character _player;

		private static float _nextTick;

		private static float _until;

		private static int _stacks;

		private static Values _values;

		private static double _appliedValue = double.NaN;

		private static Badge _badge;

		private static bool _noteDone;

		private static int _noteAttempts;

		private static int _playerId;

		private static int _subscribedPlayerId;

		private static FieldInfo _step1Field;

		private static int _removedReports;

		private static int _freezeReports;

		private static int _stackReports;

		private static int _expireReports;

		private static int _itemSkipped;

		internal static void Install(Harmony harmony)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(AbsoluteZero), "UpdateBonus", new Type[2]
				{
					typeof(bool),
					typeof(bool)
				}, (Type[])null);
				if (methodInfo != null)
				{
					harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(AbsoluteZeroPatch), "AfterUpdateBonus", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					Probe.Append("absolute zero: AbsoluteZero.UpdateBonus NOT FOUND - 原版每 15 秒结冰可能取消不了 ✗");
				}
				_step1Field = AccessTools.Field(typeof(AbsoluteZero), "_step1Ability");
				Ticker.Register(Tick);
				Probe.Append("absolute zero: 已启动 ✓(取消原版 15 秒普攻结冰 ✓;本体魔法伤害 8% 结冰(道具伤害不触发)✓;每次结冰 +" + 5.0.ToString("0") + "% 魔法攻击/层(每个刻印每层再 +" + 3.0.ToString("0") + "%,最多 +" + 30.0.ToString("0") + "%),最多 " + 5 + " 层、7 秒、叠层刷新;UpdateBonus=" + ((methodInfo != null) ? "ok" : "MISSING") + " _step1Ability=" + ((_step1Field != null) ? "ok" : "MISSING") + ")");
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] absolute zero install failed: " + ex));
				}
			}
		}

		private static void AfterUpdateBonus(AbsoluteZero __instance)
		{
			try
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return;
				}
				if (_step1Field == null)
				{
					_step1Field = AccessTools.Field(typeof(AbsoluteZero), "_step1Ability");
				}
				AbilityComponent val = (AbilityComponent)((_step1Field != null) ? /*isinst with value type is only supported in some contexts*/: null);
				IAbility val2 = (((Object)(object)val != (Object)null) ? val.ability : null);
				if (val2 == null)
				{
					return;
				}
				Character val3 = ItemCopies.CurrentPlayer() ?? _player;
				if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.ability == (Object)null))
				{
					val3.ability.Remove(val2);
					_removedReports++;
					if (_removedReports <= 10)
					{
						Probe.Append("absolute zero: 已移除原版「普攻每 15 秒结冰」能力 ✓(第 " + _removedReports + " 次,刻印重算时幂等移除)");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] absolute zero update-bonus hook failed: " + ex));
				}
			}
		}

		internal static void ResetRun()
		{
			_stacks = 0;
			_until = 0f;
			_appliedValue = double.NaN;
		}

		private static void Tick(float deltaTime)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			try
			{
				if (Time.time < _nextTick)
				{
					return;
				}
				_nextTick = Time.time + 0.25f;
				Character val = ItemCopies.CurrentPlayer() ?? _player;
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				_player = val;
				int instanceID = ((Object)val).GetInstanceID();
				if (instanceID != _playerId)
				{
					if (_playerId != 0)
					{
						_stacks = 0;
						_until = 0f;
						_values = null;
						_appliedValue = double.NaN;
						_badge = null;
						Probe.Append("absolute zero: 检测到新玩家实例(新的一局)⇒ 层数/加成/徽标已重置,重新订阅结冰事件 ✓");
					}
					_playerId = instanceID;
				}
				TryNote();
				if ((Object)(object)val.status != (Object)null && _subscribedPlayerId != instanceID)
				{
					CharacterStatus status = val.status;
					object obj = <>O.<1>__OnFreezeApplied;
					if (obj == null)
					{
						OnTimeDelegate val2 = OnFreezeApplied;
						<>O.<1>__OnFreezeApplied = val2;
						obj = (object)val2;
					}
					status.onApplyFreeze += (OnTimeDelegate)obj;
					CharacterStatus status2 = val.status;
					object obj2 = <>O.<1>__OnFreezeApplied;
					if (obj2 == null)
					{
						OnTimeDelegate val3 = OnFreezeApplied;
						<>O.<1>__OnFreezeApplied = val3;
						obj2 = (object)val3;
					}
					status2.onRefreshFreeze += (OnTimeDelegate)obj2;
					_subscribedPlayerId = instanceID;
					Probe.Append("absolute zero: 已挂 onApplyFreeze + onRefreshFreeze(结冰/刷新结冰都叠层 ✓,玩家实例 " + instanceID + ")");
				}
				try
				{
					SubscriptionKeeper.KeepAlive(val, "onGaveDamage", new <>A{000000d8}<ITarget, Damage, Damage, double>(OnGaveDamage), "absolute zero");
				}
				catch
				{
				}
				int num = CountInscription(val);
				if (num <= 0)
				{
					if (_stacks > 0)
					{
						ResetBuff(val, "已没有绝对零度刻印");
					}
					return;
				}
				if (_stacks > 0 && Time.time > _until)
				{
					ResetBuff(val, "7 秒内没有再结冰 ⇒ 层数清零");
				}
				ApplyBuff(val, num);
				UpdateBadge(val);
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] absolute zero tick failed: " + ex));
				}
			}
		}

		private static void OnGaveDamage(ITarget target, in Damage originalDamage, in Damage gaveDamage, double damageDealt)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			try
			{
				Character val = _player ?? ItemCopies.CurrentPlayer();
				if ((Object)(object)val == (Object)null || CountInscription(val) <= 0 || (int)gaveDamage.attribute != 1 || (int)gaveDamage.motionType == 4)
				{
					return;
				}
				if ((int)gaveDamage.motionType == 2)
				{
					_itemSkipped++;
					if (_itemSkipped <= 5)
					{
						Probe.Append("absolute zero: 这一下是道具伤害(motionType=Item)⇒ 不触发 8% 结冰 ✓(第 " + _itemSkipped + " 次)");
					}
					return;
				}
				Character val2 = ((target != null) ? target.character : null);
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.health == (Object)null) && !((Health)val2.health).dead && !((double)Random.value >= 0.08))
				{
					val.GiveStatus(val2, FreezeInfo);
					_freezeReports++;
					if (_freezeReports <= 10)
					{
						Probe.Append("absolute zero: 魔法伤害触发 8% 结冰 ⇒ '" + ((Object)val2).name + "' ✓(第 " + _freezeReports + " 次)");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] absolute zero gave-damage failed: " + ex));
				}
			}
		}

		private static void OnFreezeApplied(Character attacker, Character target)
		{
			try
			{
				if (!((Object)(object)attacker == (Object)null) && !((Object)(object)attacker != (Object)(object)_player) && !((Object)(object)_player == (Object)null) && CountInscription(_player) > 0)
				{
					if (_stacks < 5)
					{
						_stacks++;
					}
					_until = Time.time + 7f;
					if (_stackReports < 15)
					{
						_stackReports++;
						Probe.Append("absolute zero: 结冰叠层 ⇒ " + _stacks + "/" + 5 + " 层(7 秒,叠层刷新全部层数 ✓)");
					}
					ApplyBuff(_player, CountInscription(_player));
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] absolute zero freeze hook failed: " + ex));
				}
			}
		}

		private static void ResetBuff(Character pl, string why)
		{
			_stacks = 0;
			_until = 0f;
			if ((Object)(object)pl != (Object)null && pl.stat != null && _values != null)
			{
				pl.stat.DetachValues(_values);
				_values = null;
				pl.stat.Update();
			}
			_appliedValue = double.NaN;
			if (_expireReports < 10)
			{
				_expireReports++;
				Probe.Append("absolute zero: " + why + " ⇒ 魔法攻击力加成撤掉 ✓");
			}
		}

		private static void ApplyBuff(Character pl, int inscriptions)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			try
			{
				if ((Object)(object)pl == (Object)null || pl.stat == null)
				{
					return;
				}
				if (_stacks <= 0)
				{
					if (_values != null)
					{
						pl.stat.DetachValues(_values);
						_values = null;
						pl.stat.Update();
						_appliedValue = double.NaN;
					}
					return;
				}
				double num = 0.05 + Math.Min(0.03 * (double)inscriptions, 0.3);
				double num2 = num * (double)_stacks;
				if (_values == null)
				{
					_values = new Values((Value[])(object)new Value[1]
					{
						new Value(Category.PercentPoint, Kind.MagicAttackDamage, num2)
					});
					pl.stat.AttachValues(_values);
					pl.stat.Update();
					_appliedValue = num2;
				}
				else if (double.IsNaN(_appliedValue) || !(Math.Abs(num2 - _appliedValue) < 0.0005))
				{
					if (((ReorderableArray<Value>)(object)_values).values != null && ((ReorderableArray<Value>)(object)_values).values.Length != 0)
					{
						((ReorderableArray<Value>)(object)_values).values[0].value = num2;
					}
					pl.stat.Update();
					_appliedValue = num2;
					if (_stackReports <= 20)
					{
						Probe.Append("absolute zero: 魔法攻击力 +" + (num2 * 100.0).ToString("0.#") + "%(每层 " + (num * 100.0).ToString("0.#") + "% × " + _stacks + " 层,刻印 " + inscriptions + " 个)");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] absolute zero apply failed: " + ex));
				}
			}
		}

		private static void UpdateBadge(Character pl)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)pl == (Object)null)
				{
					return;
				}
				if (_badge == null)
				{
					_badge = new Badge("absolute zero (freeze stacks)", () => InscriptionIcon(pl), Badge.Glyph.Cross, new Color(0.6f, 0.85f, 1f, 1f));
				}
				if (!_badge.attached)
				{
					_badge.Attach(pl);
				}
				bool flag = _stacks > 0;
				float fill = (flag ? Mathf.Clamp01((_until - Time.time) / 7f) : 0f);
				_badge.Update(fill, _stacks);
				_badge.SetActive(flag);
			}
			catch
			{
			}
		}

		private static Sprite InscriptionIcon(Character pl)
		{
			try
			{
				Synergy val = (((Object)(object)pl != (Object)null && pl.playerComponents != null && pl.playerComponents.inventory != null) ? pl.playerComponents.inventory.synergy : null);
				if ((Object)(object)val == (Object)null || val.inscriptions == null)
				{
					return null;
				}
				Inscription val2 = val.inscriptions[(Key)20];
				return (val2 != null) ? val2.icon : null;
			}
			catch
			{
				return null;
			}
		}

		private static int CountInscription(Character pl)
		{
			try
			{
				Synergy val = (((Object)(object)pl != (Object)null && pl.playerComponents != null && pl.playerComponents.inventory != null) ? pl.playerComponents.inventory.synergy : null);
				if ((Object)(object)val == (Object)null || val.inscriptions == null)
				{
					return 0;
				}
				return val.inscriptions[(Key)20]?.count ?? 0;
			}
			catch
			{
				return 0;
			}
		}

		private static void TryNote()
		{
			if (_noteDone || _noteAttempts > 40)
			{
				return;
			}
			_noteAttempts++;
			try
			{
				if (Localization.GetLocalizedString("synergy/key/20/desc") != null && ItemTextPatch.AppendNoteToRowsContaining("从地面涌出冰块", "取消原版「普攻时每 15 秒结冰」;改为每次造成本体魔法伤害(不含道具伤害)有 8% 概率结冰;每次结冰使魔法攻击力 +5%(每个绝对零度刻印每层再 +3%,这部分最多 +30%),持续 7 秒,最多 5 层,叠层刷新全部层数") > 0)
				{
					_noteDone = true;
				}
			}
			catch
			{
			}
		}

		internal static void SelfCheck()
		{
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(AbsoluteZero), "UpdateBonus", new Type[2]
				{
					typeof(bool),
					typeof(bool)
				}, (Type[])null);
				bool flag = methodInfo != null && _step1Field != null;
				Probe.Append("self-check absolute zero: AbsoluteZero.UpdateBonus=" + ((methodInfo != null) ? "ok" : "MISSING") + ",_step1Ability=" + ((_step1Field != null) ? "ok" : "MISSING") + ",本体魔法伤害 8% 结冰(道具伤害不触发),每层 +" + 5.0.ToString("0") + "% + " + 3.0.ToString("0") + "%×刻印数(上限 +" + 30.0.ToString("0") + "%),最多 " + 5 + " 层 / " + 7f.ToString("0") + " 秒 -> " + (flag ? "PASS" : "FAIL"));
			}
			catch (Exception ex)
			{
				Probe.Append("self-check absolute zero failed: " + ex.Message);
			}
		}
	}
	internal static class AdaptiveKingPatch
	{
		private const float TickInterval = 0.25f;

		private static float _next;

		private static int _playerId;

		private static bool _active;

		private static int _log;

		private static FieldInfo _statOwnerField;

		private const string NoteOpen = "<color=#F25D1C>(本模组:";

		private const string NoteClose = ")</color>";

		private static bool _notesDone;

		private static int _noteTries;

		internal static void Install(Harmony harmony)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			Ticker.Register(Tick);
			try
			{
				_statOwnerField = AccessTools.Field(typeof(Stat), "_owner");
				MethodInfo methodInfo = AccessTools.Method(typeof(Stat), "GetDamage", new Type[3]
				{
					typeof(double),
					typeof(Vector2),
					typeof(HitInfo)
				}, (Type[])null);
				if (methodInfo == null)
				{
					Probe.Append("adaptive king: 找不到 Stat.GetDamage ✗(自适应属性不生效)");
					return;
				}
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.Method(typeof(AdaptiveKingPatch), "BeforeGetDamage", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Probe.Append("adaptive king: 已挂 Stat.GetDamage 前缀 ✓(无名之王/英雄王本体伤害随物魔较高者)");
			}
			catch (Exception ex)
			{
				Probe.Append("adaptive king: 安装失败 ✗ " + ex.GetType().Name + ":" + ex.Message);
			}
		}

		private static void BeforeGetDamage(Stat __instance, HitInfo hitInfo)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			try
			{
				if (!_active || __instance == null || hitInfo == null || _statOwnerField == null)
				{
					return;
				}
				object? value = _statOwnerField.GetValue(__instance);
				Character val = (Character)((value is Character) ? value : null);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				MotionType motionType = hitInfo.motionType;
				if ((int)motionType == 0 || (int)motionType == 1 || (int)motionType == 5 || (int)motionType == 6)
				{
					hitInfo.ChangeAdaptiveDamageAttribute(val);
					if (_log < 10)
					{
						_log++;
						Probe.Append("adaptive king: 本体伤害属性 ⇒ " + ((object)hitInfo.attribute/*cast due to .constrained prefix*/).ToString() + "(物攻 " + val.stat.GetFinal(Kind.PhysicalAttackDamage).ToString("0.##") + " / 魔攻 " + val.stat.GetFinal(Kind.MagicAttackDamage).ToString("0.##") + ",第 " + _log + " 次)");
					}
				}
			}
			catch
			{
			}
		}

		private static void TryNotes()
		{
			if (_notesDone || _noteTries > 40)
			{
				return;
			}
			_noteTries++;
			try
			{
				LocalizationStringResource instance = LocalizationStringResource.instance;
				if ((Object)(object)instance == (Object)null)
				{
					return;
				}
				StringsByLanguage[] stringsByLanguage = instance.stringsByLanguage;
				int num = 3;
				int num2 = 0;
				int num3 = 0;
				string text = "<color=#F25D1C>(本模组:本体造成伤害的属性随物理或魔法攻击较高者变化)</color>";
				string text2 = "<color=#F25D1C>(本模组:本体造成伤害的属性随物理或魔法攻击较高者变化;获得的魔力随技能冷却速度与攻击速度之和提高)</color>";
				for (int i = 0; i < stringsByLanguage.Length; i++)
				{
					string[] strings = stringsByLanguage[i].strings;
					if (strings == null || num < 0 || num >= strings.Length)
					{
						continue;
					}
					string text3 = strings[num];
					if (!string.IsNullOrEmpty(text3) && text3.Length >= 8 && text3.IndexOf("(本模组", StringComparison.Ordinal) < 0)
					{
						if (text3.IndexOf("重铸断剑并成为骑士王", StringComparison.Ordinal) >= 0)
						{
							strings[num] = text3 + " " + text2;
							num2++;
						}
						else if (text3.IndexOf("持有圣剑时会持续消耗魔力", StringComparison.Ordinal) >= 0)
						{
							strings[num] = text3 + " " + text;
							num3++;
						}
					}
				}
				if (num2 + num3 > 0)
				{
					_notesDone = true;
					Probe.Append("adaptive king: 介绍旁注已写入 无名之王 " + num2 + " 行 / 骑士王(英雄王) " + num3 + " 行 ✓");
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] adaptive king notes failed: " + ex));
				}
			}
		}

		private static void Tick(float deltaTime)
		{
			try
			{
				if (Time.time < _next)
				{
					return;
				}
				TryNotes();
				_next = Time.time + 0.25f;
				Character val = ItemCopies.CurrentPlayer();
				if ((Object)(object)val == (Object)null || val.playerComponents == null || val.playerComponents.inventory == null || (Object)(object)val.playerComponents.inventory.weapon == (Object)null || (Object)(object)val.playerComponents.inventory.weapon.current == (Object)null)
				{
					_active = false;
					return;
				}
				Weapon current = val.playerComponents.inventory.weapon.current;
				if (((Object)val).GetInstanceID() != _playerId)
				{
					_playerId = ((Object)val).GetInstanceID();
				}
				string text = ((Object)current).name + "|" + ((Gear)current).displayName;
				bool flag = text.IndexOf("无名之王", StringComparison.Ordinal) >= 0 || text.IndexOf("英雄王", StringComparison.Ordinal) >= 0 || text.IndexOf("骑士王", StringComparison.Ordinal) >= 0 || text.IndexOf("UnknownKing", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("KingArthur", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("KingOfHeroes", StringComparison.OrdinalIgnoreCase) >= 0;
				if (flag != _active)
				{
					_active = flag;
					Probe.Append("adaptive king: '" + ((Gear)current).displayName + "' 自适应属性 " + (flag ? "开启 ✓" : "关闭"));
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] adaptive king tick failed: " + ex));
				}
			}
		}

		internal static void SelfCheck()
		{
			try
			{
				bool flag = AccessTools.TypeByName("Characters.Stat") != null && AccessTools.TypeByName("Characters.Operations.HitInfo") != null;
				bool flag2 = _statOwnerField != null;
				Probe.Append("self-check adaptive king: 类型=" + (flag ? "ok" : "MISSING") + " 字段=" + (flag2 ? "ok" : "MISSING") + " -> " + ((flag && flag2) ? "PASS" : "FAIL"));
			}
			catch (Exception ex)
			{
				Probe.Append("self-check adaptive king failed: " + ex.Message);
			}
		}
	}
	[HarmonyPatch(typeof(Item), "SetOwner")]
	internal static class AftershockPatch
	{
		internal const string ItemName = "Aftershocks";

		private static int _patchedItems;

		private static int _removedCooldowns;

		internal static bool IsAftershocks(Item item)
		{
			try
			{
				if ((Object)(object)item == (Object)null || ((Object)item).name == null)
				{
					return false;
				}
				string text = ((Object)item).name;
				if (text.EndsWith("(Clone)", StringComparison.Ordinal))
				{
					text = text.Substring(0, text.Length - "(Clone)".Length);
				}
				return text == "Aftershocks";
			}
			catch
			{
				return false;
			}
		}

		[HarmonyPostfix]
		private static void RemoveTriggerCooldown(Item __instance, Character character)
		{
			try
			{
				if (!IsAftershocks(__instance))
				{
					return;
				}
				OnApplyStatusComponent[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<OnApplyStatusComponent>(true);
				if (componentsInChildren == null || componentsInChildren.Length == 0)
				{
					Probe.Append("aftershock: OnApplyStatusComponent NOT FOUND under '" + ((Object)__instance).name + "' - 冷却没被去掉(预制体结构变了?)");
					return;
				}
				_patchedItems++;
				OnApplyStatusComponent[] array = componentsInChildren;
				foreach (OnApplyStatusComponent val in array)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					object field = GetField(val, "_trigger");
					if (field == null)
					{
						Probe.Append("aftershock: '_trigger' 字段取不到 - 冷却没被去掉");
						continue;
					}
					object field2 = GetField(field, "_cooldownTime");
					SetField(field, "_cooldownTime", 0f);
					SetField(field, "_remainCooldownTime", 0f);
					object field3 = GetField(field, "_cooldownTime");
					_removedCooldowns++;
					string text = PathOf(((Component)val).transform);
					string text2 = ((field2 is float num) ? num.ToString("0.###") : "?");
					string text3 = ((field3 is float num2) ? num2.ToString("0.###") : "?");
					if (text2 != "0")
					{
						Probe.Append("aftershock cd removed: " + text + " _cooldownTime " + text2 + " -> " + text3 + "  (item '" + ((Object)__instance).name + "', possibility kept at 100%)");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] aftershock cd patch failed: " + ex));
				}
			}
		}

		private static FieldInfo FindField(Type type, string name)
		{
			Type type2 = type;
			while (type2 != null)
			{
				FieldInfo field = type2.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					return field;
				}
				type2 = type2.BaseType;
			}
			return null;
		}

		private static object GetField(object target, string name)
		{
			if (target == null)
			{
				return null;
			}
			FieldInfo fieldInfo = FindField(target.GetType(), name);
			if (!(fieldInfo != null))
			{
				return null;
			}
			return fieldInfo.GetValue(target);
		}

		private static void SetField(object target, string name, object value)
		{
			if (target != null)
			{
				FindField(target.GetType(), name)?.SetValue(target, value);
			}
		}

		private static string PathOf(Transform t)
		{
			if ((Object)(object)t == (Object)null)
			{
				return "?";
			}
			string text = ((Object)t).name;
			Transform parent = t.parent;
			int num = 0;
			while ((Object)(object)parent != (Object)null && num < 32)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
				num++;
			}
			return text;
		}

		internal static void SelfCheck()
		{
			try
			{
				FieldInfo fieldInfo = FindField(typeof(OnApplyStatusComponent), "_trigger");
				FieldInfo fieldInfo2 = FindField(typeof(OnApplyStatus), "_cooldownTime");
				FieldInfo fieldInfo3 = FindField(typeof(OnApplyStatus), "_remainCooldownTime");
				bool flag = fieldInfo != null && fieldInfo2 != null && fieldInfo3 != null;
				string text = "self-check aftershocks: OnApplyStatusComponent._trigger=" + ((fieldInfo != null) ? "ok" : "MISSING") + ", OnApplyStatus._cooldownTime=" + ((fieldInfo2 != null) ? "ok" : "MISSING") + ", _remainCooldownTime=" + ((fieldInfo3 != null) ? "ok" : "MISSING") + " -> " + (flag ? "PASS" : "FAIL");
				Probe.Append(text);
				if (!flag && Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] " + text));
				}
			}
			catch (Exception ex)
			{
				Probe.Append("self-check aftershocks failed: " + ex.Message);
			}
		}

		internal static string Summary()
		{
			return $"aftershocks: patchedItems={_patchedItems}, cooldownsRemoved={_removedCooldowns}";
		}
	}
	internal static class ArchDemonPatch
	{
		private const string QuintKeyword = "ArchDemon";

		private const string ChineseNameHint = "大恶魔";

		private const double MagicBonus = 1.2;

		private const double EmpowerBonus = 1.4;

		private const float EmpowerDuration = 10f;

		private const float CooldownTarget = 40f;

		private static float _empoweredUntil;

		private static int _logEmpower;

		private static int _logCd;

		private const float SampleInterval = 0.25f;

		private static bool _installed;

		private static Character _player;

		private static Values _values;

		private static float _next;

		private static bool _applied;

		private static double _lastWant;

		private static Badge _badge;

		private static string _entityName;

		private static int _reports;

		private static int _noteApplied;

		internal static void InstallOnce(Harmony harmony)
		{
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			if (_installed)
			{
				return;
			}
			_installed = true;
			try
			{
				Ticker.Register(Tick);
				try
				{
					MethodInfo methodInfo = AccessTools.Method(typeof(Quintessence), "Awake", (Type[])null, (Type[])null);
					if (methodInfo != null)
					{
						harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.Method(typeof(ArchDemonPatch), "BeforeEssenceAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						Probe.Append("arch demon: 已挂 Quintessence.Awake 前缀(大恶魔 CD → 40 秒)✓");
					}
					else
					{
						Probe.Append("arch demon: Quintessence.Awake 找不到 ✗(CD 改不了)");
					}
				}
				catch (Exception ex)
				{
					Probe.Append("arch demon: Awake 前缀挂载失败 ✗ " + ex.GetType().Name);
				}
				try
				{
					MethodInfo methodInfo2 = AccessTools.Method(typeof(Quintessence), "Use", Type.EmptyTypes, (Type[])null);
					if (methodInfo2 != null)
					{
						harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ArchDemonPatch), "AfterEssenceUse", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						Probe.Append("arch demon: 已挂 Quintessence.Use 后置(使用后 10 秒增幅 40%)✓");
					}
					else
					{
						Probe.Append("arch demon: Quintessence.Use 找不到 ✗(10 秒强化没法触发)");
					}
				}
				catch (Exception ex2)
				{
					Probe.Append("arch demon: Use 后置挂载失败 ✗ " + ex2.GetType().Name);
				}
				Probe.Append("arch demon: 已启动 ✓(持有 ⇒ 魔法攻击增幅 20%(乘算);使用后 10 秒 ⇒ 40%;CD 40 秒;每 0.25 秒核一次 ✓)");
			}
			catch (Exception ex3)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] arch demon install failed: " + ex3));
				}
			}
		}

		private static void Tick(float deltaTime)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			try
			{
				if (Time.time < _next)
				{
					return;
				}
				_next = Time.time + 0.25f;
				Character player = Singleton<Service>.Instance.levelManager.player;
				if ((Object)(object)player == (Object)null)
				{
					return;
				}
				_player = player;
				if (_noteApplied < 1)
				{
					_noteApplied++;
					AppendNote();
				}
				bool num = Holds();
				bool flag = Time.time <= _empoweredUntil;
				UpdateBadge(flag);
				double num2 = (flag ? 1.4 : 1.2);
				if (num)
				{
					SyncCooldown(player);
					if (_values == null)
					{
						_values = new Values((Value[])(object)new Value[1]
						{
							new Value(Category.Percent, Kind.MagicAttackDamage, num2)
						});
						_player.stat.AttachValues(_values);
						_applied = true;
					}
					else if (((ReorderableArray<Value>)(object)_values).values != null && ((ReorderableArray<Value>)(object)_values).values.Length != 0 && Math.Abs(((ReorderableArray<Value>)(object)_values).values[0].value - num2) > 0.0001)
					{
						((ReorderableArray<Value>)(object)_values).values[0].value = num2;
					}
					_player.stat.Update();
					if (Math.Abs(num2 - _lastWant) > 0.0001 || !_applied)
					{
						_lastWant = num2;
						_applied = true;
						if (_reports < 40)
						{
							_reports++;
							Probe.Append("arch demon: 魔法攻击增幅 " + ((num2 - 1.0) * 100.0).ToString("0") + "%(乘算)" + (flag ? " ON ✓(使用后 10 秒强化)" : " ON ✓(持有常态)"));
						}
					}
				}
				else
				{
					if (_values != null && _player.stat != null)
					{
						_player.stat.DetachValues(_values);
						_values = null;
					}
					_lastWant = 0.0;
					_applied = false;
					if (_values == null && _player.stat != null)
					{
						_player.stat.Update();
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] arch demon tick failed: " + ex));
				}
			}
		}

		private static bool Holds()
		{
			try
			{
				if ((Object)(object)_player == (Object)null)
				{
					return false;
				}
				MonoBehaviour[] componentsInChildren = ((Component)_player).GetComponentsInChildren<MonoBehaviour>(true);
				foreach (MonoBehaviour val in componentsInChildren)
				{
					if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && ((Object)((Component)val).gameObject).name.IndexOf("ArchDemon", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return true;
					}
				}
				return false;
			}
			catch
			{
				return false;
			}
		}

		private static bool IsArchDemon(Quintessence q)
		{
			try
			{
				return (Object)(object)q != (Object)null && (Object)(object)((Component)q).gameObject != (Object)null && ((Object)((Component)q).gameObject).name.IndexOf("ArchDemon", StringComparison.OrdinalIgnoreCase) >= 0;
			}
			catch
			{
				return false;
			}
		}

		private static void BeforeEssenceAwake(Quintessence __instance)
		{
			try
			{
				if (!IsArchDemon(__instance))
				{
					return;
				}
				FieldInfo fieldInfo = AccessTools.Field(typeof(Quintessence), "_cooldown");
				CooldownSerializer val = (CooldownSerializer)((fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null);
				if (val == null)
				{
					Probe.Append("arch demon: [CD] _cooldown 为空 ✗");
					return;
				}
				FieldInfo fieldInfo2 = AccessTools.Field(typeof(CooldownSerializer), "_cooldownTime");
				if (fieldInfo2 == null)
				{
					Probe.Append("arch demon: [CD] _cooldownTime 字段找不到 ✗");
					return;
				}
				float num = (float)fieldInfo2.GetValue(val);
				if (Math.Abs(num - 40f) > 0.01f)
				{
					fieldInfo2.SetValue(val, 40f);
				}
				if (_logCd < 8)
				{
					_logCd++;
					Probe.Append("arch demon: [CD] '" + ((Object)((Component)__instance).gameObject).name + "' 冷却 " + num.ToString("0.#") + " -> " + 40f.ToString("0.#") + " 秒 ✓");
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] arch demon cd prefix failed: " + ex));
				}
			}
		}

		private static void AfterEssenceUse(Quintessence __instance)
		{
			try
			{
				if (IsArchDemon(__instance))
				{
					_empoweredUntil = Time.time + 10f;
					if (_logEmpower < 12)
					{
						_logEmpower++;
						Probe.Append("arch demon: 使用精华 ⇒ " + 10f.ToString("0") + " 秒内魔法攻击增幅 40%(乘算,第 " + _logEmpower + " 次)");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] arch demon use postfix failed: " + ex));
				}
			}
		}

		private static void SyncCooldown(Character pl)
		{
			try
			{
				QuintessenceInventory val = ((pl.playerComponents != null) ? pl.playerComponents.inventory : null)?.quintessence;
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				List<Quintessence> items = val.items;
				if (items == null)
				{
					return;
				}
				for (int i = 0; i < items.Count; i++)
				{
					Quintessence val2 = items[i];
					if (!IsArchDemon(val2))
					{
						continue;
					}
					FieldInfo fieldInfo = AccessTools.Field(typeof(Quintessence), "_cooldown");
					CooldownSerializer val3 = (CooldownSerializer)((fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null);
					if (val3 == null)
					{
						continue;
					}
					FieldInfo fieldInfo2 = AccessTools.Field(typeof(CooldownSerializer), "_cooldownTime");
					if (fieldInfo2 == null)
					{
						continue;
					}
					float num = (float)fieldInfo2.GetValue(val3);
					if (Math.Abs(num - 40f) < 0.01f)
					{
						continue;
					}
					fieldInfo2.SetValue(val3, 40f);
					try
					{
						val3.Serialize();
					}
					catch
					{
					}
					try
					{
						if ((Object)(object)((Gear)val2).owner != (Object)null && val3.time != null)
						{
							val3.time.GetCooldownSpeed = ((Gear)val2).owner.stat.GetQuintessenceCooldownSpeed;
						}
					}
					catch
					{
					}
					if (_logCd < 8)
					{
						_logCd++;
						Probe.Append("arch demon: [CD] 兜底把 '" + ((Object)((Component)val2).gameObject).name + "' 冷却 " + num.ToString("0.#") + " -> " + 40f.ToString("0.#") + " 秒 ✓(重新 Serialize)");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] arch demon cd sync failed: " + ex));
				}
			}
		}

		private static void UpdateBadge(bool empowered)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!empowered)
				{
					if (_badge != null && _badge.attached)
					{
						_badge.Detach();
					}
				}
				else
				{
					if ((Object)(object)_player == (Object)null)
					{
						return;
					}
					if (_badge == null)
					{
						string name = _entityName;
						if (string.IsNullOrEmpty(name))
						{
							name = "ArchDemon";
						}
						_badge = new Badge("arch demon (empowered)", () => Badge.QuintessenceIcon(name), Badge.Glyph.Flame, new Color(0.9f, 0.35f, 0.85f, 1f));
					}
					if (!_badge.attached)
					{
						_badge.Attach(_player);
					}
					float num = Mathf.Max(0f, _empoweredUntil - Time.time);
					_badge.Update(num / 10f, 1);
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] arch demon badge failed: " + ex));
				}
			}
		}

		private static void AppendNote()
		{
			try
			{
				Type type = AccessTools.TypeByName("GameResources.LocalizationStringResource") ?? AccessTools.TypeByName("LocalizationStringResource");
				if (type == null)
				{
					Probe.Append("arch demon: [文案] 找不到 LocalizationStringResource ✗");
					return;
				}
				PropertyInfo propertyInfo = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				object obj = ((propertyInfo != null) ? propertyInfo.GetValue(null, null) : null);
				if (obj == null)
				{
					Probe.Append("arch demon: [文案] instance 为空 ✗");
					return;
				}
				PropertyInfo property = obj.GetType().GetProperty("stringsByLanguage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property == null)
				{
					Probe.Append("arch demon: [文案] 没有 stringsByLanguage ✗");
					return;
				}
				if (!(property.GetValue(obj, null) is Array array))
				{
					Probe.Append("arch demon: [文案] 表为空 ✗");
					return;
				}
				string text = "<color=#F25D1C>(本模组:持有时魔法攻击增幅 20%;使用后 10 秒内增幅提高到 40%;冷却 40 秒)</color>";
				int num = 0;
				for (int i = 0; i < array.Length; i++)
				{
					object value = array.GetValue(i);
					if (value == null)
					{
						continue;
					}
					FieldInfo field = value.GetType().GetField("strings", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field == null || !(field.GetValue(value) is string[] array2) || array2.Length <= 3)
					{
						continue;
					}
					string text2 = array2[3];
					if (!string.IsNullOrEmpty(text2) && text2.Length >= 20 && text2.IndexOf("大恶魔", StringComparison.Ordinal) >= 0)
					{
						if (text2.IndexOf("(本模组", StringComparison.Ordinal) >= 0)
						{
							num++;
							continue;
						}
						array2[3] = text2 + text;
						num++;
						Probe.Append("arch demon: [文案] ★已往第 " + i + " 行追加说明 ✓(" + array2[3].Length + " 字 ✓)");
					}
				}
				if (num == 0)
				{
					Probe.Append("arch demon: [文案] 没找到含「大恶魔」的说明行 ✗");
				}
			}
			catch (Exception ex)
			{
				Probe.Append("arch demon: [文案] 出错:" + ex.GetType().Name + " ✗");
			}
		}
	}
	internal static class AttackDamageBoostPatch
	{
		private static bool _installed;

		private static int _reports;

		private static int _hits;

		private static int _skips;

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

		internal static void InstallOnce(Harmony harmony)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			if (_installed || harmony == null)
			{
				return;
			}
			_installed = true;
			try
			{
				int num = 0;
				StringBuilder stringBuilder = new StringBuilder();
				MethodInfo methodInfo = AccessTools.Method(typeof(AttackDamageBoostPatch), "Boost", (Type[])null, (Type[])null);
				Type type = FindType("Characters.Operations.Attack.SweepAttack");
				if (type != null && methodInfo != null)
				{
					MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (MethodInfo methodInfo2 in methods)
					{
						if (methodInfo2.GetParameters().Length <= 6 && !(methodInfo2.ReturnType != typeof(void)) && !methodInfo2.ContainsGenericParameters)
						{
							try
							{
								harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(methodInfo), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
								num++;
								stringBuilder.Append(methodInfo2.Name).Append("(").Append(methodInfo2.GetParameters().Length)
									.Append("), ");
							}
							catch (Exception ex)
							{
								Probe.Append("attack boost: 挂 " + methodInfo2.Name + " 失败 -> " + ex.GetType().Name);
							}
						}
					}
				}
				Probe.Append("attack boost: 已挂 SweepAttack 自己的方法 共 " + num + " 条 -> " + stringBuilder?.ToString() + "|SweepAttack=" + ((type != null) ? type.FullName : "未找到 ✗"));
			}
			catch (Exception ex2)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] attack boost install failed: " + ex2));
				}
			}
		}

		private static void Boost(object __instance)
		{
			try
			{
				if (__instance == null)
				{
					return;
				}
				MonoBehaviour val = (MonoBehaviour)((__instance is MonoBehaviour) ? __instance : null);
				if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null)
				{
					return;
				}
				string name = ((Object)((Component)val).gameObject).name;
				if (string.IsNullOrEmpty(name))
				{
					return;
				}
				_hits++;
				if (_hits <= 25)
				{
					Probe.Append("attack boost: [命中] " + ((object)val).GetType().FullName + " 在 GO = " + name + "(第 " + _hits + " 次 ✓)");
				}
				object? obj = AccessTools.Field(__instance.GetType(), "_attackDamage")?.GetValue(__instance);
				MonoBehaviour val2 = (MonoBehaviour)((obj is MonoBehaviour) ? obj : null);
				if ((Object)(object)val2 == (Object)null)
				{
					if (_skips < 15)
					{
						_skips++;
						Probe.Append("attack boost: [跳过] _attackDamage 取不到(" + name + ")");
					}
					return;
				}
				string text = (((Object)(object)((Component)val2).gameObject != (Object)null) ? ((Object)((Component)val2).gameObject).name : null);
				string text2 = ((!string.IsNullOrEmpty(text)) ? text : name);
				if (text2.IndexOf("SymbolOfToughness", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					FieldInfo fieldInfo = AccessTools.Field(((object)val2).GetType(), "_minAttackDamage");
					FieldInfo fieldInfo2 = AccessTools.Field(((object)val2).GetType(), "_maxAttackDamage");
					if (!(fieldInfo == null) && !(fieldInfo2 == null))
					{
						int num = (int)fieldInfo.GetValue(val2);
						int num2 = (int)fieldInfo2.GetValue(val2);
						Character val3 = ItemCopies.CurrentPlayer();
						double num3 = (((Object)(object)val3 != (Object)null && (Object)(object)val3.health != (Object)null && ((Health)val3.health).shield != null) ? ((Health)val3.health).shield.amount : 0.0);
						int num4 = (int)Math.Round(num3 * 10.0);
						if (num4 < 1)
						{
							num4 = 1;
						}
						if (num != num4)
						{
							fieldInfo.SetValue(val2, num4);
						}
						if (num2 != num4)
						{
							fieldInfo2.SetValue(val2, num4);
						}
						_reports++;
						if (_reports <= 40)
						{
							Probe.Append("attack boost: 坚韧的象征(" + text2 + ")基础值 = 护盾 " + num3.ToString("0.##") + " × 10 = " + num4 + "(" + num + "~" + num2 + " -> " + num4 + "~" + num4 + ")✓");
						}
					}
					return;
				}
				double num5 = 0.0;
				string text3 = null;
				if (text2.IndexOf("GoldenMane", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					num5 = 1.5;
					text3 = "金鬃刀痕";
				}
				if (num5 <= 0.0 || text3 == null)
				{
					if (_skips < 15)
					{
						_skips++;
						Probe.Append("attack boost: [跳过] 名字不匹配 -> AttackDamage@" + text2 + "(operation@" + name + ")");
					}
					return;
				}
				FieldInfo fieldInfo3 = AccessTools.Field(((object)val2).GetType(), "_minAttackDamage");
				FieldInfo fieldInfo4 = AccessTools.Field(((object)val2).GetType(), "_maxAttackDamage");
				if (!(fieldInfo3 == null) && !(fieldInfo4 == null))
				{
					int num6 = (int)fieldInfo3.GetValue(val2);
					int num7 = (int)fieldInfo4.GetValue(val2);
					int instanceID = ((Object)val2).GetInstanceID();
					if (!Base.TryGetValue(instanceID, out var value))
					{
						value = new int[2] { num6, num7 };
						Base[instanceID] = value;
					}
					int num8 = (int)Math.Round((double)value[0] * num5);
					int num9 = (int)Math.Round((double)value[1] * num5);
					if (num6 != num8)
					{
						fieldInfo3.SetValue(val2, num8);
					}
					if (num7 != num9)
					{
						fieldInfo4.SetValue(val2, num9);
					}
					if (_reports < 40)
					{
						_reports++;
						Probe.Append("attack boost: " + text3 + "(" + text2 + ")基础值 x" + num5.ToString("0.##") + " —— 基准 " + value[0] + "~" + value[1] + " 到 " + num8 + "~" + num9 + "(实际读取点 ✓)");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] attack boost failed: " + ex));
				}
			}
		}

		private static Type FindType(string fullName)
		{
			Type type = AccessTools.TypeByName(fullName);
			if (type != null)
			{
				return type;
			}
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				try
				{
					Type[] types = assembly.GetTypes();
					foreach (Type type2 in types)
					{
						if (type2 != null && type2.Name == "SweepAttack")
						{
							return type2;
						}
					}
				}
				catch
				{
				}
			}
			return null;
		}
	}
	internal static class AttackPercentPatch
	{
		private const string Doomsday = "Doomsday";

		private const string Fellowship = "ProofOfFellowship";

		private const double DoomsdayBonus = 0.5;

		private const double PerStackBonus = 0.1;

		private static Character _player;

		private static Values _values;

		private static double _appliedPhysical = -1.0;

		private static double _appliedMagic = -1.0;

		private static int _reports;

		internal static void Tick()
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			try
			{
				if ((Object)(object)_player == (Object)null)
				{
					return;
				}
				Stat stat = _player.stat;
				if (stat == null)
				{
					return;
				}
				bool flag = Holds("Doomsday");
				int num = FellowshipStacks();
				double num2 = (flag ? (0.5 * (double)ItemCopies.CountAtLeastOne("Doomsday")) : 0.0) + (double)num * 0.1 * (double)ItemCopies.CountAtLeastOne("ProofOfFellowship");
				double num3 = num2;
				if (!(Math.Abs(num2 - _appliedPhysical) < 0.0001) || !(Math.Abs(num3 - _appliedMagic) < 0.0001))
				{
					if (_values != null)
					{
						stat.DetachValues(_values);
					}
					_values = null;
					if (num2 > 0.0)
					{
						_values = new Values((Value[])(object)new Value[2]
						{
							new Value(Category.PercentPoint, Kind.PhysicalAttackDamage, num2),
							new Value(Category.PercentPoint, Kind.MagicAttackDamage, num3)
						});
						stat.AttachValues(_values);
					}
					stat.Update();
					_appliedPhysical = num2;
					_appliedMagic = num3;
					_reports++;
					Probe.Append("attack percent: 物攻 +" + (num2 * 100.0).ToString("0.#") + "% / 魔攻 +" + (num3 * 100.0).ToString("0.#") + "%(审判之日=" + flag + ",友谊层数=" + num + ",第 " + _reports + " 次变更)");
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] attack percent tick failed: " + ex));
				}
			}
		}

		private static int FellowshipStacks()
		{
			try
			{
				if ((Object)(object)_player == (Object)null || !Holds("ProofOfFellowship"))
				{
					return 0;
				}
				CharacterAbilityManager ability = _player.ability;
				if ((Object)(object)ability == (Object)null)
				{
					return 0;
				}
				for (int i = 0; i < ability.Count; i++)
				{
					IAbilityInstance obj = ability[i];
					Instance val = (Instance)(object)((obj is Instance) ? obj : null);
					if (val == null)
					{
						continue;
					}
					object obj2 = null;
					Type type = ((object)val).GetType();
					while (type != null && obj2 == null)
					{
						FieldInfo field = type.GetField("ability", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field != null)
						{
							obj2 = field.GetValue(val);
						}
						type = type.BaseType;
					}
					if (obj2 == null)
					{
						continue;
					}
					Type type2 = obj2.GetType();
					while (type2 != null)
					{
						FieldInfo field2 = type2.GetField("stack", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field2 != null)
						{
							return Convert.ToInt32(field2.GetValue(obj2));
						}
						PropertyInfo property = type2.GetProperty("stack", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (property != null && property.CanRead)
						{
							return Convert.ToInt32(property.GetValue(obj2, null));
						}
						type2 = type2.BaseType;
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] attack percent stacks failed: " + ex));
				}
			}
			return 0;
		}

		private static bool Holds(string gearName)
		{
			try
			{
				if ((Object)(object)_player == (Object)null || _player.playerComponents == null)
				{
					return false;
				}
				List<Item> items = _player.playerComponents.inventory.item.items;
				for (int i = 0; i < items.Count; i++)
				{
					Item val = items[i];
					if (!((Object)(object)val == (Object)null) && ((Object)val).name != null && ((Object)val).name.IndexOf(gearName, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "Awake")]
		private static void WatchPlayer(Character __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			try
			{
				if (!((Object)(object)__instance == (Object)null) && (int)__instance.type == 6)
				{
					_player = __instance;
					Ticker.Register(delegate
					{
						Tick();
					});
					Probe.Append("attack percent: 已启动(审判之日 +50% 物/魔攻;友谊的证明 每层 +10%)");
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] attack percent watch failed: " + ex));
				}
			}
		}

		internal static void SelfCheck()
		{
			Probe.Append("self-check attack percent: 审判之日 +" + 50.0.ToString("0") + "% 物/魔攻(固定);友谊的证明每层 +" + 10.0.ToString("0") + "%(最多 5 层 = +50%)-> PASS");
		}
	}
	internal sealed class Badge
	{
		internal enum Glyph
		{
			Cross,
			Arrow,
			Flame
		}

		private static readonly HashSet<string> IconLogged = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private readonly string _name;

		private readonly BadgeAbility _ability;

		private readonly Func<Sprite> _iconProvider;

		private readonly Glyph _fallbackGlyph;

		private readonly Color _fallbackColor;

		private Sprite _fallback;

		private int _iconMisses;

		private Character _owner;

		private bool _attached;

		private bool _iconResolved;

		private Sprite _brightSprite;

		private Sprite _dimSprite;

		private bool _dimTried;

		private bool _active;

		internal bool attached => _attached;

		internal Character owner => _owner;

		internal string label => _name;

		internal Badge(string name, Func<Sprite> iconProvider, Glyph fallbackGlyph, Color fallbackColor)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			_name = name;
			_iconProvider = iconProvider;
			_fallbackGlyph = fallbackGlyph;
			_fallbackColor = fallbackColor;
			_ability = new BadgeAbility();
			((Ability)_ability).duration = float.PositiveInfinity;
			_ability.fill = 0f;
			_ability.stacks = 0;
			TryResolveIcon();
		}

		internal static Sprite ItemIcon(string itemName)
		{
			try
			{
				GearResource instance = GearResource.instance;
				if ((Object)(object)instance == (Object)null)
				{
					return null;
				}
				Sprite val = instance.GetItemBuffIcon(itemName);
				string text = "item buff icon";
				if ((Object)(object)val == (Object)null)
				{
					val = instance.GetGearThumbnail(itemName);
					text = "gear thumbnail";
				}
				if ((Object)(object)val != (Object)null && IconLogged.Add(itemName))
				{
					Probe.Append("badge icon: '" + itemName + "' -> sprite '" + ((Object)val).name + "' (" + text + ")");
				}
				return val;
			}
			catch
			{
				return null;
			}
		}

		internal static Sprite QuintessenceIcon(string quintName)
		{
			try
			{
				GearResource instance = GearResource.instance;
				if ((Object)(object)instance != (Object)null && !string.IsNullOrEmpty(quintName))
				{
					Sprite quintessenceHudIcon = instance.GetQuintessenceHudIcon(quintName);
					if ((Object)(object)quintessenceHudIcon != (Object)null)
					{
						if (IconLogged.Add("quint:" + quintName))
						{
							Probe.Append("badge icon: quintessence '" + quintName + "' -> sprite '" + ((Object)quintessenceHudIcon).name + "' (quintessence hud icon)");
						}
						return quintessenceHudIcon;
					}
				}
			}
			catch
			{
			}
			return ItemIcon(quintName);
		}

		private void TryResolveIcon()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (_iconResolved)
			{
				return;
			}
			try
			{
				Sprite val = ((_iconProvider != null) ? _iconProvider() : null);
				if ((Object)(object)val != (Object)null)
				{
					_ability.sprite = val;
					((Ability)_ability).defaultIcon = val;
					_iconResolved = true;
				}
				else if (++_iconMisses >= 30)
				{
					_fallback = MakeIcon(_fallbackGlyph, _fallbackColor);
					_ability.sprite = _fallback;
					((Ability)_ability).defaultIcon = _fallback;
					_iconResolved = true;
					Probe.Append($"badge[{_name}]: item icon NOT available after {_iconMisses} tries - using the drawn placeholder glyph");
				}
			}
			catch
			{
			}
		}

		internal void SetActive(bool active)
		{
			try
			{
				if (!active)
				{
					if (_attached)
					{
						Detach();
					}
					_active = false;
				}
				else
				{
					_active = true;
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] badge[" + _name + "] SetActive failed: " + ex));
				}
			}
		}

		private Sprite MakeDimmed(Sprite source)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Texture2D texture = source.texture;
				if ((Object)(object)texture == (Object)null)
				{
					return null;
				}
				int width = ((Texture)texture).width;
				int height = ((Texture)texture).height;
				Texture2D val = null;
				try
				{
					val = new Texture2D(width, height, (TextureFormat)4, false);
					val.SetPixels(texture.GetPixels());
				}
				catch
				{
					val = null;
				}
				if ((Object)(object)val == (Object)null)
				{
					Probe.Append($"badge[{_name}]: 图标纹理不可读({width}x{height})且本作没有 Graphics.Blit,无法生成压暗副本 -> 失效时仍用原图标");
					return null;
				}
				if ((Object)(object)val != (Object)null)
				{
					Color[] pixels = val.GetPixels();
					for (int i = 0; i < pixels.Length; i++)
					{
						pixels[i] = new Color(pixels[i].r * 0.35f, pixels[i].g * 0.35f, pixels[i].b * 0.35f, pixels[i].a);
					}
					val.SetPixels(pixels);
					val.Apply();
					((Object)val).hideFlags = (HideFlags)61;
					Texture2D obj2 = val;
					Rect rect = source.rect;
					float x = source.pivot.x;
					Rect rect2 = source.rect;
					float num = x / ((Rect)(ref rect2)).width;
					float y = source.pivot.y;
					rect2 = source.rect;
					Sprite obj3 = Sprite.Create(obj2, rect, new Vector2(num, y / ((Rect)(ref rect2)).height), source.pixelsPerUnit);
					((Object)obj3).hideFlags = (HideFlags)61;
					return obj3;
				}
				return null;
			}
			catch
			{
				return null;
			}
		}

		internal void Attach(Character owner)
		{
			try
			{
				if ((Object)(object)owner != (Object)null)
				{
					if (_attached && (Object)(object)_owner != (Object)null && (Object)(object)_owner != (Object)(object)owner)
					{
						Detach();
					}
					_owner = owner;
				}
				TryResolveIcon();
				if (_attached && (Object)(object)owner != (Object)null && (Object)(object)owner.ability != (Object)null)
				{
					bool flag = false;
					try
					{
						flag = owner.ability.Contains((IAbility)(object)_ability);
					}
					catch
					{
					}
					if (!flag)
					{
						_attached = false;
					}
				}
				if (!_attached && !((Object)(object)owner == (Object)null) && !((Object)(object)owner.ability == (Object)null) && (_ability.stacks > 0 || !(_ability.fill >= 1f)))
				{
					owner.ability.Add((IAbility)(object)_ability);
					_owner = owner;
					_attached = true;
					Probe.Append("badge[" + _name + "]: shown in the buff bar (icon=" + (((Object)(object)_ability.sprite != (Object)null) ? ((Object)_ability.sprite).name : "pending") + ")");
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] badge[" + _name + "] attach failed: " + ex));
				}
			}
		}

		internal void Detach()
		{
			try
			{
				if (_attached)
				{
					if ((Object)(object)_owner != (Object)null && (Object)(object)_owner.ability != (Object)null)
					{
						_owner.ability.Remove((IAbility)(object)_ability);
					}
					_attached = false;
					Probe.Append("badge[" + _name + "]: removed from the buff bar");
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] badge[" + _name + "] detach failed: " + ex));
				}
			}
		}

		internal void Release()
		{
			Detach();
			_owner = null;
			_active = false;
		}

		internal void Update(float fill, int stacks)
		{
			float num = ((fill < 0f) ? 0f : ((fill > 1f) ? 1f : fill));
			_ability.fill = 1f - num;
			_ability.stacks = ((stacks > 0) ? stacks : 0);
			if (_ability.stacks <= 0 && num <= 0f)
			{
				if (_attached)
				{
					Detach();
				}
			}
			else if (!_attached && (Object)(object)_owner != (Object)null)
			{
				Attach(_owner);
			}
		}

		private static Sprite MakeIcon(Glyph glyph, Color color)
		{
			//IL_0026: 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_009c: 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_00a8: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			Color[] array = (Color[])(object)new Color[1024];
			Color val = default(Color);
			((Color)(ref val))..ctor(0.08f, 0.06f, 0.1f, 1f);
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					bool flag = InGlyph(glyph, j, i, 32, 3);
					bool flag2 = InGlyph(glyph, j, i, 32, 0);
					array[i * 32 + j] = (Color)(flag2 ? color : (flag ? val : new Color(0f, 0f, 0f, 0f)));
				}
			}
			Texture2D val2 = new Texture2D(32, 32, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1
			};
			val2.SetPixels(array);
			val2.Apply();
			((Object)val2).hideFlags = (HideFlags)61;
			Sprite obj = Sprite.Create(val2, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 32f);
			((Object)obj).hideFlags = (HideFlags)61;
			return obj;
		}

		private static bool InGlyph(Glyph glyph, int x, int y, int size, int grow)
		{
			float num = (float)(size - 1) * 0.5f;
			float num2 = (float)(size - 1) * 0.5f;
			float num3 = (float)x - num;
			float num4 = (float)y - num2;
			switch (glyph)
			{
			case Glyph.Cross:
				if (!(Mathf.Abs(num3) <= (float)(2 + grow)) || !(Mathf.Abs(num4) <= (float)(11 + grow)))
				{
					if (Mathf.Abs(num4 - 2f) <= (float)(2 + grow))
					{
						return Mathf.Abs(num3) <= (float)(8 + grow);
					}
					return false;
				}
				return true;
			case Glyph.Arrow:
			{
				if (Mathf.Abs(num3) <= (float)(2 + grow) && num4 <= (float)(3 + grow) && num4 >= (float)(-11 - grow))
				{
					return true;
				}
				float num5 = 13 + grow;
				float num6 = 2 - grow;
				if (num4 <= num5 && num4 >= num6)
				{
					float num7 = (num5 - num4) * 0.62f + (float)grow;
					return Mathf.Abs(num3) <= num7;
				}
				return false;
			}
			case Glyph.Flame:
				if (num4 >= (float)(2 + grow) && Mathf.Abs(num3) <= (float)(12 + grow) - (num4 - 2f) * 0.8f)
				{
					return true;
				}
				if (num4 < (float)(2 + grow) && num3 * num3 + (num4 + 3f) * (num4 + 3f) <= (float)((8 + grow) * (8 + grow)))
				{
					return true;
				}
				return false;
			default:
				return false;
			}
		}
	}
	internal sealed class BadgeAbility : Ability
	{
		private sealed class BadgeInstance : AbilityInstance<BadgeAbility>
		{
			public override Sprite icon => base.ability.sprite;

			public override float iconFillAmount => base.ability.fill;

			public override int iconStacks => base.ability.stacks;

			internal BadgeInstance(Character owner, BadgeAbility ability)
				: base(owner, ability)
			{
			}

			public override void OnAttach()
			{
			}

			public override void OnDetach()
			{
			}
		}

		internal Sprite sprite;

		internal float fill;

		internal int stacks;

		public override IAbilityInstance CreateInstance(Character owner)
		{
			return (IAbilityInstance)(object)new BadgeInstance(owner, this);
		}
	}
	internal static class BansheePatch
	{
		internal const int RequiredHits = 3;

		internal const double MagicDamageMultiplier = 2.0;

		internal const float InstantRadius = 10f;

		internal const int EnemyLayerMask = 1024;

		private const string TextHint = "女妖将演奏哀乐";

		private const string Note = "使用精华时立刻让周围敌人陷入倾听;倾听状态改为受到 3 次伤害才解除;倾听状态下的敌人受到的魔法伤害 2 倍";

		private const float ClaimWindow = 3f;

		private static readonly Collider2D[] Buffer = (Collider2D[])(object)new Collider2D[96];

		private static MethodInfo _onAttach;

		private static MethodInfo _onDetach;

		private static MethodInfo _onTookDamage;

		private static MethodInfo _use;

		private static MethodInfo _takeDamage;

		private static FieldInfo _maxCountField;

		private static FieldInfo _countField;

		private static Attentiveness _template;

		private static string _essenceName;

		private static Quintessence _lastUsed;

		private static float _lastUseTime = -1000f;

		private static readonly HashSet<string> SeenEssences = new HashSet<string>(StringComparer.Ordinal);

		private static long _attaches;

		private static long _countedHits;

		private static long _boosts;

		private static long _instantApplied;

		private static int _instantReports;

		private static int _typesDumped;

		private static int _scanReports;

		private static int _deepScan;

		private static float _instantRadius = 10f;

		private static bool _radiusFromVanilla;

		private static float _nextNoteTry;

		private static bool _noteDone;

		private static bool _installed;

		internal static void Install(Harmony harmony)
		{
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Expected O, but got Unknown
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Expected O, but got Unknown
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Expected O, but got Unknown
			if (!_installed)
			{
				_installed = true;
				Type typeFromHandle = typeof(Instance);
				_maxCountField = AccessTools.Field(typeFromHandle, "_maxcount");
				_countField = AccessTools.Field(typeFromHandle, "_count");
				_onAttach = AccessTools.Method(typeFromHandle, "OnAttach", Type.EmptyTypes, (Type[])null);
				_onDetach = AccessTools.Method(typeFromHandle, "OnDetach", Type.EmptyTypes, (Type[])null);
				_onTookDamage = AccessTools.Method(typeFromHandle, "OnTookDamage", new Type[3]
				{
					typeof(Damage).MakeByRefType(),
					typeof(Damage).MakeByRefType(),
					typeof(double)
				}, (Type[])null) ?? AccessTools.Method(typeFromHandle, "OnTookDamage", (Type[])null, (Type[])null);
				_use = AccessTools.Method(typeof(Quintessence), "Use", Type.EmptyTypes, (Type[])null);
				_takeDamage = AccessTools.Method(typeof(Health), "TakeDamage", new Type[2]
				{
					typeof(Damage).MakeByRefType(),
					typeof(double).MakeByRefType()
				}, (Type[])null);
				if (_onAttach != null)
				{
					harmony.Patch((MethodBase)_onAttach, (HarmonyMethod)null, new HarmonyMethod(typeof(BansheePatch).GetMethod("AfterTranceAttached", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					Probe.Append("banshee: Attentiveness.Instance.OnAttach NOT FOUND - 3 次解除没法生效");
				}
				if (_onDetach != null)
				{
					harmony.Patch((MethodBase)_onDetach, (HarmonyMethod)null, new HarmonyMethod(typeof(BansheePatch).GetMethod("AfterTranceDetached", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				if (_onTookDamage != null)
				{
					harmony.Patch((MethodBase)_onTookDamage, (HarmonyMethod)null, new HarmonyMethod(typeof(BansheePatch).GetMethod("AfterTranceTookDamage", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					Probe.Append("banshee: Attentiveness.Instance.OnTookDamage NOT FOUND - 计数探针缺失(不影响 3 次解除)");
				}
				if (_use != null)
				{
					harmony.Patch((MethodBase)_use, (HarmonyMethod)null, new HarmonyMethod(typeof(BansheePatch).GetMethod("AfterEssenceUsed", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					Probe.Append("banshee: Quintessence.Use NOT FOUND - 立刻施加没法生效");
				}
				if (_takeDamage != null)
				{
					harmony.Patch((MethodBase)_takeDamage, new HarmonyMethod(typeof(BansheePatch).GetMethod("BoostMagicOnTranceVictim", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					Probe.Append("banshee: Health.TakeDamage(ref Damage, out double) NOT FOUND - 倾听增伤没法生效");
				}
				Ticker.Register(NoteTick);
				Probe.Append("banshee: 已启动 ✓(倾听 = Characters.Abilities.Attentiveness:挨 " + 3 + " 次伤害才解除 ✓;倾听中受到魔法伤害 " + 2.0.ToString("0.##") + " 倍 ✓;用精华立刻给半径 " + 10f.ToString("0.#") + " 内的敌人挂上 ✓)");
				if (_maxCountField == null)
				{
					Probe.Append("banshee: 找不到 Attentiveness.Instance._maxcount ✗ ⇒ 3 次解除不会生效(其余两条照常)");
				}
			}
		}

		private static void AfterTranceAttached(Instance __instance)
		{
			try
			{
				if (__instance != null)
				{
					int maxcount = __instance._maxcount;
					__instance._maxcount = 3;
					if (_template == null)
					{
						_template = ((AbilityInstance<Attentiveness>)(object)__instance).ability;
					}
					if (_typesDumped < 1)
					{
						_typesDumped++;
						DumpAbilityFacts(((AbilityInstance<Attentiveness>)(object)__instance).ability);
					}
					float num = (((Object)(object)_lastUsed != (Object)null) ? (Time.time - _lastUseTime) : (-1f));
					if (_essenceName == null && (Object)(object)_lastUsed != (Object)null && num >= 0f && num <= 3f)
					{
						_essenceName = ((Object)_lastUsed).name;
						Probe.Append("banshee: ★认领到精华 '" + _essenceName + "'(倾听在用它之后 " + num.ToString("0.###") + " 秒挂上 ⇒ 之后改为同一帧立刻施加 ✓)");
					}
					_attaches++;
					if (_attaches <= 8 || _attaches % 30 == 0L)
					{
						string text = (((Object)(object)((AbilityInstance)__instance).owner != (Object)null) ? ((Object)((AbilityInstance)__instance).owner).name : "<null>");
						Probe.Append("banshee: 倾听挂到 '" + text + "':_maxcount " + ((maxcount >= 0) ? maxcount.ToString() : "?") + " -> " + 3 + "(第 " + _attaches + " 次;距上次用精华 " + ((num >= 0f) ? (num.ToString("0.###") + " 秒") : "无") + ")");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] banshee attach hook failed: " + ex));
				}
			}
		}

		private static void DumpAbilityFacts(Attentiveness ability)
		{
			try
			{
				if (ability == null)
				{
					return;
				}
				FieldInfo fieldInfo = AccessTools.Field(typeof(Attentiveness), "_types");
				object obj = ((fieldInfo != null) ? fieldInfo.GetValue(ability) : null);
				PropertyInfo propertyInfo = obj?.GetType().GetProperty("Array");
				bool[] array = ((propertyInfo != null) ? (propertyInfo.GetValue(obj, null) as bool[]) : null);
				StringBuilder stringBuilder = new StringBuilder();
				if (array != null)
				{
					for (int i = 0; i < array.Length; i++)
					{
						stringBuilder.Append(i).Append(array[i] ? '✓' : '✗').Append(' ');
					}
				}
				else
				{
					stringBuilder.Append("<读不到>");
				}
				Probe.Append("banshee: 倾听资产事实 —— 计数认的攻击类型(0 None / 1 Melee / 2 Ranged / 3 Projectile / 4 Additional):" + stringBuilder?.ToString() + "|持续时间 " + ((Ability)ability).duration.ToString("0.###") + " 秒");
			}
			catch (Exception ex)
			{
				Probe.Append("banshee: 倾听资产事实读取失败:" + ex.GetType().Name);
			}
		}

		private static void AfterTranceDetached(Instance __instance)
		{
			try
			{
				if (__instance != null)
				{
					int count = __instance._count;
					if (_attaches <= 12 || count >= 3)
					{
						string text = (((Object)(object)((AbilityInstance)__instance).owner != (Object)null) ? ((Object)((AbilityInstance)__instance).owner).name : "<null>");
						Probe.Append("banshee: 倾听解除 '" + text + "'(挨打计数 " + count + "/" + 3 + ")");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] banshee detach hook failed: " + ex));
				}
			}
		}

		private static void AfterTranceTookDamage(Instance __instance)
		{
			try
			{
				if (__instance == null)
				{
					return;
				}
				_countedHits++;
				if (_countedHits <= 20)
				{
					int count = __instance._count;
					if (count >= 0 && count <= 5)
					{
						string text = (((Object)(object)((AbilityInstance)__instance).owner != (Object)null) ? ((Object)((AbilityInstance)__instance).owner).name : "<null>");
						Probe.Append("banshee: 倾听挨打 '" + text + "' 计数 " + count + "/" + 3 + "(第 " + _countedHits + " 次)");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] banshee hit hook failed: " + ex));
				}
			}
		}

		private static void BoostMagicOnTranceVictim(Health __instance, ref Damage damage)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			try
			{
				if ((Object)(object)__instance == (Object)null || (int)damage.attribute != 1)
				{
					return;
				}
				Character owner = __instance.owner;
				if (!((Object)(object)owner == (Object)null) && !((Object)(object)owner.ability == (Object)null) && owner.ability.GetInstanceByInstanceType<Instance>() != null)
				{
					double percentMultiplier = damage.percentMultiplier;
					damage.percentMultiplier = percentMultiplier * 2.0;
					_boosts++;
					if (_boosts <= 8 || _boosts % 30 == 0L)
					{
						Probe.Append("banshee: 倾听中魔法伤害 " + 2.0.ToString("0.##") + " 倍 '" + ((Object)owner).name + "' percentMultiplier " + percentMultiplier.ToString("0.####") + " -> " + damage.percentMultiplier.ToString("0.####") + "(第 " + _boosts + " 次 ✓)");
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] banshee magic boost failed: " + ex));
				}
			}
		}

		private static void AfterEssenceUsed(Quintessence __instance)
		{
			try
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return;
				}
				_lastUsed = __instance;
				_lastUseTime = Time.time;
				if (SeenEssences.Add(((Object)__instance).name ?? "<null>"))
				{
					string text = null;
					try
					{
						text = __instance.activeName;
					}
					catch
					{
					}
					Probe.Append("banshee: 精华使用 '" + ((Object)__instance).name + "'(主动技能名 '" + (text ?? "?") + "')");
				}
				if (!IsBansheeEssence(__instance))
				{
					return;
				}
				if (_template == null)
				{
					ScanEssence(__instance);
				}
				if (_template == null)
				{
					DeepScan();
				}
				Character owner = ((Gear)__instance).owner;
				if ((Object)(object)owner == (Object)null || (Object)(object)((Component)owner).transform == (Object)null)
				{
					return;
				}
				if (_template == null)
				{
					if (_scanReports < 3)
					{
						_scanReports++;
						Probe.Append("banshee: 用精华时还没拿到倾听资产 ✗(这一下只能等原版 7.75 秒后挂上;下一次应该就有了)");
					}
				}
				else
				{
					ApplyInstantly(owner);
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] banshee essence hook failed: " + ex));
				}
			}
		}

		private static bool IsBansheeEssence(Quintessence q)
		{
			string text = ((Object)q).name ?? string.Empty;
			if (text.IndexOf("Banshee", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return true;
			}
			if (_essenceName != null && string.Equals(text, _essenceName, StringComparison.Ordinal))
			{
				return true;
			}
			return false;
		}

		private static void ScanEssence(Quintessence q)
		{
			try
			{
				AbilityComponent[] componentsInChildren = ((Component)q).GetComponentsInChildren<AbilityComponent>(true);
				if (componentsInChildren != null)
				{
					foreach (AbilityComponent val in componentsInChildren)
					{
						if ((Object)(object)val == (Object)null)
						{
							continue;
						}
						IAbility val2 = null;
						try
						{
							val2 = val.ability;
						}
						catch
						{
						}
						if (val2 == null)
						{
							continue;
						}
						Attentiveness val3 = (Attentiveness)(object)((val2 is Attentiveness) ? val2 : null);
						if (val3 != null)
						{
							if (_template == null)
							{
								_template = val3;
								Probe.Append("banshee: ★用精华的瞬间就从精华对象上拿到倾听资产 ✓(" + ((object)val).GetType().Name + " @ '" + ((Object)((Component)val).gameObject).name + "',原版那份 ✓)");
							}
						}
						else
						{
							AttachAbilityWithinCollider val4 = (AttachAbilityWithinCollider)(object)((val2 is AttachAbilityWithinCollider) ? val2 : null);
							if (val4 != null)
							{
								ReadRadius(val4);
							}
						}
					}
				}
				if (_template == null && _scanReports < 2)
				{
					_scanReports++;
					DumpHierarchy(q);
				}
			}
			catch (Exception ex)
			{
				Probe.Append("banshee: 扫精华对象失败:" + ex.GetType().Name);
			}
		}

		private static void ReadRadius(AttachAbilityWithinCollider zone)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			try
			{
				if (_radiusFromVanilla || zone == null)
				{
					return;
				}
				FieldInfo fieldInfo = AccessTools.Field(typeof(AttachAbilityWithinCollider), "_collider");
				Collider2D val = (Collider2D)((fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null);
				if (!((Object)(object)val == (Object)null))
				{
					Bounds bounds = val.bounds;
					float num = Mathf.Max(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.y);
					if (!(num <= 0.01f) && !(num > 60f))
					{
						_instantRadius = num;
						_radiusFromVanilla = true;
						Probe.Append("banshee: 施加半径取自精华自己的范围碰撞体 -> " + num.ToString("0.##") + " ✓(" + ((object)val).GetType().Name + ")");
					}
				}
			}
			catch (Exception ex)
			{
				Probe.Append("banshee: 读范围碰撞体失败:" + ex.GetType().Name);
			}
		}

		private static void DeepScan()
		{
			try
			{
				if (_deepScan >= 2)
				{
					return;
				}
				_deepScan++;
				AbilityComponent[] array = Object.FindObjectsOfType<AbilityComponent>(true);
				if (array == null)
				{
					return;
				}
				foreach (AbilityComponent val in array)
				{
					if (!((Object)(object)val == (Object)null))
					{
						IAbility val2 = null;
						try
						{
							val2 = val.ability;
						}
						catch
						{
						}
						Attentiveness val3 = (Attentiveness)(object)((val2 is Attentiveness) ? val2 : null);
						if (val3 != null)
						{
							_template = val3;
							Probe.Append("banshee: ★全量扫描拿到倾听资产 ✓(" + ((object)val).GetType().Name + " @ '" + ((Object)((Component)val).gameObject).name + "')");
							return;
						}
						AttachAbilityWithinCollider val4 = (AttachAbilityWithinCollider)(object)((val2 is AttachAbilityWithinCollider) ? val2 : null);
						if (val4 != null)
						{
							ReadRadius(val4);
						}
					}
				}
				Probe.Append("banshee: 全量扫描也没找到 Attentiveness 资产(扫描了 " + array.Length + " 个 AbilityComponent)");
			}
			catch (Exception ex)
			{
				Probe.Append("banshee: 全量扫描失败:" + ex.GetType().Name);
			}
		}

		private static void DumpHierarchy(Quintessence q)
		{
			try
			{
				Component[] componentsInChildren = ((Component)q).GetComponentsInChildren<Component>(true);
				StringBuilder stringBuilder = new StringBuilder();
				if (componentsInChildren != null)
				{
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						if (stringBuilder.Length >= 800)
						{
							break;
						}
						if (!((Object)(object)componentsInChildren[i] == (Object)null))
						{
							stringBuilder.Append(((object)componentsInChildren[i]).GetType().Name).Append(' ');
						}
					}
				}
				Probe.Append("banshee: [诊断] 精华对象 '" + ((Object)q).name + "' 树上的组件:" + ((stringBuilder.Length > 0) ? stringBuilder.ToString() : "<空>"));
			}
			catch (Exception ex)
			{
				Probe.Append("banshee: [诊断] 组件清单读失败:" + ex.GetType().Name);
			}
		}

		private static void ApplyInstantly(Character player)
		{
			//IL_0002: 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_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_0036: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ContactFilter2D val = default(ContactFilter2D);
				((ContactFilter2D)(ref val)).SetLayerMask(LayerMask.op_Implicit(1024));
				val.useTriggers = false;
				int num = Physics2D.OverlapCircle(Vector2.op_Implicit(((Component)player).transform.position), _instantRadius, val, Buffer);
				int num2 = 0;
				for (int i = 0; i < num; i++)
				{
					Collider2D val2 = Buffer[i];
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					ITarget componentInParent = ((Component)val2).GetComponentInParent<ITarget>();
					if (componentInParent != null)
					{
						Character character = componentInParent.character;
						if (!((Object)(object)character == (Object)null) && !((Object)(object)character.health == (Object)null) && !((Health)character.health).dead && !((Object)(object)character.ability == (Object)null))
						{
							character.ability.Add((IAbility)(object)_template);
							num2++;
						}
					}
				}
				_instantApplied += num2;
				if (_instantReports < 30)
				{
					_instantReports++;
					Probe.Append("banshee: ★使用精华 ⇒ 同一帧给半径 " + _instantRadius.ToString("0.##") + " 内的 " + num2 + " 只敌人挂上倾听 ✓(碰撞体 " + num + " 个,累计 " + _instantApplied + " 只)");
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] banshee instant apply failed: " + ex));
				}
			}
		}

		private static void NoteTick(float deltaTime)
		{
			try
			{
				if (!_noteDone && !(Time.time < _nextNoteTry))
				{
					_nextNoteTry = Time.time + 1f;
					if (AppendNote())
					{
						_noteDone = true;
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] banshee note tick failed: " + ex));
				}
			}
		}

		private static bool AppendNote()
		{
			try
			{
				Type type = AccessTools.TypeByName("GameResources.LocalizationStringResource") ?? AccessTools.TypeByName("LocalizationStringResource");
				if (type == null)
				{
					return false;
				}
				PropertyInfo propertyInfo = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				object obj = ((propertyInfo != null) ? propertyInfo.GetValue(null, null) : null);
				if (obj == null)
				{
					return false;
				}
				PropertyInfo property = obj.GetType().GetProperty("stringsByLanguage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property == null)
				{
					Probe.Append("banshee: [文案] 没有 stringsByLanguage ✗");
					return true;
				}
				if (!(property.GetValue(obj, null) is Array array))
				{
					return false;
				}
				string text = "<color=#F25D1C>(本模组:使用精华时立刻让周围敌人陷入倾听;倾听状态改为受到 3 次伤害才解除;倾听状态下的敌人受到的魔法伤害 2 倍)</color>";
				int num = 0;
				for (int i = 0; i < array.Length; i++)
				{
					object value = array.GetValue(i);
					if (value == null)
					{
						continue;
					}
					FieldInfo field = value.GetType().GetField("strings", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field == null || !(field.GetValue(value) is string[] array2) || array2.Length <= 3)
					{
						continue;
					}
					string text2 = array2[3];
					if (!string.IsNullOrEmpty(text2) && text2.Length >= 20 && text2.IndexOf("女妖将演奏哀乐", StringComparison.Ordinal) >= 0)
					{
						if (text2.IndexOf("(本模组", StringComparison.Ordinal) >= 0)
						{
							num++;
							continue;
						}
						array2[3] = text2 + text;
						num++;
						Probe.Append("banshee: [文案] ★已往第 " + i + " 行追加说明 ✓(" + array2[3].Length + " 字 ✓)");
					}
				}
				if (num == 0)
				{
					Probe.Append("banshee: [文案] 没找到含「女妖将演奏哀乐」的说明行 ✗");
				}
				return num > 0;
			}
			catch (Exception ex)
			{
				Probe.Append("banshee: [文案] 出错:" + ex.GetType().Name + " ✗");
				return true;
			}
		}

		internal static void SelfCheck()
		{
			try
			{
				bool flag = _maxCountField != null && _takeDamage != null && _use != null && _onAttach != null;
				string text = "self-check banshee: Attentiveness.Instance.OnAttach=" + ((_onAttach != null) ? "ok" : "MISSING") + ", _maxcount field=" + ((_maxCountField != null) ? "ok" : "MISSING") + ", _count field=" + ((_countField != null) ? "ok" : "MISSING") + ", Quintessence.Use=" + ((_use != null) ? "ok" : "MISSING") + ", Health.TakeDamage(ref Damage, out double)=" + ((_takeDamage != null) ? "ok" : "MISSING") + ", requiredHits=" + 3 + ", magic x" + 2.0.ToString("0.##") + ", instantRadius=" + 10f.ToString("0.#") + " -> " + (flag ? "PASS" : "FAIL");
				Probe.Append(text);
				if (!flag && Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] " + text));
				}
			}
			catch (Exception ex)
			{
				Probe.Append("self-check banshee failed: " + ex.Message);
			}
		}
	}
	internal static class BattlefieldCupDiagPatch
	{
		internal static bool DiagActions = false;

		private static readonly string[] KeyWords = new string[20]
		{
			"trigger", "kind", "timing", "possibility", "cooldown", "count", "duration", "operation", "stack", "buff",
			"slash", "attack", "hit", "skill", "shield", "armor", "magic", "amount", "percent", "max"
		};

		private static int _dumps;

		private static int _actions;

		private static bool _watchPlayer;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Item), "SetOwner")]
		private static void Dump(Item __instance)
		{
			try
			{
				if ((Object)(object)__instance == (Object)null || ((Object)__instance).name == null || (((Object)__instance).name.IndexOf("BattlefieldCup", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)__instance).name.IndexOf("IronArmor", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)__instance).name.IndexOf("Steel", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)__instance).name.IndexOf("ScepterOfWhispers", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)__instance).name.IndexOf("Whisper", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)__instance).name.IndexOf("SwordOfChaos", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)__instance).name.IndexOf("CoinOfExtinction", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)__instance).name.IndexOf("Coin", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)__instance).name.IndexOf("SoulKiller", StringComparison.OrdinalIgnoreCase) < 0))
				{
					return;
				}
				StringBuilder stringBuilder = new StringBuilder();
				Component[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Component>(true);
				foreach (Component val in componentsInChildren)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					string name = ((object)val).GetType().Name;
					if (name.IndexOf("Gear", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("Sprite", StringComparison.OrdinalIgnoreCase) < 0)
					{
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append(", ");
						}
						stringBuilder.Append(name);
					}
				}
				Probe.Append("battlefield cup diag: 道具 '" + ((Object)__instance).name + "' 组件类 = " + stringBuilder);
				componentsInChildren = ((Component)__instance).GetComponentsInChildren<Component>(true);
				foreach (Component val2 in componentsInChildren)
				{
					if (!((Object)(object)val2 == (Object)null) && ((object)val2).GetType().Name.IndexOf("Gear", StringComparison.OrdinalIgnoreCase) < 0)
					{
						DumpFields(val2, ((object)val2).GetType().Name);
						DumpFields(GetMember(val2, "_ability"), ((object)val2).GetType().Name + "._ability");
						DumpFields(GetMember(val2, "_trigger"), ((object)val2).GetType().Name + "._trigger");
					}
				}
				if (((Object)__instance).name.IndexOf("ScepterOfWhispers", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)__instance).name.IndexOf("SwordOfChaos", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)__instance).name.IndexOf("CoinOfExtinction", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)__instance).name.IndexOf("SoulKiller", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					componentsInChildren = ((Component)__instance).GetComponentsInChildren<Component>(true);
					foreach (Component val3 in componentsInChildren)
					{
						if (!((Object)(object)val3 == (Object)null))
						{
							DumpAllNumbers(val3, ((object)val3).GetType().Name + "(全字段)");
							DumpAllNumbers(GetMember(val3, "_ability"), ((object)val3).GetType().Name + "._ability(全字段)");
						}
					}
				}
				_dumps++;
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] battlefield cup diag failed: " + ex));
				}
				Probe.Append("battlefield cup diag: 失败 -> " + ex.GetType().Name + ": " + ex.Message);
			}
		}

		private static void DumpAllNumbers(object target, string label)
		{
			try
			{
				if (target == null)
				{
					return;
				}
				StringBuilder stringBuilder = new StringBuilder();
				Type type = target.GetType();
				while (type != null && type != typeof(object))
				{
					FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (FieldInfo fieldInfo in fields)
					{
						Type fieldType = fieldInfo.FieldType;
						if (!(fieldType != typeof(int)) || !(fieldType != typeof(float)) || !(fieldType != typeof(double)) || !(fieldType != typeof(short)))
						{
							object obj = null;
							try
							{
								obj = fieldInfo.GetValue(target);
							}
							catch
							{
							}
							if (stringBuilder.Length > 0)
							{
								stringBuilder.Append(",");
							}
							stringBuilder.Append(fieldInfo.Name).Append("=").Append((obj != null) ? obj.ToString() : "null");
						}
					}
					type = type.BaseType;
				}
				if (stringBuilder.Length > 0)
				{
					Probe.Append("battlefield cup diag: [" + label + "] " + stringBuilder);
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] dump all numbers failed: " + ex));
				}
			}
		}

		private static void DumpFields(object target, string label)
		{
			try
			{
				if (target == null)
				{
					return;
				}
				StringBuilder stringBuilder = new StringBuilder();
				Type type = target.GetType();
				while (type != null && type != typeof(object))
				{
					FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (FieldInfo fieldInfo in fields)
					{
						string text = fieldInfo.Name.ToLowerInvariant();
						bool flag = false;
						string[] keyWords = KeyWords;
						foreach (string value in keyWords)
						{
							if (text.Contains(value))
							{
								flag = true;
								break;
							}
						}
						if (flag)
						{
							object obj = null;
							try
							{
								obj = fieldInfo.GetValue(target);
							}
							catch
							{
							}
							string text2 = ((obj != null) ? obj.ToString() : "null");
							if (text2.Length > 36)
							{
								text2 = text2.Substring(0, 36) + "…";
							}
							if (stringBuilder.Length > 0)
							{
								stringBuilder.Append(",");
							}
							stringBuilder.Append(fieldInfo.Name).Append("=").Append(text2);
						}
					}
					type = type.BaseType;
				}
				if (stringBuilder.Length > 0)
				{
					Probe.Append("battlefield cup diag: [" + label + "] " + stringBuilder);
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] battlefield cup diag dump failed: " + ex));
				}
			}
		}

		private static object GetMember(object target, string name)
		{
			if (target == null)
			{
				return null;
			}
			Type type = target.GetType();
			while (type != null)
			{
				FieldInfo field = type.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					return field.GetValue(target);
				}
				type = type.BaseType;
			}
			return null;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "Awake")]
		private static void WatchPlayer(Character __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			try
			{
				if ((Object)(object)__instance == (Object)null || (int)__instance.type != 6 || _watchPlayer)
				{
					return;
				}
				_watchPlayer = true;
				__instance.onStartAction += delegate(Action action)
				{
					//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)
					try
					{
						_actions++;
						if (_actions <= 40)
						{
							Probe.Append("battlefield cup diag: 玩家动作 #" + _actions + " type=" + ((object)action.type/*cast due to .constrained prefix*/).ToString() + "(name=" + ((Object)action).name + ")");
						}
					}
					catch
					{
					}
				};
				Probe.Append("battlefield cup diag: 已开始记录玩家动作(看技能与劈斩的先后)");
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("[STRONGERITEMS] battlefield cup diag watch failed: " + ex));
				}
			}
		}

		internal static void SelfCheck()
		{
			Probe.Append("self-check battlefield cup diag: 钩子 = Item.SetOwner / 道具 'BattlefieldCup*',已报告 " + _dumps + " 次,动作记录 " + _actions + " 条 -> PASS");
		}
	}
	internal static class BattlefieldCupPatch
	{
		private static readonly string[] GearNames = new string[1] { "BattlefieldCup" };

		private const int MysteryKey = 36;

		private const int ExecutionKey = 10;

		private static Character _player;

		private static string _lastInventory = "";

		private static int _swapReports;

		private static int _refReports;

		private static int _slashFired;

		internal static void Enforce(Item item)
		{
			try
			{
				if ((Object)(object)item == (Object)null || ((Object)item).name == null)
				{
					return;
				}
				string text = null;
				string[] gearNames = GearNames;
				foreach (string text2 in gearNames)
				{
					if (((Object)item).name.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						text = text2;
						break;
					}
				}
				if (text == null)
				{
					return;
				}
				bool flag = false;
				gearNames = new string[2] { "keyword1", "keyword2" };
				foreach (string name in gearNames)
				{
					FieldInfo fieldInfo = FindField(item, name);
					if (!(fieldInfo == null) && Convert.ToInt32(fieldInfo.GetValue(item)) == 36)
					{
						fieldInfo.SetValue(item, (object)(Key)10);
						flag = true;
					}
				}
				if (!flag)
				{
					r