Implement RPC Node
This commit is contained in:
parent
f7ee533d5a
commit
605e43273e
13 changed files with 524 additions and 206 deletions
|
|
@ -8,11 +8,18 @@ public partial class QueueManager : Node
|
|||
public static ConcurrentQueue<Action> ActionQueue = new();
|
||||
|
||||
public static ConcurrentQueue<(Sector, GameObject)> SectorReassignQueue = new();
|
||||
public static ConcurrentQueue<(long, Godot.Collections.Dictionary)> NetworkSyncQueue = new();
|
||||
|
||||
private readonly int sectorReassignQueueRateLimit = 500;
|
||||
private readonly int networkSyncQueueRateLimit = 10;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (!GameManager.Instance.playerReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (LogQueue.TryDequeue(out string text))
|
||||
{
|
||||
GD.Print(text);
|
||||
|
|
@ -25,7 +32,7 @@ public partial class QueueManager : Node
|
|||
|
||||
int sectorReassignQueueProcessed = 0;
|
||||
while (
|
||||
!GameManager.Singleton.simulating
|
||||
!GameManager.Instance.simulatingFar
|
||||
&& sectorReassignQueueProcessed++ < sectorReassignQueueRateLimit
|
||||
&& SectorReassignQueue.TryDequeue(out var item)
|
||||
)
|
||||
|
|
@ -37,5 +44,16 @@ public partial class QueueManager : Node
|
|||
|
||||
gameObject.AssignSector(sector);
|
||||
}
|
||||
|
||||
int networkSyncQueueProcessed = 0;
|
||||
while (
|
||||
networkSyncQueueProcessed++ < networkSyncQueueRateLimit
|
||||
&& NetworkSyncQueue.TryDequeue(out var item)
|
||||
)
|
||||
{
|
||||
var (clientId, gameObjectData) = item;
|
||||
|
||||
RPCNode.Instance.RpcId(clientId, nameof(RPCNode.RpcSyncGameObject), gameObjectData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue