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

32 lines
916 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
{
2021-08-09 10:49:58 +00:00
internal class PlayerRetrieveProbeEvent : QSBEvent<BoolMessage>
2021-07-26 21:55:09 +00:00
{
public override EventType Type => EventType.PlayerRetrieveProbe;
public override void SetupListener()
=> GlobalMessenger<bool>.AddListener(EventNames.QSBPlayerRetrieveProbe, Handler);
public override void CloseListener()
=> GlobalMessenger<bool>.RemoveListener(EventNames.QSBPlayerRetrieveProbe, Handler);
private void Handler(bool playEffects) => SendEvent(CreateMessage(playEffects));
private BoolMessage CreateMessage(bool playEffects) => new BoolMessage
{
AboutId = LocalPlayerId,
Value = playEffects
};
public override void OnReceiveRemote(bool server, BoolMessage message)
{
var player = QSBPlayerManager.GetPlayer(message.AboutId);
player.ProbeLauncher.RetrieveProbe(message.Value);
}
}
}