extends Node @export var door : Node @export var switches = [] # Called when the node enters the scene tree for the first time. func _ready() -> void: SignalBus.switch_changed.connect(_on_switch_changed) for i in self.get_children(): if i.is_in_group("switch"): switches.append(i) print(switches) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass func _on_switch_changed() -> void: var switches_needed = switches.size() var switches_on = 0 for i in switches: if i.switched_on: switches_on += 1 print("switches on " + str(switches_on)) if switches_on == switches_needed: if door.door_open == false: door.open() else: if door.door_open == true: door.close()