mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-10 15:53:19 +00:00
31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
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,
|
|
EnumValue = name
|
|
};
|
|
|
|
public override void OnReceiveRemote(bool server, EnumMessage<SignalName> message)
|
|
{
|
|
PlayerData.LearnSignal(message.EnumValue);
|
|
QSBEventManager.FireEvent("IdentifySignal");
|
|
var displayMsg = $"{UITextLibrary.GetString(UITextType.NotificationSignalIdentified)} <color=orange>{AudioSignal.SignalNameToString(message.EnumValue)}</color>";
|
|
var data = new NotificationData(NotificationTarget.All, displayMsg, 10f, true);
|
|
NotificationManager.SharedInstance.PostNotification(data, false);
|
|
}
|
|
}
|
|
} |