punish v6.8.18.0
This commit is contained in:
commit
e786325cda
322 changed files with 554232 additions and 0 deletions
44
Questionable/Questionable.Controller.Steps/TaskExecutor.cs
Normal file
44
Questionable/Questionable.Controller.Steps/TaskExecutor.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
|
||||
namespace Questionable.Controller.Steps;
|
||||
|
||||
internal abstract class TaskExecutor<T> : ITaskExecutor where T : class, ITask
|
||||
{
|
||||
protected T Task { get; set; }
|
||||
|
||||
public InteractionProgressContext? ProgressContext { get; set; }
|
||||
|
||||
ITask ITaskExecutor.CurrentTask => Task;
|
||||
|
||||
public virtual bool WasInterrupted()
|
||||
{
|
||||
InteractionProgressContext progressContext = ProgressContext;
|
||||
if (progressContext != null)
|
||||
{
|
||||
progressContext.Update();
|
||||
return progressContext.WasInterrupted();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Type GetTaskType()
|
||||
{
|
||||
return typeof(T);
|
||||
}
|
||||
|
||||
protected abstract bool Start();
|
||||
|
||||
public bool Start(ITask task)
|
||||
{
|
||||
if (task is T task2)
|
||||
{
|
||||
Task = task2;
|
||||
return Start();
|
||||
}
|
||||
throw new TaskException($"Unable to cast {task.GetType()} to {typeof(T)}");
|
||||
}
|
||||
|
||||
public abstract ETaskResult Update();
|
||||
|
||||
public abstract bool ShouldInterruptOnDamage();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue