Skip to main content

RadialPopulationItem

A class in Root.Township, Alta.Populations.

Population member that leaves its population once it moves past the definition's disconnect radius, then gets chunked normally and stops being saved.

Constructors​

MemberWhat it is
RadialPopulationItem()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
static readonly UpdateModule distanceCheckUpdateModuleBudgeted update module shared by all items of this type for the distance check.
5 private and internal fields
MemberWhat it is
private Vector3 centerPosition of the population's parent, set in Initialize.
private ChunkDetector detectorThe entity's chunk detector, off while this item is tracked.
private bool isInitializedTrue after Initialize; the check does nothing before.
private float radiusSquaredThe definition's disconnect radius, squared.
private IUnityUpdateMethod updateHandle for the registered distance check.

Methods​

MemberWhat it is
override void Initialize()Server: marks the item ready and stores the parent's position and the squared disconnect radius.
3 private and internal methods
MemberWhat it is
private void CheckRadius()If the item is past the disconnect radius, removes it from the population, moves it to the best chunk for its position and sets its save mode to Ignore.
private void OnDisable()Stops the check, turns the chunk detector back on and recalculates the entity's chunk.
private void OnEnable()Turns off the entity's ChunkDetector and registers the distance check with a budgeted update.