2025-11-23 20:23:53 +01:00
|
|
|
using HarmonyLib;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System;
|
2025-11-23 19:39:06 +00:00
|
|
|
using System.Collections.Generic;
|
2025-11-23 20:23:53 +01:00
|
|
|
|
|
|
|
|
public class CHRANIBotTNG : IModApi
|
|
|
|
|
{
|
|
|
|
|
public void InitMod(Mod _modInstance)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("[CHRANIBotTNG] Loading");
|
2025-11-23 19:39:06 +00:00
|
|
|
var harmony = new Harmony("com.chranibottng.mod");
|
|
|
|
|
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
|
|
|
|
Console.WriteLine("[CHRANIBotTNG] Loaded");
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-23 20:23:53 +01:00
|
|
|
|
2025-11-23 19:39:06 +00:00
|
|
|
[HarmonyPatch(typeof(GameManager), "ChatMessageServer")]
|
|
|
|
|
public class ChatMessagePatch
|
|
|
|
|
{
|
2025-11-23 19:54:53 +00:00
|
|
|
static void Prefix(string _msg, ref List<int> _recipientEntityIds)
|
2025-11-23 19:39:06 +00:00
|
|
|
{
|
|
|
|
|
if (_msg != null && _msg.StartsWith("/bot "))
|
2025-11-23 20:23:53 +01:00
|
|
|
{
|
2025-11-23 19:54:53 +00:00
|
|
|
// Clear recipients so no players see it in-game, but server still logs it
|
|
|
|
|
if (_recipientEntityIds == null)
|
|
|
|
|
{
|
|
|
|
|
_recipientEntityIds = new List<int>();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_recipientEntityIds.Clear();
|
|
|
|
|
}
|
2025-11-23 20:23:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|