documentation pass before moving on
This commit is contained in:
parent
c6923a3133
commit
ddf3590c96
17 changed files with 84 additions and 44 deletions
|
|
@ -1,6 +1,7 @@
|
|||
@abstract
|
||||
class_name BulletBehavior
|
||||
extends Resource
|
||||
## Controls the movment and actions of a [Bullet].
|
||||
|
||||
|
||||
@export_group("Actions", "action_")
|
||||
|
|
@ -14,11 +15,14 @@ extends Resource
|
|||
@export var action_on_interval: BulletAction
|
||||
|
||||
|
||||
var _bullet_delay_cooldowns: Dictionary[Bullet, float] = {}
|
||||
var _bullet_interval_cooldowns: Dictionary[Bullet, float] = {}
|
||||
|
||||
|
||||
## Performs behavior-specific initialization for a [Bullet].
|
||||
func init_bullet(bullet: Bullet) -> void:
|
||||
if action_on_delay:
|
||||
_bullet_delay_cooldowns[bullet] = action_delay
|
||||
if action_on_interval:
|
||||
_bullet_interval_cooldowns[bullet] = action_interval
|
||||
bullet.recycled.connect(deinit_bullet.bind(bullet), CONNECT_ONE_SHOT)
|
||||
|
|
@ -27,20 +31,23 @@ func init_bullet(bullet: Bullet) -> void:
|
|||
|
||||
## Cleans up behavior-specific state for a [Bullet].
|
||||
func deinit_bullet(bullet: Bullet) -> void:
|
||||
_bullet_delay_cooldowns.erase(bullet)
|
||||
_bullet_interval_cooldowns.erase(bullet)
|
||||
_deinit_bullet(bullet)
|
||||
|
||||
|
||||
## Processes one tick of a [Bullet]'s movement.
|
||||
func process_bullet(bullet: Bullet, delta: float) -> void:
|
||||
#var last_time = bullet.time_elapsed
|
||||
#bullet.time_elapsed += delta
|
||||
#if last_time < action_delay and bullet.time_elapsed >= action_delay and action_on_delay:
|
||||
#action_on_delay.perform(bullet)
|
||||
if action_on_delay and _bullet_delay_cooldowns.has(bullet):
|
||||
_bullet_delay_cooldowns[bullet] -= delta
|
||||
if _bullet_delay_cooldowns[bullet] <= 0.0:
|
||||
_bullet_delay_cooldowns.erase(bullet)
|
||||
action_on_delay.perform(bullet)
|
||||
if action_on_interval:
|
||||
_bullet_interval_cooldowns[bullet] -= delta
|
||||
if _bullet_interval_cooldowns[bullet] <= 0.0:
|
||||
_bullet_interval_cooldowns[bullet] += action_interval
|
||||
action_on_interval.perform(bullet)
|
||||
_process_bullet(bullet, delta)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
class_name SimpleLinearBehavior
|
||||
class_name LinearMotionBehavior
|
||||
extends BulletBehavior
|
||||
## Makes bullets move in [member Bullet.direction], potentially accelerating.
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue