Ejemplo n.º 1
0
 public void Update(Conditional c)
 {
     if (c.cond.Invoke())
     {
         c.act?.Invoke();
         c.isDone = true;
     }
 }
Ejemplo n.º 2
0
 public void Update(Conditional c)
 {
     c.f -= c.unscaledTime ? Time.unscaledDeltaTime : Time.deltaTime;
     if (c.f <= 0f)
     {
         c.act?.Invoke();
         c.isDone = true;
     }
 }
Ejemplo n.º 3
0
        internal void ExpandPool()
        {
            for (int i = 0; i < currentCapacity; i++)
            {
                var c = new Conditional(i + currentCapacity);
                pool.Enqueue(c);
            }

            currentCapacity *= 2;
        }
Ejemplo n.º 4
0
        public void Update(Conditional c)
        {
            c.i -= 1;

            if (c.i <= 0)
            {
                c.act?.Invoke();
                c.isDone = true;
            }
        }
Ejemplo n.º 5
0
        public void Update(Conditional c)
        {
            c.f -= c.unscaledTime ? Time.unscaledTime : Time.deltaTime;
            if (c.f <= 0f)
            {
                c.act.Invoke();
                c.i--;
                if (c.i <= 0)
                {
                    c.isDone = true;
                    return;
                }

                c.f = c.f1;
            }
        }
Ejemplo n.º 6
0
        public override void OnEnable()
        {
            Profiler.BeginSample("Conditional Pool Generation");
            if (conditionals == null)
            {
                conditionals = new List <Conditional>(256);
            }

            currentCapacity = POOL_CAPACITY;

            pool = new Queue <Conditional>(POOL_CAPACITY);
            // hash = new HashSet<Conditional>();
            for (var i = 0; i < POOL_CAPACITY; i++)
            {
                var c = new Conditional(i);
                pool.Enqueue(c);
                // hash.Add(c);
            }

            Profiler.EndSample();
        }
Ejemplo n.º 7
0
        internal Conditional Dequeue()
        {
            if (pool.Count < 1)
            {
                // Debug.LogError($"Conditional Pool Empty! Resizing to capacity: {currentCapacity * 2}");
                // ExpandPool();
                Debug.Log(
                    $"Conditional pool is empty! Creating new conditional. New size: {currentCapacity + 1}");
                var c_ = new Conditional(currentCapacity);
                pool.Enqueue(c_);
                currentCapacity++;
            }

            var c = pool.Dequeue();

            // hash.Remove(c);
            c.Reset();
#if UNITY_EDITOR && CONDITIONAL_STACK_TRACE
            c.stackTrace = StackTraceUtility.ExtractStackTrace();
#endif
            return(c);
        }
Ejemplo n.º 8
0
        private void FinishConditional(Conditional cond, int i)
        {
#if UNITY_EDITOR && CONDITIONAL_STACK_TRACE
            if (cond.debug)
            {
                Debug.Log("Conditional Done\n" + cond.stackTrace);
            }
#endif

            if (cond.onComplete != null)
            {
#if UNITY_EDITOR && CONDITIONAL_STACK_TRACE
                if (cond.debug)
                {
                    Debug.Log("Conditional On Complete Invocation\n" + cond.stackTrace);
                }
#endif

                cond.onComplete.Invoke();
            }

            conditionals.RemoveAt(i);

            if (cond.next != null)
            {
#if UNITY_EDITOR && CONDITIONAL_STACK_TRACE
                if (cond.debug)
                {
                    Debug.Log("Conditional Chaining Next\n" + cond.stackTrace);
                }
#endif

                StartConditional(cond.next);
            }

            Enqueue(cond);
        }
Ejemplo n.º 9
0
 internal void StopConditional(Conditional c)
 {
     c.isDone = true;
     // Enqueue(c);
     // conditionals.Remove(c);
 }
Ejemplo n.º 10
0
 internal void StartConditional(Conditional c)
 {
     c.isDone = false;
     conditionals.Add(c);
 }