APDatabase
Global database for storing and retrieving All Projectiles resources.
Description
The Global Database is an Autoload script specifically designed to store Projectiles, Attacks and all other plugin resources. You can access it at any time by calling the APDatabase name.
@onready var projectile_manager: ProjectileManager2D = $ProjectileManager2D
func _ready() -> void:
var example: Projectile2D = APDatabase.get_projectile("MAGIC_BOLT")
projectile_manager.set_projectile(0, APDatabase.get_projectile("FIREBALL"), false)
projectile_manager.set_projectile_from_database(1, "SOUL_SEEKER")
By default any ProjectileCaller2D or ProjectileManager2D you create will automatically add its projectiles and attacks to the Global Database at runtime. Of course, you can modify this behavior.
Note: With the default configuration you will get copies of the requested attacks/projectiles so any changes you make on them will not be reflected on the Global Database allocated objects and resources. Of course, you can change these options and use them in your favor.
Tutorials
Properties
Methods
Property Descriptions
Dictionary[StringName, Attack2D] attack_2d_dictionary
Stores Attack2D instances by their StringName ID.
Dictionary[StringName, AttackBlueprint2D] attack_blueprint_2d_dictionary
Stores AttackBlueprint2D resources by their StringName ID.
Dictionary[StringName, TimedModifier] modifiers_dictionary
Stores TimedModifier resources by their StringName ID.
Dictionary[StringName, Projectile2D] projectile_2d_dictionary
Stores Projectile2D instances by their StringName ID.
Dictionary[StringName, ProjectileBlueprint2D] projectile_blueprints_2d_dictionary
Stores ProjectileBlueprint2D resources by their StringName ID.
Method Descriptions
Attack2D get_attack_2d(id: StringName, return_copy: bool = true)
Returns the attack with key id
from the attack_2d_dictionary.
If return_copy
is true
returns a clone, otherwise returns the original reference.
Attack2DModifier get_attack_2d_modifier(id: StringName, return_copy: bool = true)
Returns an attack-specific modifier with key id
from the modifiers_dictionary.
If return_copy
is true
returns a clone, otherwise returns the original reference.
AttackBlueprint2D get_attack_blueprint_2d(id: StringName)
Returns the attack blueprint with key id
from the attack_blueprint_2d_dictionary.
TimedModifier get_modifier(id: StringName, return_copy: bool = true)
Returns the modifier with key id
from the modifiers_dictionary
If return_copy
is true
returns a clone, otherwise returns the original reference.
Projectile2D get_projectile_2d(id: StringName, return_copy: bool = true)
Returns the projectile with key id
from the projectile_2d_dictionary.
If return_copy
is true
returns a clone, otherwise returns the original reference.
Projectile2DModifier get_projectile_2d_modifier(id: StringName, return_copy: bool = true)
Returns a projectile-specific modifier with key id
from the modifiers_dictionary.
If return_copy
is true
returns a clone, otherwise returns the original reference.
ProjectileBlueprint2D get_projectile_blueprint_2d(id: StringName)
Returns the projectile blueprint with key id
from the projectile_blueprints_2d_dictionary.
Attack2D register_and_get_attack_2d(blueprint: AttackBlueprint2D, return_copy: bool = true)
Registers an AttackBlueprint2D in the attack_blueprint_dictionary under its name and returns the corresponding Attack2D object.
Automatically creates the attack if it doesn't exist in the database.
If return_copy
is true
returns a clone, otherwise returns the original reference.
Projectile2D register_and_get_projectile_2d(blueprint: ProjectileBlueprint2D, return_copy: bool = true)
Registers a ProjectileBlueprint2D in the projectile_blueprints_dictionary under its name and returns the corresponding Projectile2D object.
Automatically creates the projectile if it doesn't exist in the database.
If return_copy
is true
returns a clone, otherwise returns the original reference.
void set_attack_2d(id: StringName, attack: Attack2D)
Stores attack
in the attack_2d_dictionary under the key id
.
void set_attack_blueprint_2d(id: StringName, attack: AttackBlueprint2D)
Stores attack
in the attack_blueprint_2d_dictionary under the key id
.
void set_modifier(modifier: TimedModifier, id: StringName = modifier.name)
Stores modifier
in the modifiers_dictionary under the key id
.
void set_projectile_2d(id: StringName, projectile: Projectile2D)
Stores projectile
in the projectile_2d_dictionary under the key id
.
void set_projectile_blueprint_2d(id: StringName, projectile: ProjectileBlueprint2D)
Stores projectile
in the projectile_blueprints_2d_dictionary under the key id
.