示例#1
0
        public override void OnTermination()
        {
            base.OnTermination();

            CoroutineEnumerators.Clear();
            Warehouse.Clear();
        }
示例#2
0
 /// <summary>
 /// 是否运行中
 /// </summary>
 /// <param name="id">协程迭代器ID</param>
 /// <returns>是否运行中</returns>
 public bool IsRunning(string id)
 {
     if (!CoroutineEnumerators.ContainsKey(id))
     {
         return(false);
     }
     return(CoroutineEnumerators[id].IsRunning());
 }
示例#3
0
 /// <summary>
 /// 重启协程
 /// </summary>
 /// <param name="id">协程迭代器ID</param>
 public void Rerun(string id)
 {
     if (!CoroutineEnumerators.ContainsKey(id))
     {
         throw new HTFrameworkException(HTFrameworkModule.Coroutiner, "重启协程失败:不存在ID为 " + id + " 的协程!");
     }
     CoroutineEnumerators[id].Rerun();
 }
示例#4
0
 /// <summary>
 /// 终止指定ID的协程
 /// </summary>
 /// <param name="id">协程迭代器ID</param>
 public void Stop(string id)
 {
     if (!CoroutineEnumerators.ContainsKey(id))
     {
         GlobalTools.LogError("终止协程失败:不存在ID为 " + id + " 的协程!");
         return;
     }
     CoroutineEnumerators[id].Stop();
 }
示例#5
0
        /// <summary>
        /// 运行协程
        /// </summary>
        /// <typeparam name="T1">协程方法的参数类型</typeparam>
        /// <typeparam name="T2">协程方法的参数类型</typeparam>
        /// <param name="action">协程方法</param>
        /// <param name="arg1">协程方法的参数</param>
        /// <param name="arg2">协程方法的参数</param>
        /// <returns>协程迭代器ID</returns>
        public string Run <T1, T2>(CoroutineAction <T1, T2> action, T1 arg1, T2 arg2)
        {
            CoroutineEnumerator coroutineEnumerator = Main.m_ReferencePool.Spawn <CoroutineEnumerator>().Fill(action, new object[] { arg1, arg2 });

            coroutineEnumerator.Run();
            CoroutineEnumerators.Add(coroutineEnumerator.ID, coroutineEnumerator);
            DepositWarehouse(coroutineEnumerator);
            return(coroutineEnumerator.ID);
        }
示例#6
0
        /// <summary>
        /// 运行协程
        /// </summary>
        /// <param name="action">协程方法</param>
        /// <returns>协程迭代器ID</returns>
        public string Run(CoroutineAction action)
        {
            CoroutineEnumerator coroutineEnumerator = Main.m_ReferencePool.Spawn <CoroutineEnumerator>().Fill(action, null);

            coroutineEnumerator.Run();
            CoroutineEnumerators.Add(coroutineEnumerator.ID, coroutineEnumerator);
            DepositWarehouse(coroutineEnumerator);
            return(coroutineEnumerator.ID);
        }
 /// <summary>
 /// 终止指定ID的协程
 /// </summary>
 /// <param name="id">协程迭代器ID</param>
 public void Stop(string id)
 {
     if (!CoroutineEnumerators.ContainsKey(id))
     {
         Log.Warning("终止协程失败:不存在ID为 " + id + " 的协程!");
         return;
     }
     CoroutineEnumerators[id].Stop();
 }
示例#8
0
        /// <summary>
        /// 清理所有未运行的协程
        /// </summary>
        public void ClearNotRunning()
        {
            Dictionary <string, CoroutineEnumerator> notRunnings = new Dictionary <string, CoroutineEnumerator>();

            foreach (KeyValuePair <string, CoroutineEnumerator> enumerator in CoroutineEnumerators)
            {
                if (!enumerator.Value.IsRunning())
                {
                    notRunnings.Add(enumerator.Key, enumerator.Value);
                }
            }
            foreach (KeyValuePair <string, CoroutineEnumerator> enumerator in notRunnings)
            {
                CoroutineEnumerators.Remove(enumerator.Key);
                RemoveWarehouse(enumerator.Value);
                Main.m_ReferencePool.Despawn(enumerator.Value);
            }
            notRunnings = null;
        }
示例#9
0
 /// <summary>
 /// 是否存在
 /// </summary>
 /// <param name="id">协程迭代器ID</param>
 /// <returns>是否存在</returns>
 public bool IsExist(string id)
 {
     return(CoroutineEnumerators.ContainsKey(id));
 }