private static void ProcessLayers(TiledMapContentItem contentItem, TiledMapContent map, ContentProcessorContext context, List <TiledMapLayerContent> layers)
        {
            foreach (var layer in layers)
            {
                switch (layer)
                {
                case TiledMapImageLayerContent imageLayer:
                    ContentLogger.Log($"Processing image layer '{imageLayer.Name}'");
                    //var externalReference = new ExternalReference<Texture2DContent>(imageLayer.Image.Source);
                    var parameters = new OpaqueDataDictionary
                    {
                        { "ColorKeyColor", imageLayer.Image.TransparentColor },
                        { "ColorKeyEnabled", true }
                    };
                    //imageLayer.Image.ContentRef = context.BuildAsset<Texture2DContent, Texture2DContent>(externalReference, "", parameters, "", "");
                    contentItem.BuildExternalReference <Texture2DContent>(context, imageLayer.Image.Source, parameters);
                    ContentLogger.Log($"Processed image layer '{imageLayer.Name}'");
                    break;

                case TiledMapTileLayerContent tileLayer when tileLayer.Data.Chunks.Count > 0:
                    throw new NotSupportedException($"{map.FilePath} contains data chunks. These are currently not supported.");

                case TiledMapTileLayerContent tileLayer:
                    var data            = tileLayer.Data;
                    var encodingType    = data.Encoding ?? "xml";
                    var compressionType = data.Compression ?? "xml";

                    ContentLogger.Log($"Processing tile layer '{tileLayer.Name}': Encoding: '{encodingType}', Compression: '{compressionType}'");
                    var tileData = DecodeTileLayerData(encodingType, tileLayer);
                    var tiles    = CreateTiles(map.RenderOrder, map.Width, map.Height, tileData);
                    tileLayer.Tiles = tiles;
                    ContentLogger.Log($"Processed tile layer '{tileLayer}': {tiles.Length} tiles");
                    break;

                case TiledMapObjectLayerContent objectLayer:
                    ContentLogger.Log($"Processing object layer '{objectLayer.Name}'");

                    foreach (var obj in objectLayer.Objects)
                    {
                        TiledMapContentHelper.Process(obj, context);
                    }

                    ContentLogger.Log($"Processed object layer '{objectLayer.Name}'");
                    break;

                case TiledMapGroupLayerContent groupLayer:
                    ProcessLayers(contentItem, map, context, groupLayer.Layers);
                    break;
                }
            }
        }
        public override TiledMapTilesetContentItem Process(TiledMapTilesetContentItem contentItem, ContentProcessorContext context)
        {
            try
            {
                var tileset = contentItem.Data;

                ContentLogger.Logger = context.Logger;
                ContentLogger.Log($"Processing tileset '{tileset.Name}'");

                // Build the Texture2D asset and load it as it will be saved as part of this tileset file.
                //var externalReference = new ExternalReference<Texture2DContent>(tileset.Image.Source);
                var parameters = new OpaqueDataDictionary
                {
                    { "ColorKeyColor", tileset.Image.TransparentColor },
                    { "ColorKeyEnabled", true }
                };
                //tileset.Image.ContentRef = context.BuildAsset<Texture2DContent, Texture2DContent>(externalReference, "", parameters, "", "");
                contentItem.BuildExternalReference <Texture2DContent>(context, tileset.Image.Source, parameters);

                foreach (var tile in tileset.Tiles)
                {
                    foreach (var obj in tile.Objects)
                    {
                        TiledMapContentHelper.Process(obj, context);
                    }
                }

                ContentLogger.Log($"Processed tileset '{tileset.Name}'");

                return(contentItem);
            }
            catch (Exception ex)
            {
                context.Logger.LogImportantMessage(ex.Message);
                throw ex;
            }
        }