diff --git a/ChatBoxExtensions/ChatBoxExtensions.csproj b/ChatBoxExtensions/ChatBoxExtensions.csproj
index 66a50a8..42cb84e 100644
--- a/ChatBoxExtensions/ChatBoxExtensions.csproj
+++ b/ChatBoxExtensions/ChatBoxExtensions.csproj
@@ -1,2 +1,12 @@
-
+
+
+
+
+
+ $(MsBuildThisFileDirectory)\..\_ManagedLibs\ml_prm.dll
+ False
+
+
+
+
diff --git a/ChatBoxExtensions/Integrations/ChatBox.cs b/ChatBoxExtensions/Integrations/ChatBox.cs
index 1f1824b..23ae95c 100644
--- a/ChatBoxExtensions/Integrations/ChatBox.cs
+++ b/ChatBoxExtensions/Integrations/ChatBox.cs
@@ -10,22 +10,22 @@ internal class ChatBoxCommands : CommandBase
DateTime pingTime = DateTime.MinValue; // store the time when "ping" command was sent
Commands.RegisterCommand("ping",
- onCommandSent: (message, sound) =>
+ onCommandSent: (message, sound, displayMsg) =>
{
pingTime = DateTime.Now;
awaitingPing = true;
},
- onCommandReceived: (sender, message, sound) =>
+ onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForSelf(message, args =>
{
- ChatBox.SendMessage("/pong " + GetPlayerUsername(sender), false);
+ API.SendMessage("/pong " + GetPlayerUsername(sender), false, true);
});
});
Commands.RegisterCommand("pong",
onCommandSent: null,
- onCommandReceived: (sender, message, sound) =>
+ onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForSelf(message, args =>
{
@@ -33,11 +33,11 @@ internal class ChatBoxCommands : CommandBase
{
awaitingPing = false;
TimeSpan timeSincePing = DateTime.Now - pingTime; // calculate the time difference
- ChatBox.SendMessage($"Time since ping: {timeSincePing.TotalMilliseconds}ms", false);
+ API.SendMessage($"Time since ping: {timeSincePing.TotalMilliseconds}ms", false, true);
return;
}
- ChatBox.SendMessage($"You have to ping first, {GetPlayerUsername(sender)}!", false);
+ API.SendMessage($"You have to ping first, {GetPlayerUsername(sender)}!", false, true);
});
});
}
-}
\ No newline at end of file
+}
diff --git a/ChatBoxExtensions/Integrations/ChilloutVRBase.cs b/ChatBoxExtensions/Integrations/ChilloutVRBase.cs
index ae05883..c9d7b2f 100644
--- a/ChatBoxExtensions/Integrations/ChilloutVRBase.cs
+++ b/ChatBoxExtensions/Integrations/ChilloutVRBase.cs
@@ -9,14 +9,14 @@ internal class ChilloutVRBaseCommands : CommandBase
public static void RegisterCommands()
{
Commands.RegisterCommand("respawn",
- onCommandSent: (message, sound) =>
+ onCommandSent: (message, sound, displayMsg) =>
{
LocalCommandIgnoreOthers(message, args =>
{
RootLogic.Instance.Respawn();
});
},
- onCommandReceived: (sender, message, sound) =>
+ onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForAll(message, (args) =>
{
@@ -25,14 +25,14 @@ internal class ChilloutVRBaseCommands : CommandBase
});
Commands.RegisterCommand("mute",
- onCommandSent: (message, sound) =>
+ onCommandSent: (message, sound, displayMsg) =>
{
LocalCommandIgnoreOthers(message, args =>
{
Audio.SetMicrophoneActive(true);
});
},
- onCommandReceived: (sender, message, sound) =>
+ onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForAll(message, args =>
{
@@ -40,4 +40,4 @@ internal class ChilloutVRBaseCommands : CommandBase
});
});
}
-}
\ No newline at end of file
+}
diff --git a/ChatBoxExtensions/Integrations/ChilloutVRInput.cs b/ChatBoxExtensions/Integrations/ChilloutVRInput.cs
index 8e8a1b4..155ed66 100644
--- a/ChatBoxExtensions/Integrations/ChilloutVRInput.cs
+++ b/ChatBoxExtensions/Integrations/ChilloutVRInput.cs
@@ -1,16 +1,11 @@
-using ABI_RC.Core;
-using ABI_RC.Core.Base;
-using ABI_RC.Core.Savior;
-using Kafe.ChatBox;
-
-namespace NAK.Melons.ChatBoxExtensions.Integrations;
+namespace NAK.Melons.ChatBoxExtensions.Integrations;
internal class ChilloutVRInputCommands : CommandBase
{
public static void RegisterCommands()
{
Commands.RegisterCommand("emote",
- onCommandSent: (message, sound) =>
+ onCommandSent: (message, sound, displayMsg) =>
{
LocalCommandIgnoreOthers(message, args =>
{
@@ -20,7 +15,7 @@ internal class ChilloutVRInputCommands : CommandBase
}
});
},
- onCommandReceived: (sender, message, sound) =>
+ onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForAll(message, args =>
{
@@ -32,7 +27,7 @@ internal class ChilloutVRInputCommands : CommandBase
});
Commands.RegisterCommand("jump",
- onCommandSent: (message, sound) =>
+ onCommandSent: (message, sound, displayMsg) =>
{
LocalCommandIgnoreOthers(message, args =>
{
@@ -44,7 +39,7 @@ internal class ChilloutVRInputCommands : CommandBase
ChatBoxExtensions.InputModule.jump = true;
});
},
- onCommandReceived: (sender, message, sound) =>
+ onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForAll(message, args =>
{
@@ -55,4 +50,4 @@ internal class ChilloutVRInputCommands : CommandBase
});
});
}
-}
\ No newline at end of file
+}
diff --git a/ChatBoxExtensions/Integrations/Commands.cs b/ChatBoxExtensions/Integrations/Commands.cs
new file mode 100644
index 0000000..0309cf7
--- /dev/null
+++ b/ChatBoxExtensions/Integrations/Commands.cs
@@ -0,0 +1,46 @@
+namespace NAK.Melons.ChatBoxExtensions.Integrations;
+
+public static class Commands {
+
+ private const string Character = "/";
+ private static readonly List CommandList = new();
+
+ internal static void InitializeCommandHandlers() {
+ Kafe.ChatBox.API.OnMessageSent += (source, msg, notification, displayMsg) => HandleSentCommand(msg, notification, displayMsg);
+ Kafe.ChatBox.API.OnMessageReceived += (source, sender, msg, notification, displayMsg) => HandleReceivedCommand(sender, msg, notification, displayMsg);
+ }
+
+ internal static void RegisterCommand(string prefix, Action onCommandSent = null, Action onCommandReceived = null) {
+ var cmd = new Command { Prefix = prefix, OnCommandSent = onCommandSent, OnCommandReceived = onCommandReceived };
+ CommandList.Add(cmd);
+ }
+
+ internal static void UnregisterCommand(string prefix) {
+ CommandList.RemoveAll(cmd => cmd.Prefix == prefix);
+ }
+
+ private class Command {
+
+ internal string Prefix;
+
+ // Command Sent (message)
+ internal Action OnCommandSent;
+
+ // Command Sent (sender guid, message)
+ internal Action OnCommandReceived;
+ }
+
+ private static void HandleSentCommand(string message, bool notification, bool displayMsg) {
+ if (!message.StartsWith(Character)) return;
+ foreach (var command in CommandList.Where(command => message.StartsWith(Character + command.Prefix))) {
+ command.OnCommandSent?.Invoke(message, notification, displayMsg);
+ }
+ }
+
+ private static void HandleReceivedCommand(string sender, string message, bool notification, bool displayMsg) {
+ if (!message.StartsWith(Character)) return;
+ foreach (var command in CommandList.Where(command => message.StartsWith(Character + command.Prefix))) {
+ command.OnCommandReceived?.Invoke(sender, message, notification, displayMsg);
+ }
+ }
+}
diff --git a/ChatBoxExtensions/Integrations/PlayerRagdollMod.cs b/ChatBoxExtensions/Integrations/PlayerRagdollMod.cs
index 775d39d..46d0968 100644
--- a/ChatBoxExtensions/Integrations/PlayerRagdollMod.cs
+++ b/ChatBoxExtensions/Integrations/PlayerRagdollMod.cs
@@ -1,5 +1,4 @@
-using Kafe.ChatBox;
-using ml_prm;
+using ml_prm;
namespace NAK.Melons.ChatBoxExtensions.Integrations;
@@ -8,7 +7,7 @@ internal class PlayerRagdollModCommands : CommandBase
public static void RegisterCommands()
{
Commands.RegisterCommand("unragdoll",
- onCommandSent: (message, sound) =>
+ onCommandSent: (message, sound, displayMsg) =>
{
LocalCommandIgnoreOthers(message, (args) =>
{
@@ -18,7 +17,7 @@ internal class PlayerRagdollModCommands : CommandBase
}
});
},
- onCommandReceived: (sender, message, sound) =>
+ onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForAll(message, (args) =>
{
@@ -30,7 +29,7 @@ internal class PlayerRagdollModCommands : CommandBase
});
Commands.RegisterCommand("ragdoll",
- onCommandSent: (message, sound) =>
+ onCommandSent: (message, sound, displayMsg) =>
{
LocalCommandIgnoreOthers(message, (args) =>
{
@@ -47,7 +46,7 @@ internal class PlayerRagdollModCommands : CommandBase
}
});
},
- onCommandReceived: (sender, message, sound) =>
+ onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForAll(message, (args) =>
{
@@ -66,7 +65,7 @@ internal class PlayerRagdollModCommands : CommandBase
});
Commands.RegisterCommand("kill",
- onCommandSent: (message, sound) =>
+ onCommandSent: (message, sound, displayMsg) =>
{
LocalCommandIgnoreOthers(message, (args) =>
{
@@ -76,7 +75,7 @@ internal class PlayerRagdollModCommands : CommandBase
}
});
},
- onCommandReceived: (sender, message, sound) =>
+ onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForAll(message, (args) =>
{
diff --git a/ChatBoxExtensions/Main.cs b/ChatBoxExtensions/Main.cs
index 86e2064..8929e57 100644
--- a/ChatBoxExtensions/Main.cs
+++ b/ChatBoxExtensions/Main.cs
@@ -23,6 +23,7 @@ public class ChatBoxExtensions : MelonMod
void ApplyIntegrations()
{
+ Integrations.Commands.InitializeCommandHandlers();
Integrations.ChatBoxCommands.RegisterCommands();
Integrations.ChilloutVRBaseCommands.RegisterCommands();
ApplyPatches(typeof(HarmonyPatches.CVRInputManagerPatches));
@@ -45,4 +46,4 @@ public class ChatBoxExtensions : MelonMod
Logger.Error(e);
}
}
-}
\ No newline at end of file
+}
diff --git a/ChatBoxExtensions/Properties/AssemblyInfo.cs b/ChatBoxExtensions/Properties/AssemblyInfo.cs
index 1b5d805..f9477ce 100644
--- a/ChatBoxExtensions/Properties/AssemblyInfo.cs
+++ b/ChatBoxExtensions/Properties/AssemblyInfo.cs
@@ -21,12 +21,13 @@ using System.Reflection;
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
-[assembly: MelonOptionalDependencies("ChatBox", "PlayerRagdollMod")]
+[assembly: MelonAdditionalDependencies("ChatBox")]
+[assembly: MelonOptionalDependencies("PlayerRagdollMod")]
[assembly: HarmonyDontPatchAll]
namespace ChatBoxExtensions.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "1.0.0";
+ public const string Version = "1.0.1";
public const string Author = "NotAKidoS";
-}
\ No newline at end of file
+}
diff --git a/Directory.Build.props b/Directory.Build.props
index 515568b..4b195ad 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -43,10 +43,6 @@
$(MsBuildThisFileDirectory)\_ManagedLibs\ChatBox.dll
False
-
- $(MsBuildThisFileDirectory)\_ManagedLibs\ml_prm.dll
- False
-