2024-08-04 09:08:12 +00:00
|
|
|
|
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
|
{
|
2025-11-26 14:23:59 +00:00
|
|
|
[Tool][GlobalClass, Icon("res://addons/rokojori_action_library/Icons/SetNodeState.svg")]
|
2025-01-08 18:46:17 +00:00
|
|
|
public partial class SetNodeState : Action
|
2024-08-04 09:08:12 +00:00
|
|
|
{
|
2026-02-26 14:06:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
|
public Node[] enable = [];
|
|
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
|
public Node[] disable = [];
|
|
|
|
|
|
|
|
|
|
[ExportGroup( "Reference")]
|
2024-08-04 09:08:12 +00:00
|
|
|
[Export]
|
2026-02-26 14:06:27 +00:00
|
|
|
public SetNodeState reference;
|
2024-08-04 09:08:12 +00:00
|
|
|
|
|
|
|
|
[Export]
|
2026-02-26 14:06:27 +00:00
|
|
|
public bool inverseReference = false;
|
|
|
|
|
|
2024-08-04 09:08:12 +00:00
|
|
|
|
2025-01-08 18:46:17 +00:00
|
|
|
protected override void _OnTrigger()
|
2025-10-24 11:38:51 +00:00
|
|
|
{
|
2026-02-26 14:06:27 +00:00
|
|
|
this.CallDeferred(
|
|
|
|
|
()=>
|
|
|
|
|
{
|
|
|
|
|
var map = new System.Collections.Generic.HashSet<SetNodeState>();
|
|
|
|
|
SetStates( map, false, inverseReference );
|
|
|
|
|
}
|
|
|
|
|
);
|
2025-10-24 11:38:51 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-26 14:06:27 +00:00
|
|
|
public void SetStates( System.Collections.Generic.HashSet<SetNodeState> callMap, bool inverse, bool referenceInverse )
|
2024-08-04 09:08:12 +00:00
|
|
|
{
|
2026-02-26 14:06:27 +00:00
|
|
|
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 );
|
|
|
|
|
|
2024-08-04 09:08:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|