Skip to main content

SpawnRate

A class in Root.Township, Alta.Populations.

Asset that sets how a creature or resource population grows back: respawn interval, a growth curve to the cap, density and how much is visible at once.

Constructors​

MemberWhat it is
SpawnRate()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

7 private and internal fields
MemberWhat it is
private AnimationCurve curveToMaxPopulationCurve of population (as a share of the cap) over normalized time to maximum.
private float durationToMaximumPopulationSeconds to grow from empty to the cap. Defaults to a day.
private float emergeRatePerMinuteBacking field for EmergeRatePerMinute.
private float maxPopulationPerSquareMeterBacking field for MapPopulationPerSquareMeter.
private const float PopulationGrowthVarianceRandom variance applied to each growth result (0.1).
private float respawnIntervalBacking field for RespawnInterval, in seconds.
private float visiblePopulationBacking field for VisiblePopulation.

Properties​

MemberWhat it is
float EmergeRatePerMinute { get; }Share of the total population that may emerge each minute, up to the visible amount, so cleared areas don't refill at once.
float MapPopulationPerSquareMeter { get; }Maximum population per square metre.
TimeSpan RespawnInterval { get; }Time between respawn ticks. Defaults to 60 seconds.
float VisiblePopulation { get; }Share of the population that can be visible at once (0 to 1).

Methods​

MemberWhat it is
int EvaluateGrowth(BasicPopulation population, TimeSpan elapsedSpan)Returns how many to add to a population after elapsed time, following the curve with 10% random variance. Stores leftover time when the result is zero.

Used in​

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