Skip to content

DatabaseVFX ​

Inherits: RefCounted

The visual effects library of the project, read from the folders under res://src/data/vfx/.

Description ​

Each folder is a VFX TYPE (oneshot, loop, enchant, beam, path, weather, telegraph, material) and VFX_TYPES says which file types it takes. A type maps to a VFX class (VFXOneShot, VFXLoop ...). Subfolders are scanned too. The folders are scanned once on first use; call refresh_database after adding files.

Methods ​

voidinitialize() static
voidensure_initialized() static
voidensure_directories() static
voidrefresh_database() static
Stringget_vfx_class_name( vfx_type: String ) static
Stringget_vfx_script_path( vfx_type: String ) static
Array[String]get_scene_based_vfx_types() static
Array[String]get_vfx_types() static
Array[String]get_available_vfx( vfx_type: String ) static
Stringget_vfx_path( vfx_type: String, vfx_name: String ) static
PackedSceneget_vfx_scene( vfx_type: String, vfx_name: String ) static
Materialget_vfx_material( vfx_type: String, vfx_name: String ) static
Resourceget_vfx_resource( vfx_type: String, vfx_name: String ) static
Resourceget_random_vfx( vfx_type: String ) static
boolhas_vfx( vfx_type: String, vfx_name: String ) static
Dictionaryget_vfx_type_info( vfx_type: String ) static
Stringget_vfx_type_display_name( vfx_type: String ) static
boolis_scene_type( vfx_type: String ) static
boolis_material_type( vfx_type: String ) static
Dictionaryget_database_stats() static
Dictionaryparse_name( vfx_name: String ) static
boolis_valid_name( vfx_name: String ) static
Stringget_theme( vfx_name: String ) static
Stringget_category( vfx_name: String ) static
Stringget_display_name( vfx_name: String ) static
Array[String]get_themes( vfx_type: String = "" ) static
Array[String]get_categories( vfx_type: String = "", theme: String = "" ) static
Array[String]get_available_vfx_filtered( vfx_type: String, theme: String = "", category: String = "" ) static

Constants ​

  • String VFX_RESOURCES_PATH = "res://src/data/vfx/" - The folder the visual effects are read from.
  • const VFX_TYPES = { - VFX type definitions - maps directly to VFX classes
  • const VFX_CLASS_MAPPING = { - ========== VFX SCRIPT MAPPING ==========
  • Dictionary VFX_SCRIPT_MAP = { - Which script each folder of visual effects (oneshot, loop, beam ...) uses.
  • String NAME_PREFIX = "vfx" - The word every effect name starts with.
  • String UNSORTED = "unsorted" - What the editor shows for an effect whose name does not follow the rule.
  • String NAME_RULE_TEXT = "vfx_<theme>_<category>_<name>_<nn> e.g. vfx_fire_projectile_fireball_01" - A short text for the hover of the name rule.

Method descriptions ​

void initialize() ​

Initialize the VFX database by scanning all types

void ensure_initialized() ​

Ensure database is initialized

void ensure_directories() ​

Ensure all VFX type directories exist

void refresh_database() ​

Force refresh of the entire database (useful for development)

String get_vfx_class_name( vfx_type: String ) ​

Get VFX class name for a VFX type

String get_vfx_script_path( vfx_type: String ) ​

Get script path for VFX type

Array[String] get_scene_based_vfx_types() ​

Get only scene-based VFX types (excludes telegraph and material)

Array[String] get_vfx_types() ​

Get all available VFX types

Array[String] get_available_vfx( vfx_type: String ) ​

Get all VFX names of a specific type

String get_vfx_path( vfx_type: String, vfx_name: String ) ​

Get VFX file path by type and name

PackedScene get_vfx_scene( vfx_type: String, vfx_name: String ) ​

Get VFX PackedScene by type and name (for scene-based VFX)

Material get_vfx_material( vfx_type: String, vfx_name: String ) ​

Get VFX Material by type and name (for material-based VFX)

Resource get_vfx_resource( vfx_type: String, vfx_name: String ) ​

Get VFX Resource by type and name (generic loader)

Resource get_random_vfx( vfx_type: String ) ​

Get random VFX from a type

bool has_vfx( vfx_type: String, vfx_name: String ) ​

Check if a specific VFX exists

Dictionary get_vfx_type_info( vfx_type: String ) ​

Get VFX type info

String get_vfx_type_display_name( vfx_type: String ) ​

Get human-readable VFX type name

bool is_scene_type( vfx_type: String ) ​

Check if VFX type supports scenes

bool is_material_type( vfx_type: String ) ​

Check if VFX type supports materials

Dictionary get_database_stats() ​

Get database statistics

Dictionary parse_name( vfx_name: String ) ​

Reads a name by the rule. Gives {valid, theme, category, name, variant}; for a name that breaks the rule valid is false and the other fields are empty.

bool is_valid_name( vfx_name: String ) ​

True when the name follows the rule.

String get_theme( vfx_name: String ) ​

The theme of an effect (UNSORTED when the name breaks the rule).

String get_category( vfx_name: String ) ​

The category of an effect (UNSORTED when the name breaks the rule).

String get_display_name( vfx_name: String ) ​

The name for people: "Fireball 01" for vfx_fire_projectile_fireball_01. A name that breaks the rule is shown as it is, in words.

Array[String] get_themes( vfx_type: String = "" ) ​

The themes in use, sorted, for one kind of effect (all kinds when vfx_type is empty).

Array[String] get_categories( vfx_type: String = "", theme: String = "" ) ​

The categories in use, sorted, for one kind of effect (all when empty) and, when theme is not empty, only those of that theme.

Array[String] get_available_vfx_filtered( vfx_type: String, theme: String = "", category: String = "" ) ​

The names of one kind of effect that have the theme and the category (an empty text means any).