33 lines
1006 B
C#
Raw Normal View History

2021-07-25 21:24:31 +01:00
using QSB.Events;
using QSB.Tools.ProbeLauncherTool.WorldObjects;
using QSB.WorldSync;
using QSB.WorldSync.Events;
namespace QSB.Tools.ProbeLauncherTool.Events
{
2021-08-09 11:49:58 +01:00
internal class LaunchProbeEvent : QSBEvent<WorldObjectMessage>
2021-07-25 21:24:31 +01:00
{
public override EventType Type => EventType.LaunchProbe;
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 21:24:31 +01:00
{
AboutId = LocalPlayerId,
ObjectId = launcher.ObjectId
};
public override void OnReceiveRemote(bool server, WorldObjectMessage message)
{
var worldObject = QSBWorldSync.GetWorldFromId<QSBProbeLauncher>(message.ObjectId);
worldObject.LaunchProbe();
}
}
}