Example #1
0
        public void Despawn()
        {
            //stitch over with Previous in data structure
            if (Previous)
            {
                Previous.Next = Next;
            }
            else if (ContainingProjectile != null)
            {
                ContainingProjectile.Head = Next;
            }

            //stitch over with Next in data structure
            if (Next)
            {
                Next.Previous = Previous;
            }
            else if (ContainingProjectile != null)
            {
                ContainingProjectile.Tail = Previous;
            }

            //destroy ourselves
            Spawned spawnedComponent = this.GetComponent <Spawned>();

            if (spawnedComponent)
            {
                spawnedComponent.Despawn();
            }
            else
            {
                gameObject.Recycle();
            }
        }