Skip to main content

LinearPartCloner

A class in Root.Township, the global namespace.

Networked, saved part that clones its last copy in a row with a fixed offset and rotation, up to a count. The server syncs the count to clients.

Constructors​

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

Fields​

8 private and internal fields
MemberWhat it is
private bool isOffsetRelativeToLastWhen true the offset is in the last copy's local space, otherwise added to its local position.
private Transform lastThe latest copy, cloned for the next one. Nothing in this file sets it first, so template looks unused.
private Vector3 offsetPosition offset from one copy to the next.
private Vector3 rotationExtra rotation (Euler) for each copy.
private LinearPartClonerData saveDataSaved data holding the count.
private int spawnedCountHow many parts exist, counting the original.
private MethodSync syncMethod sync for the count (SyncCount).
private Transform templateNot read in this file.

Methods​

MemberWhat it is
override void Initialize()Sets up the count sync.
override void OnConnected(Player player)Sends the current count to a joining player.
void Spawn(int count)Sets the count and clones copies until it is reached. Server: also sends the count to clients. Copies are hidden and not saved.
3 private and internal methods
MemberWhat it is
private void OnValidate()Editor: respawns copies on a prefab instance when the count changed.
private void Regenerate()Editor context menu: respawns copies on a prefab instance.
private void SyncCount(IPlayer player, Stream stream)Writes the count (1 to 255) or, on a client, reads it and spawns copies.

Used in​

Members of other types that take, return or hold a LinearPartCloner: