Incinerator
Overview
The Incinerator component enables an entity to incinerate all or selectively filtered items in its container. It supports customizable incineration criteria via function callbacks, handles sound playback upon destruction (including live entity sounds), and dispatches events such as onincinerated, murdered, and killed to notify other systems.
Dependencies & Tags
- Component Dependencies: Relies on the entity having a
containercomponent to access and destroy contents. - Entity Interaction: May interact with items possessing
stackable,health,murderable, andmurderable(sic) components to determine behavior and sound. - Tags: None explicitly added or removed by this component.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
onincineratefn | function? | nil | Optional callback invoked after incineration completes. Receives inst (the incinerator entity) as the sole argument. |
shouldincinerateitemfn | function? | nil | Optional predicate function used to determine if an item should be incinerated. Receives (incinerator_inst, item) and returns true/false. |
incinerate_doer | entity or nil | nil (temporary) | Internal reference to the entity performing the incineration, set during Incinerate() and cleared afterward. Used for event context. |
Note: The component itself is initialized in its constructor with no explicit public properties beyond the two function callback fields.
incinerate_doeris transiently set during incineration and is not exposed via a public setter.
Main Functions
SetOnIncinerateFn(fn)
- Description: Sets the callback function to execute once incineration is fully completed.
- Parameters:
fn(function): A function accepting one argument — the incinerator entity (inst). May benilto remove the callback.
SetShouldIncinerateItemFn(fn)
- Description: Sets the predicate function used to decide whether a specific item should be incinerated during
Incinerate(). - Parameters:
fn(function): A function accepting(incinerator_inst, item)and returningtrueto incinerate the item orfalseto skip it. May benil, in which case all items are incinerated.
Incinerate(doer)
- Description: Initiates incineration of all items in the container that pass the
shouldincinerateitemfnfilter (or all items if no filter is set). Triggers associated sounds and events per item. - Parameters:
doer(entity): The entity performing the incineration. Used to emitmurderedandkilledevents for living items.
- Returns:
trueif the incineration process was started (container present),falseotherwise.
ShouldIncinerateItem(item)
- Description: Checks whether a given item satisfies the incineration criteria using the configured
shouldincinerateitemfn. - Parameters:
item(entity): The candidate item to be incinerated.
- Returns:
trueif the item should be incinerated,falseotherwise.
Events & Listeners
-
Events Emitted:
onincinerated— pushed on each incinerated item, with payload{ incinerator = inst, doer = doer }.murdered— pushed on thedoerentity for incinerated items that havehealthormurderablecomponents, with payload{ victim = item, stackmult = stacksize, incinerated = true }.killed— pushed on thedoeronly if the item also has acombatcomponent, with the same payload asmurdered.
-
Event Listeners: None — the component does not subscribe to any external events directly.