online game working
This commit is contained in:
@@ -49,5 +49,30 @@ namespace MegaKoop.Game.Networking
|
||||
}
|
||||
|
||||
public static bool TryGet(int id, out NetworkIdentity identity) => registry.TryGetValue(id, out identity);
|
||||
|
||||
/// <summary>
|
||||
/// Allows deterministic assignment so IDs match across clients.
|
||||
/// </summary>
|
||||
public void SetNetworkId(int id)
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
Debug.LogWarning("[NetworkIdentity] Cannot assign network id 0.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (networkId == id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (registry.TryGetValue(networkId, out NetworkIdentity existing) && existing == this)
|
||||
{
|
||||
registry.Remove(networkId);
|
||||
}
|
||||
|
||||
networkId = id;
|
||||
Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user