using Godot; namespace Rokojori { [Tool][GlobalClass, Icon("res://addons/rokojori_action_library/Icons/SetNodeState.svg")] public partial class SetNodeState : Action { [Export] public Node[] enable = []; [Export] public Node[] disable = []; [ExportGroup( "Reference")] [Export] public SetNodeState reference; [Export] public bool inverseReference = false; protected override void _OnTrigger() { this.CallDeferred( ()=> { var map = new System.Collections.Generic.HashSet(); SetStates( map, false, inverseReference ); } ); } public void SetStates( System.Collections.Generic.HashSet callMap, bool inverse, bool referenceInverse ) { if ( callMap.Contains( this ) ) { return; } callMap.Add( this ); if ( inverse ) { Arrays.ForEach( enable, n => NodeState.Disable( n ) ); Arrays.ForEach( disable, n => NodeState.Enable( n ) ); } else { Arrays.ForEach( enable, n => NodeState.Enable( n ) ); Arrays.ForEach( disable, n => NodeState.Disable( n ) ); } if ( reference == null ) { return; } reference.SetStates( callMap, referenceInverse, referenceInverse ); } } }