Skip to main content

BasicPopulationFolder

A class in Root.Township, Alta.Populations.

Server-side population holder for an area, such as a forest chunk. Spawns from a PopulationSetup with density from its area, and can join its chunk's ecosystem.

Constructors​

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

Fields​

6 private and internal fields
MemberWhat it is
private PopulationSetup definitionThe population setup asset. Restored from save data on load.
private float densityBacking field for DensityMultiplier.
private bool isEcosystemIf set, the population joins its chunk's ecosystem when the entity is chunked.
private int? loadPopulationPopulation count from the save, held until it is applied.
private TimeSpan? loadTimeTimer value from the save, held until it is applied.
private float squareMetersBacking field for SquareMeters.

Properties​

MemberWhat it is
float AccumulatedTime { get; set; }Seconds of growth time carried over when a spawn check adds no one. Reset to 0 when the population grows. Saved.
PopulationSetup Definition { get; }The population setup to spawn from.
float DensityMultiplier { get; }Multiplier on the population density.
IPopulationManager Manager { get; private set; }The population manager built from the spawn data.
IPointNormalEvaluator PointEvaluator { get; private set; }The component on this object that picks spawn points and normals.
BasicPopulation Population { get; private set; }The live population.
float SquareMeters { get; }Area the population covers, for density.

Methods​

MemberWhat it is
override void InitializeAsServer(SpawnData spawnData)Server: creates the manager and population, and if it is an ecosystem, joins the chunk's ecosystem when added.
void Setup(PopulationSetup definition, float squareMeters, float density, bool isEcosystem)Sets the definition, area, density and ecosystem flag. Used by ForestPopulationCreator.
3 private and internal methods
MemberWhat it is
private void AddToEcosystem(Chunk chunk)Server: when added to a chunk, adds the population to the chunk's ecosystem, then next frame adopts existing members and restores or starts its timer.
private void OnDestroy()Removes the population from its chunk's ecosystem.
private void RemoveFromEcosystem(Chunk chunk)Stops the population timer and removes it from the chunk's ecosystem.