Skip to main content

DayNightOnlyTimerDefinition

A class in Root.Township, Alta.Populations.

Population timer asset that checks its populations only when night starts (or day, if spawnOnlyDuringNight is off). Spawned elements decay after one night or day.

Constructors​

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

Fields​

2 private and internal fields
MemberWhat it is
private HashSet<GlobalPopulationDefinition> activePopulationsPopulations using this timer.
private bool spawnOnlyDuringNightTrue spawns at night, false spawns during the day.

Properties​

MemberWhat it is
override float ElementDecayTime { get; }The night duration, or the day duration when spawning during the day.
override bool SpawnOnInitialize { get; }Always false: these populations wait for the right time of day.

Methods​

MemberWhat it is
override void Clean(GlobalPopulationDefinition population)Removes a population and unhooks from night changes when none are left.
override void Setup(GlobalPopulationDefinition population)Adds a population. The first one hooks GameTimeManager.NightChanged and checks straight away.
1 private and internal method
MemberWhat it is
private void CheckSpawnedInternal(bool isNight)On a day or night change, runs CheckSpawned on every active population if the new time matches.