Files
mmo/systems/heal_system.gd
Marek Lenczewski f1d34ebf1d update
2026-04-04 00:00:15 +02:00

23 lines
899 B
GDScript

extends Node
func _ready() -> void:
EventBus.heal_requested.connect(_on_heal_requested)
func _on_heal_requested(_healer: Node, target: Node, amount: float) -> void:
if target == _get_player():
var health: float = min(PlayerData.health + amount, PlayerData.max_health)
PlayerData.set_health(health)
elif target.is_in_group("boss"):
var health: float = BossData.get_stat(target, "health")
var max_health: float = BossData.get_stat(target, "max_health")
health = min(health + amount, max_health)
BossData.set_health(target, health)
elif target.is_in_group("enemies"):
var health: float = EnemyData.get_stat(target, "health")
var max_health: float = EnemyData.get_stat(target, "max_health")
health = min(health + amount, max_health)
EnemyData.set_health(target, health)
func _get_player() -> Node:
return get_tree().get_first_node_in_group("player")