Nebula
World partition

ChunkStateEntity

The entity that carries one chunk's ChunkState entries.

generated from the sources
[DisallowMultipleComponent]
[AddComponentMenu("")]
public sealed class ChunkStateEntity : NetworkBehaviour

The entity that carries one chunk's ChunkState entries. Nebula spawns it from a built-in prefab (PrefabId) in the chunk's container the first time an object in the chunk gets an entry, and despawns it, deleting its record, when the last entry is gone. A game never adds this component or spawns the entity itself; it reads through ChunkState and writes through ChunkStateService.

The entries replicate through a NetworkMap<TKey, TValue>, so a change sends only the entries that changed, and the gateway keeps the current contents for clients that arrive later (docs/replicated-collections.md D15). They are saved through NetworkBehaviour.WritePersistentState, so the entity's PersistentEntity record is the chunk's record in the store.

Constructors

ChunkStateEntity

public ChunkStateEntity();

Fields

PrefabId

public const ushort PrefabId = NetworkPrefabs.ChunkStatePrefabId;

The built-in network prefab id of the chunk state entity. Reserved in NetworkPrefabs; no game list uses it.

PrefabName

public const string PrefabName = "NebulaChunkState";

Name of the built-in prefab, and of the prefab saved in the entity's records.

Properties

ContainerId

public string ContainerId { get; } = "";

The id of the container (chunk) whose state this entity carries. Empty before it spawns.

EntryCount

public int EntryCount { get; }

How many entries the entity holds, including ones whose expiry time has passed but that are not removed yet.

EncodedBytes

public int EncodedBytes { get; }

The encoded size of the entries, in bytes. At most ChunkState.MaxEncodedBytes.

IsEmpty

public bool IsEmpty { get; }

Whether the entity holds no entries.

Methods

WritePersistentState

public override void WritePersistentState(NetworkWriter writer);

ReadPersistentState

public override void ReadPersistentState(NetworkReader reader);

OnNetworkSpawn

public override void OnNetworkSpawn();

OnNetworkDespawn

public override void OnNetworkDespawn();

OnGainedAuthority

public override void OnGainedAuthority();

On this page