public static void EnumSpriteInSpriteManager(
            SpriteLayerDelegate beginLayer, SpriteLayerDelegate endLayer,
            PrimitiveGroupDelegate beginGroup, PrimitiveGroupDelegate endGroup,
            PrimitiveDelegate primitive)
        {
            int[] ids = SpriteManager.GetLayersID();

            foreach (int id in ids)
            {
                SpriteLayer layer = SpriteManager.GetLayer(id);

                if (beginLayer != null)
                {
                    beginLayer(id, layer.size);
                }


                for (int i = 0, e = layer.size; i < e; i++)
                {
                    SpritePrimitiveGroup group = layer[i];

                    if (beginGroup != null)
                    {
                        beginGroup(group, i, group.owner);
                    }


                    if (primitive != null)
                    {
                        primitive(group.primitives, group.count.value, group);
                    }


                    if (endGroup != null)
                    {
                        endGroup(group, i, group.owner);
                    }
                }

                if (endLayer != null)
                {
                    endLayer(id, layer.size);
                }
            }
        }
        public static void EnumSpriteInSpriteManager( 
            SpriteLayerDelegate beginLayer, SpriteLayerDelegate endLayer,
            PrimitiveGroupDelegate beginGroup, PrimitiveGroupDelegate endGroup,
            PrimitiveDelegate primitive )
        {
            int[] ids = SpriteManager.GetLayersID();

            foreach (int id in ids)
            {               
                SpriteLayer layer = SpriteManager.GetLayer(id);

                if (beginLayer != null)
                    beginLayer(id, layer.size);


                for (int i = 0, e = layer.size; i < e; i++)
                {
                    SpritePrimitiveGroup group = layer[i];

                    if (beginGroup != null)
                        beginGroup( group, i, group.owner);


                    if (primitive != null)
                        primitive( group.primitives, group.count.value, group );


                    if (endGroup != null)
                        endGroup(group, i, group.owner);
                }

                if (endLayer != null)
                    endLayer(id, layer.size);
            }
        }