示例#1
0
        protected virtual void Update()
        {
            // Decay the life of all delayed destruction calls
            for (int __i = delays.Count - 1; __i >= 0; __i--)
            {
                Delay __delay = delays[__i];

                __delay.life -= Time.deltaTime;

                // Skip to next one?
                if (__delay.life > 0.0f)
                {
                    continue;
                }

                // Remove and pool delay
                delays.RemoveAt(__i); ClassPool <Delay> .Despawn(__delay);

                // Finally despawn it after delay
                if (__delay.clone != null)
                {
                    Despawn(__delay.clone);
                }
                else
                {
                    CGDebug.LogWarning("Attempting to update the delayed destruction of a prefab clone that no longer exists, did you accidentally delete it?", this);
                }
            }
        }
示例#2
0
        private void DespawnWithDelay(GameObject clone, float t)
        {
            // If this object is already marked for delayed despawn, update the time and return
            for (int __i = delays.Count - 1; __i >= 0; __i--)
            {
                Delay __delay = delays[__i];

                if (__delay.clone != clone)
                {
                    continue;
                }

                if (t < __delay.life)
                {
                    __delay.life = t;
                }

                return;
            }

            // Create delay
            Delay __newDelay = ClassPool <Delay> .Spawn() ?? new Delay();

            __newDelay.clone = clone;
            __newDelay.life  = t;

            delays.Add(__newDelay);
        }
示例#3
0
        public void DespawnAll()
        {
            // Merge
            MergeSpawnedClonesToList();

            // Despawn
            for (int __i = spawnedClones.Count - 1; __i >= 0; __i--)
            {
                GameObject __clone = spawnedClones[__i];

                if (__clone != null)
                {
                    DespawnNow(__clone);
                }
            }

            spawnedClones.Clear();

            // Clear all delays
            for (int __i = delays.Count - 1; __i >= 0; __i--)
            {
                ClassPool <Delay> .Despawn(delays[__i]);
            }

            delays.Clear();
        }