2024-05-04 08:26:16 +00:00
|
|
|
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
2024-05-12 17:03:20 +00:00
|
|
|
/** <summary for="class ActionList">
|
|
|
|
|
|
|
|
<title>
|
|
|
|
Executes multiple actions (RJAction) at once.
|
|
|
|
</title>
|
|
|
|
|
|
|
|
<description>
|
|
|
|
The ActionList, which is an RJAction itself, executes all actions stored in the member 'actions' and also child nodes
|
|
|
|
that extend RJAction, when 'triggerDirectChildren' is checked.
|
|
|
|
|
|
|
|
</description>
|
|
|
|
|
|
|
|
</summary>
|
|
|
|
*/
|
|
|
|
|
2024-05-08 07:19:48 +00:00
|
|
|
[GlobalClass, Icon("res://Scripts/Rokojori/Rokojori-Action-Library/Icons/RJActionList.svg") ]
|
2024-05-04 08:26:16 +00:00
|
|
|
public partial class ActionList : RJAction
|
2024-05-12 17:03:20 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/** <summary for="field actions">Actions to execute</summary>*/
|
2024-05-04 08:26:16 +00:00
|
|
|
[Export]
|
|
|
|
public RJAction[] actions;
|
2024-05-12 17:03:20 +00:00
|
|
|
|
|
|
|
/** <summary for="field triggerDirectChildren">Whether to execute RJAction child nodes</summary>*/
|
|
|
|
[Export]
|
2024-05-04 08:26:16 +00:00
|
|
|
public bool triggerDirectChildren = true;
|
|
|
|
|
2024-05-05 07:52:06 +00:00
|
|
|
public override void _OnTrigger()
|
2024-05-04 08:26:16 +00:00
|
|
|
{
|
2024-05-05 07:52:06 +00:00
|
|
|
if ( actions != null )
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < actions.Length; i++ )
|
|
|
|
{
|
|
|
|
Actions.Trigger( actions[ i ] );
|
|
|
|
}
|
|
|
|
}
|
2024-05-04 08:26:16 +00:00
|
|
|
|
2024-05-05 07:52:06 +00:00
|
|
|
if ( ! triggerDirectChildren )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-05-12 17:03:20 +00:00
|
|
|
Nodes.ForEachDirectChild<RJAction>( this, a => Actions.Trigger( a ) );
|
|
|
|
|
|
|
|
/*
|
2024-05-05 07:52:06 +00:00
|
|
|
var childCount = GetChildCount();
|
|
|
|
|
|
|
|
for ( int i = 0; i < childCount; i++ )
|
|
|
|
{
|
|
|
|
var action = GetChild( i ) as RJAction;
|
|
|
|
|
|
|
|
if ( action == null )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Actions.Trigger( action );
|
|
|
|
}
|
2024-05-04 08:26:16 +00:00
|
|
|
|
2024-05-12 17:03:20 +00:00
|
|
|
*/
|
2024-05-04 08:26:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|