Skip to main content

LightCluster

A class in Root.Township, the global namespace.

Cluster that drives one light by how many parts it holds. The server syncs the count and clients set the light intensity from a curve.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private PlatformLight clusterLightThe light driven by the count.
private AnimationCurve intensityOverQuantityCurve of light intensity against part count.
private MethodSyncStruct<int> syncCountSync message for the part count.

Methods​

MemberWhat it is
override void AddingFinished(SpawnData spawnData)After parts are added, syncs the new count and updates the light.
override void Initialize()Sets up the count sync message.
override void OnConnected(Player player)Server: sends the current count to a joining player.
protected override void RemoveInternal(NetworkEntity part)After a part is removed, syncs the new count and updates the light.
2 private and internal methods
MemberWhat it is
private void SyncCount(IPlayer player, Stream stream, int count)Sends the part count (0 to 31). Remote clients update the light.
private void UpdateCount(int count)Client: turns the light off at zero parts, otherwise sets its intensity from the curve.