mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-10 06:51:36 +00:00
f434ed027b
* wrapper for sector * using world registry for sectors * using order id as unique sector key * sector manager * not checking closest sector every frame
31 lines
1001 B
C#
31 lines
1001 B
C#
using QSB.Messaging;
|
|
using QSB.TransformSync;
|
|
using System.Linq;
|
|
|
|
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.Where(x => x != null && x.IsReady && x.ReferenceSector != null))
|
|
{
|
|
GlobalMessenger<uint, QSBSector>.FireEvent(EventNames.QSBSectorChange, item.netId.Value, item.ReferenceSector);
|
|
}
|
|
}
|
|
}
|
|
}
|