Exemple #1
0
        public Coroutine StartTaskCoroutine(Task task, string methodName, object value)
        {
            MethodInfo method = task.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (method == null)
            {
                Debug.LogError((object)("Unable to start coroutine " + methodName + ": method not found"));
                return((Coroutine)null);
            }
            if (this.activeTaskCoroutines == null)
            {
                this.activeTaskCoroutines = new Dictionary <string, List <TaskCoroutine> >();
            }
            TaskCoroutine taskCoroutine = new TaskCoroutine(this, (IEnumerator)method.Invoke((object)task, new object[1]
            {
                value
            }), methodName);

            if (this.activeTaskCoroutines.ContainsKey(methodName))
            {
                List <TaskCoroutine> activeTaskCoroutine = this.activeTaskCoroutines[methodName];
                activeTaskCoroutine.Add(taskCoroutine);
                this.activeTaskCoroutines[methodName] = activeTaskCoroutine;
            }
            else
            {
                this.activeTaskCoroutines.Add(methodName, new List <TaskCoroutine>()
                {
                    taskCoroutine
                });
            }
            return(taskCoroutine.Coroutine);
        }
Exemple #2
0
        public Coroutine StartTaskCoroutine(Task task, string methodName)
        {
            MethodInfo method = task.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (method == null)
            {
                UnityEngine.Debug.LogError("Unable to start coroutine " + methodName + ": method not found");
                return(null);
            }
            if (this.activeTaskCoroutines == null)
            {
                this.activeTaskCoroutines = new Dictionary <string, List <TaskCoroutine> >();
            }
            TaskCoroutine taskCoroutine = new TaskCoroutine(this, (IEnumerator)method.Invoke(task, new object[0]), methodName);

            if (this.activeTaskCoroutines.ContainsKey(methodName))
            {
                List <TaskCoroutine> list = this.activeTaskCoroutines[methodName];
                list.Add(taskCoroutine);
                this.activeTaskCoroutines[methodName] = list;
            }
            else
            {
                List <TaskCoroutine> list2 = new List <TaskCoroutine>();
                list2.Add(taskCoroutine);
                this.activeTaskCoroutines.Add(methodName, list2);
            }
            return(taskCoroutine.Coroutine);
        }
Exemple #3
0
 public void TaskCoroutineEnded(TaskCoroutine taskCoroutine, string coroutineName)
 {
     if (this.activeTaskCoroutines.ContainsKey(coroutineName))
     {
         List <TaskCoroutine> list = this.activeTaskCoroutines[coroutineName];
         if (list.Count == 1)
         {
             this.activeTaskCoroutines.Remove(coroutineName);
         }
         else
         {
             list.Remove(taskCoroutine);
             this.activeTaskCoroutines[coroutineName] = list;
         }
     }
 }
Exemple #4
0
        public void TaskCoroutineEnded(TaskCoroutine taskCoroutine, string coroutineName)
        {
            if (!this.activeTaskCoroutines.ContainsKey(coroutineName))
            {
                return;
            }
            List <TaskCoroutine> activeTaskCoroutine = this.activeTaskCoroutines[coroutineName];

            if (activeTaskCoroutine.Count == 1)
            {
                this.activeTaskCoroutines.Remove(coroutineName);
            }
            else
            {
                activeTaskCoroutine.Remove(taskCoroutine);
                this.activeTaskCoroutines[coroutineName] = activeTaskCoroutine;
            }
        }