-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlugin.cs
More file actions
47 lines (42 loc) · 1.9 KB
/
Plugin.cs
File metadata and controls
47 lines (42 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using BepInEx;
using EFT.InventoryLogic;
using HarmonyLib;
using System.Reflection;
using SPT.Reflection.Patching;
namespace FastClear
{
// BepInPlugin attribute signifies this is a BepInEx plugin.
// The GUID should be unique to your mod.
[BepInPlugin("com.SkebbZ.FastClear", "FastClear", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
// The Awake() method is the entry point for BepInEx plugins.
private void Awake()
{
// Create a new instance of our patch class and apply it.
new KnowMalfPatch().Enable();
// Log a message to the BepInEx console to confirm the mod is loaded.
Logger.LogInfo("Plugin: Inspectionless Malfunctions is loaded and active!");
}
}
// This is your original patch class, now named with a "Patch" suffix for clarity.
// It inherits from ModulePatch, which is the SPT-standard way to handle Harmony patches.
public class KnowMalfPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
// The target method remains the same in the new version of the game.
// We get the type for the weapon's malfunction state and find the method named "IsKnownMalfType".
Type malfStateType = typeof(Weapon.WeaponMalfunctionStateClass);
return AccessTools.Method(malfStateType, nameof(Weapon.WeaponMalfunctionStateClass.IsKnownMalfType));
}
// A Postfix patch runs after the original method is complete.
[PatchPostfix]
private static void PatchPostfix(ref bool __result)
{
// __result is a special Harmony parameter that holds the return value of the original method.
// We are forcing the result to always be 'true', making the game think you always know the malf type.
__result = true;
}
}
}