A class in Root.Township, ATT.Domains.
A private space for one player, spawned by DomainController below the map (y -200, spaced 400 apart). The micro tutorial uses one: the player's body is despawned and respawned inside, then returned to where they entered.
Constructors
| Member | What it is |
|---|
Domain() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
7 private and internal fields
| Member | What it is |
|---|
private LocationChunk chunk | Backing field for Chunk, the location chunk the domain's players spawn into. |
private const float DefaultPlayerYSpawnOffset | Height above the domain's position used for the default spawn point: 1.5 metres. |
private IDomainController domainController | Domain controller injected by VContainer, used by DestroyDomain. |
private static readonly Logger logger | NLog logger for this class. |
private NetworkPrefab networkPrefab | Backing field for NetworkPrefab. |
private readonly Dictionary<IPlayer, SpawnPoint> playerEntryPoints | Where each player was before entering, used by GetPlayerEntryPoint to send them back. |
private SpawnPoint? spawnPoint | Backing field for SpawnPoint. When unset, the getter fills it from the domain's own position plus 1.5 metres up. |
Properties
| Member | What it is |
|---|
LocationChunk Chunk { get; } | The domain's own location chunk, registered when the domain is created. |
NetworkPrefab NetworkPrefab { get; } | The domain's network prefab. |
IPlayer Player { get; private set; } | The player this domain belongs to. |
SpawnPoint SpawnPoint { get; set; } | Where players spawn inside the domain. Defaults to 1.5 m above the domain's origin. |
Methods
| Member | What it is |
|---|
async Task DestroyDomain() | Asks the domain controller to destroy this domain. |
SpawnPoint GetPlayerEntryPoint(IPlayer player) | Where the player was before entering, to send them back. Falls back to a random respawn point and logs an error. |
void Inject(IDomainController injectedDomainController) | Dependency injection hook that receives the IDomainController. |
void RegisterPlayerEntry(IPlayer player, SpawnPoint entryPoint) | Records where a player entered from. |
void SetPlayer(IPlayer player) | Sets the owning player. Called by the domain controller. |
void SetSpawnPoint(Transform reference) | Sets where players spawn inside the domain from a transform. |
async void SpawnPlayer(IPlayer iPlayer) | Saves the player's current spot as their entry point, despawns their body and spawns a new one at the domain's spawn point. |
2 private and internal methods
| Member | What it is |
|---|
private void DespawnPlayerController(Player player) | Records where the player was as their entry point, saves them and destroys their controller. Uses Add, so a second entry for the same player throws. |
private void MovePlayerToSpawnPoint() | Moves the domain's Player (set by SetPlayer) to the spawn point and turns them to face its direction. |
Used in
Members of other types that take, return or hold a Domain:
DomainController.CreateDomain, DomainController.CreateDomainForPlayer, DomainController.DeregisterDomain, DomainController.DestroyDomain, DomainController.domainOffsetMap, DomainController.GetDomainForPlayer, DomainController.GetDomainIndex, DomainController.universalDomainPrefab, IDomainController.CreateDomainForPlayer, IDomainController.DestroyDomain, IDomainController.GetDomainForPlayer, MicroTutorial.domain, PlayerInPositionObserver.domain, PrefabInPositionObserver.domain.