cruelman/CruelMan/CruelManLoader.cs
2024-01-20 13:52:41 +01:00

39 lines
1.1 KiB
C#

using BepInEx;
using CruelMan.Modules;
using CruelMan.Utils;
using HarmonyLib;
namespace CruelMan {
[BepInPlugin("top.davidon.valheim.cruelman", "CruelMan", "1.0.0")]
public class CMLoader : BaseUnityPlugin {
public readonly Harmony harmony = new Harmony("top.davidon.valheim.cruelman");
public void Awake() {
Log.Info("Awake CruelMan");
harmony.PatchAll();
UnityEngine.Object.DontDestroyOnLoad(this);
CM.Init(this);
}
[HarmonyPatch(typeof(Player), "OnDeath")]
class DeathPatch {
static bool Prefix() {
return !ModuleManager.instance.GetModule<NoDeath>().Enabled;
}
}
[HarmonyPatch(typeof(Player), nameof(Player.InAttack))]
class AttackPathh {
static bool Prefix() {
return !ModuleManager.instance.GetModule<NotInAttack>().Enabled;
}
static void Postfix(ref bool __result) {
if (ModuleManager.instance.GetModule<NotInAttack>().Enabled) {
__result = false;
}
}
}
}
}