mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-11 00:52:19 +00:00
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using QSB.Events;
|
|
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
|
using QSB.WorldSync;
|
|
using QSB.WorldSync.Events;
|
|
|
|
namespace QSB.Tools.ProbeLauncherTool.Events
|
|
{
|
|
internal class RetrieveProbeEvent : QSBEvent<BoolWorldObjectMessage>
|
|
{
|
|
public override bool RequireWorldObjectsReady => true;
|
|
|
|
public override void SetupListener()
|
|
=> GlobalMessenger<QSBProbeLauncher, bool>.AddListener(EventNames.QSBRetrieveProbe, Handler);
|
|
|
|
public override void CloseListener()
|
|
=> GlobalMessenger<QSBProbeLauncher, bool>.RemoveListener(EventNames.QSBRetrieveProbe, Handler);
|
|
|
|
private void Handler(QSBProbeLauncher launcher, bool playEffects) => SendEvent(CreateMessage(launcher, playEffects));
|
|
|
|
private BoolWorldObjectMessage CreateMessage(QSBProbeLauncher launcher, bool playEffects) => new()
|
|
{
|
|
AboutId = LocalPlayerId,
|
|
ObjectId = launcher.ObjectId,
|
|
State = playEffects
|
|
};
|
|
|
|
public override void OnReceiveRemote(bool server, BoolWorldObjectMessage message)
|
|
{
|
|
var worldObject = QSBWorldSync.GetWorldFromId<QSBProbeLauncher>(message.ObjectId);
|
|
worldObject.RetrieveProbe(message.State);
|
|
}
|
|
}
|
|
}
|