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.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
NetworkEntityBehaviour,IBuildRendererPostBake,IBuildBakeable - Documented in Liquids
Constructors
| Member | What it is |
|---|---|
LiquidContainerLid() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private ILiquidContainer container | Backing field for Container. |
private Transform corkEffectOrigin | Where the cork shoot effect spawns. |
private PooledObjectDefinition corkShootEffect | Pooled effect spawned when the lid is removed with effects. |
private CurveScaler fakeCork | Scaler that shows or hides the cork model. |
private bool isClosedByDefualtIfEmpty | If true, the lid starts on when the container spawns empty. |
private bool isClosedByDefualtIfNotEmpty | If true (default), the lid starts on when the container spawns with liquid. |
private UnityEvent opened | Unity event invoked when the lid is removed with effects. |
private ParticleSystem[] popEffectParticles | Particle systems played on removal when the container isn't empty. |
private MethodSyncStruct<bool> syncOpen | Method sync for the lid state, sent to chunks and to joining players. |
Properties
| Member | What 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
| Member | What 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
| Member | What 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: