-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShutTheFuckUp.cs
47 lines (40 loc) · 1.88 KB
/
ShutTheFuckUp.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
43
44
45
46
47
using FrooxEngine;
using HarmonyLib;
using NeosModLoader;
namespace ShutTheFuckUp {
public class ShutTheFuckUp : NeosMod {
public override string Name => "ShutTheFuckUp";
public override string Author => "Psychpsyo";
public override string Version => "1.0.0";
public override string Link => "https://github.com/Psychpsyo/ShutTheFuckUp";
[AutoRegisterConfigKey]
public static ModConfigurationKey<bool> modActive = new ModConfigurationKey<bool>("Active", "You can enable or disable the mod here.", () => true);
private static ModConfiguration config;
public override void OnEngineInit() {
config = GetConfiguration();
Harmony harmony = new Harmony("Psychpsyo.ShutTheFuckUp");
harmony.PatchAll();
}
[HarmonyPatch(typeof(AudioOutput), "IsUserExluded")]
class AudioClipSilencer {
static bool Prefix(AudioOutput __instance, ref bool __result, User user) {
// do basic checks first:
if (config.GetValue(modActive) &&
user == __instance.World.LocalUser) {
// now check if we're under a context menu (a slot virtual parented to "Radial Menu")
Slot checkSlot = __instance.Slot;
for (int i = 0; i < 6 && checkSlot != null; i++) {
VirtualParent suspect = checkSlot.GetComponent<VirtualParent>();
if (suspect != null && suspect?.OverrideParent?.RawTarget.Name == "Radial Menu") {
__result = true;
return false;
}
checkSlot = checkSlot.Parent;
}
}
// we're not under a context menu so don't skip the function
return true;
}
}
}
}