quantum-space-buddies/QSB/Events/PlayerStatesRequestEvent.cs
Mister_Nebula f54cc69501 fixes
2020-08-14 19:31:33 +01:00

30 lines
938 B
C#

using QSB.Messaging;
using QSB.TransformSync;
namespace QSB.Events
{
public class PlayerStatesRequestEvent : QSBEvent<PlayerMessage>
{
public override MessageType Type => MessageType.FullStateRequest;
public override void SetupListener()
{
GlobalMessenger.AddListener(EventNames.QSBPlayerStatesRequest, () => SendEvent(CreateMessage()));
}
private PlayerMessage CreateMessage() => new PlayerMessage
{
SenderId = PlayerTransformSync.LocalInstance.netId.Value
};
public override void OnServerReceive(PlayerMessage message)
{
PlayerState.LocalInstance.Send();
foreach (var item in PlayerRegistry.TransformSyncs)
{
GlobalMessenger<uint, Sector.Name, string>.FireEvent(EventNames.QSBSectorChange, item.netId.Value, item.SectorId, item.SectorName);
}
}
}
}