rokojori_action_library/Runtime/Actions/IterateActions.cs

32 lines
590 B
C#
Raw Normal View History

2025-01-03 12:09:23 +00:00
using Godot;
2026-05-22 12:25:02 +00:00
using Rokojori.Extensions;
2025-01-03 12:09:23 +00:00
namespace Rokojori
{
[Tool][GlobalClass ]
2025-01-08 18:46:17 +00:00
public partial class IterateActions : Action
2025-01-03 12:09:23 +00:00
{
[ExportGroup( "Read Only")]
[Export]
public int iterationIndex = 0;
2025-01-08 18:46:17 +00:00
protected override void _OnTrigger()
2025-01-03 12:09:23 +00:00
{
2025-01-08 18:46:17 +00:00
var num = this.NumDirectChildrenOf<Action>();
2025-01-03 12:09:23 +00:00
if ( num == 0 )
{
iterationIndex = 0;
return;
}
2026-05-22 12:25:02 +00:00
iterationIndex = MathX.RepeatInt( iterationIndex, num );
2025-01-03 12:09:23 +00:00
2026-05-02 10:32:42 +00:00
Action.TriggerSafe( this.GetNthDirectChild<Action>( iterationIndex ) );
2025-01-03 12:09:23 +00:00
iterationIndex++;
}
}
}