示例#1
0
 public YuoDelayMod InvokeRealtime <T>(T obj, UnityAction unityAction, float delay)
 {
     tempMod           = GetMod(unityAction, delay, true);
     tempMod.coroutine = StartCoroutine(IYuoDelayRealtime(obj, tempMod));
     InvokesRealtime.Add(tempMod);
     return(tempMod);
 }
示例#2
0
 public YuoDelayMod InvokeRealtime <T>(T obj, UnityAction <YuoDelayMod> unityAction, float delay)
 {
     tempMod           = GetMod(null, delay);
     tempMod.ModAction = unityAction;
     tempMod.coroutine = StartCoroutine(IYuoDelayRealtime(obj, tempMod));
     InvokesRealtime.Add(tempMod);
     return(tempMod);
 }
示例#3
0
 /// <summary>
 /// 重要提示:请在确定该延迟指令还未结束再使用Stop,否则其他正在使用这个mod的延迟指令将被意外暂停
 /// </summary>
 /// <param name="mod"></param>
 public void StopForce(YuoDelayMod mod)
 {
     StopCoroutine(mod.coroutine);
     if (Pools.Contains(mod))
     {
         return;
     }
     if (mod.IsRealtime)
     {
         InvokesRealtime.Remove(mod);
     }
     else
     {
         Invokes.Remove(mod);
     }
     Pools.Add(mod);
 }
示例#4
0
        private IEnumerator IYuoDelay <T>(T obj, YuoDelayMod mod)
        {
            yield return(null);

            if (mod.IsUpdate)
            {
                while (Time.time - mod.StartTime < mod.DelayTime)
                {
                    yield return(null);

                    mod.UpdateAction?.Invoke();
                }
            }
            else
            {
                yield return(YuoWait.WaitTime(mod.DelayTime - Time.deltaTime));

                while (mod.ExtraDelayTime.Count > 0)
                {
                    Temp.Float = mod.ExtraDelayTime[0];
                    mod.ExtraDelayTime.RemoveAt(0);
                    yield return(YuoWait.WaitTime(Temp.Float));
                }
            }
            if (!mod.End)
            {
                if (!mod.SafeGameObject || mod.SafeGameObject.activeSelf)
                {
                    if (!mod.UseSafe || obj.ToString() != "null")
                    {
                        mod.action?.Invoke();
                        mod.ModAction?.Invoke(mod);
                    }
                }
            }
            Invokes.Remove(mod);
            Pools.Add(mod);
            mod = null;
            yield break;
        }
示例#5
0
 private YuoDelayMod GetMod(UnityAction unityAction, float delay, bool realtime = false)
 {
     if (Pools.Count > 0)
     {
         Temp.Int = 0;
         tempMod  = Pools[Pools.Count - 1];
         tempMod.ReSet();
         tempMod.action      = unityAction;
         tempMod.DelayTime   = delay;
         tempMod.StartTime   = Time.time;
         tempMod.UnStartTime = Time.unscaledTime;
         tempMod.IsRealtime  = realtime;
         Pools.Remove(tempMod);
     }
     else
     {
         tempMod = new YuoDelayMod()
         {
             StartTime = Time.time, UnStartTime = Time.unscaledTime, DelayTime = delay, action = unityAction, IsRealtime = realtime
         };
     }
     return(tempMod);
 }
示例#6
0
        private IEnumerator IYuoDelayRealtime <T>(T obj, YuoDelayMod mod)
        {
            yield return(null);

            if (mod.IsUpdate)
            {
                while (Time.unscaledTime - mod.UnStartTime < mod.DelayTime)
                {
                    yield return(null);

                    mod.UpdateAction?.Invoke();
                }
            }
            else
            {
                yield return(YuoWait.WaitUnscaledTime(mod.DelayTime));

                while (mod.ExtraDelayTime.Count > 0)
                {
                    Temp.Float = mod.ExtraDelayTime[0];
                    mod.ExtraDelayTime.RemoveAt(0);
                    yield return(YuoWait.WaitUnscaledTime(Temp.Float));
                }
            }
            if (!mod.End)
            {
                if (!mod.UseSafe || obj.ToString() != "null")
                {
                    mod.action?.Invoke();
                    mod.ModAction?.Invoke(mod);
                }
            }
            InvokesRealtime.Remove(mod);
            Pools.Add(mod);
            yield break;
        }
示例#7
0
 /// <summary>
 /// 重要提示:请在确定该延迟指令还未结束再使用Stop,否则其他正在使用这个mod的延迟指令将被意外暂停
 /// </summary>
 /// <param name="mod"></param>
 public void StopCor(YuoDelayMod mod)
 {
     mod.End = true;
 }
示例#8
0
 private void YuoDelayUpdate(YuoDelayMod mod)
 {
 }