Skip to content

Commit

Permalink
refactor: networkplayer sceneis ready notw defaults to true
Browse files Browse the repository at this point in the history
When a player first connects it is now assumed that they are in a ready scene. NetworkSceneManager will set them to not ready if it has any scenes to load.

Spawning Visible objects will still wait for a character to be added before spawning.

BREAKING CHANGE: NetworkPlayer.SceneIsReady now default to true
  • Loading branch information
James-Frowen committed Sep 8, 2021
1 parent d017e80 commit 319e8d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Assets/Mirage/Runtime/NetworkPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public sealed class NetworkPlayer : INetworkPlayer, IMessageSender
/// Flag that tells us if the scene has fully loaded in for player.
/// <para>This property is read-only. It is set by the system on the client when the scene has fully loaded, and set by the system on the server when a ready message is received from a client.</para>
/// <para>A client that is ready is sent spawned objects by the server and updates to the state of spawned objects. A client that is not ready is not sent spawned objects.</para>
/// <para>Starts as true, when a client connects it is assumed that it is already in a ready scene. It will be set to not ready if NetworkSceneManager loads a scene</para>
/// </summary>
public bool SceneIsReady { get; set; }
public bool SceneIsReady { get; set; } = true;

/// <summary>
/// Checks if this player has a <see cref="Identity"/>
Expand Down
7 changes: 3 additions & 4 deletions Assets/Tests/Runtime/Host/PlayerSceneReadyHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ public class PlayerSceneReadyHostTests : HostSetup<MockComponent>
public void SetClientReadyAndNotReadyTest()
{
(_, NetworkPlayer connection) = PipedConnections(ClientMessageHandler, ServerMessageHandler);
Assert.That(connection.SceneIsReady, Is.False);

serverObjectManager.SpawnVisibleObjects(connection);
Assert.That(connection.SceneIsReady, Is.True);
Assert.That(connection.SceneIsReady, Is.True, "Starts in a ready scene");

sceneManager.SetClientNotReady(connection);
Assert.That(connection.SceneIsReady, Is.False);


}

[Test]
Expand Down

0 comments on commit 319e8d8

Please sign in to comment.