43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using ProjectM.Simulation;
|
|
using Unity.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Authoring
|
|
{
|
|
/// <summary>
|
|
/// Authoring placed once in the gameplay subscene. Bakes a <see cref="PlayerSpawner"/> singleton
|
|
/// holding the player ghost prefab entity and a spawn point, which the server's
|
|
/// GoInGameServerSystem instantiates on each connect.
|
|
/// </summary>
|
|
public class PlayerSpawnerAuthoring : MonoBehaviour
|
|
{
|
|
[Tooltip("The Player ghost prefab to spawn for each connected client.")]
|
|
public GameObject PlayerPrefab;
|
|
|
|
public Vector3 SpawnPoint = Vector3.zero;
|
|
|
|
[Tooltip("Radius (m) of the co-op spawn ring; players land on distinct slots so they don't stack.")]
|
|
public float SpawnRingRadius = 2.5f;
|
|
|
|
[Tooltip("Evenly-spaced ring positions before players spill onto an outer ring.")]
|
|
public int RingSlots = 4;
|
|
|
|
private class PlayerSpawnerBaker : Baker<PlayerSpawnerAuthoring>
|
|
{
|
|
public override void Bake(PlayerSpawnerAuthoring authoring)
|
|
{
|
|
// The spawner itself needs no transform; it is a data singleton.
|
|
var entity = GetEntity(authoring, TransformUsageFlags.None);
|
|
|
|
AddComponent(entity, new PlayerSpawner
|
|
{
|
|
PlayerPrefab = GetEntity(authoring.PlayerPrefab, TransformUsageFlags.Dynamic),
|
|
SpawnPoint = authoring.SpawnPoint,
|
|
SpawnRingRadius = authoring.SpawnRingRadius,
|
|
RingSlots = authoring.RingSlots
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|