A class in Root.Township, the global namespace.
Tracks which chunk a network entity is in, its chunking parent and children, and which players it is spawned for. Every NetworkEntity has one; you usually use the entity's own chunk members instead.
Constructors
Fields
6 private and internal fields
| Member | What it is |
|---|
private readonly HashSet<Chunker> children | Chunkers parented to this one. They follow this chunker into whatever chunk it moves to. |
private readonly IChunkedEntity chunkedEntity | The entity as IChunkedEntity, told when its parent changes. |
private readonly HashSet<Player> despawningFor | Players whose despawn is waiting on a chunk move; finished in SetChunkInternal. |
private static readonly Logger logger | NLog logger for this class. |
private Chunker parent | Backing field for Parent. |
private readonly HashSet<Player> spawningFor | Players whose spawn is waiting on a chunk move; finished in SetChunkInternal. |
Properties
| Member | What it is |
|---|
int ChildCount { get; } | Number of chunking children. |
IEnumerable<Chunker> Children { get; } | Chunkers that follow this one's chunk. |
Chunk Chunk { get; private set; } | The chunk the entity is in, or null. |
bool IsServerOnly { get; private set; } | Whether the entity is kept off clients. |
NetworkEntity NetworkEntity { get; } | The entity this chunker belongs to. |
Chunker Parent { get; private set; } | The chunking parent; children always take the parent's chunk. |
HashSet<Player> SpawnedForPlayers { get; } | Players the entity is currently spawned for. |
Events
Methods
| Member | What it is |
|---|
void EditorEvaluateChunk(FastChunkLookup chunkLookup) | Editor: puts a root prefab entity into the chunk containing its position. |
void EvaluateChunk() | Server: moves a root entity to the chunk holding its position. Still chunkless on the next check, it is unloaded (player-held pickups go to their postbox). |
void EvaluateChunk(bool isLoggingOnFailure) | Server: moves a root entity to the chunk holding its position. Still chunkless on the next check, it is unloaded (player-held pickups go to their postbox). |
void SetChunk(Chunk newChunk) | Moves the entity (and its children) to a chunk. On the server this is ignored for entities with a chunking parent. |
void SetParent(Chunker target, bool isDestroying = false) | Sets the chunking parent (null to clear) and moves to its chunk. |
void SetServerOnly(bool isServerOnly) | Hides the entity from every player, or spawns it for the players in its chunk again. |
6 private and internal methods
| Member | What it is |
|---|
private void IChunker.EndDespawn(Player target, bool isUnloading, bool isChunkSync) | Explicit IChunker method: sends the entity destroyed message to the player for prefab entities. |
private void IChunker.EndSpawn(Player target, bool isChunkSync) | Explicit IChunker method: sends the initial serialization for serialized entities and runs OnConnected for the player. |
private async void PostToPlayer(LocationChunk oldChunk, Vector3 position, int playerId) | Pushes the entity into the postbox of the player who last held it, used when it falls out of every chunk. |
private void SetChunkInternal(Chunk newChunk) | Moves the entity and its child chunkers to a chunk, finishes pending spawns and despawns, and fires EnteredChunk and LeftChunk. |
private bool IChunker.StartDespawn(Player target, bool hasMovedChunks, bool isChunkSync) | Explicit IChunker method: removes the player from SpawnedForPlayers and runs OnDisconnected on the entity. |
private bool IChunker.StartSpawn(Player target, bool hasMovedChunks, bool isChunkSync) | Explicit IChunker method: adds the player to SpawnedForPlayers and sends the spawn message for prefab entities. |
Used in
Members of other types that take, return or hold a Chunker:
EntitySerializer.chunker, IChunkedEntity.Chunker, NetworkEntity.Alta.Networking.IChunkedEntity.Chunker, NetworkEntity.chunker, NetworkEntity.Chunker, NetworkPrefab.AccumulateChildPrefabs, ChunkDetector.chunker, ChunkDetector.StartCheckingForChunkChange, ChunkerChangedHandler.BeginInvoke, ChunkerChangedHandler.Invoke, IChunker.Children, IChunker.Parent.