Skip to main content

LiquidChunkVisuals

A class in Root.Township, Alta.Cooking.

Client visuals for the floating chunks in a liquid container (such as stew pieces in a pot), bobbing faster as the liquid heats. Removes itself on headless servers.

Constructors​

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

Fields​

9 private and internal fields
MemberWhat it is
private BobbingController bobbingControllerMoves the chunk visuals up and down.
private float bobbingSpeedMultiplierScales the liquid's wave speed for the bobbing.
private float bobbingStrengthMultiplierScales the liquid's wave strength for the bobbing.
private ILiquidContainer containerThe liquid container in the parents.
private List<LiquidChunkVisuals.LiquidChunkData> displayingChunksChunk types shown and their visuals per content level.
private static Dictionary<LiquidVisualChunkDefinition, int> existingLiquidChunksScratch counts used while swapping liquids. Shared by all instances.
private HeatPoint heatPointHeat point whose temperature drives the bobbing. Ambient temperature is used if none.
private int maxPiecesMost content levels that get chunk visuals.
private float spawnedSizeMultiplierScale of spawned chunk visuals.

Methods​

MemberWhat it is
void ClearAllVisuals()Releases every chunk visual and clears the bobbing controller.
void CreateVisualForIngredient(LiquidVisualChunkDefinition chunkVisual)Adds visuals for one chunk type, one set per current content level.
10 private and internal methods
MemberWhat it is
private void AddNewChunkVisuals(LiquidVisualChunkDefinition chunkVisual, Dictionary<int, List<PooledObject>> newVisuals, int oldLevel, int newLevel)Spawns chunk visuals for each content level gained, up to maxPieces, and adds them to the bobbing controller.
private void AddVisualsForNewChunks(LiquidContent oldType, LiquidContent newType)When the liquid changes, adds visuals for chunk types that are new and removes those no longer present.
private void Awake()Hooks the container's level, liquid and destroy events, and the heat point. Destroys itself on headless servers.
private void CreateVisualBaseOnContent(LiquidContent oldType, LiquidContent newType)Handler for the contained liquid changing: clears, creates or swaps chunk visuals and sets the bobbing.
private void ReleaseChunkVisuals(NetworkEntity entity, bool isUnload)Clears all visuals when the container entity is destroyed.
private void RemoveChunkVisuals(LiquidVisualChunkDefinition oldChunkVisual)Removes either one chunk type's visuals, or the visuals for content levels lost.
private void RemoveChunkVisuals(Dictionary<int, List<PooledObject>> newVisuals, int oldLevel, int newLevel)Removes either one chunk type's visuals, or the visuals for content levels lost.
private void UpdateBobbingValuesByTemperature(float temperature)Sets bobbing strength and speed from the liquid's temperature curves.
private void UpdateLiquidChunks(ILiquidContainer container, int oldLevel, int newLevel)Handler for the content level changing: adds or removes visuals, clearing all at level 0.
private void UpdateTemperature(HeatPoint heatPoint)Handler for the heat point changing: updates the bobbing.