2021-07-26 21:55:09 +00:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Player;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Tools.ProbeLauncherTool.Events
|
|
|
|
|
{
|
2021-08-09 10:49:58 +00:00
|
|
|
|
internal class PlayerLaunchProbeEvent : QSBEvent<PlayerMessage>
|
2021-07-26 21:55:09 +00:00
|
|
|
|
{
|
|
|
|
|
public override void SetupListener()
|
|
|
|
|
=> GlobalMessenger.AddListener(EventNames.QSBPlayerLaunchProbe, Handler);
|
|
|
|
|
|
|
|
|
|
public override void CloseListener()
|
|
|
|
|
=> GlobalMessenger.RemoveListener(EventNames.QSBPlayerLaunchProbe, Handler);
|
|
|
|
|
|
|
|
|
|
private void Handler() => SendEvent(CreateMessage());
|
|
|
|
|
|
2021-11-20 19:49:50 +00:00
|
|
|
|
private PlayerMessage CreateMessage() => new()
|
2021-07-26 21:55:09 +00:00
|
|
|
|
{
|
|
|
|
|
AboutId = LocalPlayerId
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote(bool server, PlayerMessage message)
|
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(message.AboutId);
|
|
|
|
|
player.ProbeLauncher.LaunchProbe();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|