30 lines
1 KiB
GDScript
30 lines
1 KiB
GDScript
class_name SpawnSetAction
|
|
extends BulletAction
|
|
## Spawns a new [BulletSet] at the [Bullet]'s position when triggered.
|
|
|
|
|
|
## The [BulletPreset] to use for the spawned [BulletSet].
|
|
@export var preset: BulletPreset
|
|
|
|
## If [code]true[/code], the spawned [BulletSet] will be rotated to face the
|
|
## [Bullet]'s direction.
|
|
@export var match_direction: bool = false
|
|
|
|
## If [code]true[/code], the spawned [BulletSet] will be added as a child of
|
|
## the [Bullet]'s parent [BulletSet]. If [code]false[/code], it will be added
|
|
## as a child of that [BulletSet]'s parent [Node].
|
|
@export var local_coords: bool = false
|
|
|
|
|
|
func _perform(bullet: Bullet) -> void:
|
|
var bullet_set = BulletSet.new()
|
|
bullet_set.preset = preset
|
|
bullet_set.global_position = bullet.global_position
|
|
if local_coords:
|
|
if match_direction:
|
|
bullet_set.rotation = bullet.rotation
|
|
bullet.get_parent().add_child(bullet_set)
|
|
else:
|
|
if match_direction:
|
|
bullet_set.global_rotation = bullet.global_rotation
|
|
bullet.get_parent().get_parent().add_child(bullet_set)
|