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.
- Listed in World generation
- Inherits or implements
NetworkEntityBehaviour,IPopulationFolder,ISavable<BasicPopulationFolderSaveData>,ISavableSave<BasicPopulationFolderSaveData>,ISavableSaveBase - Derived types
BasicPopulationFolderSaveData
Constructors
| Member | What it is |
|---|---|
BasicPopulationFolder() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
6 private and internal fields
| Member | What it is |
|---|---|
private PopulationSetup definition | The population setup asset. Restored from save data on load. |
private float density | Backing field for DensityMultiplier. |
private bool isEcosystem | If set, the population joins its chunk's ecosystem when the entity is chunked. |
private int? loadPopulation | Population count from the save, held until it is applied. |
private TimeSpan? loadTime | Timer value from the save, held until it is applied. |
private float squareMeters | Backing field for SquareMeters. |
Properties
| Member | What 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
| Member | What 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
| Member | What 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. |