Can't use TryPeek in older Unity

This commit is contained in:
MrGadget 2024-01-12 12:24:45 -05:00
parent 668dc91ffb
commit 3436df7ca4

View File

@ -291,11 +291,10 @@ internal struct NetworkIdPool
internal static uint GetNextNetworkId()
{
if (poolNetworkIds && netIdPool.TryPeek(out NetworkIdPool entry) && entry.timeAvailable < NetworkTime.time)
if (poolNetworkIds && netIdPool.Count > 0 && netIdPool.Peek().timeAvailable < NetworkTime.time)
{
NetworkIdPool entry = netIdPool.Dequeue();
//Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}.");
netIdPool.Dequeue();
return entry.poolNetId;
}