GlobalPopulationDefinition
A class in Root.Township, Alta.Populations.
Server-only asset for a world-wide population: spawns its prefabs in random location chunks weighted by biome attributes, up to a cap. Also the global-population (globalpop) console module with list, spawned, set-size, teleport and teleport-to commands.
- Listed in World generation
- Inherits or implements
HashedGeneralValue<GlobalPopulationDefinition> - Derived types
GlobalPopulationDefinition - Nested types
PopulationInfo - Attributes
CreateAssetMenu,Module,ServerOnly,Alias,TypeConverter - Documented in Arguments and results, Populations and spawners
Constructors
| Member | What it is |
|---|---|
GlobalPopulationDefinition() | Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets. |
Fields
10 private and internal fields
| Member | What it is |
|---|---|
private AttributeImpact[] attributes | Biome attribute impacts multiplied together to weight which location chunks elements spawn in. |
private bool isSpawningOnAStar | Backing field for IsSpawningOnAStar. |
private int iterations | Backing field for Iterations. At least 1. |
private float maxAngleFromUpDot | Backing field for MaxAngleFromUpDot, set in the inspector as an angle from up. |
private int maxSpawned | Largest number of elements alive at once. CheckSpawned tops up to this; set-size changes it. |
private AnimationCurve perTickGrowthCurve | Curve sampled with a random value on each CheckSpawned to decide how many elements to add. |
private NetworkPrefab[] prefabs | Prefabs to spawn; each element picks one at random. |
private HashSet<SpawnedElement> spawned | The live spawned elements. Null until Initialize runs. |
private int startingPopulation | Number spawned at StartUp when the timer spawns on initialize. |
private PopulationTimerDefinition timer | Timer definition that drives respawn checks and how long elements last before decaying. |
Properties
Methods
| Member | What it is |
|---|---|
void CheckSpawned() | If below the cap, spawns a random amount taken from the per-tick growth curve. |
void Clean() | Tears down the population's timer. |
void CleanElement(SpawnedElement element) | Removes one spawned element from the population, freeing a slot. |
void Initialize() | Creates the set of spawned elements if it doesn't exist yet. |
void StartUp() | Spawns the starting population if the timer says to, then sets up the growth timer. |
6 private and internal methods
| Member | What it is |
|---|---|
private static IEnumerable<LocationChunk> GetSpawned(GlobalPopulationDefinition population) | Console command globalpop spawned: lists the location chunks of a population's spawned elements. |
private static IEnumerable<GlobalPopulationDefinition.PopulationInfo> ListPopulations() | Console command globalpop list: lists every global population with its hash, name, spawned count and max size. |
private static void SetSize(GlobalPopulationDefinition population, int maxSpawned) | Console command globalpop set-size: sets the population's max size and spawns up to it straight away. |
private void SpawnQuantity(int toSpawn) | Spawns the given number of elements, each in a random location chunk weighted by the biome attributes. |
private static async Task TeleportToPopulationItem(Player player, GlobalPopulationDefinition population, float distanceAway = 3) | Console command globalpop teleport: teleports the player near a spawned element, force loading its chunk if none are loaded. |
private static async Task TeleportToSpecificPopulationItem(Player player, GlobalPopulationDefinition population, int index, float distanceAway = 3) | Console command globalpop teleport-to: teleports the player near the spawned element at the given index. |
Used in
Members of other types that take, return or hold a GlobalPopulationDefinition:
DayNightOnlyTimerDefinition.activePopulations, DayNightOnlyTimerDefinition.Clean, DayNightOnlyTimerDefinition.Setup, FrequencyTimerDefinition.Clean, FrequencyTimerDefinition.entries, FrequencyTimerDefinition.Setup, GlobalPopulationDefinition.PopulationInfo.op_Implicit, GlobalPopulationsManager.populations, PopulationTimerDefinition.Clean, PopulationTimerDefinition.Setup, SpawnedElement.populationDefinition, SpawnedElement.SpawnedElement.