From 8d4f17b8d12397851196a175564df6dbfddd0ba3 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Tue, 27 Jun 2023 17:38:20 -0500 Subject: [PATCH] [ChatBoxExtensions] Add AAS commands. --- ChatBoxExtensions/HarmonyPatches.cs | 2 +- .../Integrations/ChilloutVRAAS.cs | 32 +++++++++++++++++++ ChatBoxExtensions/Main.cs | 9 ++++-- ChatBoxExtensions/Properties/AssemblyInfo.cs | 2 +- 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 ChatBoxExtensions/Integrations/ChilloutVRAAS.cs diff --git a/ChatBoxExtensions/HarmonyPatches.cs b/ChatBoxExtensions/HarmonyPatches.cs index bf2dcd9..4f12e59 100644 --- a/ChatBoxExtensions/HarmonyPatches.cs +++ b/ChatBoxExtensions/HarmonyPatches.cs @@ -6,7 +6,7 @@ namespace NAK.ChatBoxExtensions.HarmonyPatches; public class CVRInputManagerPatches { [HarmonyPostfix] - [HarmonyPatch(typeof(CVRInputManager), "Start")] + [HarmonyPatch(typeof(CVRInputManager), nameof(CVRInputManager.Start))] static void Postfix_CVRInputManager_Start(ref CVRInputManager __instance) { ChatBoxExtensions.InputModule = __instance.gameObject.AddComponent(); diff --git a/ChatBoxExtensions/Integrations/ChilloutVRAAS.cs b/ChatBoxExtensions/Integrations/ChilloutVRAAS.cs new file mode 100644 index 0000000..5a94a4f --- /dev/null +++ b/ChatBoxExtensions/Integrations/ChilloutVRAAS.cs @@ -0,0 +1,32 @@ +using ABI_RC.Core.Player; + +namespace NAK.ChatBoxExtensions.Integrations; + +internal class ChilloutVRAASCommands : CommandBase +{ + public static void RegisterCommands() + { + // /aas [target player] [name] [value] + Commands.RegisterCommand("aas", + onCommandSent: (message, sound, displayMsg) => + { + LocalCommandIgnoreOthers(message, args => + { + if (args.Length > 2 && float.TryParse(args[2], out float value)) + { + PlayerSetup.Instance.changeAnimatorParam(args[1], value); + } + }); + }, + onCommandReceived: (sender, message, sound, displayMsg) => + { + RemoteCommandListenForAll(message, args => + { + if (args.Length > 2 && float.TryParse(args[2], out float value)) + { + PlayerSetup.Instance.changeAnimatorParam(args[1], value); + } + }); + }); + } +} \ No newline at end of file diff --git a/ChatBoxExtensions/Main.cs b/ChatBoxExtensions/Main.cs index 1d9e7ec..370eaed 100644 --- a/ChatBoxExtensions/Main.cs +++ b/ChatBoxExtensions/Main.cs @@ -12,7 +12,7 @@ public class ChatBoxExtensions : MelonMod { Logger = LoggerInstance; - if (!MelonMod.RegisteredMelons.Any(it => it.Info.Name == "ChatBox")) + if (RegisteredMelons.All(it => it.Info.Name != "ChatBox")) { Logger.Error("ChatBox was not found!"); return; @@ -23,12 +23,17 @@ public class ChatBoxExtensions : MelonMod void ApplyIntegrations() { + Integrations.Commands.InitializeCommandHandlers(); Integrations.ChatBoxCommands.RegisterCommands(); + Integrations.ChilloutVRBaseCommands.RegisterCommands(); + Integrations.ChilloutVRAASCommands.RegisterCommands(); + Integrations.ChilloutVRInputCommands.RegisterCommands(); + ApplyPatches(typeof(HarmonyPatches.CVRInputManagerPatches)); - if (MelonMod.RegisteredMelons.Any(it => it.Info.Name == "PlayerRagdollMod")) + if (RegisteredMelons.Any(it => it.Info.Name == "PlayerRagdollMod")) { Integrations.PlayerRagdollModCommands.RegisterCommands(); } diff --git a/ChatBoxExtensions/Properties/AssemblyInfo.cs b/ChatBoxExtensions/Properties/AssemblyInfo.cs index 0d38c69..bf1093f 100644 --- a/ChatBoxExtensions/Properties/AssemblyInfo.cs +++ b/ChatBoxExtensions/Properties/AssemblyInfo.cs @@ -28,6 +28,6 @@ using System.Reflection; namespace ChatBoxExtensions.Properties; internal static class AssemblyInfoParams { - public const string Version = "1.0.1"; + public const string Version = "1.0.2"; public const string Author = "NotAKidoS"; }