Skip to main content

LiquidGradualDrinker

A class in Root.Township, the global namespace.

Trigger component on a liquid container that slowly drains liquid out of another container held in its trigger (for example drinking from a bottle), instead of pouring. Server only.

Constructors​

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

Fields​

9 private and internal fields
MemberWhat it is
private ILiquidContainer containerDrinkingFromThe container liquid is currently drawn from, or null.
private int cooldownFrames left before an absent source cancels the transfer.
private const int CooldownResetFrames (35) the source container may be outside the trigger before the transfer is cancelled.
private HashSet<Component> handledRigidbodyOrCollidersRigidbodies or colliders currently inside the trigger, so each is handled once.
private bool isContainerDrinkingFromContainedTrue while the source container is inside the trigger.
private IUnityUpdateMethod outTransitionUpdateMethodHandle of the registered late update method, or null.
private IPourableContainer pourableContainerDrinkingFromThe source's IPourableContainer, whose pouring is turned off while drinking.
private LiquidContainer thisContainerThe container that receives the liquid.
private float transitionDurationSeconds a full transfer takes.

Methods​

10 private and internal methods
MemberWhat it is
private void CheckDisableTransitionUpdatingRoutine()Removes the late update method that progresses the transfer, if registered.
private void CheckEnableTransitionUpdatingRoutine()Registers UpdateOutTransition on the late update module, if not already registered.
private void HandleLiquidContainer(ILiquidContainer otherContainer)Starts drinking from a container: targets its out transition at this container, turns off its pouring and starts the update loop.
private void OnTriggerEnter(Collider other)Server: passes the entering collider's rigidbody (or the collider) to TriggerEnterInternal.
private void OnTriggerExit(Collider other)Server: passes the leaving collider's rigidbody (or the collider) to TriggerExitInternal.
private void RemoveOutTransitionAndStopUpdating()Ends drinking: turns pouring back on for the source, clears it and stops the update loop.
private void ResetOutTransition()Resets the source's unfinished out transition and detaches this receiver from it.
private void TriggerEnterInternal(Component target)Starts drinking from a new container that allows gradual consumption, or marks the current source as back inside.
private void TriggerExitInternal(Component component)Marks the current source container as no longer inside the trigger.
private void UpdateOutTransition()Each late update, moves liquid along the source's out transition, and stops when it finishes or the source has been out for CooldownReset frames.