update
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user