conforms file names to consistant standard
This commit is contained in:
23
scripts/health.gd
Normal file
23
scripts/health.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
class_name Health
|
||||
extends Node
|
||||
|
||||
signal health_depleted
|
||||
signal health_changed(health: int)
|
||||
|
||||
@export var max_health: int = 10
|
||||
|
||||
var current_health: int
|
||||
|
||||
|
||||
func take_damage(damage: int) -> void:
|
||||
current_health -= damage
|
||||
health_changed.emit(current_health)
|
||||
if current_health <= 0:
|
||||
health_depleted.emit()
|
||||
|
||||
|
||||
func heal_damage(healing: int) -> void:
|
||||
current_health += healing
|
||||
if current_health > max_health:
|
||||
current_health = max_health
|
||||
health_changed.emit(current_health)
|
||||
Reference in New Issue
Block a user