summaryrefslogtreecommitdiff
path: root/Scenes/Entities/Enemies/Components/Collision.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-04-14 21:49:20 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-04-14 21:49:20 +0200
commitf27937e6e9b6a7146dd09fc711d2d293ecf5abbf (patch)
treee0ddd5e6d356000e4f29af6211a736284a4972ee /Scenes/Entities/Enemies/Components/Collision.gd
parent96d36cee33d6321834565f0a5d412ef95c5ceffd (diff)
update
Diffstat (limited to 'Scenes/Entities/Enemies/Components/Collision.gd')
-rw-r--r--Scenes/Entities/Enemies/Components/Collision.gd18
1 files changed, 18 insertions, 0 deletions
diff --git a/Scenes/Entities/Enemies/Components/Collision.gd b/Scenes/Entities/Enemies/Components/Collision.gd
new file mode 100644
index 0000000..b2e8d9b
--- /dev/null
+++ b/Scenes/Entities/Enemies/Components/Collision.gd
@@ -0,0 +1,18 @@
+extends Node
+
+class_name Component_Collision
+
+
+signal collided
+
+@export_node_path("CharacterBody2D") var entityPath: NodePath
+@onready var entity: CharacterBody2D = get_node(entityPath)
+
+@export_node_path("CollisionShape2D") var collision_shape_path: NodePath
+@onready var collision_shape: CollisionShape2D = get_node(collision_shape_path)
+
+
+func init():
+ var collision_area = Utilities.Collision.Area.new(entity, collision_shape)
+ collision_area.connect("collided", func(area): emit_signal("collided", area))
+ entity.add_child(collision_area)