Skip to main content

MRK_ActivationLever

A class in Root.Township, the global namespace.

A pay-to-activate mechanism: filling the input dock with as many items as the cost dock shows makes it active, raises a column and fires events. The server decides; Refresh resets it.

Constructors​

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

Fields​

10 private and internal fields
MemberWhat it is
private AltaCoroutine columnAnimationThe running column animation coroutine.
private DurationCurve columnMovementDuration and curve for the column's height.
private Transform costColumnTransform moved up when active.
private PickupDock costDefinitionDock whose stored items set the price, both item type and amount.
private PickupDock costInputDock players pay into.
private Transform costOverflowTargetWhere extra items above the price are put.
private bool isActiveTrue once paid. Saved with the entity.
private UnityEvent onBecameActiveEvent raised when it becomes active, on server and clients.
private UnityEvent onBecameInactiveEvent raised when it's reset.
private MethodSyncStruct<bool> syncActiveMethod sync for the active state. Its value says whether clients snap instead of animate.

Methods​

MemberWhat it is
override void Initialize()Adds the input dock filter and creates the active state sync.
override void InitializeAsServer(SpawnData spawnData)Hooks docking on the input and snaps the column up if it loaded as active.
override void OnConnected(Player player)Sends a joining player the active state so their column snaps into place.
void Refresh()Server: destroys the paid items, becomes inactive, lowers the column and syncs.
5 private and internal methods
MemberWhat it is
private IEnumerator AnimateColumn() (iterator)Coroutine that moves the column up or down along columnMovement's curve.
private void CheckQuantity(Interactor interactor, Pickup pickup, PickupDock dock)Server: once the input holds enough, becomes active, pushes any extra items out to costOverflowTarget, animates and syncs.
private void FilterInput(Interactor interactor, Pickup pickup, ref bool result)Blocks docking while active, and allows only items the cost dock would accept.
private void StartAnimateColumn()Starts the column animation unless it's already running.
private void SyncActive(IPlayer player, Stream stream, bool isSnapping)Server to client sync of isActive. Client: snaps or animates the column and raises the matching event.