21 lines
423 B
GDScript3
21 lines
423 B
GDScript3
|
extends TextureProgressBar
|
||
|
|
||
|
@export var high: Texture2D
|
||
|
@export var medium: Texture2D
|
||
|
@export var low: Texture2D
|
||
|
|
||
|
var health: HealthComponent
|
||
|
|
||
|
func _ready():
|
||
|
health = owner.health
|
||
|
health.value_changed.connect(on_health_changed)
|
||
|
|
||
|
func on_health_changed():
|
||
|
value = health.value / health.max_value
|
||
|
|
||
|
if value < 0.45:
|
||
|
texture_progress = low
|
||
|
elif value < 0.75:
|
||
|
texture_progress = medium
|
||
|
else:
|
||
|
texture_progress = high
|