update
This commit is contained in:
@@ -10,6 +10,7 @@ func _ready() -> void:
|
||||
health_regen = stats.health_regen
|
||||
current_health = max_health
|
||||
EventBus.damage_requested.connect(_on_damage_requested)
|
||||
EventBus.heal_requested.connect(_on_heal_requested)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if current_health > 0 and current_health < max_health and health_regen > 0:
|
||||
@@ -34,3 +35,11 @@ func take_damage(amount: float, attacker: Node) -> void:
|
||||
EventBus.health_changed.emit(get_parent(), current_health, max_health)
|
||||
if current_health <= 0:
|
||||
EventBus.entity_died.emit(get_parent())
|
||||
|
||||
func heal(amount: float) -> void:
|
||||
current_health = min(current_health + amount, max_health)
|
||||
EventBus.health_changed.emit(get_parent(), current_health, max_health)
|
||||
|
||||
func _on_heal_requested(healer: Node, target: Node, amount: float) -> void:
|
||||
if target == get_parent():
|
||||
heal(amount)
|
||||
|
||||
Reference in New Issue
Block a user