Add Unit Tests for HealthComponent

This commit is contained in:
Squinty 2024-04-21 17:50:32 +00:00
parent c9d4a50412
commit aa2bbfda19
3 changed files with 64 additions and 11 deletions

View file

@ -21,19 +21,19 @@ class_name HealthComponent extends Area3D
health_changed.emit(value)
signal health_zeroed
signal health_changed(value : int)
signal health_changed(value : float)
func _ready() -> void:
heal_full()
@rpc("call_local")
func damage(amount : int) -> void:
func damage(amount : float) -> void:
health = clampf(health - amount, 0.0, max_health)
if health == 0.0:
health_zeroed.emit()
@rpc("call_local")
func _heal(amount : int) -> void:
func _heal(amount : float) -> void:
health = clampf(health + amount, 0.0, max_health)
func heal_full() -> void: