57 lines
962 B
C#
57 lines
962 B
C#
|
|
||
|
using Godot;
|
||
|
|
||
|
|
||
|
namespace Rokojori
|
||
|
{
|
||
|
[GlobalClass]
|
||
|
public partial class Delay : RJSequenceAction
|
||
|
{
|
||
|
[Export]
|
||
|
public float duration;
|
||
|
|
||
|
[Export]
|
||
|
public string message;
|
||
|
|
||
|
float elapsed = 0;
|
||
|
bool running = false;
|
||
|
bool finished = false;
|
||
|
|
||
|
int runID = 0;
|
||
|
|
||
|
public override void _Ready()
|
||
|
{
|
||
|
/// OnSequenceDone += ( id, success ) => { RJLog.Log( "OnSequenceDone", Name ); } ;
|
||
|
}
|
||
|
|
||
|
public override void _OnTrigger()
|
||
|
{
|
||
|
//RJLog.Log( "Starting", Name );
|
||
|
runID = DispatchStart();
|
||
|
|
||
|
elapsed = 0;
|
||
|
running = true;
|
||
|
finished = false;
|
||
|
|
||
|
}
|
||
|
|
||
|
public override void _Process( double delta )
|
||
|
{
|
||
|
if ( ! running )
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
elapsed += (float) delta;
|
||
|
|
||
|
if ( elapsed > duration )
|
||
|
{
|
||
|
running = false;
|
||
|
finished = true;
|
||
|
|
||
|
RJLog.Log( Name, " >> '" + message + "'" );
|
||
|
DispatchEnd( runID );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|