Fix brick throwing, add enemy death

This commit is contained in:
2025-01-05 06:41:53 +01:00
parent 5b558f9c3b
commit 697a9b7deb
44 changed files with 1061 additions and 7 deletions

View File

@@ -0,0 +1,28 @@
class_name EnemyDeathComponent
extends Node
@export var root: Node2D
@export var tween_duration: float = 0.5
@export var collision_shape_2d: CollisionShape2D
@export var health_component: HealthComponent
func _ready() -> void:
if not collision_shape_2d:
printerr("No CollisionShape2D assigned!")
return
if not health_component:
printerr("No HealthComponent assigned!")
return
health_component.on_death.connect(_on_health_component_on_death)
func _on_health_component_on_death() -> void:
call_deferred("die")
func die() -> void:
collision_shape_2d.disabled = true
var tween := create_tween()
tween.tween_property(root, "scale", Vector2(0, 0), tween_duration)
await (tween.finished)
root.queue_free()