rokojori_action_library/Runtime/Actions/Solo.cs

46 lines
904 B
C#
Raw Normal View History

2025-07-22 14:08:22 +00:00
2026-02-26 14:06:27 +00:00
using System.Linq;
2025-07-22 14:08:22 +00:00
using Godot;
namespace Rokojori
{
[Tool][GlobalClass ]
public partial class Solo:Action
{
[Export]
public Node soloNode;
[Export]
public NodeStateConfiguration soloConfiguration;
[Export]
public NodeStateConfiguration muteConifiguration;
2026-02-26 14:06:27 +00:00
[Export]
public Node[] ignore = [];
2025-07-22 14:08:22 +00:00
protected override void _OnTrigger()
{
var parent = soloNode.GetParent();
2026-02-26 14:06:27 +00:00
var soloConfig = soloConfiguration ?? NodeStateConfiguration.AllOn();
var muteConfig = muteConifiguration ?? NodeStateConfiguration.AllOff();
2025-07-22 14:08:22 +00:00
parent.ForEachDirectChild<Node>(
n =>
{
2026-02-26 14:06:27 +00:00
if ( ignore != null && ignore.Contains( n ) )
{
return;
}
var configuration = soloNode == n ? soloConfig : muteConfig;
2025-07-22 14:08:22 +00:00
NodeState.Configure( n, configuration );
}
);
}
}
}