Files
brotato/scenes/unit/unit.gd
T
2026-05-18 15:46:44 +08:00

22 lines
569 B
GDScript

extends Node2D
class_name Unit
@export var stats: UnitStats
@onready var visuals: Node2D = %Visuals
@onready var sprite: Sprite2D = %Sprite
@onready var anim_player: AnimationPlayer = $AnimationPlayer
@onready var health_component: HealthComponent = $HealthComponent
func _ready() -> void:
print(stats)
health_component.setup(stats)
func _on_hurtbox_component_on_damaged(hitbox: HitboxComponent) -> void:
if health_component.current_health <=0:
return
health_component.take_damage(hitbox.damage)
print("%s: %d" % [name, health_component.current_health] )