Skip to main content

LiquidTransition

A class in Root.Township, Alta.Liquid.

One pour in progress from a source liquid container into a receiving one. Progress builds up and each time it reaches 1, one unit of liquid moves over.

Constructors​

MemberWhat it is
LiquidTransition(ILiquidContainer sourceContainer)Creates a LiquidTransition from sourceContainer.

Fields​

5 private and internal fields
MemberWhat it is
private ILiquidTransitionController currentControllerThe controller that set the current target. Only it can progress or reset the pour.
private bool isDuringTransitionFinishingTrue while OnTransitionFinished runs, so the reset inside the fill is ignored.
private static Logger loggerNLog logger for this class.
private ILiquidContainer receivingContainerBacking field for ReceivingContainer, the container being poured into, or null.
private ILiquidContainer sourceContainerBacking field for SourceContainer, the container being poured from.

Properties​

MemberWhat it is
bool IsFinished { get; internal set; }True once the transfer ended, was cancelled or the target was removed.
float Progress { get; private set; }How far the current unit has got, from 0 to 1.
ILiquidContainer ReceivingContainer { get; }The container being poured into, or null when there's no target.
ILiquidContainer SourceContainer { get; }The container pouring.

Events​

MemberWhat it is
event Action<LiquidTransition> TransitionCancelledRaised when the target changes before finishing, or the target's liquid stops being compatible.
event Action TransitionFinishedRaised after a unit of liquid was moved.
event Action TransitionStartedRaised when a new target is set.

Methods​

MemberWhat it is
void ProgressTransition(float transitionProgress, ILiquidTransitionController controller)Adds progress, scaled by the target's receive multiplier and the global liquid speed. Ignored unless called by the current controller.
void ResetAndRemoveReceivingContainer(ILiquidTransitionController controller)Clears the target and progress and marks the pour finished, if called by the current controller.
void SetTarget(ILiquidContainer newReceivingContainer, ILiquidTransitionController controller)Starts pouring into a new compatible container, cancelling any pour to a previous one.
2 private and internal methods
MemberWhat it is
private void CheckIfTransitionIsStillValid(LiquidContent oldType, LiquidContent newType)When the receiving container's liquid changes, cancels the pour if the two containers no longer mix.
private void OnTransitionFinished()Moves one unit of liquid into the receiving container if it isn't full, then clears the target.

Used in​

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