mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Moved GetStartPosition to correct region
This commit is contained in:
parent
9ae7fa2a8c
commit
7d9175dfc7
@ -1092,6 +1092,31 @@ public static void UnRegisterStartPosition(Transform start)
|
||||
startPositions.Remove(start);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This finds a spawn position based on NetworkStartPosition objects in the scene.
|
||||
/// <para>This is used by the default implementation of OnServerAddPlayer.</para>
|
||||
/// </summary>
|
||||
/// <returns>Returns the transform to spawn a player at, or null.</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This finds a spawn position based on NetworkStartPosition objects in the scene.
|
||||
/// <para>This is used by the default implementation of OnServerAddPlayer.</para>
|
||||
/// </summary>
|
||||
/// <returns>Returns the transform to spawn a player at, or null.</returns>
|
||||
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
|
||||
/// <summary>
|
||||
/// Obsolete: Removed as a security risk. Use <see cref="NetworkServer.RemovePlayerForConnection(NetworkConnection, bool)">NetworkServer.RemovePlayerForConnection</see> instead.
|
||||
|
Loading…
Reference in New Issue
Block a user