mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
push broken mod
This commit is contained in:
parent
742f816d3d
commit
344e3bb6d6
12 changed files with 500 additions and 0 deletions
56
ChatBoxExtensions/Integrations/Base.cs
Normal file
56
ChatBoxExtensions/Integrations/Base.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
|
||||
namespace NAK.Melons.ChatBoxExtensions.Integrations;
|
||||
|
||||
public class CommandBase
|
||||
{
|
||||
internal static bool IsCommandForAll(string argument)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(argument)) return false;
|
||||
return argument == "*" || argument.StartsWith("@a") || argument.StartsWith("@e");
|
||||
}
|
||||
|
||||
internal static bool IsCommandForLocalPlayer(string argument)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(argument)) return false;
|
||||
if (argument.Contains("*"))
|
||||
{
|
||||
string partialName = argument.Replace("*", "").Trim();
|
||||
if (String.IsNullOrWhiteSpace(partialName)) return false;
|
||||
return MetaPort.Instance.username.Contains(partialName);
|
||||
}
|
||||
return MetaPort.Instance.username == argument;
|
||||
}
|
||||
|
||||
internal static void LocalCommandIgnoreOthers(string argument, Action<string[]> callback)
|
||||
{
|
||||
string[] args = argument.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray();
|
||||
|
||||
// will fail if arguments are specified which arent local player
|
||||
if (args.Length == 0 || IsCommandForAll(args[0]) || IsCommandForLocalPlayer(args[0])) callback(args);
|
||||
}
|
||||
|
||||
//remote must specify exact player, wont respawn to all
|
||||
internal static void RemoteCommandListenForSelf(string argument, Action<string[]> callback)
|
||||
{
|
||||
string[] args = argument.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray();
|
||||
|
||||
if (args.Length == 0) return;
|
||||
if (IsCommandForLocalPlayer(args[0])) callback(args);
|
||||
}
|
||||
|
||||
// remote must specify player or all, ignore commands without arguments
|
||||
internal static void RemoteCommandListenForAll(string argument, Action<string[]> callback)
|
||||
{
|
||||
string[] args = argument.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray();
|
||||
|
||||
if (args.Length == 0) return;
|
||||
if (IsCommandForAll(args[0]) || IsCommandForLocalPlayer(args[0])) callback(args);
|
||||
}
|
||||
|
||||
internal static string GetPlayerUsername(string guid)
|
||||
{
|
||||
return CVRPlayerManager.Instance.TryGetPlayerName(guid);
|
||||
}
|
||||
}
|
43
ChatBoxExtensions/Integrations/ChatBox.cs
Normal file
43
ChatBoxExtensions/Integrations/ChatBox.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using Kafe.ChatBox;
|
||||
|
||||
namespace NAK.Melons.ChatBoxExtensions.Integrations;
|
||||
|
||||
internal class ChatBoxCommands : CommandBase
|
||||
{
|
||||
public static void RegisterCommands()
|
||||
{
|
||||
bool awaitingPing = false;
|
||||
DateTime pingTime = DateTime.MinValue; // store the time when "ping" command was sent
|
||||
|
||||
Commands.RegisterCommand("ping",
|
||||
onCommandSent: (message, sound) =>
|
||||
{
|
||||
pingTime = DateTime.Now;
|
||||
awaitingPing = true;
|
||||
},
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForSelf(message, args =>
|
||||
{
|
||||
ChatBox.SendMessage("/pong " + GetPlayerUsername(sender), false);
|
||||
});
|
||||
});
|
||||
|
||||
Commands.RegisterCommand("pong",
|
||||
onCommandSent: null,
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForSelf(message, args =>
|
||||
{
|
||||
if (awaitingPing)
|
||||
{
|
||||
awaitingPing = false;
|
||||
TimeSpan timeSincePing = DateTime.Now - pingTime; // calculate the time difference
|
||||
ChatBox.SendMessage($"Time since ping: {timeSincePing.TotalMilliseconds}ms", false);
|
||||
return;
|
||||
}
|
||||
ChatBox.SendMessage($"You have to ping first, {GetPlayerUsername(sender)}!", false);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
43
ChatBoxExtensions/Integrations/ChilloutVRBase.cs
Normal file
43
ChatBoxExtensions/Integrations/ChilloutVRBase.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using ABI_RC.Core;
|
||||
using ABI_RC.Core.Base;
|
||||
using Kafe.ChatBox;
|
||||
|
||||
namespace NAK.Melons.ChatBoxExtensions.Integrations;
|
||||
|
||||
internal class ChilloutVRBaseCommands : CommandBase
|
||||
{
|
||||
public static void RegisterCommands()
|
||||
{
|
||||
Commands.RegisterCommand("respawn",
|
||||
onCommandSent: (message, sound) =>
|
||||
{
|
||||
LocalCommandIgnoreOthers(message, args =>
|
||||
{
|
||||
RootLogic.Instance.Respawn();
|
||||
});
|
||||
},
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForAll(message, (args) =>
|
||||
{
|
||||
RootLogic.Instance.Respawn();
|
||||
});
|
||||
});
|
||||
|
||||
Commands.RegisterCommand("mute",
|
||||
onCommandSent: (message, sound) =>
|
||||
{
|
||||
LocalCommandIgnoreOthers(message, args =>
|
||||
{
|
||||
Audio.SetMicrophoneActive(true);
|
||||
});
|
||||
},
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForAll(message, args =>
|
||||
{
|
||||
Audio.SetMicrophoneActive(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
58
ChatBoxExtensions/Integrations/ChilloutVRInput.cs
Normal file
58
ChatBoxExtensions/Integrations/ChilloutVRInput.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using ABI_RC.Core;
|
||||
using ABI_RC.Core.Base;
|
||||
using ABI_RC.Core.Savior;
|
||||
using Kafe.ChatBox;
|
||||
|
||||
namespace NAK.Melons.ChatBoxExtensions.Integrations;
|
||||
|
||||
internal class ChilloutVRInputCommands : CommandBase
|
||||
{
|
||||
public static void RegisterCommands()
|
||||
{
|
||||
Commands.RegisterCommand("emote",
|
||||
onCommandSent: (message, sound) =>
|
||||
{
|
||||
LocalCommandIgnoreOthers(message, args =>
|
||||
{
|
||||
if (args.Length > 0 && int.TryParse(args[0], out int emote))
|
||||
{
|
||||
ChatBoxExtensions.InputModule.emote = (float)emote;
|
||||
}
|
||||
});
|
||||
},
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForAll(message, args =>
|
||||
{
|
||||
if (args.Length > 1 && int.TryParse(args[1], out int emote))
|
||||
{
|
||||
ChatBoxExtensions.InputModule.emote = (float)emote;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Commands.RegisterCommand("jump",
|
||||
onCommandSent: (message, sound) =>
|
||||
{
|
||||
LocalCommandIgnoreOthers(message, args =>
|
||||
{
|
||||
if (args.Length > 0 && bool.TryParse(args[0], out bool jump))
|
||||
{
|
||||
ChatBoxExtensions.InputModule.jump = jump;
|
||||
return;
|
||||
}
|
||||
ChatBoxExtensions.InputModule.jump = true;
|
||||
});
|
||||
},
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForAll(message, args =>
|
||||
{
|
||||
if (bool.TryParse(args[0], out bool jump))
|
||||
{
|
||||
ChatBoxExtensions.InputModule.jump = jump;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
90
ChatBoxExtensions/Integrations/PlayerRagdollMod.cs
Normal file
90
ChatBoxExtensions/Integrations/PlayerRagdollMod.cs
Normal file
|
@ -0,0 +1,90 @@
|
|||
using Kafe.ChatBox;
|
||||
using ml_prm;
|
||||
|
||||
namespace NAK.Melons.ChatBoxExtensions.Integrations;
|
||||
|
||||
internal class PlayerRagdollModCommands : CommandBase
|
||||
{
|
||||
public static void RegisterCommands()
|
||||
{
|
||||
Commands.RegisterCommand("unragdoll",
|
||||
onCommandSent: (message, sound) =>
|
||||
{
|
||||
LocalCommandIgnoreOthers(message, (args) =>
|
||||
{
|
||||
if (RagdollController.Instance.IsRagdolled())
|
||||
{
|
||||
RagdollController.Instance.SwitchRagdoll();
|
||||
}
|
||||
});
|
||||
},
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForAll(message, (args) =>
|
||||
{
|
||||
if (RagdollController.Instance.IsRagdolled())
|
||||
{
|
||||
RagdollController.Instance.SwitchRagdoll();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Commands.RegisterCommand("ragdoll",
|
||||
onCommandSent: (message, sound) =>
|
||||
{
|
||||
LocalCommandIgnoreOthers(message, (args) =>
|
||||
{
|
||||
bool switchRagdoll = true;
|
||||
|
||||
if (args.Length > 0 && bool.TryParse(args[0], out bool state))
|
||||
{
|
||||
switchRagdoll = state != RagdollController.Instance.IsRagdolled();
|
||||
}
|
||||
|
||||
if (switchRagdoll)
|
||||
{
|
||||
RagdollController.Instance.SwitchRagdoll();
|
||||
}
|
||||
});
|
||||
},
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForAll(message, (args) =>
|
||||
{
|
||||
bool switchRagdoll = true;
|
||||
|
||||
if (args.Length > 1 && bool.TryParse(args[1], out bool state))
|
||||
{
|
||||
switchRagdoll = state != RagdollController.Instance.IsRagdolled();
|
||||
}
|
||||
|
||||
if (switchRagdoll)
|
||||
{
|
||||
RagdollController.Instance.SwitchRagdoll();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Commands.RegisterCommand("kill",
|
||||
onCommandSent: (message, sound) =>
|
||||
{
|
||||
LocalCommandIgnoreOthers(message, (args) =>
|
||||
{
|
||||
if (!RagdollController.Instance.IsRagdolled())
|
||||
{
|
||||
RagdollController.Instance.SwitchRagdoll();
|
||||
}
|
||||
});
|
||||
},
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForAll(message, (args) =>
|
||||
{
|
||||
if (!RagdollController.Instance.IsRagdolled())
|
||||
{
|
||||
RagdollController.Instance.SwitchRagdoll();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue