using QSB.Events; using QSB.Messaging; using QSB.Player; namespace QSB.FrequencySync.Events { public class IdentifySignalEvent : QSBEvent> { public override EventType Type => EventType.IdentifySignal; public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBIdentifySignal, Handler); public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBIdentifySignal, Handler); private void Handler(SignalName name) => SendEvent(CreateMessage(name)); private EnumMessage CreateMessage(SignalName name) => new EnumMessage { AboutId = QSBPlayerManager.LocalPlayerId, Value = name }; public override void OnReceiveRemote(bool server, EnumMessage message) { PlayerData.LearnSignal(message.Value); GlobalMessenger.FireEvent("IdentifySignal"); var displayMsg = $"{UITextLibrary.GetString(UITextType.NotificationSignalIdentified)} {AudioSignal.SignalNameToString(message.Value)}"; var data = new NotificationData(NotificationTarget.All, displayMsg, 10f, true); NotificationManager.SharedInstance.PostNotification(data, false); } } }