Added visibility component

This commit is contained in:
2024-02-13 20:38:17 +01:00
parent 5caf5f6c71
commit 7937645028
12 changed files with 124 additions and 107 deletions

View File

@ -8,23 +8,23 @@ const DEATH_THRESHOLD = 0.01
@export var max_value: float
var value: float
var is_dead: bool
var is_alive: bool
func _ready():
restore()
func restore():
is_dead = false
is_alive = true
value = max_value
value_changed.emit()
func take_damage(attack: DamageInstance):
if is_dead:
if !is_alive:
return
value = clampf(value - attack.damage, 0, max_value)
value_changed.emit()
if value < DEATH_THRESHOLD:
is_dead = true
is_alive = false
death.emit()