예제 #1
0
 public void SetParallel <A>(bool p = true) where A : T
 {
     if (!routines.ContainsKey(typeof(A)))
     {
         routines[typeof(A)] = new RoutineListContainer <A>();
     }
     routines[typeof(A)].parallel = p;
 }
예제 #2
0
        public IEnumerator Post <A>(A _args) where A : T
        {
            if (actions != null && actions.ContainsKey(typeof(A)))
            {
                ActionListContainer <A> action_list = actions[typeof(A)] as ActionListContainer <A>;

                List <Listener> temp = new List <Listener>(action_list);
                for (int i = 0; i < temp.Count; i++)
                {
                    Listener it = temp[i];
                    if (it == null)
                    {
                        continue;
                    }
                    (it._delegate as System.Action <A>)(_args);
                }
            }

            if (routines != null && routines.ContainsKey(typeof(A)))
            {
                RoutineListContainer <A> routine_list = routines[typeof(A)] as RoutineListContainer <A>;
                //Extensions.RunInfo inf = null;
                List <RoutineListener <A> > temp = new List <RoutineListener <A> >(routine_list);
                for (int i = 0; i < temp.Count; i++)
                {
                    RoutineListener <A> it = temp[i];
                    if (it == null)
                    {
                        continue;
                    }

/*
 *                  if (routine_list.parallel)
 *                  {
 *                      inf = it._delegate(_args).ParallelCoroutine(typeof(A).ToString());
 *                  }
 *                  else  */
                    yield return(it._delegate(_args));
                }

                /* if (routine_list.parallel)
                 * {
                 *  while (inf.count > 0) yield return null;
                 * } */
            }
        }
예제 #3
0
        public RoutineListener <A> Attach <A>(int priority, Func <A, IEnumerator> ienum) where A : T
        {
            //TODO: check if this routine has been attached already
            if (!routines.ContainsKey(typeof(A)))
            {
                routines[typeof(A)] = new RoutineListContainer <A>();
            }
            if ((routines[typeof(A)] as RoutineListContainer <A>).Find(c => c._delegate == ienum) != null)
            {
                return((routines[typeof(A)] as RoutineListContainer <A>).Find(c => c._delegate == ienum));
            }

            RoutineListener <A> final = new RoutineListener <A>(typeof(A), ienum, priority);

            routines[typeof(A)].Add(final, priority);

            return(final);
        }