Skip to main content

RockCluster

A class in Root.Township, the global namespace.

A Cluster of Rock parts that all share one BoulderDefinition. The server picks the definition and syncs it and the part list to clients; saved with RockClusterSaveData.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private BoulderDefinition definitionThe BoulderDefinition shared by every rock in the cluster. Saved.
private static Logger loggerNLog logger for this class.
private ObjectPipeline optionsObject pipeline that picks a BoulderDefinition for a freshly generated cluster.
private MethodSyncStruct<ClusterEntitiesRegisterArguments> syncMethod sync that sends the definition and part list to clients.

Methods​

MemberWhat it is
override void AddingFinished(SpawnData spawnData)Server: after all parts are added, sets them up and sends the definition and part IDs to the chunks.
override void Initialize()Creates the sync method sync on SyncA.
override void InitializeAsServer(SpawnData spawnData)Server: for newly generated spawns, picks a definition from options.
override void OnConnected(Player player)Server: sends the definition and part IDs to a joining player.
protected override void AddInternal(NetworkEntity part)Adds a part and, if the definition is known, defines the rock and makes the cluster its chunking parent.
4 private and internal methods
MemberWhat it is
private int GetTemporaryPartsIdentifiers()Writes the part entity IDs into the shared TemporaryUint256.array and returns how many it wrote.
private void Setup(NetworkEntity part)Defines one part's Rock with the cluster's definition and sets the cluster as its chunking parent.
private void SetupExisting(SpawnData spawnData)Sets up all current parts. Logs an error and picks a random definition if none is set.
private void Sync(IPlayer player, Stream stream, ClusterEntitiesRegisterArguments args)Serializes the definition hash and part IDs. Clients look up the definition and set up each part once it spawns.