VFXManager ​
Inherits: Node
Centralized VFX system with pooling, shader precompilation, and support for multiple effect types (scene-based, telegraphs, materials).
Description ​
POOLING SYSTEM: Pre-instantiates all VFX during initialization and reuses from pools for zero-cost playback. Eliminates shader compilation hitches by compiling shaders during loading screen.
VFX TYPES:
- Scene VFX: Pre-built effects (oneshot, loop, beam, path) from DatabaseVFX
- Telegraph VFX: Runtime-created ground indicators and area markers
- Material VFX: Shader-based entity effects (dissolve, outline, tint, etc.)
INITIALIZATION: Call initialize(system_hub) during game setup. This:
Preloads all VFX from database
Compiles shaders by temporarily adding to scene tree
Returns instances to pools ready for instant playback
USAGE:
- play_vfx_from_selection(selection, target, timer) - Main API for all VFX types
- VFXSelection determines type, location, attachment, and parameters
- stop_vfx(vfx) / stop_vfx_array(array) - Manual cleanup if needed
- VFX automatically return to pool when finished
HANDS VFX: Special support for dual hand VFX - automatically creates and manages left/right pairs attached to entity hand bones.
TRACKING:
- active_vfx: Currently playing scene-based VFX
- active_material_effects: Currently active material effects on entities
Variables ​
Array[VFX] | active_vfx | [] |
Array[VFXMaterial] | active_material_effects | [] |
Node3D | vfx_container | |
Dictionary | vfx_pools | {} # "type/name" -> Array[VFX] |
int | total_pooled | 0 |
bool | is_initialized | false |
Methods ​
void | initialize( system_hub: GameHost.SystemHub ) |
void | preload_all_vfx( system_hub: GameHost.SystemHub ) |
Array[VFX] | play_vfx_from_selection( selection: VFXSelection, target: Variant = null, timer: Timer = null ) |
VFXMaterial | apply_material( material_sel: VFXSelectionMaterial, target: Variant, timer: Timer = null, item: Object = null ) |
void | stop_material_effects_on_entity( entity: Entity ) |
void | stop_material_effect( material_effect: VFXMaterial ) |
Array[VFXMaterial] | get_material_effects_for_entity( entity: Entity ) |
bool | entity_has_material_effect( entity: Entity, target: VFXSelectionMaterial.MaterialTarget ) |
int | get_active_material_effect_count() |
void | stop_vfx( vfx: VFX ) |
void | stop_vfx_array( vfx_array: Array ) |
void | cleanup_everything() |
Constants ​
intMAX_POOL_SIZE =500- The most effects the pool keeps.
Variable descriptions ​
Array[VFX] active_vfx = [] ​
========== VFX TRACKING ==========
Array[VFXMaterial] active_material_effects = [] ​
The material effects on entities now.
Node3D vfx_container ​
The node the effects are placed under.
Dictionary vfx_pools = # "type/name" -> Array[VFX] ​
========== POOLING ==========
int total_pooled = 0 ​
How many effects wait in the pool.
bool is_initialized = false ​
========== INITIALIZATION ==========
Method descriptions ​
void initialize( system_hub: GameHost.SystemHub ) ​
Sets the manager up with the hub of the game systems.
void preload_all_vfx( system_hub: GameHost.SystemHub ) ​
Preload ALL VFX during loading screen and report memory usage
Array[VFX] play_vfx_from_selection( selection: VFXSelection, target: Variant = null, timer: Timer = null ) ​
Starts the effect of a selection on a target. Gives the effects made.
VFXMaterial apply_material( material_sel: VFXSelectionMaterial, target: Variant, timer: Timer = null, item: Object = null ) ​
Puts a material effect on an entity and gives it back (null when it could not go on): it lasts until its timer ends, the entity dies, or stop_material_effect. item: the enchanted item, for a selection that targets the item's own weapon.
void stop_material_effects_on_entity( entity: Entity ) ​
Stop all material effects on a specific entity
void stop_material_effect( material_effect: VFXMaterial ) ​
Stop a specific material effect
Array[VFXMaterial] get_material_effects_for_entity( entity: Entity ) ​
Get all active material effects for an entity
bool entity_has_material_effect( entity: Entity, target: VFXSelectionMaterial.MaterialTarget ) ​
Check if entity has material effect with specific target
int get_active_material_effect_count() ​
Get material effect count for debugging
void stop_vfx( vfx: VFX ) ​
Stops one effect.
void stop_vfx_array( vfx_array: Array ) ​
Stops a list of effects.
void cleanup_everything() ​
Stops every effect and empties the pool.