Skip to main content

Fillable

Overview

The Fillable component allows an entity (e.g., an empty container or vessel) to be filled with liquid—most commonly water—by consuming a water source and replacing itself with a new prefab representing the filled state. It also supports optional behavior for ocean water interactions via tag toggling.

Dependencies & Tags

  • Adds tag(s): "fillable" (on initialization)
  • Removes tag(s): "fillable", "fillable_showoceanaction", "allow_action_on_impassable" (on removal from entity)
  • No external component dependencies are explicitly required by this component’s core logic.

Properties

PropertyTypeDefault ValueDescription
instEntitynil → passed in constructorReference to the entity this component is attached to.
filledprefabstring?nilName of the prefab to spawn when the entity is filled. If nil, filling fails.
acceptsoceanwaterbooleanfalseWhether the entity accepts ocean water as a fill source (currently unused in the provided code).
showoceanactionbooleanfalseControls whether ocean-related actions (e.g., right-click to fill from ocean) appear for this entity.
overrideonfillfnfunction?nilOptional callback executed on fill; if present, replaces default fill behavior.

Note: No public properties are initialized outside the constructor beyond those listed. The commented-out properties (overrideonfillfn, oceanwatererrorreason) are not actively used in the current implementation.

Main Functions

Fill(from_object)

  • Description: Fills the entity by consuming a water source (if provided) and replacing the current entity with self.filledprefab. Handles item transfer into inventories or placement into the world if unowned.
  • Parameters:
    • from_object (Entity?): The source of the water (must have a watersource component). If nil, only overrideonfillfn (if present) is executed; otherwise, filling fails.

Events & Listeners

  • Listens for: showoceanaction event (implicitly via callback registration: showoceanaction = onshowoceanaction)
    • When showoceanaction changes, the component toggles two tags:
      • "fillable_showoceanaction"
      • "allow_action_on_impassable"
        This enables or disables UI and interaction options when the entity is on impassable terrain (e.g., ocean).
  • Pushes no custom events.