Skip to content

Commit

Permalink
fix: code smell rename Ready (#256)
Browse files Browse the repository at this point in the history
* fix: code smell renamed Ready method to allow casing fix for ready bool

* update refs
  • Loading branch information
uweeby committed Jul 11, 2020
1 parent 170326a commit 6d92d14
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Assets/Mirror/Runtime/INetworkSceneManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public interface INetworkSceneManager
{
void ChangeServerScene(string newSceneName);

void Ready(INetworkConnection conn);
void SetClientReady(INetworkConnection conn);
}
}
2 changes: 1 addition & 1 deletion Assets/Mirror/Runtime/NetworkClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void Cleanup()

ClearSpawners();
DestroyAllClientObjects();
sceneManager.ready = false;
sceneManager.Ready = false;
isSpawnFinished = false;
hostServer = null;

Expand Down
14 changes: 7 additions & 7 deletions Assets/Mirror/Runtime/NetworkSceneManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class NetworkSceneManager : MonoBehaviour, INetworkSceneManager
/// <para>This is read-only. To change the ready state of a client, use ClientScene.Ready(). The server is able to set the ready state of clients using NetworkServer.SetClientReady(), NetworkServer.SetClientNotReady() and NetworkServer.SetAllClientsNotReady().</para>
/// <para>This is done when changing scenes so that clients don't receive state update messages during scene loading.</para>
/// </summary>
public bool ready { get; internal set; }
public bool Ready { get; internal set; }

public void Start()
{
Expand Down Expand Up @@ -263,7 +263,7 @@ void OnClientNotReadyMessageInternal(INetworkConnection conn, NotReadyMessage ms
{
logger.Log("NetworkSceneManager.OnClientNotReadyMessageInternal");

ready = false;
Ready = false;
OnClientNotReady(conn);
}

Expand All @@ -287,8 +287,8 @@ internal void OnClientChangeScene(string sceneName, SceneOperation sceneOperatio
internal void OnClientSceneChanged(INetworkConnection conn)
{
//set ready after scene change has completed
if (!ready)
Ready(conn);
if (!Ready)
SetClientReady(conn);

ClientSceneChanged.Invoke(conn);
}
Expand All @@ -308,9 +308,9 @@ internal void OnClientNotReady(INetworkConnection conn)
/// <para>This could be for example when a client enters an ongoing game and has finished loading the current scene. The server should respond to the message with an appropriate handler which instantiates the players object for example.</para>
/// </summary>
/// <param name="conn">The client connection which is ready.</param>
public void Ready(INetworkConnection conn)
public void SetClientReady(INetworkConnection conn)
{
if (ready)
if (Ready)
{
throw new InvalidOperationException("A connection has already been set as ready. There can only be one.");
}
Expand All @@ -322,7 +322,7 @@ public void Ready(INetworkConnection conn)

// Set these before sending the ReadyMessage, otherwise host client
// will fail in InternalAddPlayer with null readyConnection.
ready = true;
Ready = true;
client.Connection.IsReady = true;

// Tell server we're ready to have a player object spawned
Expand Down
4 changes: 2 additions & 2 deletions Assets/Mirror/Runtime/PlayerSpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ private void OnClientAuthenticated(INetworkConnection connection)
// that when we have online/offline scenes. so we need the
// clientLoadedScene flag to prevent it.
// Ready/AddPlayer is usually triggered by a scene load completing. if no scene was loaded, then Ready/AddPlayer it here instead.
if (!client.sceneManager.ready)
client.sceneManager.Ready(connection);
if (!client.sceneManager.Ready)
client.sceneManager.SetClientReady(connection);

client.Send(new AddPlayerMessage());
}
Expand Down
10 changes: 5 additions & 5 deletions Assets/Mirror/Tests/Runtime/NetworkSceneManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ public void ChangeServerSceneExceptionTest()
[Test]
public void ReadyTest()
{
client.sceneManager.Ready(client.Connection);
Assert.That(sceneManager.ready);
client.sceneManager.SetClientReady(client.Connection);
Assert.That(sceneManager.Ready);
Assert.That(client.Connection.IsReady);
}

[Test]
public void ReadyTwiceTest()
{
sceneManager.Ready(client.Connection);
sceneManager.SetClientReady(client.Connection);

Assert.Throws<InvalidOperationException>(() =>
{
sceneManager.Ready(client.Connection);
sceneManager.SetClientReady(client.Connection);
});
}

Expand All @@ -129,7 +129,7 @@ public void ReadyNull()
{
Assert.Throws<InvalidOperationException>(() =>
{
sceneManager.Ready(null);
sceneManager.SetClientReady(null);
});
}

Expand Down

0 comments on commit 6d92d14

Please sign in to comment.