move all logic from ChatSync to ChatManager

This commit is contained in:
in0finite 2021-02-28 23:38:34 +01:00
parent e29bacf3d2
commit 26b51b99c9
2 changed files with 14 additions and 20 deletions

View file

@ -65,6 +65,10 @@ namespace SanAndreasUnity.Chat
internal void OnChatMessageReceivedOnServer(Player player, string msg)
{
msg = ChatManager.ProcessChatMessage(msg, false);
if (string.IsNullOrEmpty(msg))
return;
if (!FilterWithPreprocessors(player, ref msg))
return;
@ -73,6 +77,10 @@ namespace SanAndreasUnity.Chat
internal void OnChatMessageReceivedOnLocalPlayer(ChatMessage chatMsg)
{
chatMsg.msg = ChatManager.ProcessChatMessage(chatMsg.msg, true);
if (string.IsNullOrEmpty(chatMsg.msg))
return;
F.InvokeEventExceptionSafe(onChatMessage, chatMsg);
}

View file

@ -8,7 +8,6 @@ namespace SanAndreasUnity.Chat
public class ChatSync : NetworkBehaviour
{
Player m_player;
@ -18,16 +17,9 @@ namespace SanAndreasUnity.Chat
}
[Command]
void CmdChatMsg( string msg ) {
Player p = m_player;
msg = ChatManager.ProcessChatMessage(msg, false);
if (string.IsNullOrEmpty(msg))
return;
F.RunExceptionSafe(() => ChatManager.singleton.OnChatMessageReceivedOnServer(p, msg));
void CmdChatMsg( string msg )
{
F.RunExceptionSafe(() => ChatManager.singleton.OnChatMessageReceivedOnServer(m_player, msg));
}
internal void SendChatMsgToServer( string msg )
@ -36,18 +28,12 @@ namespace SanAndreasUnity.Chat
}
[TargetRpc]
void TargetChatMsg( NetworkConnection conn, string msg, string sender ) {
if (!this.isLocalPlayer) {
return;
}
msg = ChatManager.ProcessChatMessage(msg, true);
if (string.IsNullOrEmpty(msg))
void TargetChatMsg( NetworkConnection conn, string msg, string sender )
{
if (!this.isLocalPlayer)
return;
F.RunExceptionSafe(() => ChatManager.singleton.OnChatMessageReceivedOnLocalPlayer(new ChatMessage (msg, sender)));
}
internal void SendChatMsgToClient( NetworkConnection conn, string msg, string sender )