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
|
|
|
|
{
|
2021-12-04 16:39:37 +00:00
|
|
|
|
public override bool RequireWorldObjectsReady() => true;
|
|
|
|
|
|
2021-07-26 21:55:09 +00:00
|
|
|
|
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));
|
|
|
|
|
|
2021-11-20 19:49:50 +00:00
|
|
|
|
private BoolMessage CreateMessage(bool playEffects) => new()
|
2021-07-26 21:55:09 +00:00
|
|
|
|
{
|
|
|
|
|
AboutId = LocalPlayerId,
|
|
|
|
|
Value = playEffects
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote(bool server, BoolMessage message)
|
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(message.AboutId);
|
|
|
|
|
player.ProbeLauncher.RetrieveProbe(message.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|