rj-action-library/Runtime/Actions/Time/DelayedList.cs

57 lines
1.1 KiB
C#
Raw Normal View History

2025-01-16 07:20:32 +00:00
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class DelayedList : Action
{
[Export]
public float durationInbetween = 0.1f;
[Export]
public float growDuration = 0.0f;
[Export]
public TimeLine timeLine;
[Export]
public Action[] actions = new Action[ 0 ];
2025-01-16 07:20:32 +00:00
/** <summary for="field triggerDirectChildren">Whether to execute Action child nodes</summary>*/
[Export]
public bool triggerDirectChildren = true;
protected override void _OnTrigger()
{
var list = new List<Action>();
list.AddRange( actions );
if ( triggerDirectChildren )
{
list.AddRange( Nodes.GetDirectChildren<Action>( this ) );
}
var offset = 0f;
var grow = 0f;
for ( int i = 0; i < list.Count; i++ )
{
2025-01-19 20:35:51 +00:00
TimeLineManager.ScheduleEventIn( timeLine, offset,
2025-01-16 07:20:32 +00:00
id =>
{
Action.Trigger( list[ i ] );
}
);
grow += growDuration;
offset += durationInbetween + grow;
}
}
}
}