2021-07-25 20:24:31 +00:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using QSB.WorldSync.Events;
|
|
|
|
|
|
2021-12-24 00:26:31 +00:00
|
|
|
|
namespace QSB.Tools.ProbeLauncherTool.Messages
|
2021-07-25 20:24:31 +00:00
|
|
|
|
{
|
2021-08-09 10:49:58 +00:00
|
|
|
|
internal class LaunchProbeEvent : QSBEvent<WorldObjectMessage>
|
2021-07-25 20:24:31 +00:00
|
|
|
|
{
|
2021-12-05 11:03:09 +00:00
|
|
|
|
public override bool RequireWorldObjectsReady => true;
|
2021-12-04 16:39:37 +00:00
|
|
|
|
|
2021-07-25 20:24:31 +00:00
|
|
|
|
public override void SetupListener()
|
|
|
|
|
=> GlobalMessenger<QSBProbeLauncher>.AddListener(EventNames.QSBLaunchProbe, Handler);
|
|
|
|
|
|
|
|
|
|
public override void CloseListener()
|
|
|
|
|
=> GlobalMessenger<QSBProbeLauncher>.RemoveListener(EventNames.QSBLaunchProbe, Handler);
|
|
|
|
|
|
|
|
|
|
private void Handler(QSBProbeLauncher launcher) => SendEvent(CreateMessage(launcher));
|
|
|
|
|
|
2021-11-20 19:49:50 +00:00
|
|
|
|
private BoolWorldObjectMessage CreateMessage(QSBProbeLauncher launcher) => new()
|
2021-07-25 20:24:31 +00:00
|
|
|
|
{
|
|
|
|
|
AboutId = LocalPlayerId,
|
|
|
|
|
ObjectId = launcher.ObjectId
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote(bool server, WorldObjectMessage message)
|
|
|
|
|
{
|
2021-12-26 06:37:20 +00:00
|
|
|
|
var worldObject = message.ObjectId.GetWorldObject<QSBProbeLauncher>();
|
2021-07-25 20:24:31 +00:00
|
|
|
|
worldObject.LaunchProbe();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|