Skip to main content

PopulationPath

A class in Root.Township, the global namespace.

Server: a path edge that spawns and keeps a population of creatures along it, using a PopulationSetup picked at generation. Saves its timer and count.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private float densityMultiplierScales how many creatures the path holds.
private int? loadPopulationPopulation count from the save, used once when the path next joins a chunk.
private TimeSpan? loadTimeTimer value from the save, used once when the path next joins a chunk.
private ObjectPipeline populationPipeline that picks the PopulationSetup at generation.
private float widthMultiplierScales how far from the path's center line spawn points can be (0 to 1.5).

Properties​

MemberWhat it is
float AccumulatedTime { get; set; }Spawn time built up by the population. Saved.
PopulationSetup Definition { get; private set; }The population setup in use, chosen from the pipeline on first generation or loaded from the save.
float DensityMultiplier { get; }Scales how many creatures the path holds.
float EndRadius { get; }Width of the usable path at its end, after the end node's radius.
IPopulationManager Manager { get; private set; }The population manager for this path.
IPointNormalEvaluator PointEvaluator { get; }This path, used to pick spawn points.
BasicPopulation Population { get; private set; }The population living on this path.
float SquareMeters { get; }Rough area of the path between the two end nodes.
float StartRadius { get; }Width of the usable path at its start, after the start node's radius.

Methods​

MemberWhat it is
PointNormal? GetPoint()A random spawn point on the terrain inside the path's area, with the ground normal.
override void InitializeAsServer(SpawnData spawnData)Picks the population setup and starts the population once the entity is in a chunk.
2 private and internal methods
MemberWhat it is
private void AddedToChunk(Chunk chunk)A frame after joining a chunk, adopts existing creatures and either restores the saved timer or starts it and checks for spawns.
private void RemovedFromChunk(Chunk chunk)Stops the population timer while the path is out of a chunk.