2020-12-24 19:35:42 +00:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Player;
|
|
|
|
|
|
|
|
|
|
namespace QSB.FrequencySync.Events
|
|
|
|
|
{
|
|
|
|
|
public class IdentifySignalEvent : QSBEvent<EnumMessage<SignalName>>
|
|
|
|
|
{
|
|
|
|
|
public override EventType Type => EventType.IdentifySignal;
|
|
|
|
|
|
|
|
|
|
public override void SetupListener() => GlobalMessenger<SignalName>.AddListener(EventNames.QSBIdentifySignal, Handler);
|
|
|
|
|
public override void CloseListener() => GlobalMessenger<SignalName>.RemoveListener(EventNames.QSBIdentifySignal, Handler);
|
|
|
|
|
|
|
|
|
|
private void Handler(SignalName name) => SendEvent(CreateMessage(name));
|
|
|
|
|
|
|
|
|
|
private EnumMessage<SignalName> CreateMessage(SignalName name) => new EnumMessage<SignalName>
|
|
|
|
|
{
|
|
|
|
|
AboutId = QSBPlayerManager.LocalPlayerId,
|
2021-03-29 13:36:16 +00:00
|
|
|
|
EnumValue = name
|
2020-12-24 19:35:42 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote(bool server, EnumMessage<SignalName> message)
|
|
|
|
|
{
|
2021-03-29 13:36:16 +00:00
|
|
|
|
PlayerData.LearnSignal(message.EnumValue);
|
2021-02-10 19:59:28 +00:00
|
|
|
|
QSBEventManager.FireEvent("IdentifySignal");
|
2021-03-29 13:36:16 +00:00
|
|
|
|
var displayMsg = $"{UITextLibrary.GetString(UITextType.NotificationSignalIdentified)} <color=orange>{AudioSignal.SignalNameToString(message.EnumValue)}</color>";
|
2020-12-24 19:35:42 +00:00
|
|
|
|
var data = new NotificationData(NotificationTarget.All, displayMsg, 10f, true);
|
|
|
|
|
NotificationManager.SharedInstance.PostNotification(data, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|