mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-06 01:00:16 +00:00
EnterRemoteDialogueMessage
This commit is contained in:
parent
961a905d14
commit
22400aeb0c
@ -1,30 +0,0 @@
|
||||
using QSB.ConversationSync.WorldObjects;
|
||||
using QSB.Events;
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.ConversationSync.Messages
|
||||
{
|
||||
internal class EnterRemoteDialogueEvent : QSBEvent<EnterRemoteDialogueMessage>
|
||||
{
|
||||
public override bool RequireWorldObjectsReady => true;
|
||||
|
||||
public override void SetupListener() => GlobalMessenger<QSBRemoteDialogueTrigger, int, int>.AddListener(EventNames.QSBEnterRemoteDialogue, Handler);
|
||||
public override void CloseListener() => GlobalMessenger<QSBRemoteDialogueTrigger, int, int>.RemoveListener(EventNames.QSBEnterRemoteDialogue, Handler);
|
||||
|
||||
private void Handler(QSBRemoteDialogueTrigger remoteTrigger, int activatedIndex, int listIndex) => SendEvent(CreateMessage(remoteTrigger, activatedIndex, listIndex));
|
||||
|
||||
private EnterRemoteDialogueMessage CreateMessage(QSBRemoteDialogueTrigger remoteTrigger, int activatedIndex, int listIndex) => new()
|
||||
{
|
||||
AboutId = LocalPlayerId,
|
||||
ObjectId = remoteTrigger.ObjectId,
|
||||
ActivatedDialogueIndex = activatedIndex,
|
||||
ListDialoguesIndex = listIndex
|
||||
};
|
||||
|
||||
public override void OnReceiveRemote(bool isHost, EnterRemoteDialogueMessage message)
|
||||
{
|
||||
var qsbObj = QSBWorldSync.GetWorldFromId<QSBRemoteDialogueTrigger>(message.ObjectId);
|
||||
qsbObj.RemoteEnterDialogue(message.ActivatedDialogueIndex, message.ListDialoguesIndex);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,28 @@
|
||||
using QSB.WorldSync.Events;
|
||||
using QSB.ConversationSync.WorldObjects;
|
||||
using QSB.Messaging;
|
||||
using QuantumUNET.Transport;
|
||||
|
||||
namespace QSB.ConversationSync.Messages
|
||||
{
|
||||
public class EnterRemoteDialogueMessage : WorldObjectMessage
|
||||
internal class EnterRemoteDialogueMessage : QSBWorldObjectMessage<QSBRemoteDialogueTrigger>
|
||||
{
|
||||
public int ActivatedDialogueIndex { get; set; }
|
||||
public int ListDialoguesIndex { get; set; }
|
||||
private int ActivatedDialogueIndex;
|
||||
private int ListDialoguesIndex;
|
||||
|
||||
public EnterRemoteDialogueMessage(int activatedIndex, int listIndex)
|
||||
{
|
||||
ActivatedDialogueIndex = activatedIndex;
|
||||
ListDialoguesIndex = listIndex;
|
||||
}
|
||||
|
||||
public EnterRemoteDialogueMessage() { }
|
||||
|
||||
public override void Serialize(QNetworkWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(ActivatedDialogueIndex);
|
||||
writer.Write(ListDialoguesIndex);
|
||||
}
|
||||
|
||||
public override void Deserialize(QNetworkReader reader)
|
||||
{
|
||||
@ -15,11 +31,7 @@ namespace QSB.ConversationSync.Messages
|
||||
ListDialoguesIndex = reader.ReadInt32();
|
||||
}
|
||||
|
||||
public override void Serialize(QNetworkWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(ActivatedDialogueIndex);
|
||||
writer.Write(ListDialoguesIndex);
|
||||
}
|
||||
public override void OnReceiveRemote()
|
||||
=> WorldObject.RemoteEnterDialogue(ActivatedDialogueIndex, ListDialoguesIndex);
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
using HarmonyLib;
|
||||
using OWML.Common;
|
||||
using QSB.ConversationSync.Messages;
|
||||
using QSB.ConversationSync.WorldObjects;
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
@ -138,10 +139,8 @@ namespace QSB.ConversationSync.Patches
|
||||
|
||||
__instance._activatedDialogues[num] = true;
|
||||
|
||||
QSBEventManager.FireEvent(EventNames.QSBEnterRemoteDialogue,
|
||||
QSBWorldSync.GetWorldFromUnity<QSBRemoteDialogueTrigger>(__instance),
|
||||
num,
|
||||
__instance._listDialogues.IndexOf(dialogue));
|
||||
QSBWorldSync.GetWorldFromUnity<QSBRemoteDialogueTrigger>(__instance)
|
||||
.SendMessage(new EnterRemoteDialogueMessage(num, __instance._listDialogues.IndexOf(dialogue)));
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
|
@ -71,6 +71,5 @@
|
||||
public const string QSBSatelliteRepaired = nameof(QSBSatelliteRepairTick);
|
||||
public const string QSBJellyfishRising = nameof(QSBJellyfishRising);
|
||||
public const string QSBTornadoFormState = nameof(QSBTornadoFormState);
|
||||
public const string QSBEnterRemoteDialogue = nameof(QSBEnterRemoteDialogue);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user