Skip to main content

CookingLiquidVisual

A class in Root.Township, Alta.Cooking.

Liquid surface visual for cooking containers. Moves the surface with fullness, keeps it level, and runs boiling particles and waves from the temperature.

Constructors​

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

Fields​

10 private and internal fields
MemberWhat it is
private BoilingParticles boilingParticlesPooled boiling particles in use, or null.
private AnimationCurve boilingParticlesEmissionMultiplierCurve from liquid temperature to boiling particle emission.
private Transform boilingParticlesParentTransform the boiling particles are spawned under.
private CookingLiquidVisual.BoilingParticlesStageSetting[] boilingParticlesStagesPer-stage lifetime and height offset settings passed to the boiling particles.
private ILiquidContainer containerThe liquid container in the parent, found in Awake.
private bool isUsingBoilingParticlesWhether this visual shows boiling particles at all.
private float maximumPlaneYLocal Y of the surface when full.
private float minimumPlaneYLocal Y of the surface when empty.
private Transform surfaceBacking field for Surface; moved up and down with fullness and turned to face visual up.
private Transform topOfLiquidNotRotatingOptional transform kept at the surface height but not rotated.

Properties​

MemberWhat it is
static LiquidSurfaceMaterialCreator MaterialCreator { get; }Shared creator for the surface material and its shader property ids.
Transform Surface { get; }The surface plane transform.

Methods​

MemberWhat it is
override void SetFullness(float newFullness)Moves the surface between the min and max plane heights. Releases boiling particles when empty and clears them when the level drops by 0.1 or more.
override void SetLiquid(LiquidData liquid)Sets the liquid and sets the boiling particles up for it.
void UpdateBoilingEmissionFromTemperature(float temperature, bool isForced = false)Spawns, updates or releases boiling particles and sets wave speed and strength from the temperature.
protected override void Awake()Finds the parent ILiquidContainer.
protected override void OnDisable()Resets the surface rotation to the container's up.
protected override void OnValidate()Editor: makes sure there is at least one boiling particle stage.
protected override void SetLODRendererPropertyBlockFromLiquid(MaterialPropertyBlock propertyBlock, LiquidData liquid)Sets the LOD renderer colour to the liquid's tinted colour.
protected override void SetPropertyBlockFromLiquid(MaterialPropertyBlock propertyBlock, LiquidData liquid)Sets the surface colour to the liquid's tinted colour.
protected override Material SetupMaterialFromLiquidVisualSettings(LiquidVisualData visualSettings, Material materialTemplate)Builds the surface material from the liquid's visual settings.
protected override void UpdateVisual()Keeps the surface facing LiquidGravity.VisualUp.
2 private and internal methods
MemberWhat it is
private void AttemptReleaseBoilingParticles()Returns the boiling particles to the pool, if any are out.
private void CheckCreateOrDeleteBoilingParticles(float valueToCheck)Gets boiling particles from the pool when emission is above zero and there's liquid, otherwise releases them.

Used in​

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