Skip to main content

PopulationFolderBase

A class in Root.Township, Alta.Populations.

Base for a networked object that owns a population (a group of spawned creatures or objects), and raises inspector events when it starts, dies out or is full.

Constructors​

MemberWhat it is
PopulationFolderBase()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
protected Dictionary<int, PopulationFolderBase.SerializedChild> serializedentitiesSpawnPointLoaded child entities by spawn point, kept until Initialize adds them to the population.
3 private and internal fields
MemberWhat it is
private PopulationEvent OnPopulationDiedOutUnity event raised when the population sample dies out.
private PopulationEvent OnPopulationMaxedUnity event raised when the population sample reaches its maximum.
private PopulationEvent OnPopulationStartedUnity event raised when the population starts, and straight away in SetSample if it already has members.

Properties​

MemberWhat it is
uint Hash { get; }The population definition's hash.
PopulationSample Population { get; protected set; }The population sample: what's spawned and how many.
virtual PopulationDefinition PopulationDefinition { get; protected set; }What this population spawns. Taken from Population unless a subclass overrides it.
protected virtual bool AddToEcosystem { get; }Whether the population joins the chunk's Ecosystem when the entity is added to a procedural chunk. True by default.

Methods​

MemberWhat it is
void Initialize(LocationChunk chunk, ISpawnSystem spawner)Server: initializes the population for a chunk and spawner, and adds back any loaded children at their spawn points.
override void InitializeAsServer(SpawnData spawnData)Server: hooks up joining the ecosystem when the entity is added to a chunk.
void SetSample(PopulationSample sample)Sets the population sample once and hooks its events to the inspector events. A second sample is destroyed with an error.
1 private and internal method
MemberWhat it is
private void TryAddToEcosystem(Chunk chunk)Server: when added to a procedural chunk, registers this population with the chunk's Ecosystem.

Used in​

Members of other types that take, return or hold a PopulationFolderBase: