public void Reset() { Task = null; Delay = 0; Interval = 0; TimeSinceLastInvoke = 0; started = false; cancelTime = 0; TotalRunTime = 0; active = true; }
public void InvokeRepeating(OakTask task_, float delay_, float interval_, float cancelTime = 0) { var invokeTask = _tasksCache.GetCleanTask(); invokeTask.Delay = delay_; invokeTask.Interval = interval_; invokeTask.Task = task_; invokeTask.started = false; invokeTask.cancelTime = cancelTime; _tasks.Add(invokeTask); }
/// <summary> /// Wont break if task is not actually Invoking /// </summary> public void StopInvoke(OakTask task, float delay) { var invTask = _tasks.Find(t => t.Task == task); if (invTask == null) { return; } if (delay == 0) { StopTask(invTask); } else { invTask.cancelTime = invTask.TotalRunTime + delay; } }
/// <summary> /// Invokes just once /// </summary> public void Invoke(OakTask task_, float delay_) { // using cancelTime = delay can work because record are remove at the end of Update loop InvokeRepeating(task_, delay_, 0, delay_); }
/// <summary> /// Is any invoke of task pending? /// </summary> public static bool IsInvoking(this MonoBehaviour mono, OakTask task) { return(mono.IsInvoking(task.Method.Name)); }
/// <summary> /// Cancels all Invoke calls task on this behaviour. /// </summary> public static void CancelInvoke(this MonoBehaviour mono, OakTask task) { mono.CancelInvoke(task.Method.Name); }
/// <summary> /// Invokes the method task in time seconds. /// After the first invocation repeats calling that function every repeatRate seconds. /// </summary> public static void InvokeRepeating(this MonoBehaviour mono, OakTask task, float time, float repeatRate) { mono.InvokeRepeating(task.Method.Name, time, repeatRate); }
/// <summary> /// Invokes the method methodtask in time seconds. /// </summary> public static void Invoke(this MonoBehaviour mono, OakTask task, float time) { mono.Invoke(task.Method.Name, time); }