TeamSpawnConfig.cs
using Sandbox;
using System.Linq;
public sealed class TeamSpawnConfig : Sandbox.Component
{
public GameObject GetSpawnForTeam( ButtonMasherPlayerController.TeamType team )
{
var matchingSpawns = GameObject.Scene.GetAllComponents<TeamSpawnPoint>()
.Where( s => s.Team == team && s.GameObject.IsValid() )
.Select( s => s.GameObject )
.ToArray();
if ( matchingSpawns.Length == 0 )
return null;
if ( matchingSpawns.Length == 1 )
return matchingSpawns[0];
return matchingSpawns[Game.Random.Int( 0, matchingSpawns.Length - 1 )];
}
}