32 lines
898 B
C#
Raw Normal View History

2021-07-26 22:55:09 +01:00
using QSB.Events;
using QSB.Messaging;
using QSB.Player;
namespace QSB.Tools.ProbeLauncherTool.Messages
2021-07-26 22:55:09 +01:00
{
2021-08-09 11:49:58 +01:00
internal class PlayerRetrieveProbeEvent : QSBEvent<BoolMessage>
2021-07-26 22:55:09 +01:00
{
public override bool RequireWorldObjectsReady => true;
2021-07-26 22:55:09 +01: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 22:55:09 +01:00
{
AboutId = LocalPlayerId,
Value = playEffects
};
public override void OnReceiveRemote(bool server, BoolMessage message)
{
var player = QSBPlayerManager.GetPlayer(message.AboutId);
player.ProbeLauncher.RetrieveProbe(message.Value);
}
}
}