Nonslipgritsource
Overview
This component acts as an inventory item source for non-slip grit, enabling it to be attached to entities with the slipperyfeet component. When attached, it automatically grants non-slip grit functionality via the nonslipgrituser component, and provides hooks for delta-time updates.
Dependencies & Tags
- Uses
MakeComponentAnInventoryItemSource(self)during construction. - Relies on the presence of the
nonslipgritusercomponent on the owner entity (creates it on-demand if missing). - Requires the
slipperyfeetcomponent on the owner to trigger activation. - Relies on the
inventoryitemcomponent for standard inventory item behavior (viaMakeComponentAnInventoryItemSource). - Removes its inventory source behavior via
RemoveComponentInventoryItemSourcewhen removed.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | nil | Reference to the owning entity (assigned in constructor). |
ondeltafn | function | nil | Optional callback function used for per-frame (delta-time) processing; set via SetOnDeltaFn. |
Main Functions
OnRemoveFromEntity()
- Description: Cleans up when the component is removed from its entity. Removes the associated inventory item source behavior.
- Parameters: None.
OnItemSourceRemoved(owner)
- Description: Called when this source is removed from an owner. Notifies the owner's
nonslipgritusercomponent (if present) to remove this source. - Parameters:
owner(Entity): The entity from which this source is being removed.
OnItemSourceNewOwner(owner)
- Description: Called when this source is attached to a new owner. If the owner has the
slipperyfeetcomponent, ensures the owner has thenonslipgritusercomponent and registers this source with it. - Parameters:
owner(Entity): The new owner entity.
SetOnDeltaFn(fn)
- Description: Sets a callback function to be invoked during delta-time updates (
DoDelta). This allows external code to register periodic behavior (e.g., grit consumption or decay). - Parameters:
fn(function): Function of the formfunction(inst, dt)whereinstis this component's entity anddtis the time elapsed since the last frame.
DoDelta(dt)
- Description: Executes the registered delta callback (if any) with the current delta time. Used for time-based logic such as grit depletion or refresh.
- Parameters:
dt(number): Delta time in seconds.
Events & Listeners
None.