public abstract class BloodContainer

Inherits MonoBehaviour, Messages.IOnAfterDeserialise, Messages.IOnBeforeSerialise

Abstract base class for all liquid containers

Nested types

BloodContainer.PressureDirection

BloodContainer.SerialisableDistribution

BloodContainer.RefFloat

Fields

public const float PushPressureValue

The target pressure value of PressureDirection.Push

Constant value: 4096


public const float PullPressureValue

The target pressure value of PressureDirection.Pull

Constant value: -4096


public const float RemovalThreshold

Amount of liquid that is considered "gone", and will be removed from the distribution

Constant value: 0.02f


public UnityEvent OnDistributionChange

This event is invoked when the liquid distribution changes


public float MeasuredPressure

[HideInInspector]

The current measured pressure as decided by the contents of the container, pressure mode, and other attached container


public Dictionary<Liquid, RefFloat> LiquidDistribution

[SkipSerialisation]

The current liquid distribution. Contains each liquid type and its amount in this container.


public SerialisableDistribution[] SerialisableDistributions

The distribution that is created and read during (de)serialisation.


Properties

public float TotalLiquidAmount { get; private set; }

[SkipSerialisation]

Read-only value that returns the total amount of liquid (in liquid units). See also Liquid.LiterToLiquidUnit.


public virtual float ScaledLiquidAmount

[SkipSerialisation]

Read-only value that returns the amount of liquid ranging from 0 to 1, 0 meaning empty and 1 meaning full.


public virtual PressureDirection Pressure

[SkipSerialisation]

The target pressure mode.


public virtual bool AllowsOverflow

[SkipSerialisation]

Does this container have infinite capacity? Do note that ScaledLiquidAmount may always return 0 if this is true.


public virtual bool AllowsTransfer

[SkipSerialisation]

Does this container allow liquid transfer via wires?


public virtual Vector2 Limits

[SkipSerialisation]

The set limits of the container (in liquid units). See also Liquid.LiterToLiquidUnit.


public float UpperLimit

[SkipSerialisation]

Gets the upper limit of the container, taking AllowsOverflow and Limits into account. This should be used instead of Limits to get the upper limit because it returns float.MaxValue if the container allows for overflow.


public float LowerLimit

[SkipSerialisation]

Gets the lower limit of the container. Identical to Limits.x


public bool IsComputerColourCached

[SkipSerialisation]

Is the final liquid colour up to date?


public float BloodAmount { get; set; }

[System.Obsolete]

Use TotalLiquidAmount and ForceSetAllLiquid(float) instead.


public virtual bool AllowPressureTransfer

[SkipSerialisation]

Does this container allow pressure transfer via wires?


Methods

public float AddLiquid(Liquid type, float amount)

Add an amount of a liquid to the container. Returns the amount of liquid that was actually added, considering the upper limit of the container.

Use Liquid.GetLiquid(string) to get the instance of the liquid type.


public float RemoveLiquid(Liquid type, float amount)

Remove an amount of a liquid to the container. Returns the amount of liquid that was actually removed, considering the lower limit of the container.

Use Liquid.GetLiquid(string) to get the instance of the liquid type.


public void Drain(float amount)

Drain an amount of all liquids from this container.


public void DeleteEmptyLiquidEntries()

Delete empty entries from the distribution. Handled by the system, no need to call.


public void ForceSetAllLiquid(float amount)

Force set the total amount of liquid in this container. It scales each liquid in the container so that the total sum matches the given amount. The ratios of liquid will stay the same.


public void ClearLiquid()

Remove all liquid from the container.


public void ForceRecalculateTotalLiquidAmount()

Force a recalculation of TotalLiquidAmount. Should never be neccessary.


public float TransferTo(Liquid liquid, float amount, BloodContainer target)

Transfer a liquid from this container to a target container.Returns the actual amount transferred


public void CopyTo(Liquid liquid, float amount, BloodContainer target)

Copy a liquid from this container to a target container.


public float TransferTo(float amount, BloodContainer target, bool proportional = true)

Transfer all liquids from this container to a target container.Pass false to the proportional parameter to evenly spread the liquid to the target container.Passing true ensures that the ratio of liquids in the target container will match that of this container (default behaviour).Returns the actual amount transferred


public void CopyTo(float amount, BloodContainer target, bool proportional = true)

Duplicate an amount of liquid to the target container. This is different from transferring because this method does not remove liquid from the container.Pass false to the proportional parameter to evenly spread the liquid to the target container.Passing true ensures that the ratio of liquids in the target container will match that of this container (default behaviour).


public float GetAmount(Liquid liquid)

Get the amount of a particular liquid in this container.


public float GetPercentageOf(Liquid liquid)

Get the percentage of a particluar liquid in this container. Note that this will always return 0 if this container allows overflow.


protected virtual void Update()

Updates the liquids inside the container. Not calling this in the implementation will prevent liquids from mixing (and everything else they can do).


public Color ForceCalculateComputedColor(Color fallback)

Forcibly recalculate the liquid colour


public Color GetComputedColor()

No description provided


public Color GetComputedColor(Color fallback)

Get the colour of this liquid. Will return a cached result if no significant change has taken place.


protected virtual void OnLiquidEnter(Liquid type)

Called when a new liquid enters the container.


protected virtual void OnLiquidExit(Liquid type)

Called when a liquid exits the container, and no more of it is left.


public virtual void OnBeforeSerialise()

No description provided


public virtual void OnAfterDeserialise(List<GameObject> gameObjects)

No description provided


public bool IsFull(float percentage = 0.999f)

Is this container full? You can provide a minimum percentage


Attention!

This member is obsolete and should not be used. It is a remnant from the past.

bi bij bibi