forked from LeCloutPanda/DeafultLaserState
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatch.cs
42 lines (36 loc) · 1.38 KB
/
Patch.cs
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
using FrooxEngine;
using HarmonyLib;
using ResoniteModLoader;
namespace Default_Laser_State
{
public class Patch : ResoniteMod
{
public override string Author => "LeCloutPanda";
public override string Name => "Default Laser State";
public override string Version => "1.0.1";
public override string Link => "https://github.com/LeCloutPanda/DeafultLaserState/";
public static ModConfiguration config;
[AutoRegisterConfigKey] public static ModConfigurationKey<bool> ENABLED = new ModConfigurationKey<bool>("Default state", "What state will the lasers have", () => true);
public override void OnEngineInit()
{
config = GetConfiguration();
config.Save(true);
Harmony harmony = new Harmony("dev.lecloutpanda.defaultlaserstate");
harmony.PatchAll();
}
[HarmonyPatch(typeof(InteractionHandler), "OnAwake")]
class CommonToolPatch
{
[HarmonyPostfix]
static void Postfix(InteractionHandler __instance, Sync<bool> ____laserEnabled)
{
__instance.RunInUpdates(3, () =>
{
if (__instance.Slot.ActiveUser != __instance.LocalUser)
return;
____laserEnabled.Value = config.GetValue(ENABLED);
});
}
}
}
}