Skip to main content

Furnituredecor

Overview

The FurnitureDecor component tracks whether an entity is placed on a furniture item, manages the "furnituredecor" tag for optimized rendering or behavior, and supports optional callback hooks when the entity is placed or removed from furniture.

Dependencies & Tags

  • Adds/Removes Tag: "furnituredecor" via AddOrRemoveTag (controlled by enabled state)
  • Does not add the tag by default in _ctor (the tag addition is commented out), relying instead on runtime toggling via the enabled setter.
  • No other components are directly added or required.

Properties

PropertyTypeDefault ValueDescription
instEntity(injected)The entity instance this component is attached to.
enabledbooleantrueControls whether the "furnituredecor" tag is present on the entity.
on_furnitureboolean?nilTracks whether the entity is currently placed on a furniture object (true when on furniture, nil otherwise).
decor_animationstring"idle"A hint for animation state (currently unused in this codebase snippet).

Main Functions

onenabled(self, enabled)

  • Description: Internal setter function invoked when the enabled property is assigned. It adds or removes the "furnituredecor" tag based on the new value.
  • Parameters:
    • enabled (boolean): The new enabled state.

SetEnabled(enabled)

  • Description: Sets the enabled state and ensures onenabled is triggered (via property assignment, as defined in the class metatable).
  • Parameters:
    • enabled (boolean): Whether the "furnituredecor" tag should be active.

IsOnFurniture()

  • Description: Returns whether the entity is currently placed on a furniture item.
  • Parameters: None.

PutOnFurniture(furniture)

  • Description: Marks the entity as being placed on furniture and invokes the optional onputonfurniture callback, if set.
  • Parameters:
    • furniture (Entity?): The furniture object the entity is placed on (passed to the callback, if any).

TakeOffFurniture(furniture)

  • Description: Clears the "on furniture" state and invokes the optional ontakeofffurniture callback, if set.
  • Parameters:
    • furniture (Entity?): The furniture object the entity was removed from (passed to the callback, if any).

Events & Listeners

  • Listens for no events itself.
  • Does not push events directly.
  • Supports optional callback properties:
    • self.onputonfurniture — callable on PutOnFurniture
    • self.ontakeofffurniture — callable on TakeOffFurniture