39 lines
762 B
C#
39 lines
762 B
C#
![]() |
|
||
|
using Godot;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
|
||
|
namespace Rokojori
|
||
|
{
|
||
|
[Tool]
|
||
|
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/ConditionalAction.svg")]
|
||
|
public partial class CoolDown : Action
|
||
|
{
|
||
|
[Export]
|
||
|
public Action action;
|
||
|
|
||
|
[Export]
|
||
|
public Duration coolDownDuration;
|
||
|
|
||
|
bool _isCoolingDown = false;
|
||
|
protected override void _OnTrigger()
|
||
|
{
|
||
|
if ( _isCoolingDown )
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
_isCoolingDown = coolDownDuration != null;
|
||
|
Trigger( action );
|
||
|
|
||
|
if ( coolDownDuration != null )
|
||
|
{
|
||
|
TimeLineManager.ScheduleEventIn(
|
||
|
coolDownDuration.timeLine, coolDownDuration.GetDurationInSeconds(),
|
||
|
ev => _isCoolingDown = false
|
||
|
);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|