22 lines
623 B
GDScript
22 lines
623 B
GDScript
extends Node
|
|
|
|
@export var chests: Array[NodePath]
|
|
|
|
# Private Methods
|
|
func _ready() -> void:
|
|
for relative_node_path in chests:
|
|
var chest: BaseChest = get_node(relative_node_path)
|
|
var node_path := chest.get_path()
|
|
chest.ChestOpened.connect(func(): _on_chest_opened(chest))
|
|
|
|
if PersistenceManager.HasData(node_path):
|
|
var chest_opened: bool = PersistenceManager.GetData(node_path)
|
|
if chest_opened:
|
|
chest.call_deferred("SetOpenedFromLoad")
|
|
|
|
|
|
func _on_chest_opened(chest: BaseChest) -> void:
|
|
var node_path := chest.get_path()
|
|
PersistenceManager.UpdateData(node_path, true)
|
|
PersistenceManager.SaveToDisk()
|