47 lines
743 B
C#
47 lines
743 B
C#
|
|
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();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|