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.
- Listed in Global namespace: I to L
- Inherits or implements
MonoBehaviour,ILiquidTransitionController
Constructors
| Member | What it is |
|---|---|
LiquidGradualDrinker() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private ILiquidContainer containerDrinkingFrom | The container liquid is currently drawn from, or null. |
private int cooldown | Frames left before an absent source cancels the transfer. |
private const int CooldownReset | Frames (35) the source container may be outside the trigger before the transfer is cancelled. |
private HashSet<Component> handledRigidbodyOrColliders | Rigidbodies or colliders currently inside the trigger, so each is handled once. |
private bool isContainerDrinkingFromContained | True while the source container is inside the trigger. |
private IUnityUpdateMethod outTransitionUpdateMethod | Handle of the registered late update method, or null. |
private IPourableContainer pourableContainerDrinkingFrom | The source's IPourableContainer, whose pouring is turned off while drinking. |
private LiquidContainer thisContainer | The container that receives the liquid. |
private float transitionDuration | Seconds a full transfer takes. |
Methods
10 private and internal methods
| Member | What 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. |