32 lines
937 B
GDScript
32 lines
937 B
GDScript
@abstract
|
|
class_name BulletBehavior
|
|
extends Resource
|
|
|
|
|
|
## Performs behavior-specific initialization for a [Bullet].
|
|
func init_bullet(bullet: Bullet) -> void:
|
|
bullet.recycled.connect(deinit_bullet.bind(bullet), CONNECT_ONE_SHOT)
|
|
_init_bullet(bullet)
|
|
|
|
|
|
## Cleans up behavior-specific state for a [Bullet].
|
|
func deinit_bullet(bullet: Bullet) -> void:
|
|
_deinit_bullet(bullet)
|
|
|
|
|
|
## Processes one tick of a [Bullet]'s movement.
|
|
func process_bullet(bullet: Bullet, delta: float) -> void:
|
|
_process_bullet(bullet, delta)
|
|
|
|
|
|
## Called when a [Bullet] is spawned with this behavior in order to set up
|
|
## behavior-specific state.
|
|
@abstract func _init_bullet(bullet: Bullet) -> void
|
|
|
|
|
|
## Called when a [Bullet] is recycled in order to clean up behavior-specific state.
|
|
@abstract func _deinit_bullet(bullet: Bullet) -> void
|
|
|
|
|
|
## Called to process a tick of a [Bullet]'s movement.
|
|
@abstract func _process_bullet(bullet: Bullet, delta: float) -> void
|