mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-16 07:10:35 +00:00
44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using QSB.Messaging;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using QSB.Player;
|
|
using UnityEngine;
|
|
|
|
namespace QSB.HUD.Messages;
|
|
|
|
public class ChatMessage : QSBMessage<(string message, Color color)>
|
|
{
|
|
public ChatMessage(string msg, Color color) : base((msg, color)) { }
|
|
|
|
public override void OnReceiveLocal() => OnReceiveRemote();
|
|
|
|
public override void OnReceiveRemote()
|
|
{
|
|
MultiplayerHUDManager.Instance.WriteMessage(Data.message, Data.color);
|
|
|
|
var fromPlayer = QSBPlayerManager.GetPlayer(From);
|
|
var qsb = false;
|
|
string name;
|
|
if (Data.message.StartsWith("QSB: "))
|
|
{
|
|
name = "QSB: ";
|
|
qsb = true;
|
|
}
|
|
else if (Data.message.StartsWith($"{fromPlayer.Name}: "))
|
|
{
|
|
name = $"{fromPlayer.Name}: ";
|
|
}
|
|
else
|
|
{
|
|
// uhhh idk what happened
|
|
MultiplayerHUDManager.OnChatMessageEvent.Invoke(Data.message, From);
|
|
return;
|
|
}
|
|
|
|
var messageWithoutName = Data.message.Remove(Data.message.IndexOf(name), name.Length);
|
|
MultiplayerHUDManager.OnChatMessageEvent.Invoke(messageWithoutName, qsb ? uint.MaxValue : From);
|
|
}
|
|
} |