mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Better naming
This commit is contained in:
parent
8df429d474
commit
035afd140e
@ -274,28 +274,28 @@ internal static void ResetServerStatics()
|
|||||||
/// <summary>Gets the NetworkIdentity from the sceneIds dictionary with the corresponding id</summary>
|
/// <summary>Gets the NetworkIdentity from the sceneIds dictionary with the corresponding id</summary>
|
||||||
public static NetworkIdentity GetSceneIdentity(ulong id) => sceneIds[id];
|
public static NetworkIdentity GetSceneIdentity(ulong id) => sceneIds[id];
|
||||||
|
|
||||||
#region NetworkID Handling
|
#region Network ID Reuse
|
||||||
|
|
||||||
internal static bool reuseNetworkIds = true;
|
internal static bool reuseNetworkIds = true;
|
||||||
internal static byte reuseDelay = 1;
|
internal static byte reuseDelay = 1;
|
||||||
|
|
||||||
internal struct NetworkIdPool
|
internal struct ReusableNetworkId
|
||||||
{
|
{
|
||||||
public uint poolNetId;
|
public uint reusableNetId;
|
||||||
public double timeAvailable;
|
public double timeAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pool of NetworkIds that can be reused
|
// pool of NetworkIds that can be reused
|
||||||
internal static readonly Queue<NetworkIdPool> netIdQueue = new Queue<NetworkIdPool>();
|
internal static readonly Queue<ReusableNetworkId> netIdQueue = new Queue<ReusableNetworkId>();
|
||||||
static uint nextNetworkId = 1;
|
static uint nextNetworkId = 1;
|
||||||
|
|
||||||
internal static uint GetNextNetworkId()
|
internal static uint GetNextNetworkId()
|
||||||
{
|
{
|
||||||
if (reuseNetworkIds && netIdQueue.Count > 0 && netIdQueue.Peek().timeAvailable < NetworkTime.time)
|
if (reuseNetworkIds && netIdQueue.Count > 0 && netIdQueue.Peek().timeAvailable < NetworkTime.time)
|
||||||
{
|
{
|
||||||
NetworkIdPool entry = netIdQueue.Dequeue();
|
ReusableNetworkId entry = netIdQueue.Dequeue();
|
||||||
//Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}.");
|
//Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}.");
|
||||||
return entry.poolNetId;
|
return entry.reusableNetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nextNetworkId++;
|
return nextNetworkId++;
|
||||||
@ -663,7 +663,7 @@ void OnDestroy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isServer && reuseNetworkIds && netId > 0)
|
if (isServer && reuseNetworkIds && netId > 0)
|
||||||
netIdQueue.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay });
|
netIdQueue.Enqueue(new ReusableNetworkId { reusableNetId = netId, timeAvailable = NetworkTime.time + reuseDelay });
|
||||||
|
|
||||||
if (isLocalPlayer)
|
if (isLocalPlayer)
|
||||||
{
|
{
|
||||||
@ -1338,7 +1338,7 @@ internal void Reset()
|
|||||||
if (netId > 0)
|
if (netId > 0)
|
||||||
{
|
{
|
||||||
if (reuseNetworkIds)
|
if (reuseNetworkIds)
|
||||||
netIdQueue.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay });
|
netIdQueue.Enqueue(new ReusableNetworkId { reusableNetId = netId, timeAvailable = NetworkTime.time + reuseDelay });
|
||||||
|
|
||||||
netId = 0;
|
netId = 0;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ public override void OnPreviewGUI(Rect r, GUIStyle background)
|
|||||||
|
|
||||||
Y = DrawObservers(identity, initialX, Y);
|
Y = DrawObservers(identity, initialX, Y);
|
||||||
|
|
||||||
Y = DrawNetworkIDPool(initialX, Y);
|
Y = DrawNetworkIDQueue(initialX, Y);
|
||||||
|
|
||||||
_ = DrawOwner(identity, initialX, Y);
|
_ = DrawOwner(identity, initialX, Y);
|
||||||
|
|
||||||
@ -193,19 +193,19 @@ float DrawObservers(NetworkIdentity identity, float initialX, float Y)
|
|||||||
return Y;
|
return Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float DrawNetworkIDPool(float initialX, float Y)
|
float DrawNetworkIDQueue(float initialX, float Y)
|
||||||
{
|
{
|
||||||
if (NetworkIdentity.netIdQueue.Count > 0)
|
if (NetworkIdentity.netIdQueue.Count > 0)
|
||||||
{
|
{
|
||||||
Rect poolRect = new Rect(initialX, Y + 10, 200, 20);
|
Rect netIdRect = new Rect(initialX, Y + 10, 200, 20);
|
||||||
GUI.Label(poolRect, new GUIContent("Network ID Queue"), styles.labelStyle);
|
GUI.Label(netIdRect, new GUIContent("Network ID Queue"), styles.labelStyle);
|
||||||
poolRect.x += 20;
|
netIdRect.x += 20;
|
||||||
poolRect.y += poolRect.height;
|
netIdRect.y += netIdRect.height;
|
||||||
foreach (var entry in NetworkIdentity.netIdQueue)
|
foreach (var entry in NetworkIdentity.netIdQueue)
|
||||||
{
|
{
|
||||||
GUI.Label(poolRect, $"[{entry.poolNetId}] {entry.timeAvailable:0.000}", styles.componentName);
|
GUI.Label(netIdRect, $"[{entry.reusableNetId}] {entry.timeAvailable:0.000}", styles.componentName);
|
||||||
poolRect.y += poolRect.height;
|
netIdRect.y += netIdRect.height;
|
||||||
Y = poolRect.y;
|
Y = netIdRect.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user