NetworkServerTest: use CreateNetworkedAndSpawnPlayer

This commit is contained in:
vis2k 2021-08-01 14:42:59 +08:00
parent a55c75b945
commit 88112e7778

View File

@ -328,13 +328,11 @@ public void Destroy_HostMode_CallsOnStopAuthority()
NetworkServer.Listen(1);
ConnectHostClientBlockingAuthenticatedAndReady();
// add player object.
// spawn a player(!) object
// otherwise client wouldn't receive spawn / authority messages
CreateNetworked(out _, out NetworkIdentity player, out StopAuthorityCalledNetworkBehaviour comp);
NetworkServer.AddPlayerForConnection(NetworkServer.localConnection, player.gameObject);
// AddPlayer sends spawn message. process it so NotifyAuthority is called.
ProcessMessages();
CreateNetworkedAndSpawnPlayer(out _, out NetworkIdentity player,
out StopAuthorityCalledNetworkBehaviour comp,
NetworkServer.localConnection);
// need to have authority for this test
Assert.That(player.hasAuthority, Is.True);