Moonsparkchargeable
Overview
This component enables an entity to act as a portable source of spark charge, which can be transferred to another entity's fueled component via the DoSpark function. It tracks a fueled_percent value representing the amount of charge available and ensures the entity is tagged appropriately for gameplay logic.
Dependencies & Tags
- Component Dependency: Assumes the target of
DoSparkhas afueledcomponent (self.inst.components.fueledis checked before use). - Tags Added/Removed:
- Adds the
"moonsparkchargeable"tag upon construction. - Removes the
"moonsparkchargeable"tag when removed from the entity.
- Adds the
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
fueled_percent | number | TUNING.MOONSTORM_SPARKCHARGE_DEFAULT | The proportion of charge (0.0–1.0) that this entity contributes when sparking. |
Main Functions
SetFueledPercent(amount)
- Description: Updates the stored spark charge level (
fueled_percent) to the specified value. - Parameters:
amount(number): The new charge percentage (typically between 0 and 1, though no explicit clamping is applied within this function).
DoSpark(doer)
- Description: Attempts to transfer this component’s stored charge to the
fueledcomponent of the target entity (the entity this component is attached to). The charge is added (as a relative increment) to the target’s current fuel level, clamped to [0, 1]. No transfer occurs iffueled_percentis zero or the target lacks afueledcomponent. - Parameters:
doer(Entity): The entity triggering the spark event (not directly used in logic, but included for context in event callbacks).
Events & Listeners
None identified.