2021-07-25 20:24:31 +00:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using QSB.WorldSync.Events;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Tools.ProbeLauncherTool.Events
|
|
|
|
|
{
|
2021-08-09 10:49:58 +00:00
|
|
|
|
internal class LaunchProbeEvent : QSBEvent<WorldObjectMessage>
|
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)
|
|
|
|
|
{
|
|
|
|
|
var worldObject = QSBWorldSync.GetWorldFromId<QSBProbeLauncher>(message.ObjectId);
|
|
|
|
|
worldObject.LaunchProbe();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|