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.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.Patches;
using UnityEngine;
using UnityEngine.SceneManagement;
[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.3.0")]
[assembly: AssemblyInformationalVersion("0.2.3+f91b546ecc9e1629e637f1e50e4a05bedea669f5")]
[assembly: AssemblyProduct("ReaperBalance")]
[assembly: AssemblyTitle("ReaperBalance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.3.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 ReaperBalance
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ReaperBalance";
public const string PLUGIN_NAME = "ReaperBalance";
public const string PLUGIN_VERSION = "0.2.3";
}
}
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 sealed class ConfigUI : MonoBehaviour
{
private bool _showGui;
private Vector2 _scrollPosition;
private Rect _windowRect = new Rect(20f, 20f, 540f, 580f);
private void Update()
{
if (Input.GetKeyDown((KeyCode)287))
{
_showGui = !_showGui;
}
}
private void OnGUI()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
if (_showGui)
{
_windowRect = GUI.Window(((Object)this).GetInstanceID(), _windowRect, new WindowFunction(DrawWindow), Tr("ReaperBalance 配置面板", "ReaperBalance Config Panel"));
}
}
private void DrawWindow(int windowId)
{
//IL_0003: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0422: Unknown result type (might be due to invalid IL or missing references)
//IL_043d: Unknown result type (might be due to invalid IL or missing references)
_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(480f) });
DrawLanguageSwitch();
GUILayout.Space(8f);
DrawToggle(Tr("启用收割者平衡", "Enable Reaper Balance"), Tr("启用或禁用收割者平衡修改。", "Enable or disable Reaper balance changes."), Plugin.EnableReaperBalance, delegate(bool enabled)
{
Plugin.ToggleReaperBalance(enabled);
});
DrawToggle(Tr("启用十字斩", "Enable Cross Slash"), Tr("启用或禁用十字斩蓄力攻击。", "Enable or disable the Cross Slash heavy attack."), Plugin.EnableCrossSlash, delegate
{
RefreshPlugin("EnableCrossSlash");
});
GUILayout.Space(6f);
DrawFloatSlider(Tr("普通攻击倍率", "Normal Attack Multiplier"), Plugin.NormalAttackMultiplier, 0.1f, 3f, 0.1f);
DrawFloatSlider(Tr("下劈攻击倍率", "Down Slash Multiplier"), Plugin.DownSlashMultiplier, 0.1f, 4f, 0.1f);
DrawFloatSlider(Tr("眩晕值倍率", "Stun Damage Multiplier"), Plugin.StunDamageMultiplier, 0f, 5f, 0.1f);
DrawFloatSlider(Tr("十字斩缩放大小", "Cross Slash Scale"), Plugin.CrossSlashScale, 0.5f, 3f, 0.1f);
DrawFloatSlider(Tr("十字斩伤害倍率", "Cross Slash Damage"), Plugin.CrossSlashDamage, 0.5f, 8f, 0.1f);
GUILayout.Space(6f);
DrawFloatSlider(Tr("持续时间倍率", "Duration Multiplier"), Plugin.DurationMultiplier, 0.2f, 10f, 0.2f);
DrawFloatSlider(Tr("丝球掉落倍率", "Silk Orb Drop Multiplier"), Plugin.ReaperBundleMultiplier, 0f, 5f, 0.5f);
GUILayout.Space(6f);
DrawToggle(Tr("吸引小丝球", "Enable Silk Attraction"), Tr("收割模式下远距离吸引小丝球。", "Attract silk orbs from a distance in Reaper mode."), Plugin.EnableSilkAttraction, delegate
{
RefreshPlugin("EnableSilkAttraction");
});
DrawFloatSlider(Tr("吸引范围", "Collect Range"), Plugin.CollectRange, 1f, 24f, 0.5f);
DrawFloatSlider(Tr("吸引最大速度", "Collect Max Speed"), Plugin.CollectMaxSpeed, 0f, 60f, 1f);
DrawFloatSlider(Tr("吸引加速度", "Collect Acceleration"), Plugin.CollectAcceleration, 0f, 3000f, 20f);
GUILayout.Space(6f);
DrawToggle(Tr("启用收割者暴击", "Enable Reaper Crit"), Tr("启用收割者独享暴击系统(仅收割者纹章生效,完全覆盖原版暴击判定)", "Enable Reaper-exclusive crit system (only works with Reaper Crest, overrides vanilla crit)"), Plugin.EnableReaperCrit);
DrawFloatSlider(Tr("暴击率 %", "Crit Chance %"), Plugin.ReaperCritChancePercent, 0f, 100f, 1f);
DrawFloatSlider(Tr("暴击伤害倍率", "Crit Damage Multiplier"), Plugin.ReaperCritDamageMultiplier, 1f, 5f, 0.1f);
GUILayout.EndScrollView();
GUILayout.Space(8f);
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (GUILayout.Button(Tr("应用并保存", "Apply & Save"), Array.Empty<GUILayoutOption>()))
{
ApplyAndSave();
}
if (GUILayout.Button(Tr("重置为默认值", "Reset Defaults"), Array.Empty<GUILayoutOption>()))
{
ResetToDefaults();
}
if (GUILayout.Button(Tr("关闭面板", "Close Panel"), Array.Empty<GUILayoutOption>()))
{
_showGui = false;
}
GUILayout.EndHorizontal();
GUILayout.Space(4f);
Color color = GUI.color;
GUI.color = new Color(0.55f, 0.55f, 0.55f);
GUILayout.Label(Tr("按 F6 打开/关闭配置面板", "Press F6 to open/close config panel"), Array.Empty<GUILayoutOption>());
GUI.color = color;
GUI.DragWindow(new Rect(0f, 0f, 10000f, 24f));
}
private void DrawLanguageSwitch()
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(Tr("语言", "Language"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
bool value = Plugin.UseChinese.Value;
if (GUILayout.Button("中文", value ? GUI.skin.box : GUI.skin.button, Array.Empty<GUILayoutOption>()))
{
Plugin.UseChinese.Value = true;
}
if (GUILayout.Button("ENGLISH", value ? GUI.skin.button : GUI.skin.box, Array.Empty<GUILayoutOption>()))
{
Plugin.UseChinese.Value = false;
}
GUILayout.EndHorizontal();
}
private static void DrawToggle(string label, string description, ConfigEntry<bool> entry, Action<bool>? onChanged = null)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
bool flag = GUILayout.Toggle(entry.Value, label, Array.Empty<GUILayoutOption>());
if (flag != entry.Value)
{
entry.Value = flag;
onChanged?.Invoke(flag);
}
if (!string.IsNullOrEmpty(description))
{
Color color = GUI.color;
GUI.color = new Color(0.7f, 0.7f, 0.7f);
GUILayout.Label(" " + description, Array.Empty<GUILayoutOption>());
GUI.color = color;
}
}
private static void DrawFloatSlider(string label, ConfigEntry<float> entry, float min, float max, float step)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) });
float num = GUILayout.HorizontalSlider(entry.Value, min, max, Array.Empty<GUILayoutOption>());
float num2 = Mathf.Clamp((float)Math.Round(Mathf.Round(num / step) * step, 3), min, max);
GUILayout.Label(num2.ToString("0.###"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
GUILayout.EndHorizontal();
if (Math.Abs(num2 - entry.Value) > 1E-06f)
{
entry.Value = num2;
RefreshPlugin(label);
}
}
private static void RefreshPlugin(string reason)
{
Plugin.FindPlugin()?.RefreshReaperBalance(reason, forceConfig: true);
}
private static void ApplyAndSave()
{
try
{
Plugin? plugin = Plugin.FindPlugin();
if (plugin != null)
{
((BaseUnityPlugin)plugin).Config.Save();
}
Log.Info("[ConfigUI] Applied and saved configuration.");
}
catch (Exception ex)
{
Log.Error("[ConfigUI] Failed to apply config: " + ex.Message);
}
}
private static void ResetToDefaults()
{
try
{
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);
}
Log.Info("[ConfigUI] Reset configuration to defaults.");
}
catch (Exception ex)
{
Log.Error("[ConfigUI] Failed to reset config: " + ex.Message);
}
}
private static string Tr(string zh, string en)
{
ConfigEntry<bool> useChinese = Plugin.UseChinese;
return (useChinese == null || useChinese.Value) ? zh : en;
}
}
[BepInPlugin("ReaperBalance", "ReaperBalance", "0.2.3")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <Initialize>d__76 : 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__76(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 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()} 个方法");
((MonoBehaviour)this).StartCoroutine(Initialize());
}
[IteratorStateMachine(typeof(<Initialize>d__76))]
private IEnumerator Initialize()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Initialize>d__76(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>();
ReaperBalanceManager.AddComponent<ConfigUI>();
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.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(cachedPrefab);
UpdatePrefabDamage(cachedPrefab);
}
}
else
{
ResetHeavyAttackModifiers();
}
ModifyReaperNormal();
UpdateReaperSilkRange();
}
[IteratorStateMachine(typeof(<Initialize>d__11))]
private IEnumerator Initialize()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Initialize>d__11(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<PreloadAndCachePrefab>d__12))]
private IEnumerator PreloadAndCachePrefab()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PreloadAndCachePrefab>d__12(0)
{
<>4__this = this
};
}
private void SpawnCrossSlash()
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
GameObject cachedPrefab = _assetManager.GetCachedPrefab("Song Knight CrossSlash Cached");
if ((Object)(object)cachedPrefab == (Object)null)
{
Log.Error("CrossSlash prefab not found in AssetPool! Please wait for initialization to complete.");
return;
}
if ((Object)(object)_heroController == (Object)null)
{
_heroController = HeroController.instance;
if ((Object)(object)_heroController == (Object)null)
{
Log.Error("HeroController instance not found!");
return;
}
}
Vector3 position = _heroController.transform.position;
Quaternion spawnRotation = GetSpawnRotation();
GameObject val = Object.Instantiate<GameObject>(cachedPrefab, position, spawnRotation);
val.transform.SetParent((Transform)null);
val.SetActive(true);
SyncCrossSlashDynamicFromHeroSlash01(val);
}
private void SyncCrossSlashDynamicFromHeroSlash01(GameObject crossSlashInstance)
{
//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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
try
{
HeroController instance = HeroController.instance;
if ((Object)(object)instance == (Object)null || (Object)(object)instance.NailImbuement == (Object)null)
{
Log.Warn("Cannot sync dynamic effects: HeroController or NailImbuement not found");
return;
}
NailElements currentElement = instance.NailImbuement.CurrentElement;
NailImbuementConfig val = instance.NailImbuement.CurrentImbuement;
if ((Object)(object)val == (Object)null)
{
val = GetImbuementConfigForElement(currentElement);
}
ApplyCrossSlashImbuementVisuals(crossSlashInstance, val);
int poisonTicksFromEquipment = GetPoisonTicksFromEquipment();
int zapTicksFromEquipment = GetZapTicksFromEquipment();
Transform val2 = crossSlashInstance.transform.Find("Damager1");
if ((Object)(object)val2 != (Object)null)
{
SyncSingleDamagerDynamicEffects(((Component)val2).gameObject, val, currentElement, poisonTicksFromEquipment, zapTicksFromEquipment, "Damager1");
}
Transform val3 = crossSlashInstance.transform.Find("Damager2");
if ((Object)(object)val3 != (Object)null)
{
SyncSingleDamagerDynamicEffects(((Component)val3).gameObject, val, currentElement, poisonTicksFromEquipment, zapTicksFromEquipment, "Damager2");
}
}
catch (Exception arg)
{
Log.Error($"Failed to sync dynamic effects to CrossSlash: {arg}");
}
}
private static void ApplyCrossSlashImbuementVisuals(GameObject crossSlashInstance, NailImbuementConfig imbuementConfig)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)crossSlashInstance == (Object)null || (Object)(object)imbuementConfig == (Object)null)
{
return;
}
try
{
Color nailTintColor = imbuementConfig.NailTintColor;
TryTintTk2dSprite(crossSlashInstance.transform, nailTintColor);
Transform val = crossSlashInstance.transform.Find("Sharp Flash");
if ((Object)(object)val != (Object)null)
{
TryTintTk2dSprite(val, nailTintColor);
}
Transform val2 = crossSlashInstance.transform.Find("Sharp Flash (1)");
if ((Object)(object)val2 != (Object)null)
{
TryTintTk2dSprite(val2, nailTintColor);
}
GameObject slashEffect = imbuementConfig.SlashEffect;
if ((Object)(object)slashEffect != (Object)null)
{
GameObject val3 = Object.Instantiate<GameObject>(slashEffect, crossSlashInstance.transform);
val3.transform.localPosition = Vector3.zero;
val3.transform.localRotation = Quaternion.identity;
val3.transform.localScale = Vector3.one;
val3.SetActive(true);
}
}
catch (Exception ex)
{
Log.Debug("Failed to apply CrossSlash imbuement visuals: " + ex.Message);
}
}
private static void TryTintTk2dSprite(Transform target, Color tint)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)target == (Object)null))
{
tk2dSprite component = ((Component)target).GetComponent<tk2dSprite>();
if ((Object)(object)component != (Object)null)
{
((tk2dBaseSprite)component).color = tint;
}
}
}
private NailImbuementConfig GetImbuementConfigForElement(NailElements element)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)element == 1)
{
return Effects.FireNail;
}
return null;
}
private int GetPoisonTicksFromEquipment()
{
try
{
if ((Object)(object)Gameplay.PoisonPouchTool != (Object)null && Gameplay.PoisonPouchTool.Status.IsEquipped)
{
return 3;
}
}
catch (Exception ex)
{
Log.Debug("Failed to check PoisonPouchTool: " + ex.Message);
}
return 0;
}
private int GetZapTicksFromEquipment()
{
try
{
if ((Object)(object)Gameplay.ZapImbuementTool != (Object)null && Gameplay.ZapImbuementTool.Status.IsEquipped)
{
return 1;
}
}
catch (Exception ex)
{
Log.Debug("Failed to check ZapImbuementTool: " + ex.Message);
}
return 0;
}
private void SyncSingleDamagerDynamicEffects(GameObject damagerObject, NailImbuementConfig nailImbuement, NailElements nailElement, int poisonTicks, int zapTicks, string damagerName)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
DamageEnemies component = damagerObject.GetComponent<DamageEnemies>();
if ((Object)(object)component == (Object)null)
{
Log.Warn("DamageEnemies component not found on " + damagerName + " for dynamic sync");
return;
}
component.NailImbuement = nailImbuement;
component.NailElement = nailElement;
}
private void UpdatePrefabScale(GameObject prefab)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)prefab != (Object)null)
{
prefab.transform.localScale = Vector3.one * Plugin.CrossSlashScale.Value;
}
}
private void UpdateReaperSilkRange()
{
if ((Object)(object)_assetManager == (Object)null)
{
Log.Warn("AssetManager is not ready for range update.");
return;
}
GameObject val = _assetManager.Get<GameObject>("Reaper Silk Bundle");
if ((Object)(object)val != (Object)null)
{
ReaperSilkRangeModifier component = val.GetComponent<ReaperSilkRangeModifier>();
if ((Object)(object)component != (Object)null)
{
component.CollectRange = Plugin.CollectRange.Value;
component.CollectMaxSpeed = Plugin.CollectMaxSpeed.Value;
component.CollectAcceleration = Plugin.CollectAcceleration.Value;
}
}
((MonoBehaviour)this).StartCoroutine(UpdateExistingBundlesRange());
}
[IteratorStateMachine(typeof(<UpdateExistingBundlesRange>d__23))]
private IEnumerator UpdateExistingBundlesRange()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <UpdateExistingBundlesRange>d__23(0)
{
<>4__this = this
};
}
private void UpdatePrefabDamage(GameObject prefab)
{
try
{
ConfigureCrossSlashDamagers(prefab);
}
catch (Exception arg)
{
Log.Error($"响应式伤害更新失败: {arg}");
}
}
private Quaternion GetSpawnRotation()
{
//IL_000d: 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_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
Transform transform = HeroController.instance.transform;
float x = transform.localScale.x;
if (x < 0f)
{
return Quaternion.Euler(0f, 180f, 0f);
}
if (x > 0f)
{
return Quaternion.identity;
}
Log.Warn("Cannot determine hero facing direction, using default rotation");
return Quaternion.identity;
}
public bool IsInitialized()
{
return _isInitialized;
}
public bool IsPrefabCached()
{
if ((Object)(object)_assetManager == (Object)null)
{
return false;
}
return _assetManager.IsPrefabCached("Song Knight CrossSlash Cached");
}
private void ConfigureCrossSlashDamagers(GameObject crossSlashPrefabOrInstance)
{
try
{
Transform val = crossSlashPrefabOrInstance.transform.Find("Damager1");
if ((Object)(object)val != (Object)null)
{
ConfigureSingleCrossSlashDamager(((Component)val).gameObject, "Damager1");
}
else
{
Log.Warn("Damager1 not found in CrossSlash");
}
Transform val2 = crossSlashPrefabOrInstance.transform.Find("Damager2");
if ((Object)(object)val2 != (Object)null)
{
ConfigureSingleCrossSlashDamager(((Component)val2).gameObject, "Damager2");
}
else
{
Log.Warn("Damager2 not found in CrossSlash");
}
Log.Info("Successfully configured CrossSlash damagers with explicit settings");
}
catch (Exception arg)
{
Log.Error($"Failed to configure CrossSlash damagers: {arg}");
}
}
private void ConfigureSingleCrossSlashDamager(GameObject damagerObject, string damagerName)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
DamageEnemies component = damagerObject.GetComponent<DamageEnemies>();
if ((Object)(object)component == (Object)null)
{
Log.Warn("DamageEnemies component not found on " + damagerName);
return;
}
damagerObject.tag = "Nail Attack";
component.useNailDamage = true;
component.nailDamageMultiplier = Plugin.CrossSlashDamage.Value;
component.attackType = (AttackTypes)16;
float num = 1f;
component.stunDamage = num * Plugin.StunDamageMultiplier.Value;
component.canWeakHit = false;
component.magnitudeMult = 1f;
component.direction = 0f;
component.moveDirection = false;
Type typeFromHandle = typeof(DamageEnemies);
FieldInfo field = typeFromHandle.GetField("silkGeneration", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(component, 0);
}
FieldInfo field2 = typeFromHandle.GetField("directionSourceOverride", BindingFlags.Instance | BindingFlags.NonPublic);
if (field2 != null)
{
field2.SetValue(component, 1);
}
FieldInfo field3 = typeFromHandle.GetField("isHeroDamage", BindingFlags.Instance | BindingFlags.NonPublic);
if (field3 != null)
{
field3.SetValue(component, true);
}
FieldInfo field4 = typeFromHandle.GetField("ignoreInvuln", BindingFlags.Instance | BindingFlags.NonPublic);
if (field4 != null)
{
field4.SetValue(component, false);
}
}
private void ModifyReaperHeavy()
{
if (!Plugin.IsReaperBalanceEnabled || !Plugin.EnableCrossSlash.Value)
{
return;
}
if ((Object)(object)_heroController == (Object)null)
{
Log.Error("HeroController is null! Cannot modify FSM.");
return;
}
PlayMakerFSM val = null;
PlayMakerFSM[] components = ((Component)_heroController).GetComponents<PlayMakerFSM>();
PlayMakerFSM[] array = components;
foreach (PlayMakerFSM val2 in array)
{
if (val2.FsmName == "Nail Arts")
{
val = val2;
break;
}
}
if ((Object)(object)val != (Object)null)
{
FsmState val3 = ((IEnumerable<FsmState>)val.FsmStates).FirstOrDefault((Func<FsmState, bool>)((FsmState s) => s.Name == "Do Slash"));
if (val3 != null)
{
if (_originalDoSlashActions == null)
{
_originalDoSlashActions = val3.Actions.ToArray();
}
List<FsmStateAction> list = val3.Actions.ToList();
for (int j = 0; j < list.Count; j++)
{
FsmStateAction val4 = list[j];
if (val4 is ActivateGameObject)
{
Log.Info("禁用Do Slash状态中的ActivateGameObject动作");
SafeEmptyAction value = new SafeEmptyAction();
list[j] = (FsmStateAction)(object)value;
continue;
}
SendMessageV2 val5 = (SendMessageV2)(object)((val4 is SendMessageV2) ? val4 : null);
if (val5 != null)
{
string text = val5.functionCall?.FunctionName;
if (text == "OnSlashStarting")
{
Log.Info("替换OnSlashStarting为自定义攻击动作");
CustomSpawnAction value2 = new CustomSpawnAction
{
Owner = ((Component)val).gameObject,
Fsm = val,
Reaper = this
};
list[j] = (FsmStateAction)(object)value2;
}
}
}
val3.Actions = list.ToArray();
Log.Info("已修改Do Slash状态");
}
else
{
Log.Warn("Do Slash状态未找到");
}
}
else
{
Log.Warn("Nail Arts FSM not found on HeroController");
}
}
private void ModifyReaperNormal()
{
if (!Plugin.IsReaperBalanceEnabled)
{
Log.Info("全局开关关闭,跳过NormalAttack修改");
return;
}
if ((Object)(object)_heroController == (Object)null)
{
Log.Error("HeroController is null! Cannot modify FSM.");
return;
}
Transform val = ((Component)_heroController).gameObject.transform.Find("Attacks");
if ((Object)(object)val != (Object)null)
{
Log.Info("找到Attack GameObject");
Transform val2 = ((Component)val).gameObject.transform.Find("Scythe");
if ((Object)(object)val2 != (Object)null)
{
ModifyDamageMultiplierRecursive(val2, Plugin.NormalAttackMultiplier.Value);
Transform val3 = ((Component)val2).gameObject.transform.Find("DownSlash New");
if ((Object)(object)val3 != (Object)null)
{
DamageEnemies component = ((Component)val3).GetComponent<DamageEnemies>();
if ((Object)(object)component != (Object)null)
{
component.damageMultiplier = Plugin.DownSlashMultiplier.Value;
ApplyStunDamageMultiplier(component, ((Object)val3).name);
Log.Info($"修改 {((Object)val3).name} 的DamageEnemies: damageMultiplier={component.damageMultiplier}, stunDamage={component.stunDamage}");
}
else
{
Log.Warn("DownSlash的DamageEnemies组件未找到");
}
}
else
{
Log.Warn("DownSlash GameObject not found");
}
}
else
{
Log.Warn("Scythe GameObject not found");
}
}
else
{
Log.Warn("Attack GameObject not found");
}
}
private void ModifyDamageMultiplierRecursive(Transform transform, float multiplier)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
DamageEnemies component = ((Component)transform).GetComponent<DamageEnemies>();
if ((Object)(object)component != (Object)null && ((Object)transform).name != "DownSlash New")
{
component.damageMultiplier = multiplier;
ApplyStunDamageMultiplier(component, ((Object)transform).name);
Log.Info($"修改 {((Object)transform).name} 的DamageEnemies.damageMultiplier为 {multiplier}, stunDamage为 {component.stunDamage}");
}
foreach (Transform item in transform)
{
Transform transform2 = item;
ModifyDamageMultiplierRecursive(transform2, multiplier);
}
}
private void ApplyStunDamageMultiplier(DamageEnemies damageEnemies, string objectName)
{
int instanceID = ((Object)damageEnemies).GetInstanceID();
if (!_baseStunDamage.ContainsKey(instanceID))
{
_baseStunDamage[instanceID] = damageEnemies.stunDamage;
Log.Debug($"记录 {objectName} 的基础 stunDamage: {damageEnemies.stunDamage}");
}
float num = _baseStunDamage[instanceID];
damageEnemies.stunDamage = num * Plugin.StunDamageMultiplier.Value;
}
private void ResetStunDamageToBase(DamageEnemies damageEnemies)
{
int instanceID = ((Object)damageEnemies).GetInstanceID();
if (_baseStunDamage.TryGetValue(instanceID, out var value))
{
damageEnemies.stunDamage = value;
}
}
private void ModifyReaperSilk()
{
if (!Plugin.IsReaperBalanceEnabled)
{
Log.Info("全局开关关闭,跳过ReaperSilk修改");
return;
}
if ((Object)(object)_assetManager == (Object)null)
{
Log.Error("AssetManager instance is null!");
return;
}
GameObject val = _assetManager.Get<GameObject>("Reaper Silk Bundle");
if ((Object)(object)val == (Object)null)
{
Log.Error("Reaper Silk Bundle not found!");
return;
}
ReaperSilkRangeModifier reaperSilkRangeModifier = val.GetComponent<ReaperSilkRangeModifier>();
if ((Object)(object)reaperSilkRangeModifier == (Object)null)
{
reaperSilkRangeModifier = val.AddComponent<ReaperSilkRangeModifier>();
}
reaperSilkRangeModifier.CollectRange = Plugin.CollectRange.Value;
reaperSilkRangeModifier.CollectMaxSpeed = Plugin.CollectMaxSpeed.Value;
reaperSilkRangeModifier.CollectAcceleration = Plugin.CollectAcceleration.Value;
Log.Info("已为Reaper Silk Bundle添加范围修改组件");
((MonoBehaviour)this).StartCoroutine(ModifyExistingBundles());
}
[IteratorStateMachine(typeof(<ModifyExistingBundles>d__38))]
private IEnumerator ModifyExistingBundles()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ModifyExistingBundles>d__38(0)
{
<>4__this = this
};
}
public void ResetModifications()
{
try
{
ResetNormalAttackModifiers();
ResetHeavyAttackModifiers();
ResetReaperSilk();
_baseStunDamage.Clear();
Log.Info("已重置所有Reaper修改");
}
catch (Exception arg)
{
Log.Error($"重置修改时出错: {arg}");
}
}
private void ResetNormalAttackModifiers()
{
if ((Object)(object)_heroController == (Object)null)
{
return;
}
Transform val = ((Component)_heroController).gameObject.transform.Find("Attacks");
if ((Object)(object)val != (Object)null)
{
Transform val2 = ((Component)val).gameObject.transform.Find("Scythe");
if ((Object)(object)val2 != (Object)null)
{
ResetDamageMultiplierRecursive(val2, 1f);
}
}
}
private void ResetDamageMultiplierRecursive(Transform transform, float multiplier)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
DamageEnemies component = ((Component)transform).GetComponent<DamageEnemies>();
if ((Object)(object)component != (Object)null)
{
component.damageMultiplier = multiplier;
ResetStunDamageToBase(component);
Log.Info($"重置 {((Object)transform).name} 的DamageEnemies: damageMultiplier={multiplier}, stunDamage={component.stunDamage}");
}
foreach (Transform item in transform)
{
Transform transform2 = item;
ResetDamageMultiplierRecursive(transform2, multiplier);
}
}
private void ResetHeavyAttackModifiers()
{
if ((Object)(object)_heroController == (Object)null)
{
return;
}
PlayMakerFSM val = null;
PlayMakerFSM[] components = ((Component)_heroController).GetComponents<PlayMakerFSM>();
PlayMakerFSM[] array = components;
foreach (PlayMakerFSM val2 in array)
{
if (val2.FsmName == "Nail Arts")
{
val = val2;
break;
}
}
if (!((Object)(object)val != (Object)null))
{
return;
}
FsmState val3 = ((IEnumerable<FsmState>)val.FsmStates).FirstOrDefault((Func<FsmState, bool>)((FsmState s) => s.Name == "Do Slash"));
if (val3 != null)
{
if (_originalDoSlashActions != null)
{
val3.Actions = _originalDoSlashActions;
}
Log.Info("重置重攻击修改");
}
}
private void ResetReaperSilk()
{
if ((Object)(object)_assetManager == (Object)null)
{
Log.Error("AssetManager instance is null!");
return;
}
GameObject val = _assetManager.Get<GameObject>("Reaper Silk Bundle");
if ((Object)(object)val == (Object)null)
{
Log.Error("Reaper Silk Bundle not found!");
return;
}
Object.Destroy((Object)(object)val.GetComponent<ReaperSilkRangeModifier>());
((MonoBehaviour)this).StartCoroutine(ResetExistingBundles());
}
[IteratorStateMachine(typeof(<ResetExistingBundles>d__46))]
private IEnumerator ResetExistingBundles()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ResetExistingBundles>d__46(0)
{
<>4__this = this
};
}
}
}