diff --git a/behaviours/spawner.gd b/behaviours/spawner.gd index 53f7927..382e68c 100644 --- a/behaviours/spawner.gd +++ b/behaviours/spawner.gd @@ -30,14 +30,15 @@ func disable(): func spawn(): if not enabled: spawn_blocked.emit() - return + return null if not target: target = MainGame.get_via_group(self).default_spawn_parent if not target: target = self if not scene: Log.w(self, "Not spawning, no scene is set.") - return + return null var entity = scene.instantiate() entity.global_position = global_position target.add_child.call_deferred(entity) # Not sure why this is needed. + return entity diff --git a/entities/chupacabra.tscn b/entities/chupacabra.tscn index 2a2fc83..82ae7cb 100644 --- a/entities/chupacabra.tscn +++ b/entities/chupacabra.tscn @@ -365,7 +365,7 @@ radius = 32.0 [node name="Chupacabra" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 8 +collision_layer = 72 collision_mask = 14 motion_mode = 1 script = ExtResource("1_s4qg1") diff --git a/entities/cthulhu.tscn b/entities/cthulhu.tscn index 20f9d14..97f0885 100644 --- a/entities/cthulhu.tscn +++ b/entities/cthulhu.tscn @@ -194,7 +194,7 @@ radius = 50.0 [node name="Cthulhu" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 8 +collision_layer = 72 collision_mask = 14 script = ExtResource("1_b55wc") diff --git a/entities/gold.tscn b/entities/gold.tscn index 85e85a2..542204a 100644 --- a/entities/gold.tscn +++ b/entities/gold.tscn @@ -28,12 +28,14 @@ scale = Vector2(2, 2) texture = ExtResource("2_tt3v6") [node name="MagnetizeArea" parent="." instance=ExtResource("3_ne3sj")] +collision_mask = 128 [node name="Shape" type="CollisionShape2D" parent="MagnetizeArea"] shape = SubResource("CircleShape2D_w1h35") debug_color = Color(0.337255, 0.611765, 1, 0) [node name="CollectArea" parent="." instance=ExtResource("3_ne3sj")] +collision_mask = 128 [node name="Shape" type="CollisionShape2D" parent="CollectArea"] shape = SubResource("CircleShape2D_jm7yp") diff --git a/entities/imp.tscn b/entities/imp.tscn index 2a2c504..4214e54 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -233,7 +233,7 @@ radius = 40.0 [node name="Imp" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 8 +collision_layer = 72 collision_mask = 14 motion_mode = 1 script = ExtResource("1_dixpc") diff --git a/entities/monocle.tscn b/entities/monocle.tscn index a014df4..44c7a4d 100644 --- a/entities/monocle.tscn +++ b/entities/monocle.tscn @@ -107,7 +107,7 @@ radius = 12.0 [node name="Monocle" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 8 +collision_layer = 72 collision_mask = 14 motion_mode = 1 script = ExtResource("1_ehpfj") diff --git a/entities/sacrifice_stone.tscn b/entities/sacrifice_stone.tscn index 990d456..c6b3fa7 100644 --- a/entities/sacrifice_stone.tscn +++ b/entities/sacrifice_stone.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=3 uid="uid://ddpo03rb6068c"] +[gd_scene load_steps=7 format=3 uid="uid://ddpo03rb6068c"] [ext_resource type="Script" path="res://entities/sacrifice_stone.gd" id="1_sgl1t"] [ext_resource type="PackedScene" uid="uid://dfdr3e32lohq" path="res://behaviours/edible.tscn" id="1_y58y4"] @@ -8,6 +8,9 @@ [sub_resource type="CircleShape2D" id="CircleShape2D_yv6hf"] radius = 8.0 +[sub_resource type="RectangleShape2D" id="RectangleShape2D_55alx"] +size = Vector2(150, 150) + [node name="SacrificeStone" type="Node2D"] y_sort_enabled = true script = ExtResource("1_sgl1t") @@ -41,5 +44,15 @@ shape = SubResource("CircleShape2D_yv6hf") one_way_collision_margin = 27.5 debug_color = Color(1, 0, 0, 0) +[node name="ForbidSpawn" type="Area2D" parent="."] +position = Vector2(0, -29) +collision_layer = 64 +collision_mask = 0 +monitoring = false + +[node name="Shape" type="CollisionShape2D" parent="ForbidSpawn"] +shape = SubResource("RectangleShape2D_55alx") +debug_color = Color(0.733333, 0.447059, 0.411765, 0.419608) + [connection signal="tracked" from="StoneArea/SacrificeTracker" to="." method="_on_tracked"] [connection signal="untracked" from="StoneArea/SacrificeTracker" to="." method="_on_untracked"] diff --git a/entities/sheep.tscn b/entities/sheep.tscn index 60db440..9865833 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -210,7 +210,7 @@ radius = 8.65 [node name="Sheep" type="CharacterBody2D"] z_index = 1 y_sort_enabled = true -collision_layer = 8 +collision_layer = 72 collision_mask = 14 motion_mode = 1 script = ExtResource("1_4dmll") diff --git a/entities/skull.tscn b/entities/skull.tscn index 17d5a8e..9b4745b 100644 --- a/entities/skull.tscn +++ b/entities/skull.tscn @@ -115,7 +115,7 @@ radius = 32.0 [node name="Skull" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 8 +collision_layer = 72 collision_mask = 14 motion_mode = 1 script = ExtResource("1_7g8bu") diff --git a/entities/top_hat.tscn b/entities/top_hat.tscn index e904197..3c8761e 100644 --- a/entities/top_hat.tscn +++ b/entities/top_hat.tscn @@ -106,7 +106,7 @@ radius = 12.0 [node name="TopHat" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 8 +collision_layer = 72 collision_mask = 14 motion_mode = 1 script = ExtResource("1_0eh11") diff --git a/entities/tree.tscn b/entities/tree.tscn index d82fd81..6427e58 100644 --- a/entities/tree.tscn +++ b/entities/tree.tscn @@ -16,7 +16,7 @@ scale = Vector2(2, 2) texture = ExtResource("1_yk0t0") [node name="Upper" type="StaticBody2D" parent="."] -collision_layer = 16 +collision_layer = 80 collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Upper"] diff --git a/entities/watcher.tscn b/entities/watcher.tscn index 9741cb1..1d78981 100644 --- a/entities/watcher.tscn +++ b/entities/watcher.tscn @@ -192,7 +192,7 @@ radius = 40.0 [node name="Watcher" type="CharacterBody2D"] z_index = 10 -collision_layer = 16 +collision_layer = 80 collision_mask = 18 script = ExtResource("1_brahc") diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd index 457a4d9..a0a435d 100644 --- a/scenes/game/cursor.gd +++ b/scenes/game/cursor.gd @@ -69,8 +69,8 @@ func _input(event: InputEvent) -> void: if event.pressed: var counter: Counter = game.inventory.get_counter(&"Gold") if counter.value >= sheep_spawn_cost: - counter.decrease(sheep_spawn_cost) - sheep_spawner.spawn() + if sheep_spawner.spawn(): + counter.decrease(sheep_spawn_cost) func _physics_process(_delta: float) -> void: diff --git a/scenes/game/cursor.tscn b/scenes/game/cursor.tscn index 4737f8e..0b7f3d2 100644 --- a/scenes/game/cursor.tscn +++ b/scenes/game/cursor.tscn @@ -14,7 +14,7 @@ radius = 8.0 [node name="Cursor" type="Area2D" groups=["cursor"]] z_index = 100 -collision_layer = 64 +collision_layer = 128 collision_mask = 56 script = ExtResource("1_1og6v") @@ -31,9 +31,13 @@ script = ExtResource("3_tutfd") scene = ExtResource("4_7isfg") [node name="Tracker" parent="SheepSpawner" instance=ExtResource("5_ewy4o")] +collision_mask = 64 [node name="Shape" type="CollisionShape2D" parent="SheepSpawner/Tracker"] shape = SubResource("CircleShape2D_dc2ul") +[connection signal="area_entered" from="SheepSpawner/Tracker" to="SheepSpawner/Tracker" method="track"] +[connection signal="area_exited" from="SheepSpawner/Tracker" to="SheepSpawner/Tracker" method="untrack"] [connection signal="empty" from="SheepSpawner/Tracker" to="SheepSpawner" method="enable"] +[connection signal="tracked" from="SheepSpawner/Tracker" to="SheepSpawner/Tracker" method="log_tracked"] [connection signal="tracked" from="SheepSpawner/Tracker" to="SheepSpawner" method="disable" unbinds=1]