Skip to main content

Belt

A class in Root.Township, the global namespace.

A pulley belt in the mechanical power system: a Turnable that wraps the outside of its connected pulleys and flips spin direction for pulleys inside it.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private List<Turnable> exteriorConnected turnables the belt wraps around the outside of. Set in the editor by EvaluateExterior.
private float offsetBacking field for Offset.
private float rotationBacking field for Rotation.
private float speedMultiplierSerialized speed multiplier. Not read anywhere in this class.

Properties​

MemberWhat it is
float Offset { get; }Belt offset passed to the exterior calculation.
float Rotation { get; }How far the belt has turned so far.

Events​

MemberWhat it is
event Action RotatedRaised each frame the belt's rotation changes, probably so visuals can scroll the belt.

Methods​

MemberWhat it is
override void BranchUpdate(Turnable from, ref float totalTorque, ref float totalMoi, HashSet<Turnable> cluster, ref bool isJammed, bool isFlipped = false)Flips direction when the update comes from a turnable not on the exterior, then runs the base update.
protected override void BranchToConnected(ref float totalTorque, ref float totalMoi, HashSet<Turnable> cluster, ref bool isJammed, bool isFlipped)Passes the torque update to each connected turnable, flipped when that turnable is on the belt's exterior.
protected override void Rotate()Advances rotation from the current speed and fires Rotated, when the belt is moving.
1 private and internal method
MemberWhat it is
private bool EvaluateExterior()Editor helper: recalculates which connected pulleys the belt wraps around the outside of. Returns true if that changed.

Used in​

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