extends Node # GameState.gd - simple resource manager singleton (add as Autoload 'GameState' in Project Settings) var resources := { "metal": 100, "energy": 50 } func add_resource(kind: String, amount: int): if not resources.has(kind): resources[kind] = 0 resources[kind] += amount func spend_resource(kind: String, amount: int) -> bool: if resources.get(kind, 0) >= amount: resources[kind] -= amount return true return false