test week rc

This commit is contained in:
2026-05-29 10:02:24 +05:30
parent 0a1d3c7262
commit d62bf9e06b
6 changed files with 129 additions and 68 deletions
+30 -1
View File
@@ -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{