Sync working project files - hub layout, boss roster, doc updates

This commit is contained in:
2026-03-05 15:50:37 -05:00
parent 6ce4531b76
commit f1b4820307
47 changed files with 1476 additions and 402 deletions
+38 -26
View File
@@ -1,4 +1,5 @@
extends CharacterBody2D
class_name EnemyBase
# ---------------------------------------------------------------------------
# Stats — override in derived enemy types
@@ -10,11 +11,13 @@ var contact_damage: float = 1.0
var contact_cooldown: float = 0.8
# ---------------------------------------------------------------------------
# Internal state
# Internal state — shared across all enemies
# ---------------------------------------------------------------------------
var _contact_timer: float = 0.0
var _flash_timer: float = 0.0
var _player: Node2D = null
var _contact_timer: float = 0.0
var _flash_timer: float = 0.0
var _slow_factor: float = 1.0
var _slow_timer: float = 0.0
var _player: Node2D = null
@onready var visual: Node2D = $Visual
@@ -22,22 +25,41 @@ func _ready() -> void:
add_to_group("enemies")
$ContactArea.body_entered.connect(_on_contact_entered)
func _physics_process(delta: float) -> void:
_contact_timer = maxf(_contact_timer - delta, 0.0)
_tick_flash(delta)
_chase_player()
move_and_slide()
# ---------------------------------------------------------------------------
# AI — simple chaser
# Shared helpers — call from derived _physics_process as needed
# ---------------------------------------------------------------------------
func _chase_player() -> void:
func _find_player() -> void:
if _player == null or not is_instance_valid(_player):
_player = get_tree().get_first_node_in_group("player")
if _player != null:
velocity = (_player.global_position - global_position).normalized() * speed
func _tick_contact(delta: float) -> void:
if _contact_timer > 0.0:
_contact_timer -= delta
if _contact_timer <= 0.0:
_contact_timer = 0.0
# Re-apply damage if player is still overlapping after cooldown
for body in $ContactArea.get_overlapping_bodies():
if body.is_in_group("player"):
body.take_damage(contact_damage)
_contact_timer = contact_cooldown
break
func _tick_flash(delta: float) -> void:
if _flash_timer > 0.0:
_flash_timer -= delta
visual.modulate = Color(2.5, 2.5, 2.5)
else:
velocity = Vector2.ZERO
visual.modulate = Color(1.0, 1.0, 1.0)
func apply_slow(duration: float, factor: float) -> void:
_slow_factor = factor
_slow_timer = duration
func _tick_slow(delta: float) -> void:
if _slow_timer > 0.0:
_slow_timer -= delta
if _slow_timer <= 0.0:
_slow_factor = 1.0
# ---------------------------------------------------------------------------
# Damage / death
@@ -63,14 +85,4 @@ func _spawn_drop() -> void:
func _on_contact_entered(body: Node) -> void:
if body.is_in_group("player") and _contact_timer == 0.0:
body.take_damage(contact_damage)
_contact_timer = contact_cooldown
# ---------------------------------------------------------------------------
# Hit flash
# ---------------------------------------------------------------------------
func _tick_flash(delta: float) -> void:
if _flash_timer > 0.0:
_flash_timer -= delta
visual.modulate = Color(2.5, 2.5, 2.5)
else:
visual.modulate = Color(1.0, 1.0, 1.0)
_contact_timer = contact_cooldown