38 lines
756 B
C#
38 lines
756 B
C#
![]() |
using Base;
|
||
|
using Unity.VisualScripting;
|
||
|
|
||
|
namespace AI
|
||
|
{
|
||
|
public abstract class JobBase
|
||
|
{
|
||
|
public Entity.Entity entity;
|
||
|
private int timeoutTicks = 1000;
|
||
|
public bool Running=>timeoutTicks > 0;
|
||
|
|
||
|
public virtual void StartJob(Entity.Entity target)
|
||
|
{
|
||
|
entity = target;
|
||
|
}
|
||
|
|
||
|
protected abstract void UpdateJob();
|
||
|
|
||
|
public bool Update()
|
||
|
{
|
||
|
if(!Running)
|
||
|
return false;
|
||
|
UpdateJob();
|
||
|
timeoutTicks--;
|
||
|
if (timeoutTicks <= 0)
|
||
|
{
|
||
|
StopJob();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
public virtual void StopJob()
|
||
|
{
|
||
|
timeoutTicks = 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|