Skip to main content

PourableContainer

A class in Root.Township, Alta.Liquid.

Lets a liquid container pour when tilted. Each frame it reads pouring strength, drives the pour particles, and on the server moves liquid to whichever container the particles hit most (or spills it into the global container).

Constructors​

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

Fields​

16 private and internal fields
MemberWhat it is
private ILiquidContainer containerBacking field for InternalContainer.
private float containerLipRadiusRadius of the container's lip, used to place the particles.
private float currentPouringStrengthPouring strength computed this frame.
private Dictionary<ILiquidContainer, int> destinationContainerHitCountsParticle hits per container since the last recheck.
private bool isFullyPouringSet by the strength controller when the container is fully tipped; particles then pour fully.
private bool isMovingParticlesToLowestPointOnLipIf true, particles are moved to the lowest point on the lip each frame.
private float minPouringStrengthToDetectStrength below which nothing pours and particles are released.
private PooledObjectDefinition overridePouringParticlesParticles to use instead of the default from LiquidSettings.
private AltaCoroutine pouringCoroutineThe running UpdatePouringTransition coroutine, or null.
private float pouringParticlePouringMultiplierMultiplier from pouring strength to particle strength.
private PouringParticles pouringParticlesCurrent pour particles, or null when not pouring.
private float pouringParticlesAmountSerialized but not read by this class.
private Transform pouringParticlesParentTransform the pour particles attach to.
private PouringStrengthController pouringStrengthControllerWorks out pouring strength from the container's tilt.
private float pouringStrengthMultiplierForParticlesSerialized but not read by this class.
private float timeToRecheckPouringDestinationSeconds between retargeting the destination container.

Properties​

MemberWhat it is
ILiquidContainer InternalContainer { get; }The ILiquidContainer on the same object.
bool IsActive { get; set; }When false, pouring strength is zero and no liquid moves. Defaults to true.
bool IsSubmergedInOtherContainer { get; set; }Set by liquid triggers while this container is dunked in another; stops pouring.

Methods​

MemberWhat it is
void RegisterPouringParticleHit(ILiquidContainer containerPouringInto)Counts a pour particle hitting a container that can take this liquid. Called by LiquidPouringParticlesMarker.
void SetEnabled(bool isEnabled)Enables or disables the component; disabling stops pouring and releases particles.
protected virtual void Awake()Gets the container, subscribes to its level and liquid changes, and releases particles when the entity is destroyed.
protected virtual void Start()Runs the content check once so the component starts enabled or disabled correctly.
11 private and internal methods
MemberWhat it is
private void ContainerContainedLiquidChanged(LiquidContent oldType, LiquidContent newType)Enables pouring only while the container holds a liquid type.
private void ContainerContentAmountChanged(ILiquidContainer container, int oldLevel, int newLevel)Enables pouring only while the container isn't empty.
private ILiquidContainer FindMostPouredIntoContainer()Returns the compatible container hit by the most particles since the last recheck, or null.
private void LateUpdate()Reads pouring strength (zero if lidded, inactive or submerged), starts or stops pouring on the server, and updates particles.
private void OnDrawGizmosSelected()Empty.
private void ProgressOutTransition()Advances the outgoing liquid transfer by strength times frame time.
private void ReleasePouringParticles()Returns the pour particles to the pool.
private void StartPouring()Server: starts the pouring coroutine if it isn't running.
private void StopPouring()Stops the pouring coroutine and clears the outgoing transfer's target.
private void UpdatePouringParticles()Spawns, updates or releases the pour particles from current strength and content level.
private IEnumerator UpdatePouringTransition() (iterator)Coroutine: transfers liquid every frame and every recheck interval retargets the most-hit container or the global container.

Used in​

Members of other types that take, return or hold a PourableContainer: