Skip to content

Commit

Permalink
style: renaming NumPlayers to NumberOfPlayers (MirageNet#646)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Use NetworkServer.NumberOfPlayers instead of NetworkServer.NumPlayers
  • Loading branch information
James-Frowen committed Mar 2, 2021
1 parent 303ddf0 commit 27b99be
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Assets/Mirage/Runtime/NetworkServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class NetworkServer : MonoBehaviour, INetworkServer
/// Number of active player objects across all connections on the server.
/// <para>This is only valid on the host / server.</para>
/// </summary>
public int NumPlayers => connections.Count(kv => kv.Identity != null);
public int NumberOfPlayers => connections.Count(kv => kv.Identity != null);

/// <summary>
/// A list of local connections on the server.
Expand Down
4 changes: 2 additions & 2 deletions Assets/Mirage/Samples~/Pong/Scripts/PaddleSpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public class PaddleSpawner : PlayerSpawner
public override void OnServerAddPlayer(INetworkConnection conn)
{
// add player at correct spawn position
Transform start = Server.NumPlayers == 0 ? leftRacketSpawn : rightRacketSpawn;
Transform start = Server.NumberOfPlayers == 0 ? leftRacketSpawn : rightRacketSpawn;
NetworkIdentity player = Instantiate(PlayerPrefab, start.position, start.rotation);
ServerObjectManager.AddPlayerForConnection(conn, player.gameObject);

// spawn ball if two players
if (Server.NumPlayers == 2)
if (Server.NumberOfPlayers == 2)
{
ball = Instantiate(ballPrefab);
ServerObjectManager.Spawn(ball);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private IEnumerator DisplayFramesPerSecons()
long messages = messageCount - previousMessageCount;

#if UNITY_EDITOR
Debug.LogFormat("{0} FPS {1} messages {2} clients", frames, messages, server.NumPlayers);
Debug.LogFormat("{0} FPS {1} messages {2} clients", frames, messages, server.NumberOfPlayers);
#else
Console.WriteLine("{0} FPS {1} messages {2} clients", frames, messages, server.NumPlayers);
#endif
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/Runtime/ClientServer/NetworkServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void InitializeTest()
[Test]
public void NumPlayersTest()
{
Assert.That(server.NumPlayers, Is.EqualTo(1));
Assert.That(server.NumberOfPlayers, Is.EqualTo(1));
}

[Test]
Expand Down

0 comments on commit 27b99be

Please sign in to comment.