public sealed class PlayerSpawnerGives a connection a body, and takes it away again.
Remarks
Unreal's AGameModeBase, minus the god object. That class owns spawning, class substitution, login, match state and the HUD; what is genuinely load-bearing in it is "when a player joins, make a controller, make a pawn, and put one in charge of the other", which is this. Everything else it owns already lives somewhere better here — the spawn is NetworkSpawner's, the ownership is NetworkOwnership's, the camera is PlayerCameras's, and match state is the game's.
Server side only. A client never decides who has a body; it is told, and LocalPlayerSystem is the half that notices. Splitting them means a dedicated-server build links this and a client build links that, rather than both linking one class with half its methods throwing.
[29](../../../docs/plan/29-players-and-possession.md) § Authority is the table this implements one row of.
Fields and properties (2)
public int CountHow many players have a controller.
public IEnumerable<PlayerId> PlayersThe players that have one.
Methods (6)
public PlayerSpawner(NetworkSpawner spawner)Gives a connection a body, and takes it away again.
public Entity ControllerOf(PlayerId player)The controller a player was given, or Null.
public Entity Join(World world, PlayerId player, string pawnAddress, LocalTransform? at = null, SceneHandle scene = default(SceneHandle))Gives a player a controller and a body, and possesses one with the other.
public Entity Respawn(World world, PlayerId player, string pawnAddress, LocalTransform? at = null, SceneHandle scene = default(SceneHandle))Gives a player a new body, keeping the controller they already had.
public bool Leave(World world, PlayerId player)Takes a player's body and controller away.
public void Clear()Forgets every player, for a server that is shutting a match down.
Used by (1)
- PlayerSpawnerTestsVixen.Net.Engine.Tests