mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-27 03:35:20 +00:00
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using QSB.Events;
|
|
using QuantumUNET.Components;
|
|
|
|
namespace QSB.AuthoritySync
|
|
{
|
|
public class AuthQueueEvent : QSBEvent<AuthQueueMessage>
|
|
{
|
|
public override bool RequireWorldObjectsReady => true;
|
|
|
|
public override void SetupListener() =>
|
|
GlobalMessenger<QNetworkIdentity, AuthQueueAction>.AddListener(EventNames.QSBAuthQueue, Handler);
|
|
|
|
public override void CloseListener() =>
|
|
GlobalMessenger<QNetworkIdentity, AuthQueueAction>.RemoveListener(EventNames.QSBAuthQueue, Handler);
|
|
|
|
private void Handler(QNetworkIdentity identity, AuthQueueAction action) => SendEvent(CreateMessage(identity, action));
|
|
|
|
private AuthQueueMessage CreateMessage(QNetworkIdentity identity, AuthQueueAction action) => new()
|
|
{
|
|
OnlySendToHost = true,
|
|
Identity = identity,
|
|
EnumValue = action
|
|
};
|
|
|
|
|
|
public override void OnReceiveLocal(bool isHost, AuthQueueMessage message) => OnReceive(message);
|
|
public override void OnReceiveRemote(bool isHost, AuthQueueMessage message) => OnReceive(message);
|
|
|
|
private static void OnReceive(AuthQueueMessage message)
|
|
{
|
|
message.Identity.UpdateAuthQueue(message.FromId, message.EnumValue);
|
|
}
|
|
}
|
|
}
|