RobotFire/Assets/Scripts/Runtime/Networking/ServerPlayerSpawnPoints.cs
AderKonstantin b0eccf53b5 feat: add base functionality
Add ServerPlayerSpawnPoints.cs with its functionality
Add to Trooper OnServerSpawnPlayer() for spawning on SpawnPoint.
2024-12-09 17:43:02 +03:00

41 lines
831 B
C#

using System.Collections.Generic;
using UnityEngine;
public class ServerPlayerSpawnPoints : MonoBehaviour
{
[SerializeField]
List<GameObject> m_SpawnPoints;
static ServerPlayerSpawnPoints s_Instance;
public static ServerPlayerSpawnPoints Instance
{
get
{
if (s_Instance == null)
{
s_Instance = FindObjectOfType<ServerPlayerSpawnPoints>();
}
return s_Instance;
}
}
void OnDestroy()
{
s_Instance = null;
}
public GameObject ConsumeNextSpawnPoint()
{
if (m_SpawnPoints.Count == 0)
{
return null;
}
var toReturn = m_SpawnPoints[m_SpawnPoints.Count - 1];
m_SpawnPoints.RemoveAt(m_SpawnPoints.Count - 1);
return toReturn;
}
}