Cluster
A class in Root.Township, the global namespace.
A network entity that groups child entities (its parts) and destroys itself on the server once every part is gone. On server spawn it collects the network prefabs under its transform.
- Listed in Global namespace: C to D
- Inherits or implements
NetworkEntityBehaviour - Derived types
LightCluster,RockCluster
Constructors
| Member | What it is |
|---|---|
Cluster() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
protected HashSet<NetworkEntity> parts | The entities currently in the cluster. |
Methods
| Member | What it is |
|---|---|
void Add(NetworkEntity part, bool isSingle, SpawnData spawnData) | Adds an entity as a part and watches for it being destroyed. Pass isSingle true to call AddingFinished straight after. |
virtual void AddingFinished(SpawnData spawnData) | Hook for subclasses, called once the parts have been added. Does nothing by default. |
virtual void CheckDestroy() | Server: destroys the cluster entity if it has no parts left. |
override void InitializeAsServer(SpawnData spawnData) | Adds every child network prefab as a part, makes the cluster their chunking parent, then calls AddingFinished. |
void Remove(NetworkEntity part) | Removes a part, calls RemoveInternal, then CheckDestroy. Also runs when a part is destroyed. |
protected virtual void AddInternal(NetworkEntity part) | Hook for subclasses, called when a new part is added. |
protected virtual void RemoveInternal(NetworkEntity part) | Hook for subclasses, called when a part is removed. |
1 private and internal method
| Member | What it is |
|---|---|
private void Remove(NetworkEntity part, bool isUnloading) | Removes a part, calls RemoveInternal, then CheckDestroy. Also runs when a part is destroyed. |
Used in
Members of other types that take, return or hold a Cluster: