2020-12-14 16:24:52 +00:00
|
|
|
|
using QSB.Events;
|
2020-12-14 16:28:03 +00:00
|
|
|
|
using QSB.Messaging;
|
2020-11-03 21:33:48 +00:00
|
|
|
|
using QSB.Player;
|
2020-08-10 14:40:06 +01:00
|
|
|
|
|
2021-04-11 17:08:18 +01:00
|
|
|
|
namespace QSB.ProbeSync.Events
|
2020-08-10 14:40:06 +01:00
|
|
|
|
{
|
2021-07-12 22:02:50 +01:00
|
|
|
|
internal class PlayerProbeEvent : QSBEvent<EnumMessage<ProbeEvent>>
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
2021-07-04 16:03:45 +01:00
|
|
|
|
public override EventType Type => EventType.ProbeEvent;
|
2020-08-10 14:40:06 +01:00
|
|
|
|
|
2021-07-07 09:02:23 +01:00
|
|
|
|
public override void SetupListener()
|
2021-07-04 23:15:53 +01:00
|
|
|
|
=> GlobalMessenger<ProbeEvent>.AddListener(EventNames.QSBProbeEvent, Handler);
|
2020-08-10 14:40:06 +01:00
|
|
|
|
|
2021-07-07 09:02:23 +01:00
|
|
|
|
public override void CloseListener()
|
2021-07-04 23:15:53 +01:00
|
|
|
|
=> GlobalMessenger<ProbeEvent>.RemoveListener(EventNames.QSBProbeEvent, Handler);
|
2020-08-15 20:32:58 +01:00
|
|
|
|
|
2021-07-04 16:03:45 +01:00
|
|
|
|
private void Handler(ProbeEvent probeEvent) => SendEvent(CreateMessage(probeEvent));
|
2020-08-15 21:52:43 +02:00
|
|
|
|
|
2021-07-04 16:03:45 +01:00
|
|
|
|
private EnumMessage<ProbeEvent> CreateMessage(ProbeEvent probeEvent) => new EnumMessage<ProbeEvent>
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
AboutId = LocalPlayerId,
|
2021-07-04 16:03:45 +01:00
|
|
|
|
EnumValue = probeEvent
|
2020-12-02 21:23:01 +00:00
|
|
|
|
};
|
2020-08-10 18:17:54 +02:00
|
|
|
|
|
2021-07-04 16:03:45 +01:00
|
|
|
|
public override void OnReceiveRemote(bool server, EnumMessage<ProbeEvent> message)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(message.AboutId);
|
2021-07-04 16:03:45 +01:00
|
|
|
|
var probe = player.Probe;
|
2020-08-10 14:40:06 +01:00
|
|
|
|
|
2021-07-04 16:03:45 +01:00
|
|
|
|
probe.HandleEvent(message.EnumValue);
|
|
|
|
|
}
|
2020-12-14 21:20:53 +00:00
|
|
|
|
}
|
2021-07-04 16:03:45 +01:00
|
|
|
|
}
|