mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 18:32:45 +00:00
34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using QSB.Events;
|
|
using QSB.Messaging;
|
|
|
|
namespace QSB.Utility.Events
|
|
{
|
|
public class DebugEvent : QSBEvent<EnumMessage<DebugEventEnum>>
|
|
{
|
|
public override EventType Type => EventType.DebugEvent;
|
|
|
|
public override void SetupListener() => GlobalMessenger<DebugEventEnum>.AddListener(EventNames.QSBDebugEvent, Handler);
|
|
public override void CloseListener() => GlobalMessenger<DebugEventEnum>.RemoveListener(EventNames.QSBDebugEvent, Handler);
|
|
|
|
private void Handler(DebugEventEnum type) => SendEvent(CreateMessage(type));
|
|
|
|
private EnumMessage<DebugEventEnum> CreateMessage(DebugEventEnum type) => new EnumMessage<DebugEventEnum>
|
|
{
|
|
AboutId = LocalPlayerId,
|
|
EnumValue = type
|
|
};
|
|
|
|
public override void OnReceiveLocal(bool isHost, EnumMessage<DebugEventEnum> message) => OnReceiveRemote(isHost, message);
|
|
|
|
public override void OnReceiveRemote(bool isHost, EnumMessage<DebugEventEnum> message)
|
|
{
|
|
switch (message.EnumValue)
|
|
{
|
|
case DebugEventEnum.TriggerSupernova:
|
|
TimeLoop.SetSecondsRemaining(0f);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|