rokojori_action_library/Runtime/Actions/Solo.cs

47 lines
935 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;
2026-05-22 12:25:02 +00:00
using Rokojori.Extensions;
2025-07-22 14:08:22 +00:00
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;
2026-05-22 12:25:02 +00:00
NodeState.ConfigureWith( n, configuration );
2025-07-22 14:08:22 +00:00
}
);
}
}
}