A class in Root.Township, Alta.Populations.
The older, simpler population type: keeps a folder of spawned items up to a cap set by area and density, and spawns more on a tick timer. Server side.
Constructors
Fields
2 private and internal fields
| Member | What it is |
|---|
private HashSet<BasicPopulationItem> items | The population items currently registered, added by Register and AdoptExisting and removed when an item is removed. |
private static Logger logger | NLog logger for this class. |
Properties
| Member | What it is |
|---|
PopulationSetup Definition { get; private set; } | The PopulationSetup with the spawn rate settings. |
IPopulationFolder Folder { get; private set; } | The folder entity the spawned items live under. |
int PopulationCap { get; } | Most items: population per square metre times the folder's area and density multiplier. |
TickTimer Timer { get; private set; } | Tick timer at the respawn interval that triggers CheckSpawn. |
int TotalPopulation { get; set; } | How many items the population counts as existing, visible or not. |
int VisiblePopulation { get; } | How many entities are actually in the folder now. |
Events
Methods
| Member | What it is |
|---|
void AdoptExisting() | Registers every entity already in the folder as a member, for example after loading. |
void CheckSpawn(TimeSpan elapsed) | Grows the total by the spawn rate for the elapsed time, then spawns members toward it, limited by the emerge rate. |
void Deregister(BasicPopulationItem item) | Removes an item and raises PopulationDecreased. Called when an item is removed. |
void LoadTime(TimeSpan time, int totalPopulation) | Restores the saved total and timer, then catches up spawning for the time since the save. |
void Register(BasicPopulationItem item) | Adds an item, listens for its removal and raises PopulationIncreased. |
void Replace(BasicPopulationItem basicPopulationItem, NetworkEntity replacement) | Swaps a member for a new entity, keeping it counted. Used when a population item is replaced, such as a grown plant. |
1 private and internal method
| Member | What it is |
|---|
private void CheckSpawn() | Grows the total by the spawn rate for the elapsed time, then spawns members toward it, limited by the emerge rate. |
Used in
Members of other types that take, return or hold a BasicPopulation:
BasicEcosystem.Add, BasicEcosystem.Get, BasicEcosystem.populations, BasicEcosystem.Remove, BasicPopulation.PopulationEventHandler.BeginInvoke, BasicPopulation.PopulationEventHandler.Invoke, BasicPopulationFolder.Population, BasicPopulationItem.Create, BasicPopulationItem.Population, IPopulationFolder.Population, SpawnRate.EvaluateGrowth, PopulationPath.Population.