mirror of
https://github.com/RYGhub/the-cold-night.git
synced 2024-11-22 12:44:20 +00:00
✨ Create Damageable behaviour
This commit is contained in:
parent
62220e1126
commit
113a68bda3
2 changed files with 24 additions and 0 deletions
18
src/entities/behaviours/Damageable.gd
Normal file
18
src/entities/behaviours/Damageable.gd
Normal file
|
@ -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
|
6
src/entities/behaviours/Damageable.tscn
Normal file
6
src/entities/behaviours/Damageable.tscn
Normal file
|
@ -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 )
|
Loading…
Reference in a new issue