mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkLobbyManager.OnValidate simplified by using Mathf.Clamp/Min/Max
This commit is contained in:
parent
dd6f47a82d
commit
0c89e11c9f
@ -43,30 +43,9 @@ struct PendingPlayer
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
if (m_MaxPlayers <= 0)
|
||||
{
|
||||
m_MaxPlayers = 1;
|
||||
}
|
||||
|
||||
if (m_MaxPlayersPerConnection <= 0)
|
||||
{
|
||||
m_MaxPlayersPerConnection = 1;
|
||||
}
|
||||
|
||||
if (m_MaxPlayersPerConnection > maxPlayers)
|
||||
{
|
||||
m_MaxPlayersPerConnection = maxPlayers;
|
||||
}
|
||||
|
||||
if (m_MinPlayers < 0)
|
||||
{
|
||||
m_MinPlayers = 0;
|
||||
}
|
||||
|
||||
if (m_MinPlayers > m_MaxPlayers)
|
||||
{
|
||||
m_MinPlayers = m_MaxPlayers;
|
||||
}
|
||||
m_MaxPlayers = Mathf.Max(m_MaxPlayers, 1); // > 1
|
||||
m_MaxPlayersPerConnection = Mathf.Clamp(m_MaxPlayersPerConnection, 1, maxPlayers); // [1, maxPlayers]
|
||||
m_MinPlayers = Mathf.Clamp(m_MinPlayers, 0, m_MaxPlayers); // [0, maxPlayers]
|
||||
|
||||
if (m_LobbyPlayerPrefab != null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user