-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDefaultVoiceMode.cs
39 lines (33 loc) · 1.43 KB
/
DefaultVoiceMode.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
using FrooxEngine;
using HarmonyLib;
using ResoniteModLoader;
namespace DefaultVoiceMode
{
public class DefaultVoiceMode : ResoniteMod
{
public override string Name => "DefaultVoiceMode";
public override string Author => "Psychpsyo";
public override string Version => "2.0.0";
public override string Link => "https://github.com/Psychpsyo/DefaultVoiceMode";
public static bool setInitialVoiceMode = false;
[AutoRegisterConfigKey]
public static ModConfigurationKey<VoiceMode> defaultVoiceMode = new ModConfigurationKey<VoiceMode>("Default Voice Mode", "What to set your voice mode to on startup.", () => VoiceMode.Normal);
private static ModConfiguration config;
public override void OnEngineInit() {
config = GetConfiguration();
Harmony harmony = new Harmony("Psychpsyo.DefaultVoiceMode");
harmony.PatchAll();
}
[HarmonyPatch(typeof(VoiceModeSync), "OnCommonUpdate")]
class SetDefaultVoiceModeOnStartup
{
static void Postfix(VoiceModeSync __instance) {
if (!setInitialVoiceMode) {
__instance.FocusedWorldVoiceMode.Value = config.GetValue(defaultVoiceMode);
__instance.GlobalMute.Value = config.GetValue(defaultVoiceMode) == VoiceMode.Mute;
setInitialVoiceMode = true;
}
}
}
}
}