Decompiled source of BasicIncrease v0.1.1

BasicIncrease.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BasicIncrease")]
[assembly: AssemblyDescription("基础属性增强模组")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("hyy")]
[assembly: AssemblyProduct("BasicIncrease")]
[assembly: AssemblyCopyright("Copyright © hyy 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("00000000-0000-0000-0000-000000000000")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace BasicIncrease;

[BepInPlugin("com.hyy.basicincrease", "基础属性增强", "1.0.0")]
[BepInProcess("REPO.exe")]
public class Plugin : BaseUnityPlugin
{
	public static Plugin Instance;

	public static ConfigEntry<float> MoveSpeedMultiplier;

	public static ConfigEntry<float> SprintSpeedMultiplier;

	public static ConfigEntry<float> CrouchSpeedMultiplier;

	public static ConfigEntry<float> JumpForceMultiplier;

	public static ConfigEntry<int> ExtraJumps;

	public static ConfigEntry<float> GravityMultiplier;

	public static ConfigEntry<float> StaminaDrainMultiplier;

	public static ConfigEntry<float> StaminaRegenMultiplier;

	public static ConfigEntry<float> StaminaRegenDelayMultiplier;

	public static ConfigEntry<bool> InfiniteStamina;

	public static ConfigEntry<float> GrabStrengthMultiplier;

	public static ConfigEntry<float> ThrowStrengthMultiplier;

	public static ConfigEntry<float> GrabRangeMultiplier;

	public static ConfigEntry<bool> EnableDebugLogs;

	public static ConfigEntry<bool> EnableGrabEnhancement;

	private readonly Harmony harmony = new Harmony("com.hyy.basicincrease");

	public static void LogInfo(string message)
	{
		if (EnableDebugLogs.Value)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
		}
	}

	public static void LogError(string message)
	{
		((BaseUnityPlugin)Instance).Logger.LogError((object)message);
	}

	public static void LogWarning(string message)
	{
		((BaseUnityPlugin)Instance).Logger.LogWarning((object)message);
	}

	private void Awake()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Expected O, but got Unknown
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Expected O, but got Unknown
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Expected O, but got Unknown
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Expected O, but got Unknown
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Expected O, but got Unknown
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Expected O, but got Unknown
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Expected O, but got Unknown
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Expected O, but got Unknown
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Expected O, but got Unknown
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Expected O, but got Unknown
		//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Expected O, but got Unknown
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Expected O, but got Unknown
		//IL_034a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Expected O, but got Unknown
		Instance = this;
		EnableDebugLogs = ((BaseUnityPlugin)this).Config.Bind<bool>("调试", "启用调试日志", true, new ConfigDescription("是否启用调试日志输出", (AcceptableValueBase)null, Array.Empty<object>()));
		EnableGrabEnhancement = ((BaseUnityPlugin)this).Config.Bind<bool>("调试", "启用抓取增强", true, new ConfigDescription("是否启用抓取增强功能", (AcceptableValueBase)null, Array.Empty<object>()));
		MoveSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("移动", "移动速度倍数", 1.5f, new ConfigDescription("基础移动速度的倍数 (默认: 1.5)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		SprintSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("移动", "冲刺速度倍数", 1.5f, new ConfigDescription("冲刺速度的倍数 (默认: 1.5)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		CrouchSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("移动", "蹲伏速度倍数", 1.5f, new ConfigDescription("蹲伏移动速度的倍数 (默认: 1.5)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		JumpForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("跳跃", "跳跃高度倍数", 2f, new ConfigDescription("跳跃高度的倍数 (默认: 2.0)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		ExtraJumps = ((BaseUnityPlugin)this).Config.Bind<int>("跳跃", "额外跳跃次数", 0, new ConfigDescription("空中额外跳跃次数 (默认: 0)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
		GravityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("物理", "重力倍数", 0.8f, new ConfigDescription("重力的倍数 (值越小重力越弱, 默认: 0.8)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
		StaminaDrainMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("耐力", "耐力消耗倍数", 0.5f, new ConfigDescription("冲刺时耐力消耗速度的倍数 (值越小消耗越慢, 默认: 0.5)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
		StaminaRegenMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("耐力", "耐力回复倍数", 2f, new ConfigDescription("耐力回复速度的倍数 (默认: 2.0)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		StaminaRegenDelayMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("耐力", "耐力回复延迟倍数", 0.5f, new ConfigDescription("停止冲刺后开始回复耐力的延迟时间的倍数 (值越小回复越快, 默认: 0.5)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
		InfiniteStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("耐力", "无限耐力", false, new ConfigDescription("是否拥有无限耐力 (默认: 关闭)", (AcceptableValueBase)null, Array.Empty<object>()));
		GrabStrengthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("抓取", "抓取力量倍数", 3f, new ConfigDescription("抓取物体时的力量倍数 (默认: 3.0)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
		ThrowStrengthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("抓取", "投掷力量倍数", 3f, new ConfigDescription("投掷物体时的力量倍数 (默认: 3.0)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
		GrabRangeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("抓取", "抓取距离倍数", 2f, new ConfigDescription("抓取距离的倍数 (默认: 2.0)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		try
		{
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony补丁已成功应用");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("应用Harmony补丁时出错: " + ex.Message));
			((BaseUnityPlugin)this).Logger.LogError((object)ex.StackTrace);
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"基础属性增强模组已加载!");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"作者: hyy | 版本: 1.0.0");
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"移动速度倍数: {MoveSpeedMultiplier.Value}");
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"冲刺速度倍数: {SprintSpeedMultiplier.Value}");
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"跳跃高度倍数: {JumpForceMultiplier.Value}");
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"抓取力量倍数: {GrabStrengthMultiplier.Value}");
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"投掷力量倍数: {ThrowStrengthMultiplier.Value}");
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"抓取距离倍数: {GrabRangeMultiplier.Value}");
		((BaseUnityPlugin)this).Config.SettingChanged += OnConfigChanged;
	}

	private void OnConfigChanged(object sender, SettingChangedEventArgs e)
	{
		if (e.ChangedSetting.Definition.Section == "抓取")
		{
			LogInfo($"抓取配置已更改: {e.ChangedSetting.Definition.Key} = {e.ChangedSetting.BoxedValue}");
		}
	}

	private void OnDestroy()
	{
		((BaseUnityPlugin)this).Config.SettingChanged -= OnConfigChanged;
	}

	private void Update()
	{
		if (Time.frameCount % 300 != 0 || !EnableGrabEnhancement.Value || (!(GrabStrengthMultiplier.Value > 1.01f) && !(ThrowStrengthMultiplier.Value > 1.01f) && !(GrabRangeMultiplier.Value > 1.01f)))
		{
			return;
		}
		try
		{
			PhysGrabber[] array = Object.FindObjectsOfType<PhysGrabber>();
			if (array == null || array.Length == 0)
			{
				return;
			}
			int num = 0;
			PhysGrabber[] array2 = array;
			foreach (PhysGrabber val in array2)
			{
				if ((Object)(object)val != (Object)null)
				{
					EnhancedDirectGrabEnhancement(val);
					num++;
				}
			}
			LogInfo($"定期增强: 增强了 {num} 个抓取器");
		}
		catch (Exception ex)
		{
			LogError("定期增强出错: " + ex.Message);
		}
	}

	private void EnhancedDirectGrabEnhancement(PhysGrabber grabber)
	{
		try
		{
			Type type = ((object)grabber).GetType();
			FieldInfo field = type.GetField("grabStrength", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null && GrabStrengthMultiplier.Value > 1f)
			{
				float num = (float)field.GetValue(grabber);
				float num2 = 10f;
				float num3 = num2 * GrabStrengthMultiplier.Value;
				if (num < num3 * 0.9f)
				{
					field.SetValue(grabber, num3);
					LogInfo($"直接增强抓取力量: {num} -> {num3}");
				}
			}
			FieldInfo field2 = type.GetField("throwStrength", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 != null && ThrowStrengthMultiplier.Value > 1f)
			{
				float num4 = (float)field2.GetValue(grabber);
				float num5 = 1f;
				float num6 = num5 * ThrowStrengthMultiplier.Value;
				if (num4 < num6 * 0.9f)
				{
					field2.SetValue(grabber, num6);
					LogInfo($"直接增强投掷力量: {num4} -> {num6}");
				}
			}
			FieldInfo field3 = type.GetField("grabRange", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field3 != null && GrabRangeMultiplier.Value > 1f)
			{
				float num7 = (float)field3.GetValue(grabber);
				float num8 = 4f;
				float num9 = Mathf.Min(num8 * GrabRangeMultiplier.Value, 50f);
				if (num7 < num9 * 0.9f)
				{
					field3.SetValue(grabber, num9);
					LogInfo($"直接增强抓取范围: {num7} -> {num9}");
				}
			}
		}
		catch (Exception ex)
		{
			LogError("直接增强抓取器时出错: " + ex.Message);
		}
	}
}
[HarmonyPatch]
public class PlayerControllerPatches
{
	private static float originalMoveSpeed;

	private static float originalSprintSpeed;

	private static float originalCrouchSpeed;

	private static float originalCustomGravity;

	private static float originalJumpForce;

	private static float originalEnergySprintDrain;

	private static FieldInfo playerOriginalMoveSpeedField;

	private static FieldInfo playerOriginalSprintSpeedField;

	private static FieldInfo playerOriginalCrouchSpeedField;

	private static FieldInfo playerOriginalCustomGravityField;

	private static FieldInfo jumpExtraField;

	private static FieldInfo sprintRechargeAmountField;

	private static FieldInfo sprintRechargeTimeField;

	private static bool valuesInitialized;

	[HarmonyPatch(typeof(PlayerController), "Start")]
	[HarmonyPostfix]
	private static void StartPostfix(PlayerController __instance)
	{
		if (!valuesInitialized && (Object)(object)__instance != (Object)null)
		{
			try
			{
				originalMoveSpeed = __instance.MoveSpeed;
				originalSprintSpeed = __instance.SprintSpeed;
				originalCrouchSpeed = __instance.CrouchSpeed;
				originalCustomGravity = __instance.CustomGravity;
				originalJumpForce = __instance.JumpForce;
				originalEnergySprintDrain = __instance.EnergySprintDrain;
				Type typeFromHandle = typeof(PlayerController);
				playerOriginalMoveSpeedField = typeFromHandle.GetField("playerOriginalMoveSpeed", BindingFlags.Instance | BindingFlags.NonPublic);
				playerOriginalSprintSpeedField = typeFromHandle.GetField("playerOriginalSprintSpeed", BindingFlags.Instance | BindingFlags.NonPublic);
				playerOriginalCrouchSpeedField = typeFromHandle.GetField("playerOriginalCrouchSpeed", BindingFlags.Instance | BindingFlags.NonPublic);
				playerOriginalCustomGravityField = typeFromHandle.GetField("playerOriginalCustomGravity", BindingFlags.Instance | BindingFlags.NonPublic);
				jumpExtraField = typeFromHandle.GetField("JumpExtra", BindingFlags.Instance | BindingFlags.Public);
				sprintRechargeAmountField = typeFromHandle.GetField("sprintRechargeAmount", BindingFlags.Instance | BindingFlags.NonPublic);
				sprintRechargeTimeField = typeFromHandle.GetField("sprintRechargeTime", BindingFlags.Instance | BindingFlags.NonPublic);
				Plugin.LogInfo($"原始移动速度: {originalMoveSpeed}");
				Plugin.LogInfo($"原始冲刺速度: {originalSprintSpeed}");
				Plugin.LogInfo($"原始跳跃力量: {originalJumpForce}");
				Plugin.LogInfo($"原始耐力消耗: {originalEnergySprintDrain}");
				valuesInitialized = true;
			}
			catch (Exception ex)
			{
				Plugin.LogError("初始化原始值时出错: " + ex.Message);
			}
		}
	}

	private static void ApplyModifications(PlayerController player)
	{
		if (!valuesInitialized || (Object)(object)player == (Object)null)
		{
			return;
		}
		try
		{
			float originalValue = GetOriginalValue(playerOriginalMoveSpeedField, player, originalMoveSpeed);
			float originalValue2 = GetOriginalValue(playerOriginalSprintSpeedField, player, originalSprintSpeed);
			float originalValue3 = GetOriginalValue(playerOriginalCrouchSpeedField, player, originalCrouchSpeed);
			float originalValue4 = GetOriginalValue(playerOriginalCustomGravityField, player, originalCustomGravity);
			player.MoveSpeed = originalMoveSpeed * Plugin.MoveSpeedMultiplier.Value;
			player.SprintSpeed = originalSprintSpeed * Plugin.SprintSpeedMultiplier.Value;
			player.CrouchSpeed = originalCrouchSpeed * Plugin.CrouchSpeedMultiplier.Value;
			SetOriginalValue(playerOriginalMoveSpeedField, player, player.MoveSpeed);
			SetOriginalValue(playerOriginalSprintSpeedField, player, player.SprintSpeed);
			SetOriginalValue(playerOriginalCrouchSpeedField, player, player.CrouchSpeed);
			player.CustomGravity = originalCustomGravity * Plugin.GravityMultiplier.Value;
			SetOriginalValue(playerOriginalCustomGravityField, player, player.CustomGravity);
			player.JumpForce = originalJumpForce * Plugin.JumpForceMultiplier.Value;
			if (jumpExtraField != null)
			{
				jumpExtraField.SetValue(player, Plugin.ExtraJumps.Value);
			}
			player.EnergySprintDrain = originalEnergySprintDrain * Plugin.StaminaDrainMultiplier.Value;
			if (Plugin.InfiniteStamina.Value)
			{
				player.EnergyCurrent = player.EnergyStart;
				player.DebugEnergy = true;
			}
			else
			{
				player.DebugEnergy = false;
			}
		}
		catch (Exception ex)
		{
			Plugin.LogError("应用修改时出错: " + ex.Message);
		}
	}

	private static float GetOriginalValue(FieldInfo field, PlayerController player, float defaultValue)
	{
		if (field != null)
		{
			try
			{
				return (float)field.GetValue(player);
			}
			catch
			{
				return defaultValue;
			}
		}
		return defaultValue;
	}

	private static void SetOriginalValue(FieldInfo field, PlayerController player, float value)
	{
		if (field != null)
		{
			try
			{
				field.SetValue(player, value);
			}
			catch
			{
			}
		}
	}

	[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
	[HarmonyPostfix]
	private static void FixedUpdatePostfix(PlayerController __instance)
	{
		ApplyModifications(__instance);
	}

	[HarmonyPatch(typeof(PlayerController), "Update")]
	[HarmonyPostfix]
	private static void UpdatePostfix(PlayerController __instance)
	{
		if ((Object)(object)__instance == (Object)null)
		{
			return;
		}
		try
		{
			if (sprintRechargeTimeField != null)
			{
				float num = (float)sprintRechargeTimeField.GetValue(__instance);
				float num2 = num * Plugin.StaminaRegenDelayMultiplier.Value;
				sprintRechargeTimeField.SetValue(__instance, num2);
			}
			if (sprintRechargeAmountField != null)
			{
				float num3 = (float)sprintRechargeAmountField.GetValue(__instance);
				float num4 = num3 * Plugin.StaminaRegenMultiplier.Value;
				sprintRechargeAmountField.SetValue(__instance, num4);
			}
		}
		catch
		{
		}
	}

	[HarmonyPatch(typeof(PlayerController), "OverrideSpeedLogic")]
	[HarmonyPrefix]
	private static bool OverrideSpeedLogicPrefix()
	{
		return false;
	}

	[HarmonyPatch(typeof(PlayerController), "OverrideTimeScaleLogic")]
	[HarmonyPrefix]
	private static bool OverrideTimeScaleLogicPrefix()
	{
		return false;
	}

	[HarmonyPatch(typeof(PlayerController), "OverrideSpeedTick")]
	[HarmonyPrefix]
	private static bool OverrideSpeedTickPrefix()
	{
		return false;
	}

	[HarmonyPatch(typeof(PlayerController), "OverrideTimeScaleTick")]
	[HarmonyPrefix]
	private static bool OverrideTimeScaleTickPrefix()
	{
		return false;
	}
}
[HarmonyPatch]
public class PhysGrabberPatches
{
	private static float lastGrabMultiplier = 1f;

	private static float lastThrowMultiplier = 1f;

	private static float lastRangeMultiplier = 1f;

	[HarmonyPatch(typeof(PhysGrabber), "Start")]
	[HarmonyPostfix]
	private static void StartPostfix(PhysGrabber __instance)
	{
		Plugin.LogInfo("PhysGrabber 已初始化,准备应用增强");
		ApplyGrabEnhancements(__instance);
	}

	private static void ApplyGrabEnhancements(PhysGrabber grabber)
	{
		if (!((Object)(object)grabber == (Object)null) && (Plugin.GrabStrengthMultiplier.Value > 1.01f || Plugin.ThrowStrengthMultiplier.Value > 1.01f || Plugin.GrabRangeMultiplier.Value > 1.01f))
		{
			Plugin.LogInfo("应用抓取增强...");
			EnhanceViaDynamicMethod(grabber);
		}
	}

	private static void EnhanceViaDynamicMethod(PhysGrabber grabber)
	{
		try
		{
			Type type = ((object)grabber).GetType();
			PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
			PropertyInfo[] array = properties;
			foreach (PropertyInfo propertyInfo in array)
			{
				try
				{
					if (propertyInfo.PropertyType == typeof(float))
					{
						string text = propertyInfo.Name.ToLower();
						if (text.Contains("grab") && text.Contains("strength") && propertyInfo.CanWrite)
						{
							float num = (float)propertyInfo.GetValue(grabber);
							float num2 = Mathf.Max(num, 1f) * Plugin.GrabStrengthMultiplier.Value;
							propertyInfo.SetValue(grabber, num2);
							Plugin.LogInfo($"通过属性增强抓取力量: {num} -> {num2}");
						}
						else if (text.Contains("throw") && text.Contains("strength") && propertyInfo.CanWrite)
						{
							float num3 = (float)propertyInfo.GetValue(grabber);
							float num4 = Mathf.Max(num3, 1f) * Plugin.ThrowStrengthMultiplier.Value;
							propertyInfo.SetValue(grabber, num4);
							Plugin.LogInfo($"通过属性增强投掷力量: {num3} -> {num4}");
						}
						else if (text.Contains("range") && propertyInfo.CanWrite)
						{
							float num5 = (float)propertyInfo.GetValue(grabber);
							float num6 = Mathf.Max(num5, 4f) * Plugin.GrabRangeMultiplier.Value;
							propertyInfo.SetValue(grabber, Mathf.Min(num6, 50f));
							Plugin.LogInfo($"通过属性增强抓取范围: {num5} -> {num6}");
						}
					}
				}
				catch
				{
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.LogError("动态增强抓取时出错: " + ex.Message);
		}
	}

	[HarmonyPatch(typeof(PhysGrabber), "FixedUpdate")]
	[HarmonyPostfix]
	private static void FixedUpdatePostfix(PhysGrabber __instance)
	{
		if (Plugin.GrabStrengthMultiplier.Value != lastGrabMultiplier || Plugin.ThrowStrengthMultiplier.Value != lastThrowMultiplier || Plugin.GrabRangeMultiplier.Value != lastRangeMultiplier)
		{
			lastGrabMultiplier = Plugin.GrabStrengthMultiplier.Value;
			lastThrowMultiplier = Plugin.ThrowStrengthMultiplier.Value;
			lastRangeMultiplier = Plugin.GrabRangeMultiplier.Value;
			ApplyGrabEnhancements(__instance);
		}
	}
}
[HarmonyPatch]
public class PhysGrabberTranspiler
{
	private static bool transpilerApplied;

	public static void InitializeAndApplyEnhancements()
	{
		if (transpilerApplied)
		{
			return;
		}
		try
		{
			EnhanceGrabberFields();
			transpilerApplied = true;
			Plugin.LogInfo("Transpiler 初始化完成");
		}
		catch (Exception ex)
		{
			Plugin.LogError("Transpiler 初始化失败: " + ex.Message);
		}
	}

	[HarmonyPatch(typeof(PhysGrabObject), "PhysicsGrabbingManipulation")]
	[HarmonyTranspiler]
	private static IEnumerable<CodeInstruction> PhysicsGrabbingManipulationTranspiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Expected O, but got Unknown
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Expected O, but got Unknown
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Expected O, but got Unknown
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Expected O, but got Unknown
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Expected O, but got Unknown
		Plugin.LogInfo("开始 Transpile PhysicsGrabbingManipulation 方法...");
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		bool flag = false;
		for (int i = 0; i < list.Count; i++)
		{
			if (list[i].opcode == OpCodes.Ldfld && list[i].operand is FieldInfo fieldInfo)
			{
				string text = fieldInfo.Name.ToLower();
				if (text.Contains("grab") && text.Contains("strength"))
				{
					Plugin.LogInfo("找到抓取力量字段: " + fieldInfo.Name);
					list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PhysGrabberTranspiler), "GetGrabStrengthMultiplier", (Type[])null, (Type[])null)));
					list.Insert(i + 2, new CodeInstruction(OpCodes.Mul, (object)null));
					flag = true;
					Plugin.LogInfo($"在位置 {i} 注入了抓取力量增强");
				}
				else if (text.Contains("throw") && text.Contains("strength"))
				{
					Plugin.LogInfo("找到投掷力量字段: " + fieldInfo.Name);
					list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PhysGrabberTranspiler), "GetThrowStrengthMultiplier", (Type[])null, (Type[])null)));
					list.Insert(i + 2, new CodeInstruction(OpCodes.Mul, (object)null));
					flag = true;
					Plugin.LogInfo($"在位置 {i} 注入了投掷力量增强");
				}
			}
			if (!(list[i].opcode == OpCodes.Ldfld) || !(list[i].operand is FieldInfo fieldInfo2))
			{
				continue;
			}
			string text2 = fieldInfo2.Name.ToLower();
			if (text2.Contains("range") || text2.Contains("distance"))
			{
				Plugin.LogInfo("找到范围/距离字段: " + fieldInfo2.Name);
				if (i > 0 && list[i - 1].opcode == OpCodes.Ldarg_0)
				{
					list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PhysGrabberTranspiler), "GetGrabRangeMultiplier", (Type[])null, (Type[])null)));
					list.Insert(i + 2, new CodeInstruction(OpCodes.Mul, (object)null));
					flag = true;
					Plugin.LogInfo($"在位置 {i} 注入了抓取范围增强");
				}
			}
		}
		if (!flag)
		{
			Plugin.LogWarning("未找到可修改的抓取相关字段,尝试备用方案...");
			for (int j = 0; j < list.Count; j++)
			{
				if (!(list[j].opcode == OpCodes.Ldc_R4))
				{
					continue;
				}
				float num = (float)list[j].operand;
				if (!(num >= 1f) || !(num <= 100f))
				{
					continue;
				}
				bool flag2 = false;
				for (int k = Math.Max(0, j - 5); k < j; k++)
				{
					if (list[k].opcode == OpCodes.Ldstr && list[k].operand is string text3 && (text3.ToLower().Contains("grab") || text3.ToLower().Contains("throw")))
					{
						flag2 = true;
						break;
					}
				}
				if (flag2)
				{
					Plugin.LogInfo($"找到可能的抓取相关常量: {num}");
					float num2 = num * Plugin.GrabStrengthMultiplier.Value;
					list[j].operand = num2;
					flag = true;
				}
			}
		}
		if (flag)
		{
			Plugin.LogInfo("PhysicsGrabbingManipulation 方法已成功修改");
		}
		else
		{
			Plugin.LogWarning("PhysicsGrabbingManipulation 方法修改失败");
		}
		return list;
	}

	[HarmonyPatch(typeof(PhysGrabObject), "Throw")]
	[HarmonyTranspiler]
	private static IEnumerable<CodeInstruction> ThrowTranspiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Expected O, but got Unknown
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Expected O, but got Unknown
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Expected O, but got Unknown
		Plugin.LogInfo("开始 Transpile Throw 方法...");
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		bool flag = false;
		for (int i = 0; i < list.Count; i++)
		{
			if (list[i].opcode == OpCodes.Ldfld && list[i].operand is FieldInfo fieldInfo)
			{
				string text = fieldInfo.Name.ToLower();
				if (text.Contains("throw") && text.Contains("strength"))
				{
					Plugin.LogInfo("在 Throw 方法中找到投掷力量字段: " + fieldInfo.Name);
					list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PhysGrabberTranspiler), "GetThrowStrengthMultiplier", (Type[])null, (Type[])null)));
					list.Insert(i + 2, new CodeInstruction(OpCodes.Mul, (object)null));
					flag = true;
					Plugin.LogInfo("Throw 方法已增强");
					break;
				}
			}
		}
		if (!flag)
		{
			for (int j = 0; j < list.Count - 2; j++)
			{
				if (list[j].opcode == OpCodes.Mul && list[j - 1].opcode == OpCodes.Ldfld && list[j - 1].operand is FieldInfo)
				{
					list.Insert(j + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PhysGrabberTranspiler), "GetThrowStrengthMultiplier", (Type[])null, (Type[])null)));
					list.Insert(j + 2, new CodeInstruction(OpCodes.Mul, (object)null));
					flag = true;
					Plugin.LogInfo("通过备用方法增强了 Throw");
					break;
				}
			}
		}
		return list;
	}

	[HarmonyPatch(typeof(PhysGrabber), "RayCheck")]
	[HarmonyTranspiler]
	private static IEnumerable<CodeInstruction> RayCheckTranspiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		Plugin.LogInfo("开始 Transpile RayCheck 方法...");
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		for (int i = 0; i < list.Count; i++)
		{
			if (list[i].opcode == OpCodes.Ret)
			{
				list.Insert(i, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PhysGrabberTranspiler), "ApplyGrabRangeMultiplier", (Type[])null, (Type[])null)));
				Plugin.LogInfo("RayCheck 方法已增强");
				break;
			}
		}
		return list;
	}

	[HarmonyPatch(typeof(PhysGrabber), "Start")]
	[HarmonyPostfix]
	private static void StartPostfix(PhysGrabber __instance)
	{
		if ((Object)(object)__instance == (Object)null)
		{
			return;
		}
		try
		{
			Plugin.LogInfo("PhysGrabber Start 补丁执行");
			EnhanceGrabberInstance(__instance);
		}
		catch (Exception ex)
		{
			Plugin.LogError("增强 PhysGrabber 实例时出错: " + ex.Message);
		}
	}

	[HarmonyPatch(typeof(PhysGrabber), "Update")]
	[HarmonyPostfix]
	private static void UpdatePostfix(PhysGrabber __instance)
	{
		if ((Object)(object)__instance == (Object)null)
		{
			return;
		}
		try
		{
			if (Plugin.GrabStrengthMultiplier.Value > 1.01f || Plugin.ThrowStrengthMultiplier.Value > 1.01f || Plugin.GrabRangeMultiplier.Value > 1.01f)
			{
				EnhanceGrabberInstance(__instance);
			}
		}
		catch
		{
		}
	}

	private static void EnhanceGrabberInstance(PhysGrabber grabber)
	{
		try
		{
			Type type = ((object)grabber).GetType();
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				try
				{
					if (fieldInfo.FieldType == typeof(float))
					{
						float num = (float)fieldInfo.GetValue(grabber);
						float num2 = num;
						if (fieldInfo.Name.ToLower().Contains("grab") && fieldInfo.Name.ToLower().Contains("strength"))
						{
							num2 = num * Plugin.GrabStrengthMultiplier.Value;
							fieldInfo.SetValue(grabber, num2);
						}
						else if (fieldInfo.Name.ToLower().Contains("throw") && fieldInfo.Name.ToLower().Contains("strength"))
						{
							num2 = num * Plugin.ThrowStrengthMultiplier.Value;
							fieldInfo.SetValue(grabber, num2);
						}
						else if (fieldInfo.Name.ToLower().Contains("range") || fieldInfo.Name.ToLower().Contains("distance"))
						{
							num2 = num * Plugin.GrabRangeMultiplier.Value;
							fieldInfo.SetValue(grabber, Mathf.Min(num2, 50f));
						}
					}
				}
				catch
				{
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.LogError("增强抓取器实例时出错: " + ex.Message);
		}
	}

	public static float GetGrabStrengthMultiplier()
	{
		return Plugin.GrabStrengthMultiplier.Value;
	}

	public static float GetThrowStrengthMultiplier()
	{
		return Plugin.ThrowStrengthMultiplier.Value;
	}

	public static float GetGrabRangeMultiplier()
	{
		return Plugin.GrabRangeMultiplier.Value;
	}

	public static float ApplyGrabRangeMultiplier(float originalValue)
	{
		return originalValue * Plugin.GrabRangeMultiplier.Value;
	}

	private static void EnhanceGrabberFields()
	{
		try
		{
			PhysGrabber[] array = Object.FindObjectsOfType<PhysGrabber>();
			if (array == null || array.Length == 0)
			{
				return;
			}
			PhysGrabber[] array2 = array;
			foreach (PhysGrabber val in array2)
			{
				if ((Object)(object)val != (Object)null)
				{
					EnhanceGrabberInstance(val);
				}
			}
			Plugin.LogInfo($"增强了 {array.Length} 个 PhysGrabber 实例");
		}
		catch (Exception ex)
		{
			Plugin.LogError("动态增强抓取字段时出错: " + ex.Message);
		}
	}
}
[HarmonyPatch]
public class DirectGrabEnhancement
{
	[HarmonyPatch(typeof(PhysGrabObject), "FixedUpdate")]
	[HarmonyPostfix]
	private static void FixedUpdatePostfix(PhysGrabObject __instance)
	{
		if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.rb == (Object)null)
		{
			return;
		}
		try
		{
			if (__instance.playerGrabbing != null && __instance.playerGrabbing.Count > 0)
			{
				float value = Plugin.GrabStrengthMultiplier.Value;
				if (!(value > 1f))
				{
					return;
				}
				float num = 10f;
				try
				{
					Type type = ((object)__instance).GetType();
					FieldInfo field = type.GetField("massOriginal", BindingFlags.Instance | BindingFlags.NonPublic);
					if (field != null)
					{
						object value2 = field.GetValue(__instance);
						if (value2 != null)
						{
							num = (float)value2;
						}
					}
				}
				catch
				{
				}
				float num2 = num / value;
				num2 = Mathf.Max(num2, 0.1f);
				__instance.rb.mass = num2;
				__instance.rb.drag = Mathf.Max(__instance.rb.drag / value, 0.01f);
				__instance.rb.angularDrag = Mathf.Max(__instance.rb.angularDrag / value, 0.01f);
			}
			else
			{
				if (__instance.grabbed)
				{
					return;
				}
				try
				{
					Type type2 = ((object)__instance).GetType();
					FieldInfo field2 = type2.GetField("massOriginal", BindingFlags.Instance | BindingFlags.NonPublic);
					if (!(field2 != null))
					{
						return;
					}
					object value3 = field2.GetValue(__instance);
					if (value3 != null)
					{
						float num3 = (float)value3;
						if (num3 > 0f)
						{
							__instance.rb.mass = num3;
						}
					}
					return;
				}
				catch
				{
					return;
				}
			}
		}
		catch (Exception)
		{
		}
	}

	[HarmonyPatch(typeof(PhysGrabObject), "Throw")]
	[HarmonyPostfix]
	private static void ThrowPostfix(PhysGrabObject __instance, PhysGrabber player)
	{
		//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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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)
		if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.rb == (Object)null || (Object)(object)player == (Object)null)
		{
			return;
		}
		try
		{
			float value = Plugin.ThrowStrengthMultiplier.Value;
			if (value > 1f)
			{
				Vector3 velocity = __instance.rb.velocity;
				Vector3 velocity2 = velocity * value;
				float num = 50f * value;
				if (((Vector3)(ref velocity2)).magnitude > num)
				{
					velocity2 = ((Vector3)(ref velocity2)).normalized * num;
				}
				__instance.rb.velocity = velocity2;
				Plugin.LogInfo($"投掷速度增强: {((Vector3)(ref velocity)).magnitude:F2} -> {((Vector3)(ref velocity2)).magnitude:F2}");
			}
		}
		catch (Exception ex)
		{
			Plugin.LogWarning("投掷增强出错: " + ex.Message);
		}
	}
}
public static class GrabEnhancement
{
	public static void EnhanceGrab()
	{
		try
		{
			PhysGrabber[] array = Object.FindObjectsOfType<PhysGrabber>();
			if (array == null || array.Length == 0)
			{
				return;
			}
			PhysGrabber[] array2 = array;
			foreach (PhysGrabber val in array2)
			{
				if (!((Object)(object)val != (Object)null))
				{
					continue;
				}
				Type type = ((object)val).GetType();
				FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				FieldInfo[] array3 = fields;
				foreach (FieldInfo fieldInfo in array3)
				{
					try
					{
						if (fieldInfo.FieldType == typeof(float))
						{
							string text = fieldInfo.Name.ToLower();
							if (text.Contains("grab") && text.Contains("strength"))
							{
								float num = (float)fieldInfo.GetValue(val);
								float num2 = num * Plugin.GrabStrengthMultiplier.Value;
								fieldInfo.SetValue(val, num2);
							}
							else if (text.Contains("throw") && text.Contains("strength"))
							{
								float num3 = (float)fieldInfo.GetValue(val);
								float num4 = num3 * Plugin.ThrowStrengthMultiplier.Value;
								fieldInfo.SetValue(val, num4);
							}
							else if (text.Contains("grab") && text.Contains("range"))
							{
								float num5 = (float)fieldInfo.GetValue(val);
								float num6 = num5 * Plugin.GrabRangeMultiplier.Value;
								fieldInfo.SetValue(val, num6);
							}
						}
					}
					catch
					{
					}
				}
			}
			Plugin.LogInfo($"已增强 {array.Length} 个抓取器实例");
		}
		catch (Exception ex)
		{
			Plugin.LogError("增强抓取功能时出错: " + ex.Message);
		}
	}
}
[HarmonyPatch]
public class GrabTimerPatches
{
	private static float timer;

	[HarmonyPatch(typeof(PlayerController), "Update")]
	[HarmonyPostfix]
	private static void UpdatePostfix()
	{
		timer += Time.deltaTime;
		if (timer >= 5f)
		{
			timer = 0f;
			if (Plugin.GrabStrengthMultiplier.Value > 1.01f || Plugin.ThrowStrengthMultiplier.Value > 1.01f || Plugin.GrabRangeMultiplier.Value > 1.01f)
			{
				GrabEnhancement.EnhanceGrab();
			}
		}
	}
}
public static class GrabStrengthHelper
{
	public static void ApplyGrabStrengthInGame(PhysGrabber physGrabber)
	{
		if ((Object)(object)physGrabber == (Object)null)
		{
			return;
		}
		try
		{
			Type type = ((object)physGrabber).GetType();
			FieldInfo field = type.GetField("grabStrength", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field2 = type.GetField("throwStrength", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field3 = type.GetField("grabRange", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				float num = (float)field.GetValue(physGrabber);
				float num2 = Mathf.Max(num, 1f) * Plugin.GrabStrengthMultiplier.Value;
				field.SetValue(physGrabber, num2);
			}
			if (field2 != null)
			{
				float num3 = (float)field2.GetValue(physGrabber);
				float num4 = Mathf.Max(num3, 1f) * Plugin.ThrowStrengthMultiplier.Value;
				field2.SetValue(physGrabber, num4);
			}
			if (field3 != null)
			{
				float num5 = (float)field3.GetValue(physGrabber);
				float num6 = Mathf.Max(num5, 4f) * Plugin.GrabRangeMultiplier.Value;
				field3.SetValue(physGrabber, num6);
			}
		}
		catch (Exception ex)
		{
			Plugin.LogError("应用抓取力量帮助方法时出错: " + ex.Message);
		}
	}
}