online fix

This commit is contained in:
2025-10-27 14:34:26 +01:00
parent 3c5507dd87
commit cf44edc19a
4 changed files with 80 additions and 4 deletions

View File

@@ -279,6 +279,19 @@ namespace MegaKoop.Game.Networking
hasPendingRemoteSpawn = false;
return;
}
EnemyDefinitionRegistry.Register(definition);
if (pendingRemoteSpawn.NetworkId != 0 && NetworkIdentity.TryGet(pendingRemoteSpawn.NetworkId, out var existingIdentity) && existingIdentity != null)
{
var existingInstance = existingIdentity.gameObject;
if (existingInstance != null)
{
existingInstance.SetActive(true);
existingInstance.transform.SetPositionAndRotation(pendingRemoteSpawn.Position + definition.PrefabPivotOffset, pendingRemoteSpawn.Rotation);
hasPendingRemoteSpawn = false;
}
return;
}
bool success = spawner != null && spawner.TrySpawn(definition, pendingRemoteSpawn.Position);
if (success)
@@ -348,7 +361,6 @@ namespace MegaKoop.Game.Networking
var identity = instance.GetComponent<NetworkIdentity>();
if (identity != null && pendingRemoteSpawn.NetworkId != 0 && identity.NetworkId != pendingRemoteSpawn.NetworkId)
{
NetworkIdAllocator.SyncEnemyCursor(pendingRemoteSpawn.NetworkId);
identity.SetNetworkId(pendingRemoteSpawn.NetworkId);
}
}