Add new level, collapsable component, knockback component

This commit is contained in:
2024-12-31 02:51:07 +01:00
parent 529dc0f5dc
commit 366c269817
17 changed files with 647 additions and 31 deletions

View File

@@ -1,7 +1,20 @@
class_name DamageComponent
extends Node2D
extends Node
@export var damage: float = 0.25
@export var area2d: Area2D
func _ready() -> void:
if not area2d:
printerr("No area2d assigned!")
return
area2d.body_entered.connect(on_area2d_body_entered)
func deal_damage(target: HealthComponent):
target.decrease_health(damage)
func on_area2d_body_entered(body: Node2D):
if body.has_node("HealthComponent"):
var health_component: HealthComponent = body.get_node("HealthComponent")
deal_damage(health_component)