Skip to main content

AutoContainerLid

A class in Root.Township, the global namespace.

Server component that puts a liquid container's lid back on automatically: when it's docked, or a few seconds after a player lets go of it.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private Pickup containerPickupThe container's pickup.
private bool isClosingIfEmptyIf true, the lid closes even when the container is empty.
private LiquidContainerLid lidThe lid component on this object.
private AltaCoroutine relidCoroutineThe running recork coroutine, if any.
private float relidTimerSeconds after release before the lid goes back on (5 by default).

Methods​

MemberWhat it is
override void InitializeAsServer(SpawnData spawnData)Server: hooks the pickup's dock and interaction events, and the content level change unless isClosingIfEmpty.
6 private and internal methods
MemberWhat it is
private void AddLid(Interactor interactor, Pickup pickup, PickupDock dock)Closes the lid if it's off and the container isn't empty (or isClosingIfEmpty is set). The overload is the dock handler.
private void AddLid()Closes the lid if it's off and the container isn't empty (or isClosingIfEmpty is set). The overload is the dock handler.
private void ContentLevelChanged(ILiquidContainer container, int oldLevel, int newLevel)When the container gains liquid while nobody holds it, closes the lid now if docked or starts the delayed recork.
private void InteractionEnded(Interactable interactable, Interactor interactor)Starts the delayed recork when the container is released undocked.
private void InteractionStarted(Interactable interactable, Interactor interactor)Cancels a pending recork when someone grabs the container.
private IEnumerator Recork() (iterator)Coroutine: waits relidTimer seconds, then closes the lid.