From da81aa103e4cf76d23bc932f858f3be718e2420f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 3 Apr 2022 09:06:30 +0200 Subject: [PATCH] :wrench: Free enemy on death --- src/entities/Enemy.gd | 5 +++++ src/entities/Enemy.tscn | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/entities/Enemy.gd diff --git a/src/entities/Enemy.gd b/src/entities/Enemy.gd new file mode 100644 index 0000000..5e1f5c3 --- /dev/null +++ b/src/entities/Enemy.gd @@ -0,0 +1,5 @@ +extends KinematicBody2D + + +func _on_Damageable_dead(): + queue_free() diff --git a/src/entities/Enemy.tscn b/src/entities/Enemy.tscn index 434d2e7..32f9329 100644 --- a/src/entities/Enemy.tscn +++ b/src/entities/Enemy.tscn @@ -1,16 +1,18 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://src/mechanics/Black.png" type="Texture" id=1] [ext_resource path="res://src/entities/behaviours/ErraticMovement.tscn" type="PackedScene" id=2] [ext_resource path="res://src/entities/behaviours/AttractedTo.tscn" type="PackedScene" id=3] [ext_resource path="res://src/entities/behaviours/Damageable.tscn" type="PackedScene" id=4] [ext_resource path="res://src/entities/behaviours/Alliance.tscn" type="PackedScene" id=5] +[ext_resource path="res://src/entities/Enemy.gd" type="Script" id=6] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 16, 16 ) [node name="Enemy" type="KinematicBody2D"] collision_layer = 3 +script = ExtResource( 6 ) [node name="Shape" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) @@ -26,3 +28,5 @@ texture = ExtResource( 1 ) [node name="Alliance" parent="." instance=ExtResource( 5 )] alliance = -1 + +[connection signal="dead" from="Damageable" to="." method="_on_Damageable_dead"]