2024-02-13 00:22:27 +01:00

19 lines
293 B
GDScript

class_name HealthComponent
extends Node
signal value_changed
@export var max_value: float
var value: float
func _ready():
value = max_value
value_changed.emit()
func take_damage(attack: DamageInstance):
value -= attack.damage
value_changed.emit()
if value <= 0:
owner.queue_free()