update
This commit is contained in:
22
systems/heal_system.gd
Normal file
22
systems/heal_system.gd
Normal file
@@ -0,0 +1,22 @@
|
||||
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")
|
||||
Reference in New Issue
Block a user