From e789ea0717332c44fb38ba13e82579aed4a68fef Mon Sep 17 00:00:00 2001 From: godzilla5hrimp Date: Sun, 20 Sep 2026 16:29:17 +0200 Subject: [PATCH] feat: add persistence to the opened chest via SceneManager opened_chests array; --- Scenes/SceneManager/scene_manager.gd | 10 +--------- Scenes/TreasureChest/treasure_chest.gd | 4 ++++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Scenes/SceneManager/scene_manager.gd b/Scenes/SceneManager/scene_manager.gd index bfb4973..872d07f 100644 --- a/Scenes/SceneManager/scene_manager.gd +++ b/Scenes/SceneManager/scene_manager.gd @@ -1,12 +1,4 @@ extends Node2D var player_next_scene_spawn_pos: Vector2 - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass +var opened_chests: Array[String] = [] diff --git a/Scenes/TreasureChest/treasure_chest.gd b/Scenes/TreasureChest/treasure_chest.gd index 5b0d0a3..f924a32 100644 --- a/Scenes/TreasureChest/treasure_chest.gd +++ b/Scenes/TreasureChest/treasure_chest.gd @@ -7,6 +7,8 @@ var scroll_number = 0 func _ready() -> void: scroll_number = randi_range(1, 4) + if SceneManager.opened_chests.has(name): + is_open = true func _process(delta: float) -> void: if Input.is_action_just_pressed("Interact") and can_interact: @@ -17,6 +19,8 @@ func _process(delta: float) -> void: print("found sprite num: ", scroll_number) scrolls[scroll_number].visible = true is_open = true + SceneManager.opened_chests.append(name) + print(SceneManager.opened_chests) func _on_timer_timeout() -> void: print("removing sprite: ", scroll_number)