Create persistence manager and connectors for chests and gates
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user