Skip to content

Commit

Permalink
fix wrong current player count
Browse files Browse the repository at this point in the history
  • Loading branch information
sonodima committed Apr 7, 2024
1 parent 3c58a80 commit 719c3b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/LobbyHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ namespace BetterLobby;

internal static class LobbyHelpers
{
private static readonly int s_dNumPlayers = 1;
private static readonly int s_dMaxPlayers = 4;

internal static bool IsFull => PhotonNetwork.CountOfPlayers
internal static bool IsFull => (NumPlayers ?? s_dNumPlayers)
>= (MaxPlayers ?? s_dMaxPlayers);

internal static int? NumPlayers
=> PlayerHandler.instance?.players.Count;

internal static int? MaxPlayers =>
Traverse.Create(MainMenuHandler.SteamLobbyHandler)
.Field("m_MaxPlayers")
Expand Down
2 changes: 1 addition & 1 deletion src/PauseMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private static GameObject UIMenu
private static GameObject UIButtonList
=> UIMenu?.transform.Find("LIST")?.gameObject;

internal static bool AddMainButton(string name, string text, UnityAction action)
internal static bool AddButton(string name, string text, UnityAction action)
{
var uiButtonList = UIButtonList;
if (uiButtonList == null)
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
+= (player) => StartCoroutine(OnPlayerJoined(player));
}

PauseMenu.AddMainButton("FILL", "FILL LOBBY", OnFillPress);
PauseMenu.AddButton("FILL", "FILL LOBBY", OnFillPress);
}

private IEnumerator OnPlayerJoined(Player player)
Expand Down

0 comments on commit 719c3b2

Please sign in to comment.