documentation pass before moving on

This commit is contained in:
Haze Weathers 2026-01-02 20:30:18 -06:00
parent c6923a3133
commit ddf3590c96
17 changed files with 84 additions and 44 deletions

View file

@ -8,19 +8,21 @@ extends Area2D
signal recycled()
# ## The number of bullets to allocate at startup.
#const INITIAL_ALLOCATED_BULLETS: int = 2000
# cached shapes for each hitbox size
static var _hitbox_shapes: Dictionary[Vector2i, RectangleShape2D] = {}
## Texture to draw for the bullet.
## Base graphic/animation to display, modulated by [member color].
@export var base_graphic: AnimationStrip = null:
set(value):
base_graphic = value
queue_redraw()
_update_visibility_notifier()
## The color that [member base_graphic] will be modulated by.
@export var color: Color
## Extra graphic drawn over [member base_graphic] and not modulated by [member color].
@export var overlay_graphic: AnimationStrip = null:
set(value):
overlay_graphic = value
@ -49,22 +51,13 @@ var time_elapsed: float = 0.0
## Whether the bullet has already been grazed by the player.
var grazed: bool = false
#static var _cached_bullets: Array[Bullet] = []
static var _hitbox_shapes: Dictionary[Vector2i, RectangleShape2D] = {}
var _hitbox: CollisionShape2D = CollisionShape2D.new()
## Returns a new [Bullet], which may be sourced from the cached bullets.
@warning_ignore("shadowed_variable")
static func create(
preset: BulletPreset,
direction: Vector2 = Vector2.RIGHT,
) -> Bullet:
#var bullet: Bullet = _cached_bullets.pop_back()
#if not bullet:
#bullet = Bullet.new()
static func create(preset: BulletPreset, direction: Vector2 = Vector2.RIGHT) -> Bullet:
var bullet := Bullet.new()
if not preset.base_graphics.is_empty():
@ -84,21 +77,6 @@ static func create(
return bullet
## Removes the bullet from the scene tree and returns it to the bullet cache to be
## re-used later.
func recycle() -> void:
#if is_inside_tree():
#get_parent().remove_child(self)
#_cached_bullets.append(self)
queue_free()
recycled.emit()
#static func _static_init() -> void:
#for _i in INITIAL_ALLOCATED_BULLETS:
#_cached_bullets.append(Bullet.new())
func _init() -> void:
monitoring = false
collision_layer = 1 << 3
@ -130,6 +108,13 @@ func _get_configuration_warnings() -> PackedStringArray:
return []
## Removes the bullet from the scene tree and returns it to the bullet cache to be
## re-used later.
func recycle() -> void:
queue_free()
recycled.emit()
# sets the canvas item up to notify when it leaves the screen
# this essentially mimics `VisibleOnScreenNotifier` without an additional node
func _update_visibility_notifier() -> void: