A class in Root.Township, Alta.Populations.
Server: one slot of a global population in a location chunk. It picks a spot, spawns the prefab when the chunk is fully loaded, and can decay after a set time.
Constructors
Fields
9 private and internal fields
| Member | What it is |
|---|
private Timeline.IEntry decay | Timeline entry for the decay timer, or null when there is none. |
private NetworkEntity entity | Backing field for Entity. |
private bool hasDecayed | Set when the decay timer ended while the entity was alive. |
private bool hasRaycasted | Whether the spawn position and rotation were already picked. They're reused on later respawns. |
private LocationChunk locationChunk | Backing field for LocationChunk. |
private GlobalPopulationDefinition populationDefinition | The global population definition that owns this slot. |
private Vector3 position | Picked spawn position. |
private NetworkPrefab prefab | Prefab spawned for this slot. |
private Quaternion rotation | Picked spawn rotation: random yaw, aligned to the ground normal unless on A*. |
Properties
| Member | What it is |
|---|
NetworkEntity Entity { get; } | The spawned entity, or null when it isn't spawned (chunk not loaded, or it was destroyed). |
LocationChunk LocationChunk { get; } | The location chunk this slot belongs to. |
Methods
| Member | What it is |
|---|
void Initialize() | Spawns now if the chunk is fully loaded, and again each time it fully loads. |
4 private and internal methods
| Member | What it is |
|---|
private void Decay() | Runs when the decay timer ends. Removes the slot now if nothing is spawned, else marks it to go when the entity next unloads or dies. |
private void Destroy() | Cancels the decay timer, removes the slot from its population definition and unhooks from the chunk. |
private void EntityDestroyed(NetworkEntity entity, bool isUnload) | When the entity goes, ends the slot unless it was only a chunk unload of an undecayed slot. Clears entity either way. |
private void SpawnElement(Chunk chunk) | Finds a spot the first time (raycast, or nearest A* node), then spawns the prefab there with save mode set to ignore. |
Used in
Members of other types that take, return or hold a SpawnedElement: