1
0
mirror of https://github.com/misternebula/quantum-space-buddies.git synced 2025-02-19 12:40:56 +00:00

55 lines
1.2 KiB
C#
Raw Normal View History

using OWML.Common;
2021-12-25 16:29:00 -08:00
using QSB.Messaging;
using QSB.Player;
using QSB.Utility;
using QSB.WorldSync;
2020-10-24 15:31:20 +01:00
2022-03-02 19:46:33 -08:00
namespace QSB.ConversationSync.Messages;
public class ConversationStartEndMessage : QSBMessage<(int TreeId, bool Start)>
2020-10-24 15:31:20 +01:00
{
2022-03-02 19:46:33 -08:00
public ConversationStartEndMessage(int treeId, bool start)
{
2022-03-02 19:46:33 -08:00
Data.TreeId = treeId;
Data.Start = start;
}
2021-12-25 16:29:00 -08:00
2022-03-02 19:46:33 -08:00
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
2021-12-25 16:29:00 -08:00
2022-03-02 19:46:33 -08:00
public override void OnReceiveRemote()
{
if (Data.TreeId == -1)
2021-12-25 16:29:00 -08:00
{
2022-03-02 19:46:33 -08:00
DebugLog.ToConsole("Warning - Received conv. start/end event with char id -1.", MessageType.Warning);
return;
2021-12-25 16:29:00 -08:00
}
2022-03-02 19:46:33 -08:00
var dialogueTree = QSBWorldSync.OldDialogueTrees[Data.TreeId];
if (Data.Start)
2021-12-25 16:29:00 -08:00
{
2022-03-02 19:46:33 -08:00
StartConversation(From, Data.TreeId, dialogueTree);
2021-12-25 16:29:00 -08:00
}
2022-03-02 19:46:33 -08:00
else
{
2022-03-02 19:46:33 -08:00
EndConversation(From, dialogueTree);
}
2020-12-02 21:23:01 +00:00
}
2022-03-02 19:46:33 -08:00
private static void StartConversation(
uint playerId,
int treeId,
CharacterDialogueTree tree)
{
QSBPlayerManager.GetPlayer(playerId).CurrentCharacterDialogueTreeId = treeId;
tree.GetInteractVolume().DisableInteraction();
}
private static void EndConversation(
uint playerId,
CharacterDialogueTree tree)
{
QSBPlayerManager.GetPlayer(playerId).CurrentCharacterDialogueTreeId = -1;
tree.GetInteractVolume().EnableInteraction();
}
}