2021-12-26 00:29:00 +00:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Player;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using QSB.WorldSync;
|
2020-12-16 09:08:38 +00:00
|
|
|
|
using QuantumUNET.Transport;
|
2020-10-24 14:31:20 +00:00
|
|
|
|
|
2021-12-24 00:26:31 +00:00
|
|
|
|
namespace QSB.ConversationSync.Messages
|
2020-10-24 14:31:20 +00:00
|
|
|
|
{
|
2021-12-26 00:29:00 +00:00
|
|
|
|
public class ConversationStartEndMessage : QSBBoolMessage
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
2021-12-26 00:29:00 +00:00
|
|
|
|
private int TreeId;
|
|
|
|
|
private uint PlayerId;
|
2020-10-24 14:31:20 +00:00
|
|
|
|
|
2021-12-26 00:29:00 +00:00
|
|
|
|
public ConversationStartEndMessage(int treeId, uint playerId, bool start)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
2021-12-26 00:29:00 +00:00
|
|
|
|
TreeId = treeId;
|
|
|
|
|
PlayerId = playerId;
|
|
|
|
|
Value = start;
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2020-10-24 14:31:20 +00:00
|
|
|
|
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public override void Serialize(QNetworkWriter writer)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
2021-04-29 17:30:45 +00:00
|
|
|
|
writer.Write(TreeId);
|
2020-12-02 21:23:01 +00:00
|
|
|
|
writer.Write(PlayerId);
|
2021-12-26 00:29:00 +00:00
|
|
|
|
writer.Write(Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Deserialize(QNetworkReader reader)
|
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
|
|
|
|
TreeId = reader.ReadInt32();
|
|
|
|
|
PlayerId = reader.ReadUInt32();
|
|
|
|
|
Value = reader.ReadBoolean();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
if (TreeId == -1)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole("Warning - Received conv. start/end event with char id -1.", MessageType.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dialogueTree = QSBWorldSync.OldDialogueTrees[TreeId];
|
|
|
|
|
|
|
|
|
|
if (Value)
|
|
|
|
|
{
|
|
|
|
|
StartConversation(PlayerId, TreeId, dialogueTree);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
EndConversation(PlayerId, dialogueTree);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|