added project with nerabochie cows
This commit is contained in:
13
scenes/components/damage_component.gd
Normal file
13
scenes/components/damage_component.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
class_name DamageComponent
|
||||
extends Node2D
|
||||
|
||||
@export var max_damage = 1
|
||||
@export var current_damage = 0
|
||||
|
||||
signal max_damaged_reached
|
||||
|
||||
func apply_damage(damage: int) -> void:
|
||||
current_damage = clamp(current_damage + damage, 0, max_damage)
|
||||
|
||||
if current_damage == max_damage:
|
||||
max_damaged_reached.emit()
|
||||
Reference in New Issue
Block a user