From 7aca23c19816e1898a5ee0fda47e37b43609433a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuel.por.aca@gmail.com>
Date: Tue, 12 Nov 2024 10:21:33 -0300
Subject: [PATCH] Helper block for collision with group

This is a 3-in-1 helper block for the common pattern found in the demos.
It replaces adding:
- A "when this node collides with ..." block
- An "if" block
- An "is node in group" block
---
 .../rigidbody2d_on_entered_group.tres         | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 addons/block_code/blocks/communication/rigidbody2d_on_entered_group.tres

diff --git a/addons/block_code/blocks/communication/rigidbody2d_on_entered_group.tres b/addons/block_code/blocks/communication/rigidbody2d_on_entered_group.tres
new file mode 100644
index 00000000..a0d38b5e
--- /dev/null
+++ b/addons/block_code/blocks/communication/rigidbody2d_on_entered_group.tres
@@ -0,0 +1,29 @@
+[gd_resource type="Resource" load_steps=5 format=3 uid="uid://vkxfyk7uglo7"]
+
+[ext_resource type="Script" path="res://addons/block_code/blocks/communication/groups.gd" id="1_2f03u"]
+[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_aom4j"]
+[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_xf3iq"]
+
+[sub_resource type="Resource" id="Resource_1plv6"]
+script = ExtResource("1_aom4j")
+selected = 0
+items = []
+
+[resource]
+script = ExtResource("1_xf3iq")
+name = &"rigidbody2d_on_entered_group"
+target_node_class = "RigidBody2D"
+description = ""
+category = "Communication | Methods"
+type = 1
+variant_type = 0
+display_template = "when this node collides with [something: OBJECT] in group {group: STRING}"
+code_template = "func _on_body_entered(something: Node2D):
+	if not something.is_in_group({group}):
+		return"
+defaults = {
+"group": SubResource("Resource_1plv6")
+}
+signal_name = "body_entered"
+scope = ""
+extension_script = ExtResource("1_2f03u")