Fix build script and API usage
- Add all required assembly references (mscorlib, netstandard, System.dll, System.Core.dll) - Use GameManager.ChatMessageServer instead of NetPackageChat - Use Log.Out (proper 7DTD API) instead of Debug.Log
This commit is contained in:
@@ -1,29 +1,37 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public class BotCommandMod : IModApi
|
public class BotCommandMod : IModApi
|
||||||
{
|
{
|
||||||
public void InitMod(Mod _modInstance)
|
public void InitMod(Mod _modInstance)
|
||||||
{
|
{
|
||||||
Debug.Log("[BotCommandMod] Loading");
|
Log.Out("[BotCommandMod] Loading");
|
||||||
var harmony = new Harmony("com.botcommand.mod");
|
var harmony = new Harmony("com.botcommand.mod");
|
||||||
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
||||||
Debug.Log("[BotCommandMod] Loaded");
|
Log.Out("[BotCommandMod] Loaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(NetPackageChat))]
|
[HarmonyPatch(typeof(ConsoleCmdAbstract))]
|
||||||
[HarmonyPatch("ProcessPackage")]
|
[HarmonyPatch("getCommands")]
|
||||||
public class ChatCommandPatch
|
public class ChatInterceptPatch
|
||||||
{
|
{
|
||||||
static bool Prefix(NetPackageChat __instance, World _world)
|
static void Postfix(ref string __result)
|
||||||
{
|
{
|
||||||
if (__instance.Message != null && __instance.Message.StartsWith("/bot "))
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(GameManager))]
|
||||||
|
[HarmonyPatch("ChatMessageServer")]
|
||||||
|
public class ChatMessagePatch
|
||||||
|
{
|
||||||
|
static bool Prefix(ClientInfo _cInfo, EChatType _type, int _senderId, string _msg, string _mainName, bool _localizeMain, List<int> _recipientEntityIds)
|
||||||
|
{
|
||||||
|
if (_msg != null && _msg.StartsWith("/bot "))
|
||||||
{
|
{
|
||||||
ClientInfo cInfo = ConnectionManager.Instance.Clients.ForEntityId(__instance.Sender);
|
string playerName = _cInfo != null ? _cInfo.playerName : "Server";
|
||||||
string playerName = cInfo != null ? cInfo.playerName : "Unknown";
|
Log.Out($"[Bot] {playerName}: {_msg}");
|
||||||
Debug.Log($"[Bot] {playerName}: {__instance.Message}");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
4
build.sh
4
build.sh
@@ -5,6 +5,10 @@ GAME_DIR="${GAME_DIR:-$HOME/.local/share/7DaysToDie}"
|
|||||||
|
|
||||||
mcs -target:library \
|
mcs -target:library \
|
||||||
-out:BotCommandMod.dll \
|
-out:BotCommandMod.dll \
|
||||||
|
-r:"$GAME_DIR/7DaysToDie_Data/Managed/mscorlib.dll" \
|
||||||
|
-r:"$GAME_DIR/7DaysToDie_Data/Managed/netstandard.dll" \
|
||||||
|
-r:"$GAME_DIR/7DaysToDie_Data/Managed/System.dll" \
|
||||||
|
-r:"$GAME_DIR/7DaysToDie_Data/Managed/System.Core.dll" \
|
||||||
-r:"$GAME_DIR/7DaysToDie_Data/Managed/Assembly-CSharp.dll" \
|
-r:"$GAME_DIR/7DaysToDie_Data/Managed/Assembly-CSharp.dll" \
|
||||||
-r:"$GAME_DIR/7DaysToDie_Data/Managed/UnityEngine.CoreModule.dll" \
|
-r:"$GAME_DIR/7DaysToDie_Data/Managed/UnityEngine.CoreModule.dll" \
|
||||||
-r:"$GAME_DIR/7DaysToDie_Data/Managed/0Harmony.dll" \
|
-r:"$GAME_DIR/7DaysToDie_Data/Managed/0Harmony.dll" \
|
||||||
|
|||||||
Reference in New Issue
Block a user