<commit_before>using System.Diagnostics;

namespace Cocos2D
{
    public class CCSpriteBatchNode : CCNode, ICCTextureProtocol
    {
        private const int kDefaultSpriteBatchCapacity = 29;

        protected CCBlendFunc m_blendFunc;
        protected CCRawList<CCSprite> m_pobDescendants;
        protected CCTextureAtlas m_pobTextureAtlas;

        public CCTextureAtlas TextureAtlas
        {
            get { return m_pobTextureAtlas; }
            set { m_pobTextureAtlas = value; }
        }

        public CCRawList<CCSprite> Descendants
        {
            get { return m_pobDescendants; }
        }

        #region ICCTextureProtocol Members

        public CCBlendFunc BlendFunc
        {
            get { return m_blendFunc; }
            set { m_blendFunc = value; }
        }

        public virtual CCTexture2D Texture
        {
            get { return m_pobTextureAtlas.Texture; }
            set
            {
                m_pobTextureAtlas.Texture = value;
                UpdateBlendFunc();
                if (value != null)
                {
                    m_obContentSize = value.ContentSize;
            	}
        	}
        }

		public bool IsAntialiased
		{
			get { return Texture.IsAntialiased; }

			set { Texture.IsAntialiased = value; }
		}

        #endregion

        public CCSpriteBatchNode()
        {
        }

        public CCSpriteBatchNode(CCTexture2D tex)
        {
            InitWithTexture(tex, kDefaultSpriteBatchCapacity);
        }

        public CCSpriteBatchNode(CCTexture2D tex, int capacity)
        {
            InitWithTexture(tex, capacity);
        }

        public CCSpriteBatchNode(string fileImage)
        {
            InitWithFile(fileImage, kDefaultSpriteBatchCapacity);
        }

        public CCSpriteBatchNode(string fileImage, int capacity)
        {
            InitWithFile(fileImage, capacity);
        }

        protected virtual bool InitWithFile(string fileImage, int capacity)
        {
            CCTexture2D pTexture2D = CCTextureCache.SharedTextureCache.AddImage(fileImage);
            return InitWithTexture(pTexture2D, capacity);
        }

        protected virtual bool InitWithTexture(CCTexture2D tex, int capacity)
        {
            m_blendFunc = CCBlendFunc.AlphaBlend;

            m_pobTextureAtlas = new CCTextureAtlas();

            if (capacity == 0)
            {
                capacity = kDefaultSpriteBatchCapacity;
            }

            ContentSize= tex.ContentSize; // @@ TotallyEvil - contentSize should return the size of the sprite sheet
            m_pobTextureAtlas.InitWithTexture(tex, capacity);

            UpdateBlendFunc();

            // no lazy alloc in this node
            m_pChildren = new CCRawList<CCNode>(capacity);

            m_pobDescendants = new CCRawList<CCSprite>(capacity);

            return true;
        }

        public override bool Init()
        {
            var texture = new CCTexture2D();
            return InitWithTexture(texture, 0);
        }

        public override void Visit()
        {<commit_msg>another fix where the children by tag dictionary is not created when the children list is created.<commit_after>using System.Diagnostics;

namespace Cocos2D
{
    public class CCSpriteBatchNode : CCNode, ICCTextureProtocol
    {
        private const int kDefaultSpriteBatchCapacity = 29;

        protected CCBlendFunc m_blendFunc;
        protected CCRawList<CCSprite> m_pobDescendants;
        protected CCTextureAtlas m_pobTextureAtlas;

        public CCTextureAtlas TextureAtlas
        {
            get { return m_pobTextureAtlas; }
            set { m_pobTextureAtlas = value; }
        }

        public CCRawList<CCSprite> Descendants
        {
            get { return m_pobDescendants; }
        }

        #region ICCTextureProtocol Members

        public CCBlendFunc BlendFunc
        {
            get { return m_blendFunc; }
            set { m_blendFunc = value; }
        }

        public virtual CCTexture2D Texture
        {
            get { return m_pobTextureAtlas.Texture; }
            set
            {
                m_pobTextureAtlas.Texture = value;
                UpdateBlendFunc();
                if (value != null)
                {
                    m_obContentSize = value.ContentSize;
            	}
        	}
        }

		public bool IsAntialiased
		{
			get { return Texture.IsAntialiased; }

			set { Texture.IsAntialiased = value; }
		}

        #endregion

        public CCSpriteBatchNode()
        {
        }

        public CCSpriteBatchNode(CCTexture2D tex)
        {
            InitWithTexture(tex, kDefaultSpriteBatchCapacity);
        }

        public CCSpriteBatchNode(CCTexture2D tex, int capacity)
        {
            InitWithTexture(tex, capacity);
        }

        public CCSpriteBatchNode(string fileImage)
        {
            InitWithFile(fileImage, kDefaultSpriteBatchCapacity);
        }

        public CCSpriteBatchNode(string fileImage, int capacity)
        {
            InitWithFile(fileImage, capacity);
        }

        protected virtual bool InitWithFile(string fileImage, int capacity)
        {
            CCTexture2D pTexture2D = CCTextureCache.SharedTextureCache.AddImage(fileImage);
            return InitWithTexture(pTexture2D, capacity);
        }

        protected virtual bool InitWithTexture(CCTexture2D tex, int capacity)
        {
            m_blendFunc = CCBlendFunc.AlphaBlend;

            m_pobTextureAtlas = new CCTextureAtlas();

            if (capacity == 0)
            {
                capacity = kDefaultSpriteBatchCapacity;
            }

            ContentSize= tex.ContentSize; // @@ TotallyEvil - contentSize should return the size of the sprite sheet
            m_pobTextureAtlas.InitWithTexture(tex, capacity);

            UpdateBlendFunc();

            // no lazy alloc in this node
            m_pChildren = new CCRawList<CCNode>(capacity);
            m_pChildrenByTag = new System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<CCNode>>();
            m_pobDescendants = new CCRawList<CCSprite>(capacity);

            return true;
        }

        public override bool Init()
        {
            var texture = new CCTexture2D();
            return InitWithTexture(texture, 0);
        }

        public override void Visit()
        {
{'fraction_non_alphanumeric': 0.06407035175879397, 'fraction_numerical': 0.004082914572864322, 'mean_word_length': 1.7983304042179262, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3857493', 'n_tokens_mistral': 1815, 'n_tokens_neox': 1720, 'n_words': 372}