rokojori_action_library/Runtime/Behavior/BehaviorSequence.cs

47 lines
743 B
C#
Raw Normal View History

2026-10-05 19:25:04 +00:00
using Godot;
using Rokojori.Extensions;
namespace Rokojori;
[Tool]
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Action.svg")]
public partial class BehaviorSequence:Sequence
{
[Export]
public bool loop = false;
[Export]
public bool isExclusive = true;
[Export]
public bool reinitialize = false;
Brain _brain;
public override void _Ready()
{
base._Ready();
_brain = NodesWalker.Get().GetParentWithType<Brain>( this );
onSequenceDone.AddAction( OnDone );
}
void OnDone( SequenceActionFinishedEvent ev )
{
if ( _brain == null || _brain.activeSequence != this )
{
return;
}
if ( loop )
{
Trigger();
}
else
{
_brain.Trigger();
}
}
}