Skip to main content

PouringParticles

A class in Root.Township, Alta.Liquid.

Pooled particle effect for liquid pouring out of a container, coloured to the liquid. Client side visual.

Constructors​

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

Fields​

9 private and internal fields
MemberWhat it is
private float coneRadiusOriginal cone radius of the particle shape.
private bool isFullyPouringTrue while in full pour (circle) mode.
private float maxPouringParticleEmissionOriginal emission rate, the maximum for pouring.
private float openingRadiusRadius of the container opening, used for full pour.
private Transform particlesParentTransform on the container the particles are placed relative to.
private LiquidParticlesRendererColorer particleSystemRendererColorerColours the particle renderer to match the liquid.
private ParticleSystem.MainModule pouringParticleMainModuleCached main module of the particle system.
private ParticleSystem.EmissionModule pouringParticlesEmissionModuleCached emission module of the particle system.
private ParticleSystem pouringParticleSystemThe particle system.

Properties​

MemberWhat it is
IPourableContainer PourableContainer { get; private set; }The container these particles are pouring from, or null when free.

Methods​

MemberWhat it is
void PlacePouringParticlesOnLip(float containerLipRadius)Moves the effect to the lowest point of the container lip.
void PourFully(float pouringStrength)Switches to a circle shape over the whole opening and sets emission by strength.
override void Release()Unparents, stops the particles and returns to the pool once they finish.
void ResetToNormalPouringMode()Restores the cone shape and radius.
void SetupForPourableContainer(IPourableContainer liquidContainer, Transform particlesParent, float openingRadius)Claims the particles for a container, colours them and listens for liquid changes. Logs an error if already claimed.
void UpdatePouringStrength(float currentPouringStrength)Sets emission to the maximum times the strength, leaving full pour mode if needed.
7 private and internal methods
MemberWhat it is
private void Awake()Caches the particle modules and restarts the particles each time the object is taken from the pool.
private void ContainerLiquidTypeChanged(LiquidContent oldType, LiquidContent newType)Recolours the particles when the container's liquid changes.
private void ResetBeforeRelease()Unhooks from the container and resets shape and emission.
private void SetupPouringParticles()Caches the emission and main modules, maximum emission and cone radius.
private void SetupToFullyPour()Sets the shape to a circle the size of the opening at the parent position.
private void StartParticlesAgain(PooledObject pooledObject)Plays the particle system again after being taken from the pool.
private IEnumerator WaitForParticleSystemToRelease() (iterator)Stops emitting, waits the particle duration, then resets and releases to the pool.

Used in​

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