rabidus-test/Assets/Plugins/QFSW/Quantum Console/Source/Scripts/Actions/Wait.cs

30 lines
713 B
C#
Raw Permalink Normal View History

2023-08-22 15:41:12 +03:00
using UnityEngine;
namespace QFSW.QC.Actions
{
/// <summary>
/// Waits for the given amount of seconds using scaled time.
/// </summary>
public class Wait : ICommandAction
{
private float _startTime;
private readonly float _duration;
public bool IsFinished => Time.time >= _startTime + _duration;
public bool StartsIdle => true;
/// <param name="seconds">The duration to wait in seconds.</param>
public Wait(float seconds)
{
_duration = seconds;
}
public void Start(ActionContext ctx)
{
_startTime = Time.time;
}
public void Finalize(ActionContext ctx) { }
}
}