diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-04-27 20:06:49 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-04-27 20:06:49 +0200 |
commit | 81cc6f1d22677dd4a60aa9377c91b291bf10e523 (patch) | |
tree | 9c22712a9746ed0598a44be6e88727d021436860 /Scenes/Entities/Enemies/Components/Collision.gd | |
parent | c8a316e4b8987dad963656a34665fa0e23dedcb1 (diff) |
update
Diffstat (limited to 'Scenes/Entities/Enemies/Components/Collision.gd')
-rw-r--r-- | Scenes/Entities/Enemies/Components/Collision.gd | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Scenes/Entities/Enemies/Components/Collision.gd b/Scenes/Entities/Enemies/Components/Collision.gd index b2e8d9b..2dfba2a 100644 --- a/Scenes/Entities/Enemies/Components/Collision.gd +++ b/Scenes/Entities/Enemies/Components/Collision.gd @@ -11,8 +11,19 @@ signal collided @export_node_path("CollisionShape2D") var collision_shape_path: NodePath @onready var collision_shape: CollisionShape2D = get_node(collision_shape_path) +@export_node_path("Component_Health") var component_health_path: NodePath +var component_health: Component_Health + func init(): var collision_area = Utilities.Collision.Area.new(entity, collision_shape) + collision_area.set_collision_mask_value(Utilities.Collision.Layer.PLAYER, true) collision_area.connect("collided", func(area): emit_signal("collided", area)) entity.add_child(collision_area) + + if component_health_path: + component_health = get_node(component_health_path) + collision_area.connect("collided", func(area): + if area.is_in_group("explosions"): + component_health.take_damage() + ) |