Decompiled source of ReaperBalance v0.2.1

ReaperBalance/ReaperBalance.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GlobalSettings;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using Microsoft.CodeAnalysis;
using ReaperBalance.Source.Behaviours;
using ReaperBalance.Source.ModMenu;
using ReaperBalance.Source.Patches;
using Silksong.ModMenu;
using Silksong.ModMenu.Elements;
using Silksong.ModMenu.Models;
using Silksong.ModMenu.Screens;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ReaperBalance")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.2.1.0")]
[assembly: AssemblyInformationalVersion("0.2.1+f91b546ecc9e1629e637f1e50e4a05bedea669f5")]
[assembly: AssemblyProduct("ReaperBalance")]
[assembly: AssemblyTitle("ReaperBalance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MonoDetour.HookGen
{
	internal static class DefaultMonoDetourManager
	{
		internal static MonoDetourManager Instance { get; } = New();


		internal static MonoDetourManager New()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			return new MonoDetourManager(typeof(DefaultMonoDetourManager).Assembly.GetName().Name);
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
	internal class MonoDetourTargetsAttribute : Attribute, IMonoDetourTargets
	{
		public Type? TargetType { get; }

		public bool IncludeNestedTypes { get; set; }

		public bool DistinguishOverloadsByName { get; set; }

		public string[]? Members { get; set; }

		public string[]? MemberNamePrefixes { get; set; }

		public string[]? MemberNameSuffixes { get; set; }

		public bool GenerateControlFlowVariants { get; set; }

		public MonoDetourTargetsAttribute(Type? targetType = null)
		{
			TargetType = targetType;
			IncludeNestedTypes = true;
			base..ctor();
		}
	}
}
namespace ReaperBalance
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ReaperBalance";

		public const string PLUGIN_NAME = "ReaperBalance";

		public const string PLUGIN_VERSION = "0.2.1";
	}
}
namespace ReaperBalance.Source
{
	internal sealed class AssetManager : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <Initialize>d__14 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AssetManager <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Initialize>d__14(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (<>4__this._initialized || <>4__this._initializing)
					{
						return false;
					}
					<>4__this._initializing = true;
					Log.Info("AssetManager initializing...");
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.LoadAssetsFromBundles();
					<>4__this._initialized = true;
					<>4__this._initializing = false;
					Log.Info($"AssetManager initialized with {<>4__this._loadedAssets.Count} assets");
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static readonly string[] RequiredAssets = new string[2] { "Song Knight CrossSlash Friendly", "Reaper Silk Bundle" };

		private readonly Dictionary<string, GameObject> _loadedAssets = new Dictionary<string, GameObject>();

		private readonly Dictionary<string, GameObject> _cachedPrefabs = new Dictionary<string, GameObject>();

		private GameObject _assetPool = null;

		private bool _initialized = false;

		private bool _initializing = false;

		private void Awake()
		{
			SceneManager.activeSceneChanged += OnSceneChanged;
			CreateAssetPool();
			((MonoBehaviour)this).StartCoroutine(Initialize());
		}

		private void OnDestroy()
		{
			SceneManager.activeSceneChanged -= OnSceneChanged;
		}

		private void OnSceneChanged(Scene oldScene, Scene newScene)
		{
			if (((Scene)(ref newScene)).name == "Menu_Title")
			{
				CleanupAssetPool();
			}
		}

		private void CreateAssetPool()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Transform val = ((Component)this).transform.Find("AssetPool");
			if ((Object)(object)val != (Object)null)
			{
				_assetPool = ((Component)val).gameObject;
				return;
			}
			_assetPool = new GameObject("AssetPool");
			_assetPool.transform.SetParent(((Component)this).transform);
			_assetPool.SetActive(false);
		}

		public void CleanupAssetPool()
		{
			if (!((Object)(object)_assetPool == (Object)null))
			{
				((MonoBehaviour)this).StopAllCoroutines();
				_initializing = false;
				int childCount = _assetPool.transform.childCount;
				for (int num = childCount - 1; num >= 0; num--)
				{
					Object.Destroy((Object)(object)((Component)_assetPool.transform.GetChild(num)).gameObject);
				}
				_cachedPrefabs.Clear();
				_loadedAssets.Clear();
				_initialized = false;
			}
		}

		public void StorePrefabInPool(string name, GameObject prefab)
		{
			if (!((Object)(object)_assetPool == (Object)null))
			{
				prefab.transform.SetParent(_assetPool.transform);
				prefab.SetActive(false);
				_cachedPrefabs[name] = prefab;
			}
		}

		public GameObject GetCachedPrefab(string name)
		{
			GameObject value;
			return _cachedPrefabs.TryGetValue(name, out value) ? value : null;
		}

		public bool IsPrefabCached(string name)
		{
			return _cachedPrefabs.ContainsKey(name) && (Object)(object)_cachedPrefabs[name] != (Object)null;
		}

		[IteratorStateMachine(typeof(<Initialize>d__14))]
		public IEnumerator Initialize()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Initialize>d__14(0)
			{
				<>4__this = this
			};
		}

		private void LoadAssetsFromBundles()
		{
			_loadedAssets.Clear();
			foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
			{
				if ((Object)(object)allLoadedAssetBundle == (Object)null)
				{
					continue;
				}
				try
				{
					string[] allAssetNames = allLoadedAssetBundle.GetAllAssetNames();
					if (allAssetNames == null)
					{
						continue;
					}
					string[] array = allAssetNames;
					foreach (string text in array)
					{
						string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
						string[] requiredAssets = RequiredAssets;
						foreach (string text2 in requiredAssets)
						{
							if (fileNameWithoutExtension.Contains(text2, StringComparison.OrdinalIgnoreCase))
							{
								GameObject val = allLoadedAssetBundle.LoadAsset<GameObject>(text);
								if ((Object)(object)val != (Object)null && !_loadedAssets.ContainsKey(text2))
								{
									_loadedAssets[text2] = val;
								}
								break;
							}
						}
					}
				}
				catch (Exception ex)
				{
					Log.Error("Error processing bundle: " + ex.Message);
				}
			}
		}

		public T Get<T>(string assetName) where T : Object
		{
			if (_loadedAssets.TryGetValue(assetName, out GameObject value))
			{
				return (T)(object)((value is T) ? value : null);
			}
			Log.Warn("Asset '" + assetName + "' not in cache, reloading...");
			LoadAssetsFromBundles();
			if (_loadedAssets.TryGetValue(assetName, out value))
			{
				return (T)(object)((value is T) ? value : null);
			}
			Log.Error("Asset '" + assetName + "' not found");
			return default(T);
		}

		public IEnumerable<string> GetAllAssetNames()
		{
			return _loadedAssets.Keys;
		}

		public bool IsInitialized()
		{
			return _initialized;
		}
	}
	internal static class Log
	{
		private static ManualLogSource? _logSource;

		private static string LogPrefix => $"[{Assembly.GetExecutingAssembly().GetName().Version}] ";

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object debug)
		{
			ManualLogSource? logSource = _logSource;
			if (logSource != null)
			{
				logSource.LogDebug((object)(LogPrefix + debug));
			}
		}

		internal static void Error(object error)
		{
			ManualLogSource? logSource = _logSource;
			if (logSource != null)
			{
				logSource.LogError((object)(LogPrefix + error));
			}
		}

		internal static void Fatal(object fatal)
		{
			ManualLogSource? logSource = _logSource;
			if (logSource != null)
			{
				logSource.LogFatal((object)(LogPrefix + fatal));
			}
		}

		internal static void Info(object info)
		{
			ManualLogSource? logSource = _logSource;
			if (logSource != null)
			{
				logSource.LogInfo((object)(LogPrefix + info));
			}
		}

		internal static void Message(object message)
		{
			ManualLogSource? logSource = _logSource;
			if (logSource != null)
			{
				logSource.LogMessage((object)(LogPrefix + message));
			}
		}

		internal static void Warn(object warning)
		{
			ManualLogSource? logSource = _logSource;
			if (logSource != null)
			{
				logSource.LogWarning((object)(LogPrefix + warning));
			}
		}
	}
	internal static class Menu
	{
		private sealed class SliderDebounceState
		{
			public float LastDragEndTime = -1f;
		}

		private sealed class AgentSliderDragEndTracker : MonoBehaviour, IEndDragHandler, IEventSystemHandler, IPointerUpHandler
		{
			public SliderDebounceState? DebounceState;

			public void OnEndDrag(PointerEventData eventData)
			{
				RecordDragEnd();
			}

			public void OnPointerUp(PointerEventData eventData)
			{
				RecordDragEnd();
			}

			private void RecordDragEnd()
			{
				if (DebounceState != null)
				{
					DebounceState.LastDragEndTime = Time.unscaledTime;
				}
			}
		}

		private sealed class AgentPointerProxy : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
		{
			public GameObject? ProxyTo;

			public string Tag = "";

			public Text? DescText;

			private bool _hovered;

			private float _lastForcedAtUnscaled;

			private RectTransform? _selfRect;

			private Canvas? _canvas;

			private Camera? _uiCam;

			private bool _lastInside;

			private bool _lastRaycastHover;

			private static readonly List<RaycastResult> _raycastResults = new List<RaycastResult>(32);

			public void OnPointerEnter(PointerEventData eventData)
			{
				Forward(eventData, isEnter: true);
			}

			public void OnPointerExit(PointerEventData eventData)
			{
				Forward(eventData, isEnter: false);
			}

			private void Awake()
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Invalid comparison between Unknown and I4
				try
				{
					_selfRect = ((Component)this).GetComponent<RectTransform>();
					_canvas = ((Component)this).GetComponentInParent<Canvas>();
					if ((Object)(object)_canvas != (Object)null && (int)_canvas.renderMode > 0)
					{
						_uiCam = _canvas.worldCamera;
					}
				}
				catch
				{
				}
			}

			private void LateUpdate()
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if ((Object)(object)DescText == (Object)null)
					{
						return;
					}
					string topHitName;
					bool flag = IsPointerOverSelfHierarchy(out topHitName);
					bool lastInside = false;
					if ((Object)(object)_selfRect != (Object)null)
					{
						lastInside = RectTransformUtility.RectangleContainsScreenPoint(_selfRect, Vector2.op_Implicit(Input.mousePosition), _uiCam);
					}
					_lastRaycastHover = flag;
					_lastInside = lastInside;
					if (!flag)
					{
						return;
					}
					if (!((Component)DescText).gameObject.activeInHierarchy)
					{
						((Component)DescText).gameObject.SetActive(true);
					}
					Color color = ((Graphic)DescText).color;
					if (color.a < 0.95f)
					{
						color.a = 0.95f;
						((Graphic)DescText).color = color;
						if (Time.unscaledTime - _lastForcedAtUnscaled > 0.05f)
						{
							_lastForcedAtUnscaled = Time.unscaledTime;
						}
					}
				}
				catch
				{
				}
			}

			private bool IsPointerOverSelfHierarchy(out string topHitName)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				topHitName = "<none>";
				try
				{
					if ((Object)(object)EventSystem.current == (Object)null)
					{
						return false;
					}
					PointerEventData val = new PointerEventData(EventSystem.current)
					{
						position = Vector2.op_Implicit(Input.mousePosition)
					};
					_raycastResults.Clear();
					EventSystem.current.RaycastAll(val, _raycastResults);
					for (int i = 0; i < _raycastResults.Count; i++)
					{
						RaycastResult val2 = _raycastResults[i];
						GameObject gameObject = ((RaycastResult)(ref val2)).gameObject;
						if (!((Object)(object)gameObject == (Object)null))
						{
							if (i == 0)
							{
								topHitName = ((Object)gameObject).name;
							}
							if (gameObject.transform.IsChildOf(((Component)this).transform))
							{
								return true;
							}
						}
					}
					return false;
				}
				catch
				{
					return false;
				}
			}

			private void Forward(PointerEventData eventData, bool isEnter)
			{
				try
				{
					if (!((Object)(object)ProxyTo == (Object)null))
					{
						if (isEnter)
						{
							ExecuteEvents.Execute<IPointerEnterHandler>(ProxyTo, (BaseEventData)(object)eventData, ExecuteEvents.pointerEnterHandler);
						}
						else
						{
							ExecuteEvents.Execute<IPointerExitHandler>(ProxyTo, (BaseEventData)(object)eventData, ExecuteEvents.pointerExitHandler);
						}
						_hovered = isEnter;
					}
				}
				catch
				{
				}
			}
		}

		private sealed class AgentForceSelectOnHover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerDownHandler
		{
			[CompilerGenerated]
			private sealed class <ForceSelectNextFrameCoroutine>d__9 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public string evt;

				public AgentForceSelectOnHover <>4__this;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <ForceSelectNextFrameCoroutine>d__9(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>2__current = null;
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						try
						{
							if ((Object)(object)<>4__this.SelectTarget == (Object)null || (Object)(object)EventSystem.current == (Object)null)
							{
								return false;
							}
							if ((Object)(object)EventSystem.current.currentSelectedGameObject == (Object)(object)<>4__this.SelectTarget)
							{
								return false;
							}
							EventSystem.current.SetSelectedGameObject(<>4__this.SelectTarget);
						}
						catch
						{
						}
						finally
						{
							<>4__this._pendingLateSelect = false;
						}
						return false;
					}
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			public GameObject? SelectTarget;

			public string Tag = "";

			public bool SelectOnEnter = true;

			public bool SelectOnDown = true;

			private bool _pendingLateSelect;

			public void OnPointerEnter(PointerEventData eventData)
			{
				if (SelectOnEnter)
				{
					ForceSelectImmediate("PointerEnter");
				}
			}

			public void OnPointerDown(PointerEventData eventData)
			{
				if (SelectOnDown)
				{
					ForceSelectNextFrame("PointerDown");
				}
			}

			private void ForceSelectImmediate(string evt)
			{
				try
				{
					if (!((Object)(object)SelectTarget == (Object)null) && !((Object)(object)EventSystem.current == (Object)null) && !((Object)(object)EventSystem.current.currentSelectedGameObject == (Object)(object)SelectTarget))
					{
						EventSystem.current.SetSelectedGameObject(SelectTarget);
					}
				}
				catch
				{
				}
			}

			private void ForceSelectNextFrame(string evt)
			{
				try
				{
					if (((Behaviour)this).isActiveAndEnabled && !_pendingLateSelect)
					{
						_pendingLateSelect = true;
						((MonoBehaviour)this).StartCoroutine(ForceSelectNextFrameCoroutine(evt));
					}
				}
				catch
				{
				}
			}

			[IteratorStateMachine(typeof(<ForceSelectNextFrameCoroutine>d__9))]
			private IEnumerator ForceSelectNextFrameCoroutine(string evt)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <ForceSelectNextFrameCoroutine>d__9(0)
				{
					<>4__this = this,
					evt = evt
				};
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static MenuElementGenerator <>9__0_0;

			public static Action<bool> <>9__1_0;

			public static Action <>9__1_5;

			public static Action<bool> <>9__1_1;

			public static Action<bool> <>9__1_2;

			public static Action<bool> <>9__1_3;

			public static Action<bool> <>9__1_4;

			public static IndexedToString<float> <>9__3_0;

			public static IndexedToString<float> <>9__4_1;

			public static IndexedToString<float> <>9__5_2;

			public static IndexedToString<float> <>9__5_3;

			internal SelectableElement <Init>b__0_0()
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Expected O, but got Unknown
				<>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0
				{
					menu = BuildCustomMenu()
				};
				return (SelectableElement)new TextButton("ReaperBalance")
				{
					OnSubmit = delegate
					{
						MenuScreenNavigation.Show(CS$<>8__locals0.menu, (HistoryMode)0);
					}
				};
			}

			internal void <BuildCustomMenu>b__1_0(bool enabled)
			{
				Plugin.ToggleReaperBalance(enabled);
			}

			internal void <BuildCustomMenu>b__1_5()
			{
				Plugin.EnableReaperBalance.Value = (bool)((ConfigEntryBase)Plugin.EnableReaperBalance).DefaultValue;
				Plugin.UseChinese.Value = (bool)((ConfigEntryBase)Plugin.UseChinese).DefaultValue;
				Plugin.EnableCrossSlash.Value = (bool)((ConfigEntryBase)Plugin.EnableCrossSlash).DefaultValue;
				Plugin.EnableSilkAttraction.Value = (bool)((ConfigEntryBase)Plugin.EnableSilkAttraction).DefaultValue;
				Plugin.CrossSlashScale.Value = (float)((ConfigEntryBase)Plugin.CrossSlashScale).DefaultValue;
				Plugin.CrossSlashDamage.Value = (float)((ConfigEntryBase)Plugin.CrossSlashDamage).DefaultValue;
				Plugin.NormalAttackMultiplier.Value = (float)((ConfigEntryBase)Plugin.NormalAttackMultiplier).DefaultValue;
				Plugin.DownSlashMultiplier.Value = (float)((ConfigEntryBase)Plugin.DownSlashMultiplier).DefaultValue;
				Plugin.CollectRange.Value = (float)((ConfigEntryBase)Plugin.CollectRange).DefaultValue;
				Plugin.CollectMaxSpeed.Value = (float)((ConfigEntryBase)Plugin.CollectMaxSpeed).DefaultValue;
				Plugin.CollectAcceleration.Value = (float)((ConfigEntryBase)Plugin.CollectAcceleration).DefaultValue;
				Plugin.DurationMultiplier.Value = (float)((ConfigEntryBase)Plugin.DurationMultiplier).DefaultValue;
				Plugin.StunDamageMultiplier.Value = (float)((ConfigEntryBase)Plugin.StunDamageMultiplier).DefaultValue;
				Plugin.ReaperBundleMultiplier.Value = (float)((ConfigEntryBase)Plugin.ReaperBundleMultiplier).DefaultValue;
				Plugin.EnableReaperCrit.Value = (bool)((ConfigEntryBase)Plugin.EnableReaperCrit).DefaultValue;
				Plugin.ReaperCritChancePercent.Value = (float)((ConfigEntryBase)Plugin.ReaperCritChancePercent).DefaultValue;
				Plugin.ReaperCritDamageMultiplier.Value = (float)((ConfigEntryBase)Plugin.ReaperCritDamageMultiplier).DefaultValue;
				Plugin.IsReaperBalanceEnabled = Plugin.EnableReaperBalance.Value;
				Plugin plugin = Plugin.FindPlugin();
				if ((Object)(object)plugin != (Object)null)
				{
					((BaseUnityPlugin)plugin).Config.Save();
					plugin.RefreshReaperBalance("ResetDefaults", forceConfig: true);
					MenuScreenNavigation.Show(BuildCustomMenu(), (HistoryMode)1);
				}
			}

			internal void <BuildCustomMenu>b__1_1(bool isChinese)
			{
				Plugin.UseChinese.Value = isChinese;
				Plugin plugin = Plugin.FindPlugin();
				if ((Object)(object)plugin != (Object)null)
				{
					((BaseUnityPlugin)plugin).Config.Save();
					MenuScreenNavigation.Show(BuildCustomMenu(), (HistoryMode)1);
				}
			}

			internal void <BuildCustomMenu>b__1_2(bool enabled)
			{
				Plugin.EnableCrossSlash.Value = enabled;
				Plugin plugin = Plugin.FindPlugin();
				if ((Object)(object)plugin != (Object)null)
				{
					((BaseUnityPlugin)plugin).Config.Save();
					plugin.RefreshReaperBalance("EnableCrossSlash", forceConfig: true);
				}
			}

			internal void <BuildCustomMenu>b__1_3(bool enabled)
			{
				Plugin.EnableSilkAttraction.Value = enabled;
				Plugin plugin = Plugin.FindPlugin();
				if ((Object)(object)plugin != (Object)null)
				{
					((BaseUnityPlugin)plugin).Config.Save();
					plugin.RefreshReaperBalance("EnableSilkAttraction", forceConfig: true);
				}
			}

			internal void <BuildCustomMenu>b__1_4(bool enabled)
			{
				Plugin.EnableReaperCrit.Value = enabled;
				Plugin plugin = Plugin.FindPlugin();
				if ((Object)(object)plugin != (Object)null)
				{
					((BaseUnityPlugin)plugin).Config.Save();
				}
			}

			internal string <CreateFloatSlider>b__3_0(int _, float value)
			{
				return value.ToString("0.###");
			}

			internal string <CreateFloatChoice>b__4_1(int _, float v)
			{
				return v.ToString("0.###");
			}

			internal string <CreateFloatChoiceWithSlider>b__5_2(int _, float v)
			{
				return v.ToString("0.###");
			}

			internal string <CreateFloatChoiceWithSlider>b__5_3(int _, float v)
			{
				return v.ToString("0.###");
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass0_0
		{
			public AbstractMenuScreen menu;

			internal void <Init>b__1()
			{
				MenuScreenNavigation.Show(menu, (HistoryMode)0);
			}
		}

		public static void Init()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			try
			{
				object obj = <>c.<>9__0_0;
				if (obj == null)
				{
					MenuElementGenerator val = delegate
					{
						//IL_0017: Unknown result type (might be due to invalid IL or missing references)
						//IL_001c: Unknown result type (might be due to invalid IL or missing references)
						//IL_002f: Expected O, but got Unknown
						AbstractMenuScreen menu = BuildCustomMenu();
						return (SelectableElement)new TextButton("ReaperBalance")
						{
							OnSubmit = delegate
							{
								MenuScreenNavigation.Show(menu, (HistoryMode)0);
							}
						};
					};
					<>c.<>9__0_0 = val;
					obj = (object)val;
				}
				Registry.AddModMenu("ReaperBalance", (MenuElementGenerator)obj);
				Log.Info("ModMenu integration initialized via Registry.AddModMenu()");
			}
			catch (Exception ex)
			{
				Log.Error("Failed to register ModMenu: " + ex.Message);
			}
		}

		public static AbstractMenuScreen BuildCustomMenu()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Expected O, but got Unknown
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Expected O, but got Unknown
			ChoiceElement<bool> val = new ChoiceElement<bool>(Tr("Enable Reaper Balance", "启用收割者平衡"), (IChoiceModel<bool>)(object)ChoiceModels.ForBool(Tr("Disabled", "禁用"), Tr("Enabled", "启用")), Tr("Enable or disable Reaper balance changes.", "启用或禁用收割者平衡修改。"))
			{
				Value = Plugin.IsReaperBalanceEnabled
			};
			((SelectableValueElement<bool>)(object)val).OnValueChanged += delegate(bool enabled)
			{
				Plugin.ToggleReaperBalance(enabled);
			};
			TextButton val2 = new TextButton(Tr("Reset to Defaults", "重置为默认值"));
			val2.OnSubmit = (Action)Delegate.Combine(val2.OnSubmit, (Action)delegate
			{
				Plugin.EnableReaperBalance.Value = (bool)((ConfigEntryBase)Plugin.EnableReaperBalance).DefaultValue;
				Plugin.UseChinese.Value = (bool)((ConfigEntryBase)Plugin.UseChinese).DefaultValue;
				Plugin.EnableCrossSlash.Value = (bool)((ConfigEntryBase)Plugin.EnableCrossSlash).DefaultValue;
				Plugin.EnableSilkAttraction.Value = (bool)((ConfigEntryBase)Plugin.EnableSilkAttraction).DefaultValue;
				Plugin.CrossSlashScale.Value = (float)((ConfigEntryBase)Plugin.CrossSlashScale).DefaultValue;
				Plugin.CrossSlashDamage.Value = (float)((ConfigEntryBase)Plugin.CrossSlashDamage).DefaultValue;
				Plugin.NormalAttackMultiplier.Value = (float)((ConfigEntryBase)Plugin.NormalAttackMultiplier).DefaultValue;
				Plugin.DownSlashMultiplier.Value = (float)((ConfigEntryBase)Plugin.DownSlashMultiplier).DefaultValue;
				Plugin.CollectRange.Value = (float)((ConfigEntryBase)Plugin.CollectRange).DefaultValue;
				Plugin.CollectMaxSpeed.Value = (float)((ConfigEntryBase)Plugin.CollectMaxSpeed).DefaultValue;
				Plugin.CollectAcceleration.Value = (float)((ConfigEntryBase)Plugin.CollectAcceleration).DefaultValue;
				Plugin.DurationMultiplier.Value = (float)((ConfigEntryBase)Plugin.DurationMultiplier).DefaultValue;
				Plugin.StunDamageMultiplier.Value = (float)((ConfigEntryBase)Plugin.StunDamageMultiplier).DefaultValue;
				Plugin.ReaperBundleMultiplier.Value = (float)((ConfigEntryBase)Plugin.ReaperBundleMultiplier).DefaultValue;
				Plugin.EnableReaperCrit.Value = (bool)((ConfigEntryBase)Plugin.EnableReaperCrit).DefaultValue;
				Plugin.ReaperCritChancePercent.Value = (float)((ConfigEntryBase)Plugin.ReaperCritChancePercent).DefaultValue;
				Plugin.ReaperCritDamageMultiplier.Value = (float)((ConfigEntryBase)Plugin.ReaperCritDamageMultiplier).DefaultValue;
				Plugin.IsReaperBalanceEnabled = Plugin.EnableReaperBalance.Value;
				Plugin plugin5 = Plugin.FindPlugin();
				if ((Object)(object)plugin5 != (Object)null)
				{
					((BaseUnityPlugin)plugin5).Config.Save();
					plugin5.RefreshReaperBalance("ResetDefaults", forceConfig: true);
					MenuScreenNavigation.Show(BuildCustomMenu(), (HistoryMode)1);
				}
			});
			ReaperBalancePaginatedMenuScreen reaperBalancePaginatedMenuScreen = new ReaperBalancePaginatedMenuScreen("ReaperBalance", (SelectableElement)(object)val2);
			VerticalGroup val3 = new VerticalGroup();
			val3.Add((IMenuEntity)(object)val);
			ChoiceElement<bool> val4 = new ChoiceElement<bool>(Tr("Language", "语言"), (IChoiceModel<bool>)(object)ChoiceModels.ForBool("English", "中文"), Tr("Switch the menu language.", "切换菜单语言。"))
			{
				Value = Plugin.UseChinese.Value
			};
			((SelectableValueElement<bool>)(object)val4).OnValueChanged += delegate(bool isChinese)
			{
				Plugin.UseChinese.Value = isChinese;
				Plugin plugin4 = Plugin.FindPlugin();
				if ((Object)(object)plugin4 != (Object)null)
				{
					((BaseUnityPlugin)plugin4).Config.Save();
					MenuScreenNavigation.Show(BuildCustomMenu(), (HistoryMode)1);
				}
			};
			val3.Add((IMenuEntity)(object)val4);
			ChoiceElement<float> val5 = CreateFloatChoiceWithSlider(Tr("Normal Attack Multiplier", "普通攻击倍率"), Tr("Damage multiplier for normal attacks", "普通攻击的伤害倍率"), Plugin.NormalAttackMultiplier, 0.1f, 3f, 0.1f, "ModMenu.NormalAttackMultiplier");
			val3.Add((IMenuEntity)(object)val5);
			val3.Add((IMenuEntity)(object)CreateFloatChoiceWithSlider(Tr("Down Slash Multiplier", "下劈攻击倍率"), Tr("Damage multiplier for down slash attacks", "下劈攻击的伤害倍率"), Plugin.DownSlashMultiplier, 0.1f, 4f, 0.1f, "ModMenu.DownSlashMultiplier"));
			val3.Add((IMenuEntity)(object)CreateFloatChoiceWithSlider(Tr("Stun Damage Multiplier", "眩晕值倍率"), Tr("Stun damage multiplier (Normal/Down/Cross)", "影响普攻/下劈/十字斩的眩晕值"), Plugin.StunDamageMultiplier, 0f, 5f, 0.1f, "ModMenu.StunDamageMultiplier"));
			ChoiceElement<bool> val6 = new ChoiceElement<bool>(Tr("Enable Cross Slash", "启用十字斩"), (IChoiceModel<bool>)(object)ChoiceModels.ForBool(Tr("Disabled", "禁用"), Tr("Enabled", "启用")), Tr("Enable or disable the Cross Slash heavy attack.", "启用或禁用十字斩蓄力攻击。"))
			{
				Value = Plugin.EnableCrossSlash.Value
			};
			((SelectableValueElement<bool>)(object)val6).OnValueChanged += delegate(bool enabled)
			{
				Plugin.EnableCrossSlash.Value = enabled;
				Plugin plugin3 = Plugin.FindPlugin();
				if ((Object)(object)plugin3 != (Object)null)
				{
					((BaseUnityPlugin)plugin3).Config.Save();
					plugin3.RefreshReaperBalance("EnableCrossSlash", forceConfig: true);
				}
			};
			val3.Add((IMenuEntity)(object)val6);
			val3.Add((IMenuEntity)(object)CreateFloatSlider(Tr("Cross Slash Scale", "十字斩缩放大小"), Plugin.CrossSlashScale, 0.5f, 3f, 0.1f, "ModMenu.CrossSlashScale"));
			val3.Add((IMenuEntity)(object)CreateFloatSlider(Tr("Cross Slash Damage Multiplier", "十字斩伤害倍率"), Plugin.CrossSlashDamage, 0.5f, 8f, 0.1f, "ModMenu.CrossSlashDamage"));
			reaperBalancePaginatedMenuScreen.AddPage((INavigableMenuEntity)(object)val3);
			VerticalGroup val7 = new VerticalGroup();
			val7.Add((IMenuEntity)(object)CreateFloatChoiceWithSlider(Tr("Duration Multiplier", "持续时间倍率"), Tr("Reaper mode duration multiplier", "收割者模式持续时间倍率"), Plugin.DurationMultiplier, 0.2f, 10f, 0.2f, "ModMenu.DurationMultiplier"));
			val7.Add((IMenuEntity)(object)CreateFloatChoiceWithSlider(Tr("Silk Orb Drop Multiplier", "丝球掉落倍率"), Tr("Silk orb drop multiplier in Reaper mode", "收割模式攻击敌人时掉落丝球的倍率"), Plugin.ReaperBundleMultiplier, 0f, 5f, 0.5f, "ModMenu.ReaperBundleMultiplier"));
			ChoiceElement<bool> val8 = new ChoiceElement<bool>(Tr("Enable Silk Attraction", "吸引小丝球"), (IChoiceModel<bool>)(object)ChoiceModels.ForBool(Tr("Disabled", "禁用"), Tr("Enabled", "启用")), Tr("Attract silk orbs from a distance in Reaper mode.", "收割模式下远距离吸引小丝球。"))
			{
				Value = Plugin.EnableSilkAttraction.Value
			};
			((SelectableValueElement<bool>)(object)val8).OnValueChanged += delegate(bool enabled)
			{
				Plugin.EnableSilkAttraction.Value = enabled;
				Plugin plugin2 = Plugin.FindPlugin();
				if ((Object)(object)plugin2 != (Object)null)
				{
					((BaseUnityPlugin)plugin2).Config.Save();
					plugin2.RefreshReaperBalance("EnableSilkAttraction", forceConfig: true);
				}
			};
			val7.Add((IMenuEntity)(object)val8);
			val7.Add((IMenuEntity)(object)CreateFloatSlider(Tr("Collect Range", "吸引范围"), Plugin.CollectRange, 1f, 24f, 0.5f, "ModMenu.CollectRange"));
			val7.Add((IMenuEntity)(object)CreateFloatSlider(Tr("Collect Max Speed", "吸引最大速度"), Plugin.CollectMaxSpeed, 0f, 60f, 1f, "ModMenu.CollectMaxSpeed"));
			val7.Add((IMenuEntity)(object)CreateFloatSlider(Tr("Collect Acceleration", "吸引加速度"), Plugin.CollectAcceleration, 0f, 3000f, 20f, "ModMenu.CollectAcceleration"));
			reaperBalancePaginatedMenuScreen.AddPage((INavigableMenuEntity)(object)val7);
			VerticalGroup val9 = new VerticalGroup();
			ChoiceElement<bool> val10 = new ChoiceElement<bool>(Tr("Enable Reaper Crit", "启用收割者暴击"), (IChoiceModel<bool>)(object)ChoiceModels.ForBool(Tr("Disabled", "禁用"), Tr("Enabled", "启用")), Tr("Enable Reaper-exclusive crit system (only works with Reaper Crest, overrides vanilla crit)", "启用收割者独享暴击系统(仅收割者纹章生效,完全覆盖原版暴击判定)"))
			{
				Value = Plugin.EnableReaperCrit.Value
			};
			((SelectableValueElement<bool>)(object)val10).OnValueChanged += delegate(bool enabled)
			{
				Plugin.EnableReaperCrit.Value = enabled;
				Plugin plugin = Plugin.FindPlugin();
				if ((Object)(object)plugin != (Object)null)
				{
					((BaseUnityPlugin)plugin).Config.Save();
				}
			};
			val9.Add((IMenuEntity)(object)val10);
			val9.Add((IMenuEntity)(object)CreateFloatSlider(Tr("Crit Chance %", "暴击率 %"), Plugin.ReaperCritChancePercent, 0f, 100f, 1f, "ModMenu.ReaperCritChancePercent"));
			val9.Add((IMenuEntity)(object)CreateFloatSlider(Tr("Crit Damage Multiplier", "暴击伤害倍率"), Plugin.ReaperCritDamageMultiplier, 1f, 5f, 0.1f, "ModMenu.ReaperCritDamageMultiplier"));
			reaperBalancePaginatedMenuScreen.AddPage((INavigableMenuEntity)(object)val9);
			return (AbstractMenuScreen)(object)reaperBalancePaginatedMenuScreen;
		}

		private static string Tr(string en, string zh)
		{
			ConfigEntry<bool> useChinese = Plugin.UseChinese;
			return (useChinese == null || useChinese.Value) ? zh : en;
		}

		private static SliderElement<float> CreateFloatSlider(string label, ConfigEntry<float> entry, float min, float max, float step, string refreshReason)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			ConfigEntry<float> entry2 = entry;
			string refreshReason2 = refreshReason;
			int num = Mathf.RoundToInt((max - min) / step) + 1;
			if (num < 2)
			{
				num = 2;
			}
			LinearFloatSliderModel val = new LinearFloatSliderModel(min, max, num);
			((SliderModel<float>)(object)val).DisplayFn = (int _, float value) => value.ToString("0.###");
			float value2 = Mathf.Clamp(entry2.Value, Mathf.Min(min, max), Mathf.Max(min, max));
			((AbstractValueModel<float>)(object)val).SetValue(value2);
			int index = ((SliderModel<float>)(object)val).Index;
			SliderElement<float> result = new SliderElement<float>(label, (SliderModel<float>)(object)val);
			if (index != ((SliderModel<float>)(object)val).MinimumIndex)
			{
				((SliderModel<float>)(object)val).Index = ((SliderModel<float>)(object)val).MinimumIndex;
				((SliderModel<float>)(object)val).Index = index;
			}
			((AbstractValueModel<float>)(object)val).OnValueChanged += delegate(float value)
			{
				entry2.Value = value;
				Plugin plugin = Plugin.FindPlugin();
				if ((Object)(object)plugin != (Object)null)
				{
					plugin.RefreshReaperBalance(refreshReason2, forceConfig: true);
				}
			};
			return result;
		}

		private static ChoiceElement<float> CreateFloatChoice(string label, string description, ConfigEntry<float> entry, float min, float max, float step, string refreshReason)
		{
			ConfigEntry<float> entry2 = entry;
			string refreshReason2 = refreshReason;
			List<float> list = new List<float>();
			for (float num = min; num <= max + step * 0.5f; num += step)
			{
				list.Add((float)Math.Round(num, 3));
			}
			ListChoiceModel<float> val = new ListChoiceModel<float>(list)
			{
				Circular = false,
				DisplayFn = (int _, float v) => v.ToString("0.###")
			};
			float num2 = Mathf.Clamp(entry2.Value, min, max);
			int index = 0;
			float num3 = float.MaxValue;
			for (int i = 0; i < list.Count; i++)
			{
				float num4 = Mathf.Abs(list[i] - num2);
				if (num4 < num3)
				{
					num3 = num4;
					index = i;
				}
			}
			val.Index = index;
			ChoiceElement<float> result = new ChoiceElement<float>(label, (IChoiceModel<float>)(object)val, description)
			{
				Value = list[index]
			};
			((AbstractValueModel<float>)(object)val).OnValueChanged += delegate(float value)
			{
				entry2.Value = value;
				Plugin plugin = Plugin.FindPlugin();
				if ((Object)(object)plugin != (Object)null)
				{
					plugin.RefreshReaperBalance(refreshReason2, forceConfig: true);
				}
			};
			return result;
		}

		private static ChoiceElement<float> CreateFloatChoiceWithSlider(string label, string description, ConfigEntry<float> entry, float min, float max, float step, string refreshReason)
		{
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_0180: Expected O, but got Unknown
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Expected O, but got Unknown
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<float> entry2 = entry;
			string refreshReason2 = refreshReason;
			List<float> values = new List<float>();
			for (float num = min; num <= max + step * 0.5f; num += step)
			{
				values.Add((float)Math.Round(num, 3));
			}
			ListChoiceModel<float> choiceModel = new ListChoiceModel<float>(values)
			{
				Circular = false,
				DisplayFn = (int _, float v) => v.ToString("0.###")
			};
			float num2 = Mathf.Clamp(entry2.Value, min, max);
			int num3 = 0;
			float num4 = float.MaxValue;
			for (int i = 0; i < values.Count; i++)
			{
				float num5 = Mathf.Abs(values[i] - num2);
				if (num5 < num4)
				{
					num4 = num5;
					num3 = i;
				}
			}
			choiceModel.Index = num3;
			ChoiceElement<float> val = new ChoiceElement<float>(label, (IChoiceModel<float>)(object)choiceModel, description)
			{
				Value = values[num3]
			};
			int num6 = values.Count;
			if (num6 < 2)
			{
				num6 = 2;
			}
			LinearFloatSliderModel val2 = new LinearFloatSliderModel(min, max, num6);
			((SliderModel<float>)val2).DisplayFn = (int _, float v) => v.ToString("0.###");
			LinearFloatSliderModel sliderModel = val2;
			((AbstractValueModel<float>)(object)sliderModel).SetValue(values[num3]);
			SliderElement<float> val3 = new SliderElement<float>("_temp_", (SliderModel<float>)(object)sliderModel);
			GameObject gameObject = ((Component)val3.Slider).gameObject;
			if ((Object)(object)val3.LabelText != (Object)null)
			{
				((Component)val3.LabelText).gameObject.SetActive(false);
			}
			RectTransform component = ((Component)val.ChoiceText).GetComponent<RectTransform>();
			RectTransform component2 = gameObject.GetComponent<RectTransform>();
			Transform parent = ((Component)component).transform.parent;
			if ((Object)(object)parent != (Object)null)
			{
				gameObject.transform.SetParent(parent, false);
				((Transform)component2).SetSiblingIndex(((Component)component).transform.GetSiblingIndex());
			}
			else
			{
				gameObject.transform.SetParent(((MenuElement)val).Container.transform, false);
			}
			float y = component2.sizeDelta.y;
			component2.anchorMin = component.anchorMin;
			component2.anchorMax = component.anchorMax;
			component2.pivot = component.pivot;
			float num7 = 0.5f;
			float x = component.sizeDelta.x;
			float num8 = x * num7;
			float num9 = x - num8;
			float num10 = x * 0.25f;
			component2.anchoredPosition = component.anchoredPosition + new Vector2(num9 - num10, 0f);
			component2.sizeDelta = new Vector2(num8, Mathf.Max(11f, y));
			float num11 = -1f;
			foreach (Transform item in gameObject.transform)
			{
				Transform val4 = item;
				RectTransform component3 = ((Component)val4).GetComponent<RectTransform>();
				if (!((Object)(object)component3 == (Object)null))
				{
					string text = ((Object)val4).name.ToLowerInvariant();
					if (text.Contains("background") || text.Contains("fill") || text.Contains("handle") || text.Contains("slider"))
					{
						component3.anchorMin = new Vector2(num11, component3.anchorMin.y);
						component3.offsetMin = new Vector2(0f, component3.offsetMin.y);
					}
				}
			}
			((Component)val.ChoiceText).gameObject.SetActive(false);
			try
			{
				if ((Object)(object)val3.Slider != (Object)null)
				{
					val3.Slider.SetValueWithoutNotify((float)num3);
				}
				Transform[] componentsInChildren = gameObject.GetComponentsInChildren<Transform>(true);
				foreach (Transform val5 in componentsInChildren)
				{
					if (((Object)val5).name == "CursorHotspot" || ((Object)val5).name == "CursorLeft" || ((Object)val5).name == "CursorRight")
					{
						((Component)val5).gameObject.SetActive(false);
					}
				}
				if ((Object)(object)parent != (Object)null)
				{
					AttachPointerProxy(gameObject, ((Component)parent).gameObject, "SliderToValueChoice:" + label, val.DescriptionText);
				}
				AttachForceSelect(((Component)val.LabelText).gameObject, ((Component)((SelectableElement)val).SelectableComponent).gameObject, "ChoiceLabel:" + label, selectOnEnter: true, selectOnDown: true);
				AttachForceSelect(((Component)((SelectableElement)val).SelectableComponent).gameObject, ((Component)((SelectableElement)val).SelectableComponent).gameObject, "ChoiceSelectable:" + label, selectOnEnter: true, selectOnDown: true);
				AttachForceSelect(gameObject, ((Component)((SelectableElement)val).SelectableComponent).gameObject, "SliderRedirect:" + label, selectOnEnter: false, selectOnDown: true);
			}
			catch
			{
			}
			if ((Object)(object)((MenuElement)val3).Container != (Object)null && (Object)(object)((MenuElement)val3).Container != (Object)(object)gameObject)
			{
				Object.Destroy((Object)(object)((MenuElement)val3).Container);
			}
			bool isSyncing = false;
			SliderDebounceState debounceState = new SliderDebounceState();
			AttachSliderDragEndTracker(gameObject, debounceState);
			((AbstractValueModel<float>)(object)choiceModel).OnValueChanged += delegate(float value)
			{
				if (!isSyncing && (!(debounceState.LastDragEndTime >= 0f) || !(Time.unscaledTime - debounceState.LastDragEndTime < 0.2f)))
				{
					isSyncing = true;
					entry2.Value = value;
					((AbstractValueModel<float>)(object)sliderModel).SetValue(value);
					Plugin plugin2 = Plugin.FindPlugin();
					if ((Object)(object)plugin2 != (Object)null)
					{
						plugin2.RefreshReaperBalance(refreshReason2, forceConfig: true);
					}
					isSyncing = false;
				}
			};
			((AbstractValueModel<float>)(object)sliderModel).OnValueChanged += delegate(float value)
			{
				if (!isSyncing)
				{
					isSyncing = true;
					int num12 = 0;
					float num13 = float.MaxValue;
					for (int k = 0; k < values.Count; k++)
					{
						float num14 = Mathf.Abs(values[k] - value);
						if (num14 < num13)
						{
							num13 = num14;
							num12 = k;
						}
					}
					if (choiceModel.Index != num12)
					{
						choiceModel.Index = num12;
					}
					entry2.Value = values[num12];
					Plugin plugin = Plugin.FindPlugin();
					if ((Object)(object)plugin != (Object)null)
					{
						plugin.RefreshReaperBalance(refreshReason2, forceConfig: true);
					}
					isSyncing = false;
				}
			};
			return val;
		}

		private static void AttachSliderDragEndTracker(GameObject sliderGO, SliderDebounceState state)
		{
			AgentSliderDragEndTracker agentSliderDragEndTracker = sliderGO.GetComponent<AgentSliderDragEndTracker>();
			if ((Object)(object)agentSliderDragEndTracker == (Object)null)
			{
				agentSliderDragEndTracker = sliderGO.AddComponent<AgentSliderDragEndTracker>();
			}
			agentSliderDragEndTracker.DebounceState = state;
		}

		private static void AttachForceSelect(GameObject target, GameObject selectTarget, string tag, bool selectOnEnter, bool selectOnDown)
		{
			AgentForceSelectOnHover agentForceSelectOnHover = target.GetComponent<AgentForceSelectOnHover>();
			if ((Object)(object)agentForceSelectOnHover == (Object)null)
			{
				agentForceSelectOnHover = target.AddComponent<AgentForceSelectOnHover>();
			}
			agentForceSelectOnHover.SelectTarget = selectTarget;
			agentForceSelectOnHover.Tag = tag;
			agentForceSelectOnHover.SelectOnEnter = selectOnEnter;
			agentForceSelectOnHover.SelectOnDown = selectOnDown;
		}

		private static void AttachPointerProxy(GameObject target, GameObject proxyTo, string tag, Text descText)
		{
			AgentPointerProxy agentPointerProxy = target.GetComponent<AgentPointerProxy>();
			if ((Object)(object)agentPointerProxy == (Object)null)
			{
				agentPointerProxy = target.AddComponent<AgentPointerProxy>();
			}
			agentPointerProxy.ProxyTo = proxyTo;
			agentPointerProxy.Tag = tag;
			agentPointerProxy.DescText = descText;
		}
	}
	internal class ModMenuIgnoreAttribute : Attribute
	{
	}
	[BepInPlugin("ReaperBalance", "ReaperBalance", "0.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[ModMenuIgnore]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <Initialize>d__78 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Plugin <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Initialize>d__78(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if ((Object)(object)GameManager.instance == (Object)null)
				{
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				}
				<>4__this.CreateManager();
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const string ModMenuPluginId = "org.silksong-modding.modmenu";

		private static Harmony _harmony = null;

		private GameObject ReaperBalanceManager = null;

		private ChangeReaper? _changeReaperComponent = null;

		public static bool IsReaperBalanceEnabled { get; set; } = true;


		public static ConfigEntry<bool> EnableReaperBalance { get; private set; } = null;


		public static ConfigEntry<bool> UseChinese { get; private set; } = null;


		public static ConfigEntry<bool> EnableCrossSlash { get; private set; } = null;


		public static ConfigEntry<bool> EnableSilkAttraction { get; private set; } = null;


		public static ConfigEntry<float> CrossSlashScale { get; private set; } = null;


		public static ConfigEntry<float> CrossSlashDamage { get; private set; } = null;


		public static ConfigEntry<float> NormalAttackMultiplier { get; private set; } = null;


		public static ConfigEntry<float> DownSlashMultiplier { get; private set; } = null;


		public static ConfigEntry<float> CollectRange { get; private set; } = null;


		public static ConfigEntry<float> CollectMaxSpeed { get; private set; } = null;


		public static ConfigEntry<float> CollectAcceleration { get; private set; } = null;


		public static ConfigEntry<float> DurationMultiplier { get; private set; } = null;


		public static ConfigEntry<float> StunDamageMultiplier { get; private set; } = null;


		public static ConfigEntry<float> ReaperBundleMultiplier { get; private set; } = null;


		public static ConfigEntry<bool> EnableReaperCrit { get; private set; } = null;


		public static ConfigEntry<float> ReaperCritChancePercent { get; private set; } = null;


		public static ConfigEntry<float> ReaperCritDamageMultiplier { get; private set; } = null;


		private void Awake()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			SceneManager.activeSceneChanged += OnSceneChange;
			InitializeConfig();
			IsReaperBalanceEnabled = EnableReaperBalance.Value;
			_harmony = new Harmony("ReaperBalance");
			_harmony.PatchAll(typeof(HealthManagerCritPatch));
			_harmony.PatchAll(typeof(HeroControllerBindCompletedPatch));
			_harmony.PatchAll(typeof(HeroControllerGetReaperPayoutPatch));
			_harmony.PatchAll(typeof(ToolItemPatches));
			Log.Info($"Harmony补丁已应用,已注册 {_harmony.GetPatchedMethods().Count()} 个方法");
			if (Chainloader.PluginInfos.ContainsKey("org.silksong-modding.modmenu"))
			{
				Log.Info("Silksong ModMenu is loaded!");
				InitializeModMenu();
			}
			else
			{
				Log.Info("Silksong ModMenu not found, menu integration disabled");
			}
			((MonoBehaviour)this).StartCoroutine(Initialize());
		}

		private static void InitializeModMenu()
		{
			try
			{
				Type type = typeof(Plugin).Assembly.GetType("ReaperBalance.Source.Menu");
				if (type == null)
				{
					Log.Warn("Menu type could not be loaded, ModMenu integration skipped");
					return;
				}
				MethodInfo method = type.GetMethod("Init", BindingFlags.Static | BindingFlags.Public);
				if (method == null)
				{
					Log.Warn("Menu.Init method not found");
					return;
				}
				method.Invoke(null, null);
				Log.Info("ModMenu integration initialized via reflection");
			}
			catch (Exception ex)
			{
				Log.Error("Failed to initialize ModMenu integration: " + ex.Message);
			}
		}

		[IteratorStateMachine(typeof(<Initialize>d__78))]
		private IEnumerator Initialize()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Initialize>d__78(0)
			{
				<>4__this = this
			};
		}

		private void OnSceneChange(Scene oldScene, Scene newScene)
		{
			if (((Scene)(ref newScene)).name == "Menu_Title")
			{
				CleanupOnMenuReturn();
			}
			else if (((Scene)(ref oldScene)).name == "Menu_Title")
			{
				EnsureAssetManagerInitialized();
				RefreshReaperBalance("EnterGame", forceConfig: true);
			}
			else if (((Scene)(ref newScene)).name != "Pre_Menu_Intro" || ((Scene)(ref newScene)).name != "Menu_Title")
			{
				EnsureAssetManagerInitialized();
				RefreshReaperBalance("SceneChange", forceConfig: true);
			}
		}

		private void CleanupOnMenuReturn()
		{
			if ((Object)(object)_changeReaperComponent != (Object)null)
			{
				_changeReaperComponent.ResetModifications();
				Object.Destroy((Object)(object)_changeReaperComponent);
				_changeReaperComponent = null;
			}
			if ((Object)(object)ReaperBalanceManager != (Object)null)
			{
				AssetManager component = ReaperBalanceManager.GetComponent<AssetManager>();
				if ((Object)(object)component != (Object)null)
				{
					component.CleanupAssetPool();
				}
			}
			Log.Info("Menu return cleanup completed");
		}

		private void EnsureAssetManagerInitialized()
		{
			if (!((Object)(object)ReaperBalanceManager == (Object)null))
			{
				AssetManager assetManager = ReaperBalanceManager.GetComponent<AssetManager>();
				if ((Object)(object)assetManager == (Object)null)
				{
					assetManager = ReaperBalanceManager.AddComponent<AssetManager>();
				}
				if (!assetManager.IsInitialized())
				{
					((MonoBehaviour)this).StartCoroutine(assetManager.Initialize());
				}
			}
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
		}

		private void InitializeConfig()
		{
			EnableReaperBalance = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableReaperBalance", true, "是否启用Reaper平衡修改 (默认: true)");
			UseChinese = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseChinese", true, "是否使用中文菜单 (true=中文, false=English) (默认: true)");
			EnableCrossSlash = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableCrossSlash", true, "是否启用十字斩 (默认: true)");
			EnableSilkAttraction = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableSilkAttraction", true, "是否吸引小丝球 (默认: true)");
			CrossSlashScale = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperBalance", "CrossSlashScale", 1.2f, "十字斩击缩放大小 (默认: 1.2)");
			CrossSlashDamage = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperBalance", "CrossSlashDamage", 2.3f, "十字斩伤害倍率 (nailDamageMultiplier) (默认: 2.3)");
			NormalAttackMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperBalance", "NormalAttackMultiplier", 1.2f, "普通攻击倍率 (默认: 1.2)");
			DownSlashMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperBalance", "DownSlashMultiplier", 1.5f, "下劈攻击倍率 (默认: 1.5)");
			CollectRange = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperBalance", "CollectRange", 8f, "灵魂吸收范围 (默认: 8)");
			CollectMaxSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperBalance", "CollectMaxSpeed", 20f, "吸引最大速度 (默认: 20)");
			CollectAcceleration = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperBalance", "CollectAcceleration", 800f, "吸引加速度 (默认: 800)");
			DurationMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperBalance", "DurationMultiplier", 3f, "持续时间倍率 (默认: 3.0)");
			StunDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperBalance", "StunDamageMultiplier", 1.2f, "眩晕值倍率,影响普攻/下劈/十字斩的眩晕值 (默认: 1.2)");
			ReaperBundleMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperBalance", "ReaperBundleMultiplier", 1f, "小丝球掉落倍率,影响攻击敌人时掉落的丝球数量 (默认: 1.0)");
			EnableReaperCrit = ((BaseUnityPlugin)this).Config.Bind<bool>("ReaperCrit", "EnableReaperCrit", false, "是否启用收割者独享暴击系统(仅收割者纹章生效,完全覆盖原版暴击判定)(默认: false)");
			ReaperCritChancePercent = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperCrit", "ReaperCritChancePercent", 10f, "收割者暴击概率百分比 (默认: 10, 范围: 0-100)");
			ReaperCritDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("ReaperCrit", "ReaperCritDamageMultiplier", 3f, "收割者暴击伤害倍率 (默认: 3.0, 范围: 1-5)");
			Log.Info("ReaperBalance配置已初始化");
		}

		internal static Plugin? FindPlugin()
		{
			Plugin[] array = Resources.FindObjectsOfTypeAll<Plugin>();
			if (array != null && array.Length != 0)
			{
				return array[0];
			}
			return null;
		}

		private void CreateManager()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			ReaperBalanceManager = GameObject.Find("ReaperBalanceManager");
			if ((Object)(object)ReaperBalanceManager == (Object)null)
			{
				ReaperBalanceManager = new GameObject("ReaperBalanceManager");
				Object.DontDestroyOnLoad((Object)(object)ReaperBalanceManager);
				ReaperBalanceManager.AddComponent<AssetManager>();
				Log.Info("创建持久化组件");
			}
			else
			{
				Log.Info("找到已存在的持久化存档切换管理器");
			}
		}

		public void RefreshReaperBalance(string reason, bool forceConfig)
		{
			if (!((Object)(object)ReaperBalanceManager == (Object)null))
			{
				UpdateChangeReaperComponent();
				if (forceConfig && (Object)(object)_changeReaperComponent != (Object)null)
				{
					_changeReaperComponent.ApplyAllChanges(reason);
				}
			}
		}

		private void UpdateChangeReaperComponent()
		{
			if ((Object)(object)ReaperBalanceManager == (Object)null)
			{
				return;
			}
			bool flag = IsReaperBalanceEnabled && IsReaperCrestEquipped();
			_changeReaperComponent = ReaperBalanceManager.GetComponent<ChangeReaper>();
			bool flag2 = (Object)(object)_changeReaperComponent != (Object)null;
			if (flag && !flag2)
			{
				_changeReaperComponent = ReaperBalanceManager.AddComponent<ChangeReaper>();
				Log.Info("添加ChangeReaper组件 - 全局开关开启且装备Reaper护符");
			}
			else if (!flag && flag2)
			{
				if ((Object)(object)_changeReaperComponent != (Object)null)
				{
					_changeReaperComponent.ResetModifications();
				}
				Object.Destroy((Object)(object)_changeReaperComponent);
				_changeReaperComponent = null;
				Log.Info("移除ChangeReaper组件 - 全局开关关闭或未装备Reaper护符");
			}
		}

		public bool IsReaperCrestEquipped()
		{
			try
			{
				return (Object)(object)Gameplay.ReaperCrest != (Object)null && ((ToolBase)Gameplay.ReaperCrest).IsEquipped;
			}
			catch (Exception ex)
			{
				Log.Warn("获取Reaper护符状态失败: " + ex.Message);
				return false;
			}
		}

		public static void ToggleReaperBalance(bool enabled)
		{
			IsReaperBalanceEnabled = enabled;
			if (EnableReaperBalance != null)
			{
				EnableReaperBalance.Value = enabled;
			}
			Log.Info("Reaper平衡修改已" + (enabled ? "启用" : "禁用"));
			Plugin plugin = FindPlugin();
			if ((Object)(object)plugin != (Object)null)
			{
				plugin.RefreshReaperBalance("ToggleReaperBalance", forceConfig: true);
			}
		}

		public static bool ShouldApplyPatches()
		{
			return IsReaperBalanceEnabled;
		}
	}
}
namespace ReaperBalance.Source.Patches
{
	[HarmonyPatch(typeof(HealthManager))]
	[HarmonyPatch("ApplyDamageScaling")]
	internal static class HealthManagerCritPatch
	{
		[HarmonyPrefix]
		private static void Prefix(ref HitInstance hitInstance)
		{
			if (!Plugin.ShouldApplyPatches() || !Plugin.EnableReaperCrit.Value || !((ToolBase)Gameplay.ReaperCrest).IsEquipped || !hitInstance.IsHeroDamage || !((HitInstance)(ref hitInstance)).IsNailDamage)
			{
				return;
			}
			try
			{
				bool criticalHit = hitInstance.CriticalHit;
				hitInstance.CriticalHit = false;
				float num = Plugin.ReaperCritChancePercent.Value / 100f;
				if (Random.value < num)
				{
					hitInstance.CriticalHit = true;
					float wandererCritMultiplier = Gameplay.WandererCritMultiplier;
					if (wandererCritMultiplier > 0f)
					{
						float num2 = Plugin.ReaperCritDamageMultiplier.Value / wandererCritMultiplier;
						hitInstance.DamageDealt = Mathf.RoundToInt((float)hitInstance.DamageDealt * num2);
					}
					Log.Info($"Reaper暴击触发!原始伤害调整为 {hitInstance.DamageDealt},最终倍率将为 {Plugin.ReaperCritDamageMultiplier.Value}x");
				}
				else if (criticalHit)
				{
					Log.Debug("原版暴击被Reaper暴击系统覆盖:未触发");
				}
			}
			catch (Exception arg)
			{
				Log.Error($"Reaper暴击处理出错:{arg}");
			}
		}
	}
	[HarmonyPatch(typeof(HeroController))]
	[HarmonyPatch("BindCompleted")]
	internal static class HeroControllerBindCompletedPatch
	{
		[HarmonyPostfix]
		private static void Postfix(HeroController __instance)
		{
			if (!Plugin.ShouldApplyPatches() || !((ToolBase)Gameplay.ReaperCrest).IsEquipped)
			{
				return;
			}
			FieldInfo field = typeof(HeroController).GetField("reaperState", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field == null)
			{
				Log.Error("无法找到HeroController的reaperState字段");
				return;
			}
			try
			{
				object value = field.GetValue(__instance);
				if (value == null)
				{
					Log.Error("reaperState为null");
					return;
				}
				FieldInfo field2 = value.GetType().GetField("ReaperModeDurationLeft");
				if (field2 == null)
				{
					Log.Error("无法找到ReaperModeDurationLeft字段");
					return;
				}
				float num = (float)field2.GetValue(value);
				float num2 = num * Plugin.DurationMultiplier.Value;
				field2.SetValue(value, num2);
				field.SetValue(__instance, value);
				Log.Info($"Reaper模式持续时间翻倍:{num} -> {num2}");
			}
			catch (Exception arg)
			{
				Log.Error($"修改Reaper模式持续时间时出错:{arg}");
			}
		}
	}
	[HarmonyPatch(typeof(HeroController))]
	[HarmonyPatch("GetReaperPayout")]
	internal static class HeroControllerGetReaperPayoutPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ref int __result)
		{
			if (!Plugin.ShouldApplyPatches() || !((ToolBase)Gameplay.ReaperCrest).IsEquipped)
			{
				return;
			}
			try
			{
				int num = __result;
				float num2 = (float)num * Plugin.ReaperBundleMultiplier.Value;
				__result = Mathf.Max(1, Mathf.RoundToInt(num2));
				if (Plugin.ReaperBundleMultiplier.Value != 1f)
				{
					Log.Debug($"Reaper bundle payout: {num} -> {__result} (multiplier: {Plugin.ReaperBundleMultiplier.Value})");
				}
			}
			catch (Exception arg)
			{
				Log.Error($"修改Reaper bundle payout时出错:{arg}");
			}
		}
	}
	[HarmonyPatch(typeof(ToolItemManager))]
	internal static class ToolItemPatches
	{
		[HarmonyPatch("SetEquippedCrest")]
		[HarmonyPostfix]
		private static void SetEquippedCrest_Postfix(string crestId)
		{
			Log.Info("[ToolItemPatches] 护符装备状态已改变: " + crestId);
			Plugin plugin = Plugin.FindPlugin();
			if ((Object)(object)plugin != (Object)null)
			{
				plugin.RefreshReaperBalance("ToolItemManager.SetEquippedCrest", forceConfig: true);
			}
		}

		[HarmonyPatch("RefreshEquippedState")]
		[HarmonyPostfix]
		private static void RefreshEquippedState_Postfix()
		{
			Log.Info("[ToolItemPatches] 护符装备状态已刷新");
			Plugin plugin = Plugin.FindPlugin();
			if ((Object)(object)plugin != (Object)null)
			{
				plugin.RefreshReaperBalance("ToolItemManager.RefreshEquippedState", forceConfig: true);
			}
		}

		[HarmonyPatch("SendEquippedChangedEvent")]
		[HarmonyPostfix]
		private static void SendEquippedChangedEvent_Postfix(bool force)
		{
			Log.Info("[ToolItemPatches] 护符装备变更事件已发送");
			Plugin plugin = Plugin.FindPlugin();
			if ((Object)(object)plugin != (Object)null)
			{
				plugin.RefreshReaperBalance("ToolItemManager.SendEquippedChangedEvent", forceConfig: true);
			}
		}
	}
}
namespace ReaperBalance.Source.ModMenu
{
	public class ReaperBalancePaginatedMenuScreen : AbstractMenuScreen
	{
		private class SelectableWrapper : INavigable
		{
			private readonly Selectable _button;

			public SelectableWrapper(Selectable button)
			{
				_button = button;
			}

			public void ClearNeighbors()
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				Navigation navigation = _button.navigation;
				((Navigation)(ref navigation)).mode = (Mode)4;
				((Navigation)(ref navigation)).selectOnUp = null;
				((Navigation)(ref navigation)).selectOnDown = null;
				((Navigation)(ref navigation)).selectOnLeft = null;
				((Navigation)(ref navigation)).selectOnRight = null;
				_button.navigation = navigation;
			}

			public void ClearNeighbor(NavigationDirection direction)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected I4, but got Unknown
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				Navigation navigation = _button.navigation;
				((Navigation)(ref navigation)).mode = (Mode)4;
				switch ((int)direction)
				{
				case 0:
					((Navigation)(ref navigation)).selectOnUp = null;
					break;
				case 3:
					((Navigation)(ref navigation)).selectOnDown = null;
					break;
				case 1:
					((Navigation)(ref navigation)).selectOnLeft = null;
					break;
				case 2:
					((Navigation)(ref navigation)).selectOnRight = null;
					break;
				}
				_button.navigation = navigation;
			}

			public void SetNeighbor(NavigationDirection direction, Selectable selectable)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected I4, but got Unknown
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				Navigation navigation = _button.navigation;
				((Navigation)(ref navigation)).mode = (Mode)4;
				switch ((int)direction)
				{
				case 0:
					((Navigation)(ref navigation)).selectOnUp = selectable;
					break;
				case 3:
					((Navigation)(ref navigation)).selectOnDown = selectable;
					break;
				case 1:
					((Navigation)(ref navigation)).selectOnLeft = selectable;
					break;
				case 2:
					((Navigation)(ref navigation)).selectOnRight = selectable;
					break;
				}
				_button.navigation = navigation;
			}

			public bool GetSelectable(NavigationDirection direction, out Selectable selectable)
			{
				selectable = _button;
				return true;
			}
		}

		private readonly List<INavigableMenuEntity> _pages = new List<INavigableMenuEntity>();

		private readonly IntRangeChoiceModel _pageNumberModel;

		private readonly ChoiceElement<int> _pageNumberElement;

		private readonly SelectableElement _resetButtonElement;

		public Vector2 Anchor = new Vector2(0f, 300f);

		public int PageNumber
		{
			get
			{
				return ((AbstractValueModel<int>)(object)_pageNumberModel).Value;
			}
			set
			{
				((AbstractValueModel<int>)(object)_pageNumberModel).Value = value;
			}
		}

		public int PageCount => _pages.Count;

		private INavigableMenuEntity? ActivePage => (_pages.Count > 0) ? _pages[PageNumber] : null;

		public ReaperBalancePaginatedMenuScreen(string title, SelectableElement resetButton)
			: base(title)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			_resetButtonElement = resetButton;
			_pageNumberModel = new IntRangeChoiceModel(0, 0, 0)
			{
				Circular = true,
				DisplayFn = (int i) => (i + 1).ToString()
			};
			((AbstractValueModel<int>)(object)_pageNumberModel).OnValueChanged += delegate
			{
				((AbstractMenuScreen)this).UpdateLayout();
			};
			_pageNumberElement = new ChoiceElement<int>("Page", (IChoiceModel<int>)(object)_pageNumberModel, "");
			((MenuElement)_pageNumberElement).SetGameObjectParent(base.ControlsPane);
			((MenuElement)_resetButtonElement).SetGameObjectParent(base.ControlsPane);
			RectTransform component = ((Component)base.BackButton).GetComponent<RectTransform>();
			Vector2 anchoredPosition = component.anchoredPosition;
			float vSPACE_MEDIUM = SpacingConstants.VSPACE_MEDIUM;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			((MenuElement)_pageNumberElement).RectTransform.anchorMin = val;
			((MenuElement)_pageNumberElement).RectTransform.anchorMax = val;
			((MenuElement)_resetButtonElement).RectTransform.anchorMin = val;
			((MenuElement)_resetButtonElement).RectTransform.anchorMax = val;
			((MenuElement)_pageNumberElement).RectTransform.anchoredPosition = anchoredPosition;
			anchoredPosition.y -= vSPACE_MEDIUM;
			((MenuElement)_resetButtonElement).RectTransform.anchoredPosition = anchoredPosition;
			anchoredPosition.y -= vSPACE_MEDIUM;
			component.anchoredPosition = anchoredPosition;
			((AbstractMenuScreen)this).UpdateLayout();
		}

		protected override IEnumerable<MenuElement> AllElements()
		{
			return _pages.SelectMany((INavigableMenuEntity p) => ((IMenuEntity)p).AllElements()).Concat((IEnumerable<MenuElement>)(object)new MenuElement[2]
			{
				(MenuElement)_pageNumberElement,
				(MenuElement)_resetButtonElement
			});
		}

		public void AddPage(INavigableMenuEntity page)
		{
			_pages.Add(page);
			((IMenuEntity)page).SetGameObjectParent(base.ContentPane);
		}

		public void AddPages(IEnumerable<INavigableMenuEntity> pages)
		{
			foreach (INavigableMenuEntity page in pages)
			{
				AddPage(page);
			}
		}

		protected override SelectableElement? GetDefaultSelectableInternal()
		{
			INavigableMenuEntity? activePage = ActivePage;
			return (activePage != null) ? activePage.GetDefaultSelectable() : null;
		}

		protected override void UpdateLayout()
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (_pages.Count == 0)
			{
				return;
			}
			_pageNumberModel.ResetParams(0, _pages.Count - 1, ((SelectableValueElement<int>)(object)_pageNumberElement).Value);
			((MenuElement)_pageNumberElement).Visibility.VisibleSelf = _pages.Count > 1;
			for (int i = 0; i < _pages.Count; i++)
			{
				((IMenuEntity)_pages[i]).Visibility.VisibleSelf = i == PageNumber;
			}
			INavigableMenuEntity? activePage = ActivePage;
			if (activePage != null)
			{
				((IMenuEntity)activePage).UpdateLayout(Anchor);
			}
			List<INavigable> list = new List<INavigable>();
			if (ActivePage != null)
			{
				list.Add((INavigable)(object)ActivePage);
			}
			if (_pages.Count > 1)
			{
				list.Add((INavigable)(object)_pageNumberElement);
			}
			list.Add((INavigable)(object)_resetButtonElement);
			list.Add((INavigable)(object)new SelectableWrapper((Selectable)(object)base.BackButton));
			foreach (INavigable item in list)
			{
				item.ClearNeighbors();
			}
			Selectable val3 = default(Selectable);
			Selectable val4 = default(Selectable);
			for (int j = 0; j < list.Count; j++)
			{
				INavigable val = list[j];
				INavigable val2 = list[(j + 1) % list.Count];
				if (val.GetSelectable((NavigationDirection)3, ref val3))
				{
					val2.SetNeighbor((NavigationDirection)0, val3);
				}
				if (val2.GetSelectable((NavigationDirection)0, ref val4))
				{
					val.SetNeighbor((NavigationDirection)3, val4);
				}
			}
		}
	}
}
namespace ReaperBalance.Source.Behaviours
{
	internal sealed class ChangeReaper : MonoBehaviour
	{
		private class SafeEmptyAction : FsmStateAction
		{
			public override void OnEnter()
			{
				((FsmStateAction)this).Finish();
			}
		}

		private class CustomSpawnAction : FsmStateAction
		{
			public GameObject Owner { get; set; }

			public PlayMakerFSM Fsm { get; set; }

			public ChangeReaper Reaper { get; set; }

			public override void OnEnter()
			{
				try
				{
					if ((Object)(object)Reaper != (Object)null && Reaper.IsInitialized())
					{
						Reaper.SpawnCrossSlash();
					}
					else
					{
						Log.Error("ChangeReaper未初始化,无法生成攻击");
					}
					((FsmStateAction)this).Finish();
					Log.Info("自定义攻击动作执行完成");
				}
				catch (Exception arg)
				{
					Log.Error($"自定义攻击动作执行出错: {arg}");
					((FsmStateAction)this).Finish();
				}
			}
		}

		private class ReaperSilkRangeModifier : MonoBehaviour
		{
			public float CollectRange = 8f;

			public float CollectMaxSpeed = 20f;

			public float CollectAcceleration = 800f;

			private bool _isModified = false;

			private RangeCollectAction _rangeAction = null;

			private void Start()
			{
				ModifyFSM();
			}

			private void Update()
			{
				if (!_isModified)
				{
					ModifyFSM();
				}
				else if (_rangeAction != null)
				{
					_rangeAction.CollectRange = CollectRange;
					_rangeAction.MaxSpeed = CollectMaxSpeed;
					_rangeAction.Acceleration = CollectAcceleration;
				}
			}

			private void ModifyFSM()
			{
				PlayMakerFSM component = ((Component)this).GetComponent<PlayMakerFSM>();
				if ((Object)(object)component == (Object)null || component.Fsm == null)
				{
					return;
				}
				FsmState val = ((IEnumerable<FsmState>)component.FsmStates).FirstOrDefault((Func<FsmState, bool>)((FsmState state) => state.Name == "Collectable"));
				if (val != null)
				{
					List<FsmStateAction> list = val.Actions.ToList();
					if (!list.Any((FsmStateAction action) => action is RangeCollectAction))
					{
						Log.Info("为Reaper Silk Bundle添加范围检测功能(保留原有碰撞检测)");
						_rangeAction = new RangeCollectAction
						{
							Owner = ((Component)this).gameObject,
							Fsm = component,
							CollectRange = CollectRange,
							MaxSpeed = CollectMaxSpeed,
							Acceleration = CollectAcceleration
						};
						list.Add((FsmStateAction)(object)_rangeAction);
						val.Actions = list.ToArray();
						_isModified = true;
						Log.Info("范围检测功能添加成功");
					}
					else if (((IEnumerable<FsmStateAction>)list).FirstOrDefault((Func<FsmStateAction, bool>)((FsmStateAction action) => action is RangeCollectAction)) is RangeCollectAction rangeAction)
					{
						_rangeAction = rangeAction;
						_rangeAction.CollectRange = CollectRange;
						_rangeAction.MaxSpeed = CollectMaxSpeed;
						_rangeAction.Acceleration = CollectAcceleration;
						_isModified = true;
						Log.Info($"更新现有范围检测动作,范围: {CollectRange}");
					}
				}
			}
		}

		private class RangeCollectAction : FsmStateAction
		{
			private GameObject _hero;

			private Rigidbody2D _rb;

			private bool _isInRange = false;

			private float _checkInterval = 0.1f;

			private float _lastCheckTime = 0f;

			public GameObject Owner { get; set; }

			public PlayMakerFSM Fsm { get; set; }

			public float CollectRange { get; set; } = 8f;


			public float MaxSpeed { get; set; } = 20f;


			public float Acceleration { get; set; } = 800f;


			public override void OnEnter()
			{
				HeroController instance = HeroController.instance;
				_hero = ((instance != null) ? ((Component)instance).gameObject : null);
				if ((Object)(object)_hero == (Object)null)
				{
					((FsmStateAction)this).Finish();
					return;
				}
				_rb = Owner.GetComponent<Rigidbody2D>();
				if ((Object)(object)_rb == (Object)null)
				{
					Log.Warn("Reaper Silk Bundle没有Rigidbody2D组件,无法实现移动效果");
					((FsmStateAction)this).Finish();
				}
				else
				{
					Log.Info($"开始范围检测,吸收范围: {CollectRange}");
				}
			}

			public override void OnUpdate()
			{
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_025c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0261: Unknown result type (might be due to invalid IL or missing references)
				//IL_0148: Unknown result type (might be due to invalid IL or missing references)
				//IL_0158: Unknown result type (might be due to invalid IL or missing references)
				//IL_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0162: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0170: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_018e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_0192: Unknown result type (might be due to invalid IL or missing references)
				//IL_0197: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_0283: Unknown result type (might be due to invalid IL or missing references)
				//IL_0288: Unknown result type (might be due to invalid IL or missing references)
				//IL_0298: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0211: Unknown result type (might be due to invalid IL or missing references)
				//IL_0216: Unknown result type (might be due to invalid IL or missing references)
				//IL_0219: Unknown result type (might be due to invalid IL or missing references)
				//IL_0224: Unknown result type (might be due to invalid IL or missing references)
				Vector2 linearVelocity;
				if ((Object)(object)_hero == (Object)null || (Object)(object)Owner == (Object)null || (Object)(object)Fsm == (Object)null || (Object)(object)_rb == (Object)null)
				{
					((FsmStateAction)this).Finish();
				}
				else if (!Plugin.EnableSilkAttraction.Value)
				{
					if (_isInRange)
					{
						linearVelocity = _rb.linearVelocity;
						if (((Vector2)(ref linearVelocity)).magnitude > 0.1f)
						{
							_rb.linearVelocity = Vector2.zero;
							_isInRange = false;
						}
					}
				}
				else
				{
					if (Time.time - _lastCheckTime < _checkInterval)
					{
						return;
					}
					_lastCheckTime = Time.time;
					try
					{
						float num = Vector3.Distance(Owner.transform.position, _hero.transform.position);
						if (num <= CollectRange)
						{
							if (!_isInRange)
							{
								Log.Info($"进入吸收范围,距离: {num:F2}");
								_isInRange = true;
							}
							Vector3 val = _hero.transform.position - Owner.transform.position;
							Vector2 val2 = Vector2.op_Implicit(((Vector3)(ref val)).normalized);
							Vector2 linearVelocity2 = _rb.linearVelocity;
							Vector2 val3 = val2 * MaxSpeed;
							Vector2 val4 = val3 - linearVelocity2;
							float num2 = Acceleration * Time.deltaTime;
							if (((Vector2)(ref val4)).magnitude > num2)
							{
								val4 = ((Vector2)(ref val4)).normalized * num2;
							}
							Rigidbody2D rb = _rb;
							rb.linearVelocity += val4;
							linearVelocity = _rb.linearVelocity;
							if (((Vector2)(ref linearVelocity)).magnitude > MaxSpeed)
							{
								Rigidbody2D rb2 = _rb;
								linearVelocity = _rb.linearVelocity;
								rb2.linearVelocity = ((Vector2)(ref linearVelocity)).normalized * MaxSpeed;
							}
						}
						else if (_isInRange)
						{
							Log.Info("离开吸收范围");
							_isInRange = false;
							linearVelocity = _rb.linearVelocity;
							if (((Vector2)(ref linearVelocity)).magnitude > 0.1f)
							{
								_rb.linearVelocity = Vector2.Lerp(_rb.linearVelocity, Vector2.zero, 2f * Time.deltaTime);
							}
							else
							{
								_rb.linearVelocity = Vector2.zero;
							}
						}
					}
					catch (Exception arg)
					{
						Log.Error($"范围检测过程中出错: {arg}");
						((FsmStateAction)this).Finish();
					}
				}
			}

			public override void OnExit()
			{
				_hero = null;
				_rb = null;
				_isInRange = false;
			}
		}

		[CompilerGenerated]
		private sealed class <ApplyAllChangesWhenReady>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string reason;

			public ChangeReaper <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ApplyAllChangesWhenReady>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this._isInitialized));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.ApplyAllChangesInternal(reason);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <Initialize>d__11 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ChangeReaper <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Initialize>d__11(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Expected O, but got Unknown
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this._heroController = HeroController.instance;
					<>4__this._assetManager = ((Component)<>4__this).GetComponent<AssetManager>();
					if ((Object)(object)<>4__this._assetManager == (Object)null)
					{
						Log.Error("AssetManager is missing on ReaperBalanceManager.");
						return false;
					}
					<>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this._assetManager.IsInitialized()));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = <>4__this.PreloadAndCachePrefab();
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.ModifyReaperHeavy();
					<>4__this.ModifyReaperNormal();
					<>4__this._isInitialized = true;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>4__this.ModifyReaperSilk();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <ModifyExistingBundles>d__38 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ChangeReaper <>4__this;

			private GameObject[] <allBundles>5__1;

			private int <modifiedCount>5__2;

			private GameObject[] <>s__3;

			private int <>s__4;

			private GameObject <bundle>5__5;

			private ReaperSilkRangeModifier <existingModifier>5__6;

			private ReaperSilkRangeModifier <modifier>5__7;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ModifyExistingBundles>d__38(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<allBundles>5__1 = null;
				<>s__3 = null;
				<bundle>5__5 = null;
				<existingModifier>5__6 = null;
				<modifier>5__7 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Log.Info("开始查找并修改已存在的Reaper Silk Bundle实例");
					<allBundles>5__1 = Resources.FindObjectsOfTypeAll<GameObject>().Where(delegate(GameObject obj)
					{
						//IL_0013: Unknown result type (might be due to invalid IL or missing references)
						//IL_0018: Unknown result type (might be due to invalid IL or missing references)
						int result;
						if (((Object)obj).name.Contains("Reaper Silk Bundle"))
						{
							Scene scene = obj.scene;
							result = (((Scene)(ref scene)).IsValid() ? 1 : 0);
						}
						else
						{
							result = 0;
						}
						return (byte)result != 0;
					}).ToArray();
					Log.Info($"找到 {<allBundles>5__1.Length} 个Reaper Silk Bundle实例");
					<modifiedCount>5__2 = 0;
					<>s__3 = <allBundles>5__1;
					for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
					{
						<bundle>5__5 = <>s__3[<>s__4];
						<existingModifier>5__6 = <bundle>5__5.GetComponent<ReaperSilkRangeModifier>();
						if ((Object)(object)<existingModifier>5__6 == (Object)null)
						{
							<modifier>5__7 = <bundle>5__5.AddComponent<ReaperSilkRangeModifier>();
							<modifier>5__7.CollectRange = Plugin.CollectRange.Value;
							<modifier>5__7.CollectMaxSpeed = Plugin.CollectMaxSpeed.Value;
							<modifier>5__7.CollectAcceleration = Plugin.CollectAcceleration.Value;
							<modifiedCount>5__2++;
							Log.Info("为实例 " + ((Object)<bundle>5__5).name + " 添加范围修改组件");
							<modifier>5__7 = null;
						}
						else
						{
							<existingModifier>5__6.CollectRange = Plugin.CollectRange.Value;
							<existingModifier>5__6.CollectMaxSpeed = Plugin.CollectMaxSpeed.Value;
							<existingModifier>5__6.CollectAcceleration = Plugin.CollectAcceleration.Value;
							<modifiedCount>5__2++;
							Log.Info("实例 " + ((Object)<bundle>5__5).name + " 已有范围修改组件");
						}
						<existingModifier>5__6 = null;
						<bundle>5__5 = null;
					}
					<>s__3 = null;
					Log.Info($"成功为 {<modifiedCount>5__2} 个现有实例添加范围修改组件");
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <PreloadAndCachePrefab>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ChangeReaper <>4__this;

			private GameObject <crossSlashPrefab>5__1;

			private GameObject <cachedPrefab>5__2;

			private GameObject <existing>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PreloadAndCachePrefab>d__12(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<crossSlashPrefab>5__1 = null;
				<cachedPrefab>5__2 = null;
				<existing>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				if (<>4__this._assetManager.IsPrefabCached("Song Knight CrossSlash Cached"))
				{
					<existing>5__3 = <>4__this._assetManager.GetCachedPrefab("Song Knight CrossSlash Cached");
					if ((Object)(object)<existing>5__3 != (Object)null)
					{
						return false;
					}
					<existing>5__3 = null;
				}
				<crossSlashPrefab>5__1 = <>4__this._assetManager.Get<GameObject>("Song Knight CrossSlash Friendly");
				if ((Object)(object)<crossSlashPrefab>5__1 == (Object)null)
				{
					Log.Error("Song Knight CrossSlash prefab not found in AssetManager!");
					return false;
				}
				<cachedPrefab>5__2 = Object.Instantiate<GameObject>(<crossSlashPrefab>5__1);
				((Object)<cachedPrefab>5__2).name = "Song Knight CrossSlash Cached";
				<cachedPrefab>5__2.SetActive(false);
				<cachedPrefab>5__2.transform.localScale = Vector3.one * Plugin.CrossSlashScale.Value;
				<>4__this.ConfigureCrossSlashDamagers(<cachedPrefab>5__2);
				<>4__this._assetManager.StorePrefabInPool("Song Knight CrossSlash Cached", <cachedPrefab>5__2);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <ResetExistingBundles>d__46 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ChangeReaper <>4__this;

			private GameObject[] <allBundles>5__1;

			private int <modifiedCount>5__2;

			private GameObject[] <>s__3;

			private int <>s__4;

			private GameObject <bundle>5__5;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ResetExistingBundles>d__46(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<allBundles>5__1 = null;
				<>s__3 = null;
				<bundle>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Log.Info("开始查找并修改已存在的Reaper Silk Bundle实例");
					<allBundles>5__1 = Resources.FindObjectsOfTypeAll<GameObject>().Where(delegate(GameObject obj)
					{
						//IL_0013: Unknown result type (might be due to invalid IL or missing references)
						//IL_0018: Unknown result type (might be due to invalid IL or missing references)
						int result;
						if (((Object)obj).name.Contains("Reaper Silk Bundle"))
						{
							Scene scene = obj.scene;
							result = (((Scene)(ref scene)).IsValid() ? 1 : 0);
						}
						else
						{
							result = 0;
						}
						return (byte)result != 0;
					}).ToArray();
					Log.Info($"找到 {<allBundles>5__1.Length} 个Reaper Silk Bundle实例");
					<modifiedCount>5__2 = 0;
					<>s__3 = <allBundles>5__1;
					for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
					{
						<bundle>5__5 = <>s__3[<>s__4];
						Object.Destroy((Object)(object)<bundle>5__5.GetComponent<ReaperSilkRangeModifier>());
						<modifiedCount>5__2++;
						<bundle>5__5 = null;
					}
					<>s__3 = null;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <UpdateExistingBundlesRange>d__23 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ChangeReaper <>4__this;

			private GameObject[] <allBundles>5__1;

			private int <updatedCount>5__2;

			private GameObject[] <>s__3;

			private int <>s__4;

			private GameObject <bundle>5__5;

			private ReaperSilkRangeModifier <modifier>5__6;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <UpdateExistingBundlesRange>d__23(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<allBundles>5__1 = null;
				<>s__3 = null;
				<bundle>5__5 = null;
				<modifier>5__6 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<allBundles>5__1 = Resources.FindObjectsOfTypeAll<GameObject>().Where(delegate(GameObject obj)
					{
						//IL_0013: Unknown result type (might be due to invalid IL or missing references)
						//IL_0018: Unknown result type (might be due to invalid IL or missing references)
						int result;
						if (((Object)obj).name.Contains("Reaper Silk Bundle"))
						{
							Scene scene = obj.scene;
							result = (((Scene)(ref scene)).IsValid() ? 1 : 0);
						}
						else
						{
							result = 0;
						}
						return (byte)result != 0;
					}).ToArray();
					<updatedCount>5__2 = 0;
					<>s__3 = <allBundles>5__1;
					for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
					{
						<bundle>5__5 = <>s__3[<>s__4];
						<modifier>5__6 = <bundle>5__5.GetComponent<ReaperSilkRangeModifier>();
						if ((Object)(object)<modifier>5__6 != (Object)null)
						{
							<modifier>5__6.CollectRange = Plugin.CollectRange.Value;
							<modifier>5__6.CollectMaxSpeed = Plugin.CollectMaxSpeed.Value;
							<modifier>5__6.CollectAcceleration = Plugin.CollectAcceleration.Value;
							<updatedCount>5__2++;
						}
						<modifier>5__6 = null;
						<bundle>5__5 = null;
					}
					<>s__3 = null;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private bool _isInitialized = false;

		private HeroController _heroController;

		private AssetManager _assetManager;

		private const string CROSS_SLASH_PREFAB_NAME = "Song Knight CrossSlash Cached";

		private FsmStateAction[] _originalDoSlashActions = null;

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

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine(Initialize());
		}

		public void ApplyAllChanges(string reason)
		{
			if (!_isInitialized)
			{
				((MonoBehaviour)this).StartCoroutine(ApplyAllChangesWhenReady(reason));
			}
			else
			{
				ApplyAllChangesInternal(reason);
			}
		}

		[IteratorStateMachine(typeof(<ApplyAllChangesWhenReady>d__2))]
		private IEnumerator ApplyAllChangesWhenReady(string reason)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ApplyAllChangesWhenReady>d__2(0)
			{
				<>4__this = this,
				reason = reason
			};
		}

		private void ApplyAllChangesInternal(string reason)
		{
			ForceUpdateConfig();
		}

		public void ForceUpdateConfig()
		{
			if (!_isInitialized)
			{
				return;
			}
			if (Plugin.EnableCrossSlash.Value)
			{
				ModifyReaperHeavy();
				GameObject cachedPrefab = _assetManager.GetCachedPrefab("Song Knight CrossSlash Cached");
				if ((Object)(object)cachedPrefab != (Object)null)
				{
					UpdatePrefabScale(