Skip to main content

LiquidContainerLid

A class in Root.Township, Alta.Liquid.

A cork or lid on a liquid container. While on, liquid can't be added or poured out. The server decides open or closed and syncs it to clients, who play the pop effects.

Constructors​

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

Fields​

9 private and internal fields
MemberWhat it is
private ILiquidContainer containerBacking field for Container.
private Transform corkEffectOriginWhere the cork shoot effect spawns.
private PooledObjectDefinition corkShootEffectPooled effect spawned when the lid is removed with effects.
private CurveScaler fakeCorkScaler that shows or hides the cork model.
private bool isClosedByDefualtIfEmptyIf true, the lid starts on when the container spawns empty.
private bool isClosedByDefualtIfNotEmptyIf true (default), the lid starts on when the container spawns with liquid.
private UnityEvent openedUnity event invoked when the lid is removed with effects.
private ParticleSystem[] popEffectParticlesParticle systems played on removal when the container isn't empty.
private MethodSyncStruct<bool> syncOpenMethod sync for the lid state, sent to chunks and to joining players.

Properties​

MemberWhat it is
ILiquidContainer Container { get; }The ILiquidContainer in the parents that this lid covers.
bool IsOnContainer { get; private set; }True while the lid is on and the container is sealed.

Methods​

MemberWhat it is
void CloseLid()Server: puts the lid on. isForced reapplies it even if already on.
void CloseLid(bool isForced, bool isPlayingEffects = true)Server: puts the lid on. isForced reapplies it even if already on.
override void Initialize()Creates the syncOpen method sync.
override void InitializeAsServer(SpawnData spawnData)Starts CheckEmpty to set the default lid state on spawn.
override void OnConnected(Player player)Sends the current lid state to a joining player without effects.
void RemoveLid()Server: takes the lid off. isForced reapplies it even if already off.
void RemoveLid(bool isForced, bool isPlayingEffects = true)Server: takes the lid off. isForced reapplies it even if already off.
7 private and internal methods
MemberWhat it is
private void AddFilter(LiquidData data, ref bool result)Filter on the container's AddFilter that refuses liquid while the lid is on.
private void Awake()Finds the parent liquid container and registers the add filter.
private IEnumerator CheckEmpty() (iterator)Server, one frame after spawn: closes or removes the lid without effects, based on whether the container is empty.
private void InternalCloseLid(bool isForced = false, bool isPlayingEffects = true)Shows the cork, blocks removing liquid, and on the server sends the new state to the chunk.
private void InternalRemoveLid(bool isForced = false, bool isPlayingEffects = true)Hides the cork, allows removing liquid, plays the opened event and pop effects (not headless), and syncs on the server.
private void IBuildRendererPostBake.PostBake()Build step that removes null entries from popEffectParticles.
private void SyncOpen(IPlayer player, Stream stream, bool isPlayingEffects)Serializes the lid state; clients apply it on read.

Used in​

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