Exemplo n.º 1
0
 public virtual void Add(Sprite sprite)
 {
     lock (group_lock)
     {
         ShaderGroup  s = GetShaderGroupOrDefault(sprite.Shader);
         TextureGroup t = s.GetTextureGroupOrDefault(sprite.Texture);
         t.group.Add(sprite);
         valid = false;
     }
     count++;
 }
Exemplo n.º 2
0
        public virtual bool Contains(Sprite sprite)
        {
            ShaderGroup group = GetShaderGroup(sprite.Shader);

            if (group != null)
            {
                TextureGroup tgroup = group.GetTextureGroup(sprite.Texture);
                if (tgroup != null)
                {
                    return(tgroup.group.Contains(sprite));
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        public TextureGroup GetTextureGroupOrDefault(Texture tex)
        {
            foreach (TextureGroup t in group)
            {
                if (t.key == tex || t.key.ID == tex.ID)
                {
                    return(t);
                }
            }

            TextureGroup new_group = new TextureGroup();

            new_group.key = tex;
            group.Add(new_group);

            return(new_group);
        }
Exemplo n.º 4
0
        public virtual void ForEach(Action <Sprite> callBack)
        {
            List <Sprite>       invalids      = new List <Sprite>();
            List <TextureGroup> invalid_group = new List <TextureGroup>();

            foreach (ShaderGroup shader in group)
            {
                foreach (TextureGroup texture in shader.group)
                {
                    foreach (Sprite sprite in texture.group)
                    {
                        if (sprite.Texture.ID != texture.key.ID)
                        {
                            invalids.Add(sprite);
                            invalid_group.Add(texture);
                            continue;
                        }

                        callBack(sprite);
                    }
                }
            }

            for (int i = 0; i < invalids.Count; i++)
            {
                Sprite       sprite = invalids[i];
                TextureGroup t      = invalid_group[i];

                ShaderGroup s = GetShaderGroupOrDefault(sprite.Shader);
                lock (group_lock)
                {
                    if (t.group.Contains(sprite))
                    {
                        t.group.Remove(sprite);
                    }
                }

                Add(sprite);
            }

            invalids.Clear();
        }