Decompiled source of Hunter Damage Halver v2.0.0

RepoFirstMod.dll

Decompiled a day ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: AssemblyProduct("RepoFirstMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RepoFirstMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0f4ffe05-9a3f-4605-9876-fe6a1584ccad")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RepoFirstMod;

[BepInPlugin("com.lhd.hunterdamage", "猎人给我滚啊", "2.0.0")]
public class Plugin : BaseUnityPlugin
{
	public static ConfigEntry<bool> ModEnabled;

	public static ConfigEntry<int> HunterDamage;

	public static ManualLogSource ModLogger;

	private void Awake()
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Expected O, but got Unknown
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Expected O, but got Unknown
		ModLogger = ((BaseUnityPlugin)this).Logger;
		ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Mod", true, "是否启用猎人伤害修改。勾选后生效,取消后恢复原版伤害。");
		HunterDamage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Hunter Damage", 50, new ConfigDescription("猎人对玩家造成的伤害值", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), new object[0]));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"=== 猎人给我滚啊!Mod v2.0 已加载 ===");
		((BaseUnityPlugin)this).Logger.LogInfo((object)("默认伤害: " + HunterDamage.Value + " | 启用状态: " + ModEnabled.Value));
		Harmony val = new Harmony("com.lhd.hunterdamage");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony Patch 注入完成。按 F1 打开 REPOConfig 进行配置。");
	}
}
[HarmonyPatch(typeof(EnemyHunter), "Awake")]
public static class HunterDamagePatch
{
	[HarmonyPostfix]
	public static void Postfix(EnemyHunter __instance)
	{
		if (!Plugin.ModEnabled.Value || (Object)(object)__instance == (Object)null)
		{
			return;
		}
		HurtCollider hurtCollider = __instance.hurtCollider;
		if (!((Object)(object)hurtCollider == (Object)null))
		{
			int value = Plugin.HunterDamage.Value;
			int playerDamage = hurtCollider.playerDamage;
			if (playerDamage != value)
			{
				hurtCollider.playerDamage = value;
				Plugin.ModLogger.LogInfo((object)("[猎人给我滚啊] 伤害已修改: " + playerDamage + " -> " + value));
			}
		}
	}
}