ChunkDetector
A class in Root.Township, the global namespace.
Server: keeps a chunked entity in the right chunk by re-evaluating its chunk whenever its transform moves. Only runs while the entity has no parent chunker and isn't in the global chunk.
- Listed in Global namespace: C to D
- Inherits or implements
NetworkEntityBehaviour - Attributes
DisallowMultipleComponent,ExecuteInEditMode - Documented in Chunks
Constructors
| Member | What it is |
|---|---|
ChunkDetector() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
static uint Testing | Static counter not used anywhere in the game code. |
6 private and internal fields
| Member | What it is |
|---|---|
private Chunker chunker | The entity's Chunker. |
private static UpdateModule chunkUpdateModule | Shared update module that runs every detector's check during Update. |
private bool isEnabled | Backing field for IsEnabled. |
private static Logger logger | NLog logger for this class. |
private Transform targetTransform | Transform watched for movement. Set to this transform by default. |
private IUnityUpdateMethod update | Handle of the registered per-frame check, or null. |
Properties
| Member | What it is |
|---|---|
bool HasUpdate { get; } | True while the per-frame chunk check is registered. |
bool IsEnabled { get; set; } | Turns detection on or off. Can only be on for the server. |
Methods
| Member | What it is |
|---|---|
override void InitializeAsServer(SpawnData spawnData) | Schedules DelayInitialize for the next frame. |
7 private and internal methods
| Member | What it is |
|---|---|
private void CheckForChunkUpdate() | Per-frame update: re-evaluates the chunk if the target transform has changed. Logs and rethrows if the entity is gone. |
private void DelayInitialize() | One frame after server init, enables the component if the entity is still alive and has a real identifier. |
private bool EditorSetup() | Editor helper: sets the target transform to this one and disables the component by default. |
private void OnDisable() | Removes the update and the parent-change hook. |
private void OnEnable() | Gets the entity's chunker, starts checking if it has no parent, and watches for parent changes. |
private void RegisterUpdate() | Evaluates the chunk once, then registers the per-frame check (skipped for global-chunk entities). |
private void StartCheckingForChunkChange(Chunker oldChunkerParent, Chunker newChunkerParent) | Stops checking when the chunker gets a parent (the parent decides the chunk) and resumes when it's unparented. |
Used in
Members of other types that take, return or hold a ChunkDetector: