diff --git a/behaviours/collectable.tscn b/behaviours/collectable.tscn index d9cfe9b..82d564c 100644 --- a/behaviours/collectable.tscn +++ b/behaviours/collectable.tscn @@ -9,6 +9,8 @@ radius = 16.0 script = ExtResource("1_p0pc3") [node name="MouseArea" type="Area2D" parent="."] +collision_layer = 0 +collision_mask = 0 monitorable = false [node name="Shape" type="CollisionShape2D" parent="MouseArea"] diff --git a/behaviours/draggable.tscn b/behaviours/draggable.tscn index 6750bf5..24c8ffc 100644 --- a/behaviours/draggable.tscn +++ b/behaviours/draggable.tscn @@ -7,6 +7,8 @@ radius = 8.0 [node name="Draggable" type="Area2D"] +collision_layer = 0 +collision_mask = 0 script = ExtResource("1_hdedq") [node name="Shape" type="CollisionShape2D" parent="."] diff --git a/behaviours/hover_detector.tscn b/behaviours/hover_detector.tscn index 04097d6..d79fa3e 100644 --- a/behaviours/hover_detector.tscn +++ b/behaviours/hover_detector.tscn @@ -6,6 +6,8 @@ radius = 8.0 [node name="HoverDetector" type="Area2D"] +collision_layer = 0 +collision_mask = 0 monitorable = false script = ExtResource("1_51m5p") diff --git a/behaviours/hunter.tscn b/behaviours/hunter.tscn index f206d8c..42fcfc7 100644 --- a/behaviours/hunter.tscn +++ b/behaviours/hunter.tscn @@ -9,6 +9,9 @@ radius = 100.0 script = ExtResource("1_3bmd5") [node name="DetectionArea" type="Area2D" parent="."] +collision_layer = 0 +collision_mask = 24 +monitorable = false [node name="Shape" type="CollisionShape2D" parent="DetectionArea"] shape = SubResource("CircleShape2D_kxb8e") diff --git a/behaviours/move_towards_target.tscn b/behaviours/move_towards_target.tscn index 0a18f6e..433b6e8 100644 --- a/behaviours/move_towards_target.tscn +++ b/behaviours/move_towards_target.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=3 format=3 uid="uid://c7b4v6h7a3dy6"] +[gd_scene load_steps=3 format=3 uid="uid://kceb2v2dm0qn"] [ext_resource type="Script" path="res://behaviours/move_towards_target.gd" id="1_703gy"] [ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/hover_detector.tscn" id="2_nq6qb"] @@ -7,6 +7,7 @@ script = ExtResource("1_703gy") [node name="CaptureArea" parent="." instance=ExtResource("2_nq6qb")] +collision_mask = 24 [connection signal="mouse_entered" from="CaptureArea" to="." method="_on_capture_area_mouse_entered"] [connection signal="mouse_exited" from="CaptureArea" to="." method="_on_capture_area_mouse_exited"] diff --git a/behaviours/spawner.gd b/behaviours/spawner.gd new file mode 100644 index 0000000..13a0411 --- /dev/null +++ b/behaviours/spawner.gd @@ -0,0 +1,18 @@ +extends Node2D +class_name Spawner + +signal spawned(entity: Node2D) + +@export var scene: PackedScene +@export var parent: Node2D + +func spawn(): + var entity = scene.instantiate() + entity.global_scale = global_scale + entity.global_position = global_position + entity.global_rotation = global_rotation + parent.add_child(entity) + +func _ready(): + if parent == null: + parent = MainGame.get_ancestor(self).get_node("SpawnedEntities") diff --git a/behaviours/spawner.tscn b/behaviours/spawner.tscn new file mode 100644 index 0000000..2154f4a --- /dev/null +++ b/behaviours/spawner.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://cyrg770fsetyu"] + +[ext_resource type="Script" path="res://behaviours/spawner.gd" id="1_b4uk0"] + +[node name="Spawner" type="Node2D"] +script = ExtResource("1_b4uk0") diff --git a/entities/sheep.tscn b/entities/sheep.tscn index bca940d..56d1ffe 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -10,6 +10,8 @@ radius = 16.0 [sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_08frh"] [node name="Sheep" type="CharacterBody2D"] +collision_layer = 8 +collision_mask = 14 script = ExtResource("1_4dmll") [node name="Shape" type="CollisionShape2D" parent="."] diff --git a/project.godot b/project.godot index 804c00b..4d6dda9 100644 --- a/project.godot +++ b/project.godot @@ -33,6 +33,16 @@ main_menu={ ] } +[layer_names] + +2d_physics/layer_1="Unset" +2d_physics/layer_2="Tiles" +2d_physics/layer_3="Trees" +2d_physics/layer_4="Entities (grounded)" +2d_physics/layer_5="Entities (air)" +2d_physics/layer_6="Pickups" +2d_physics/layer_7="System" + [physics] common/physics_ticks_per_second=100 diff --git a/scenes/game/cursor_magnet.tscn b/scenes/game/cursor_magnet.tscn index c262ae5..05866a1 100644 --- a/scenes/game/cursor_magnet.tscn +++ b/scenes/game/cursor_magnet.tscn @@ -7,6 +7,8 @@ radius = 16.0 [node name="CursorMagnet" type="Area2D"] +collision_layer = 64 +collision_mask = 8 script = ExtResource("1_xk040") [node name="Shape" type="CollisionShape2D" parent="."] diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index 543c167..7ee58c3 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -66,3 +66,5 @@ position = Vector2(-135, -134) [node name="Sheep2" parent="." instance=ExtResource("5_63bwb")] position = Vector2(-462, -77) + +[node name="SpawnedEntities" type="Node2D" parent="."]