Skip to main content

LogicFloatChangeOnBool

A class in Root.Township, Alta.Logic.

Logic component that moves a float output from a start value to an end value over time while powered, and optionally back when unpowered. Saves its progress.

Constructors​

MemberWhat it is
LogicFloatChangeOnBool()Creates a LogicFloatChangeOnBool with default values.

Fields​

12 private and internal fields
MemberWhat it is
private float currentProgressProgress from 0 to 1 along the current direction.
private float currentTimerTime waited since the last direction change.
private float endValueValue sent at the end of the move.
private bool errorMessagePostedStops the missing-sender warning from repeating.
private bool isPoweredWhether the input is on.
private float moveSpeedPerSecHow fast the value moves, in value units per second.
private bool movingForwardTrue while moving from start to end.
private bool oneWayWhen set, does not turn around at the end.
private bool returnToStartIfUnpoweredWhether to move back to the start value when power goes off.
private LogicFloatSender senderFloat sender the value is output on.
private float startValueValue sent at the start of the move.
private float timeBeforeMovingSeconds to wait before moving after a direction change.

Methods​

MemberWhat it is
void IsPowered(bool value)Sets the powered state; powering it on re-enables updates.
void Update()After waiting timeBeforeMoving, moves toward the end while powered, or back to the start while unpowered if returnToStartIfUnpowered.
4 private and internal methods
MemberWhat it is
private void Awake()Resets the missing-sender warning flag.
private bool Move()Advances progress by the move speed and sends the new value; returns false once it passes the end.
private void OnValueChanged()Sends the value for the current progress and direction through sender.
private void SwitchDirections(bool resetProgress)Flips the direction and resets the wait timer, optionally mirroring the progress.