using System.Linq; using Godot; using Godot.Collections; namespace Cirno.Scripts.Interactables; public partial class Switch : Interactable { [Export] public Node2D Target { get; set; } [Export] public Array Targets { get; private set; } = new Array(); [Export] public ActivationType ActivationType { get; set; } = ActivationType.Toggle; public override bool Activate() { if (!MeetsRequirements()) return false; // Compatibility for old single system bool success = ActivateTarget(Target); return Targets.Aggregate(success, (current, target) => ActivateTarget(target) | success); } private bool ActivateTarget(Node2D target) { if (target is not IActivable activable) return false; activable?.Activate(ActivationType); return true; } }