forked from aly/qstbak
42 lines
826 B
C#
42 lines
826 B
C#
using System;
|
|
|
|
namespace Questionable.Controller.Steps.Common;
|
|
|
|
internal static class WaitCondition
|
|
{
|
|
internal sealed record Task(Func<bool> Predicate, string Description) : ITask
|
|
{
|
|
public override string ToString()
|
|
{
|
|
return Description;
|
|
}
|
|
}
|
|
|
|
internal sealed class WaitConditionExecutor : TaskExecutor<Task>
|
|
{
|
|
private long _continueAtMs;
|
|
|
|
protected override bool Start()
|
|
{
|
|
return !base.Task.Predicate();
|
|
}
|
|
|
|
public override ETaskResult Update()
|
|
{
|
|
if (_continueAtMs == 0L && base.Task.Predicate())
|
|
{
|
|
_continueAtMs = Environment.TickCount64 + 500;
|
|
}
|
|
if (_continueAtMs <= 0 || Environment.TickCount64 < _continueAtMs)
|
|
{
|
|
return ETaskResult.StillRunning;
|
|
}
|
|
return ETaskResult.TaskComplete;
|
|
}
|
|
|
|
public override bool ShouldInterruptOnDamage()
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|