quantum-space-buddies/QSB/Tools/ProbeLauncherTool/Events/PlayerLaunchProbeEvent.cs

31 lines
813 B
C#
Raw Normal View History

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