Added health bars
This commit is contained in:
7
client/player/health/DamageInstance.gd
Normal file
7
client/player/health/DamageInstance.gd
Normal file
@ -0,0 +1,7 @@
|
||||
class_name DamageInstance
|
||||
|
||||
var damage: float
|
||||
|
||||
func _init(_damage: float):
|
||||
damage = _damage
|
||||
|
18
client/player/health/HealthComponent.gd
Normal file
18
client/player/health/HealthComponent.gd
Normal file
@ -0,0 +1,18 @@
|
||||
class_name HealthComponent
|
||||
extends Node
|
||||
|
||||
signal value_changed
|
||||
|
||||
@export var max_value: float
|
||||
var value: float
|
||||
|
||||
func _ready():
|
||||
value = max_value
|
||||
value_changed.emit()
|
||||
|
||||
func take_damage(attack: DamageInstance):
|
||||
value -= attack.damage
|
||||
value_changed.emit()
|
||||
|
||||
if value <= 0:
|
||||
owner.queue_free()
|
6
client/player/health/HealthComponent.tscn
Normal file
6
client/player/health/HealthComponent.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://2bbycjulf00g"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/health/HealthComponent.gd" id="1_403dm"]
|
||||
|
||||
[node name="Health" type="Node"]
|
||||
script = ExtResource("1_403dm")
|
Reference in New Issue
Block a user