feat(rooms): add RoomChest nodes to Floor 0 rooms

ReceptionDesk, GiftShopShelf, RestaurantCounter, EmergencyCabinet added
to their respective tscn files. Fixes spawn_items deferred call to avoid
add_child race during _ready tree setup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Steven Wroblewski
2026-05-09 01:16:15 +02:00
parent 87db92955a
commit a877d8f5fe
6 changed files with 83 additions and 5 deletions
+7 -1
View File
@@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://cozypaw_emergency"]
[gd_scene load_steps=5 format=3 uid="uid://cozypaw_emergency"]
[ext_resource type="PackedScene" path="res://scenes/objects/InteractiveObject.tscn" id="1_iobj"]
[ext_resource type="PackedScene" path="res://scenes/objects/Ambulance.tscn" id="2_ambulance"]
[ext_resource type="Script" path="res://scripts/objects/snap_point.gd" id="3_snap"]
[ext_resource type="Script" path="res://scripts/objects/room_chest.gd" id="4_chest"]
[node name="EmergencyRoom" type="Node2D"]
@@ -79,3 +80,8 @@ trigger_room = 3
position = Vector2(310, 480)
script = ExtResource("3_snap")
pose = "lying"
[node name="EmergencyCabinet" type="Node2D" parent="."]
position = Vector2(150.0, 400.0)
script = ExtResource("4_chest")
chest_id = "emergency_cabinet"
+7 -1
View File
@@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=3 uid="uid://cozypaw_giftshop"]
[gd_scene load_steps=4 format=3 uid="uid://cozypaw_giftshop"]
[ext_resource type="PackedScene" path="res://scenes/objects/InteractiveObject.tscn" id="1_iobj"]
[ext_resource type="Script" path="res://scripts/objects/snap_point.gd" id="2_snap"]
[ext_resource type="Script" path="res://scripts/objects/room_chest.gd" id="3_chest"]
[node name="GiftShop" type="Node2D"]
@@ -68,3 +69,8 @@ position = Vector2(640, 510)
[node name="SnapCounter" type="Node2D" parent="."]
position = Vector2(640, 528)
script = ExtResource("2_snap")
[node name="GiftShopShelf" type="Node2D" parent="."]
position = Vector2(120.0, 300.0)
script = ExtResource("3_chest")
chest_id = "giftshop_shelf"
+7 -1
View File
@@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=3 uid="uid://cozypaw_reception"]
[gd_scene load_steps=4 format=3 uid="uid://cozypaw_reception"]
[ext_resource type="PackedScene" path="res://scenes/objects/InteractiveObject.tscn" id="1_iobj"]
[ext_resource type="Script" path="res://scripts/objects/snap_point.gd" id="2_snap"]
[ext_resource type="Script" path="res://scripts/objects/room_chest.gd" id="3_chest"]
[node name="Reception" type="Node2D"]
@@ -102,3 +103,8 @@ script = ExtResource("2_snap")
[node name="SnapBenchRight2" type="Node2D" parent="."]
position = Vector2(1080, 555)
script = ExtResource("2_snap")
[node name="ReceptionDesk" type="Node2D" parent="."]
position = Vector2(120.0, 555.0)
script = ExtResource("3_chest")
chest_id = "reception_desk"
+7 -1
View File
@@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=3 uid="uid://cozypaw_restaurant"]
[gd_scene load_steps=4 format=3 uid="uid://cozypaw_restaurant"]
[ext_resource type="PackedScene" path="res://scenes/objects/InteractiveObject.tscn" id="1_iobj"]
[ext_resource type="Script" path="res://scripts/objects/snap_point.gd" id="2_snap"]
[ext_resource type="Script" path="res://scripts/objects/room_chest.gd" id="3_chest"]
[node name="Restaurant" type="Node2D"]
@@ -118,3 +119,8 @@ script = ExtResource("2_snap")
[node name="SnapTable3Right" type="Node2D" parent="."]
position = Vector2(1120, 510)
script = ExtResource("2_snap")
[node name="RestaurantCounter" type="Node2D" parent="."]
position = Vector2(120.0, 555.0)
script = ExtResource("3_chest")
chest_id = "restaurant_counter"
+1 -1
View File
@@ -18,7 +18,7 @@ func _ready() -> void:
_item_configs = RoomChestConfig.get_items(chest_id)
if not chest_id.is_empty() and GameState.has_method("get_chest_state"):
if not GameState.get_chest_state(chest_id).is_empty():
spawn_items()
call_deferred("spawn_items")
func spawn_items() -> void:
+54
View File
@@ -0,0 +1,54 @@
## Tests for RoomChest presence and item counts in Floor 0 rooms.
extends GutTest
func test_reception_has_chest_reception_desk() -> void:
var room: Node = preload("res://scenes/rooms/floor0/Reception.tscn").instantiate()
add_child_autofree(room)
assert_not_null(room.get_node_or_null("ReceptionDesk"))
func test_reception_desk_has_three_items() -> void:
var room: Node = preload("res://scenes/rooms/floor0/Reception.tscn").instantiate()
add_child_autofree(room)
var chest: RoomChest = room.get_node_or_null("ReceptionDesk") as RoomChest
assert_eq(chest.get_item_config_count(), 3)
func test_giftshop_has_chest_giftshop_shelf() -> void:
var room: Node = preload("res://scenes/rooms/floor0/GiftShop.tscn").instantiate()
add_child_autofree(room)
assert_not_null(room.get_node_or_null("GiftShopShelf"))
func test_giftshop_shelf_has_three_items() -> void:
var room: Node = preload("res://scenes/rooms/floor0/GiftShop.tscn").instantiate()
add_child_autofree(room)
var chest: RoomChest = room.get_node_or_null("GiftShopShelf") as RoomChest
assert_eq(chest.get_item_config_count(), 3)
func test_restaurant_has_chest_restaurant_counter() -> void:
var room: Node = preload("res://scenes/rooms/floor0/Restaurant.tscn").instantiate()
add_child_autofree(room)
assert_not_null(room.get_node_or_null("RestaurantCounter"))
func test_restaurant_counter_has_three_items() -> void:
var room: Node = preload("res://scenes/rooms/floor0/Restaurant.tscn").instantiate()
add_child_autofree(room)
var chest: RoomChest = room.get_node_or_null("RestaurantCounter") as RoomChest
assert_eq(chest.get_item_config_count(), 3)
func test_emergency_has_chest_emergency_cabinet() -> void:
var room: Node = preload("res://scenes/rooms/floor0/EmergencyRoom.tscn").instantiate()
add_child_autofree(room)
assert_not_null(room.get_node_or_null("EmergencyCabinet"))
func test_emergency_cabinet_has_three_items() -> void:
var room: Node = preload("res://scenes/rooms/floor0/EmergencyRoom.tscn").instantiate()
add_child_autofree(room)
var chest: RoomChest = room.get_node_or_null("EmergencyCabinet") as RoomChest
assert_eq(chest.get_item_config_count(), 3)