Esempio n. 1
0
 public void Reset()
 {
     Task                = null;
     Delay               = 0;
     Interval            = 0;
     TimeSinceLastInvoke = 0;
     started             = false;
     cancelTime          = 0;
     TotalRunTime        = 0;
     active              = true;
 }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
    /// <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;
        }
    }
Esempio n. 4
0
 /// <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_);
 }
Esempio n. 5
0
 /// <summary>
 /// Is any invoke of task pending?
 /// </summary>
 public static bool IsInvoking(this MonoBehaviour mono, OakTask task)
 {
     return(mono.IsInvoking(task.Method.Name));
 }
Esempio n. 6
0
 /// <summary>
 /// Cancels all Invoke calls task on this behaviour.
 /// </summary>
 public static void CancelInvoke(this MonoBehaviour mono, OakTask task)
 {
     mono.CancelInvoke(task.Method.Name);
 }
Esempio n. 7
0
 /// <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);
 }
Esempio n. 8
0
 /// <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);
 }