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).
- Listed in Stats, effects, heat and liquid
- Inherits or implements
MonoBehaviour,IPourableContainer,ILiquidTransitionController - Documented in Liquids
Constructors
| Member | What it is |
|---|---|
PourableContainer() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
16 private and internal fields
| Member | What it is |
|---|---|
private ILiquidContainer container | Backing field for InternalContainer. |
private float containerLipRadius | Radius of the container's lip, used to place the particles. |
private float currentPouringStrength | Pouring strength computed this frame. |
private Dictionary<ILiquidContainer, int> destinationContainerHitCounts | Particle hits per container since the last recheck. |
private bool isFullyPouring | Set by the strength controller when the container is fully tipped; particles then pour fully. |
private bool isMovingParticlesToLowestPointOnLip | If true, particles are moved to the lowest point on the lip each frame. |
private float minPouringStrengthToDetect | Strength below which nothing pours and particles are released. |
private PooledObjectDefinition overridePouringParticles | Particles to use instead of the default from LiquidSettings. |
private AltaCoroutine pouringCoroutine | The running UpdatePouringTransition coroutine, or null. |
private float pouringParticlePouringMultiplier | Multiplier from pouring strength to particle strength. |
private PouringParticles pouringParticles | Current pour particles, or null when not pouring. |
private float pouringParticlesAmount | Serialized but not read by this class. |
private Transform pouringParticlesParent | Transform the pour particles attach to. |
private PouringStrengthController pouringStrengthController | Works out pouring strength from the container's tilt. |
private float pouringStrengthMultiplierForParticles | Serialized but not read by this class. |
private float timeToRecheckPouringDestination | Seconds between retargeting the destination container. |
Properties
| Member | What 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
| Member | What 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
| Member | What 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: