mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-06 01:00:16 +00:00
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using QSB.ConversationSync.WorldObjects;
|
|
using QSB.Messaging;
|
|
using QSB.Player;
|
|
using QSB.WorldSync;
|
|
using System.Text.RegularExpressions;
|
|
using UnityEngine;
|
|
|
|
namespace QSB.ConversationSync.Messages;
|
|
|
|
public class ConversationMessage : QSBMessage<(ConversationType Type, int Id, string Message)>
|
|
{
|
|
public ConversationMessage(ConversationType type, int id, string message = "") : base((type, id, message)) { }
|
|
|
|
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
|
|
|
public override void OnReceiveRemote()
|
|
{
|
|
switch (Data.Type)
|
|
{
|
|
case ConversationType.Character:
|
|
var translated = TextTranslation.Translate(Data.Message).Trim();
|
|
translated = Regex.Replace(translated, @"<[Pp]ause=?\d*\.?\d*\s?\/?>", "");
|
|
ConversationManager.Instance.DisplayCharacterConversationBox(Data.Id, translated);
|
|
break;
|
|
|
|
case ConversationType.Player:
|
|
ConversationManager.Instance.DisplayPlayerConversationBox((uint)Data.Id, Data.Message);
|
|
break;
|
|
|
|
case ConversationType.CloseCharacter:
|
|
if (Data.Id == -1)
|
|
{
|
|
break;
|
|
}
|
|
|
|
var tree = Data.Id.GetWorldObject<QSBCharacterDialogueTree>().AttachedObject;
|
|
Object.Destroy(ConversationManager.Instance.BoxMappings[tree]);
|
|
break;
|
|
|
|
case ConversationType.ClosePlayer:
|
|
Object.Destroy(QSBPlayerManager.GetPlayer((uint)Data.Id).CurrentDialogueBox);
|
|
break;
|
|
}
|
|
}
|
|
} |