test week rc
This commit is contained in:
@@ -808,8 +808,37 @@ public class GameManager : NetworkBehaviour
|
||||
// LevelLoadManager.LoadLevel("MainMenu");
|
||||
}
|
||||
|
||||
|
||||
bool _thirdPlayerLeaveTriggered;
|
||||
|
||||
/// <summary>
|
||||
/// Called when the local client spawns into a match. If three <see cref="NetPlayer"/> instances exist
|
||||
/// (matchmaker sent an extra client into a full room), disconnect and return to the main menu.
|
||||
/// </summary>
|
||||
public void OnLocalPlayerJoinedMatch()
|
||||
{
|
||||
if (!isClient || _thirdPlayerLeaveTriggered)
|
||||
return;
|
||||
StartCoroutine(CoLeaveIfThirdPlayer());
|
||||
}
|
||||
|
||||
IEnumerator CoLeaveIfThirdPlayer()
|
||||
{
|
||||
const int maxFrames = 30;
|
||||
for (int i = 0; i < maxFrames; i++)
|
||||
{
|
||||
yield return null;
|
||||
if (FindObjectsByType<NetPlayer>(FindObjectsSortMode.None).Length >= 3)
|
||||
{
|
||||
_thirdPlayerLeaveTriggered = true;
|
||||
Logger.Log("Third player in a 2-player match (matchmaker bug); leaving to main menu.");
|
||||
if (LevelLoadManager.instance != null)
|
||||
LevelLoadManager.instance.Leave();
|
||||
else
|
||||
LevelLoadManager.LoadLevel("MainMenu");
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StopClient(){
|
||||
try{
|
||||
|
||||
Reference in New Issue
Block a user