using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

namespace MonoGame.FourEngine.Tiled
{
    internal abstract class LayerBase
    {
        public static LayerBase Parse(XElement xElement)
        {
            switch (xElement.Name.LocalName)
            {
                case "layer":
                    return TileLayer.Parse(xElement);
                case "objectgroup":
                    return ObjectLayer.Parse(xElement);
                default:
                    return null;
            }
        }

        public static IEnumerable<LayerBase> Parse(IEnumerable<XElement> xElements)
            => xElements.Where(x => x != null).Select(x => Parse(x));

        public abstract IEnumerable<Entity> GetEntities(List<Tileset> tilesets, int layer, MapOrientation orientation = MapOrientation.Orthogonal);
    }
}
