ProjectileProcessor2D

Inherits: Node2D < CanvasItem < Node < Object

Class for the All Projectiles engine.


Description

ProjectileProcessor2D is in charge of managing all requested projectiles from all ProjectileCaller2D. It handles projectile instancing, movement, drawing, and disposal.

A successful request_projectile call from any ProjectileCaller2D will create or repurpose a Projectile2D from the inactive id queue. The ProjectileProcessor2D will process all projectiles at runtime; lifetime updates every frame, and movement updates on physic frames.

Note: ProjectileProcessor2D acts as a singleton i.e. it's created when needed and actively restricts the creation of more instances.

Note: ProjectileProcessor2D is intentionally kept obtuse and unapproachable by design. Please avoid using it directly in any way that is not strictly necessary and use ProjectileCaller2D instead.


Properties



Methods



Signals

projectile_array_expanded()

Emitted when a new Projectile2D is added to the projectiles array property.

Note: This signal is not emitted when a new projectile is created, only when the projectiles array expands its capacity.


projectile_inactive_queue_contracted()

Emitted when an element id is removed from the inactive_projectiles_queue array property.


projectile_inactive_queue_expanded()

Emitted when a new element id is added to the inactive_projectiles_queue array property.



Property Descriptions

Array[int] inactive_projectiles_queue = []

A list of all the available indices from inactive Projectile2D's in the projectiles property.


Array[Projectile2D] projectiles = []

A list of all active or inactive Projectile2D's managed by the ProjectileProcessor2D.



Method Descriptions

void _add_projectile(resource: ProjectileBlueprint2D, _position: Vector2, direction: Vector2, destination: Vector2, target: Node2D = null, move_method: Callable = Callable(), start_method: Callable = Callable(), collision_method: Callable = Callable(), expired_method: Callable = Callable())

Creates a new projectile from the given indications.


void add_projectiles_resource(resource: ProjectileBlueprint2D, _position: Vector2, destination: Vector2, target: Node2D = null, move_method: Callable = Callable(), start_method: Callable = Callable(), collision_method: Callable = Callable(), expired_method: Callable = Callable())

Creates a new projectile and all its instances from the given ProjectileBlueprint2D resource.