diff --git a/src/entities/behaviours/Damageable.gd b/src/entities/behaviours/Damageable.gd new file mode 100644 index 0000000..d7814d3 --- /dev/null +++ b/src/entities/behaviours/Damageable.gd @@ -0,0 +1,18 @@ +extends Node + + +export var health: int = 1 setget set_health, get_health +export var max_health: int = 1 + +signal health_changed(value) +signal dead + + +func set_health(value): + health = value + emit_signal("health_changed", value) + if health <= 0: + emit_signal("dead") + +func get_health(): + return health diff --git a/src/entities/behaviours/Damageable.tscn b/src/entities/behaviours/Damageable.tscn new file mode 100644 index 0000000..c7bd5c2 --- /dev/null +++ b/src/entities/behaviours/Damageable.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/entities/behaviours/Damageable.gd" type="Script" id=1] + +[node name="Damageable" type="Node"] +script = ExtResource( 1 )