This commit is contained in:
Marek Le
2026-03-30 09:03:29 +02:00
parent 80a65fa555
commit 4fddc74df1
31 changed files with 295 additions and 153 deletions

View File

@@ -1,16 +1,19 @@
extends Node
@export var max_health := 100.0
const HEALTH_REGEN := 1.0
@export var stats: EntityStats
var max_health: float
var health_regen: float
var current_health: float
func _ready() -> void:
max_health = stats.max_health
health_regen = stats.health_regen
current_health = max_health
EventBus.damage_requested.connect(_on_damage_requested)
func _process(delta: float) -> void:
if current_health > 0 and current_health < max_health:
current_health = min(current_health + HEALTH_REGEN * delta, max_health)
if current_health > 0 and current_health < max_health and health_regen > 0:
current_health = min(current_health + health_regen * delta, max_health)
EventBus.health_changed.emit(get_parent(), current_health, max_health)
func _on_damage_requested(attacker: Node, target: Node, amount: float) -> void: