bullets bullets bullets bullets

This commit is contained in:
Haze Weathers 2025-12-31 14:09:06 -06:00
parent 846040c0e4
commit 55059788b2
25 changed files with 139 additions and 91 deletions

View file

@ -0,0 +1,12 @@
@abstract
class_name BulletAction
extends Resource
## Performs the action on a given [Bullet].
func perform(bullet: Bullet) -> void:
_perform(bullet)
## Called to perform the action on a given [Bullet].
@abstract func _perform(bullet: Bullet) -> void

View file

@ -0,0 +1 @@
uid://mivkgn34ox41

View file

@ -0,0 +1,7 @@
class_name DespawnAction
extends BulletAction
## Removes and recycles the [Bullet] when triggered.
func _perform(bullet: Bullet) -> void:
bullet.recycle()

View file

@ -0,0 +1 @@
uid://pn143vuxc7wp

View file

@ -0,0 +1,12 @@
class_name MultiAction
extends BulletAction
## Performs a set of [BulletAction]s in order when triggered.
## [BulletAction]s to perform when triggered.
@export var actions: Array[BulletAction] = []
func _perform(bullet: Bullet) -> void:
for action in actions:
action.perform(bullet)

View file

@ -0,0 +1 @@
uid://mair8nsxn7lp

View file

@ -0,0 +1,30 @@
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)

View file

@ -0,0 +1 @@
uid://oug6n1t6tnor