NetworkLobbyManager.OnValidate simplified by using Mathf.Clamp/Min/Max

This commit is contained in:
vis2k 2018-06-10 15:01:11 +02:00
parent dd6f47a82d
commit 0c89e11c9f

View File

@ -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)
{