beta-1.4/persistence-implementation (#3)

Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
2026-03-19 13:27:37 -06:00
parent bfe4f7d6a9
commit 5fb4a96159
26 changed files with 277 additions and 15 deletions

View File

@@ -0,0 +1,40 @@
extends Node
@export var gates: Array[NodePath]
# Private Methods
func _ready() -> void:
for node_path in gates:
_handle_spike_gate(node_path)
func _handle_spike_gate(node_path: NodePath) -> bool:
var node := get_node(node_path)
node_path = node.get_path()
if not node.name.begins_with("Spike Gate"):
return false
# Connect Signal
node.connect("Opened", func(): _on_spike_gate_opened(node))
if not PersistenceManager.HasData(node_path):
return true
var is_open: bool = PersistenceManager.GetData(node_path)
if not is_open:
return true
var collision_shape: CollisionShape2D = node.get_node("CollisionShape2D")
var animated_sprite: AnimatedSprite2D = node.get_node("AnimatedSprite2D")
node.set_deferred("is_open", true)
collision_shape.set_deferred("disabled", true)
animated_sprite.call_deferred("play", "open")
return true
func _on_spike_gate_opened(node: Node) -> void:
var path := node.get_path()
PersistenceManager.UpdateData(path, true)
PersistenceManager.SaveToDisk()