From 7d9175dfc7bd045386370bd67d8f4fd9f637962c Mon Sep 17 00:00:00 2001 From: Chris Langsenkamp Date: Wed, 27 May 2020 22:51:26 -0400 Subject: [PATCH] Moved GetStartPosition to correct region --- Assets/Mirror/Runtime/NetworkManager.cs | 50 ++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 182067e43..34ea9b67a 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -1092,6 +1092,31 @@ public static void UnRegisterStartPosition(Transform start) startPositions.Remove(start); } + /// + /// This finds a spawn position based on NetworkStartPosition objects in the scene. + /// This is used by the default implementation of OnServerAddPlayer. + /// + /// Returns the transform to spawn a player at, or null. + public Transform GetStartPosition() + { + // first remove any dead transforms + startPositions.RemoveAll(t => t == null); + + if (startPositions.Count == 0) + return null; + + if (playerSpawnMethod == PlayerSpawnMethod.Random) + { + return startPositions[UnityEngine.Random.Range(0, startPositions.Count)]; + } + else + { + Transform startPosition = startPositions[startPositionIndex]; + startPositionIndex = (startPositionIndex + 1) % startPositions.Count; + return startPosition; + } + } + #endregion #region Server Internal Message Handlers @@ -1306,31 +1331,6 @@ public virtual void OnServerAddPlayer(NetworkConnection conn) NetworkServer.AddPlayerForConnection(conn, player); } - /// - /// This finds a spawn position based on NetworkStartPosition objects in the scene. - /// This is used by the default implementation of OnServerAddPlayer. - /// - /// Returns the transform to spawn a player at, or null. - public Transform GetStartPosition() - { - // first remove any dead transforms - startPositions.RemoveAll(t => t == null); - - if (startPositions.Count == 0) - return null; - - if (playerSpawnMethod == PlayerSpawnMethod.Random) - { - return startPositions[UnityEngine.Random.Range(0, startPositions.Count)]; - } - else - { - Transform startPosition = startPositions[startPositionIndex]; - startPositionIndex = (startPositionIndex + 1) % startPositions.Count; - return startPosition; - } - } - // Deprecated 5/2/2020 /// /// Obsolete: Removed as a security risk. Use NetworkServer.RemovePlayerForConnection instead.