internal void LoadLayerDataCsv(Layer mapLayer, TiledLayer tiledLayer)
        {
            string[] strArray = tiledLayer.Data.Data.Split(new char[4]
            {
                ',',
                '\r',
                '\n',
                '\t'
            }, StringSplitOptions.RemoveEmptyEntries);
            Location origin = Location.Origin;

            foreach (string s in strArray)
            {
                int gid = int.Parse(s);
                mapLayer.Tiles[origin] = LoadTile(mapLayer, gid);
                ++origin.X;
                if (origin.X >= mapLayer.LayerWidth)
                {
                    origin.X = 0;
                    ++origin.Y;
                }
            }
        }
 internal void StoreLayers(Map map, TiledMap tiledMap)
 {
     foreach (Layer layer in map.Layers)
     {
         TiledLayer tiledLayer1 = new TiledLayer();
         tiledLayer1.Name   = layer.Id;
         tiledLayer1.Width  = layer.LayerWidth;
         tiledLayer1.Height = layer.LayerHeight;
         int num1 = !layer.Visible ? 1 : 0;
         tiledLayer1.Hidden = num1 != 0;
         tiledLayer1.Data   = new TiledLayerData()
         {
             EncodingType = "csv"
         };
         List <TiledProperty> tiledPropertyList = new List <TiledProperty>();
         tiledLayer1.Properties = tiledPropertyList;
         TiledLayer tiledLayer2 = tiledLayer1;
         List <int> intList     = new List <int>();
         for (int index1 = 0; index1 < layer.LayerHeight; ++index1)
         {
             for (int index2 = 0; index2 < layer.LayerWidth; ++index2)
             {
                 Tile tile = layer.Tiles[index2, index1];
                 if (tile is AnimatedTile animatedTile)
                 {
                     foreach (TiledTileSet tileSet in tiledMap.TileSets.Where(t => t.SheetName == animatedTile.TileSheet.Id))
                     {
                         TiledTile tiledTile1 = tileSet.Tiles.FirstOrDefault(tiledTile => tiledTile.TileId == tile.TileIndex);
                         if (tiledTile1 == null)
                         {
                             tileSet.Tiles.Add(new TiledTile()
                             {
                                 TileId    = tile.TileIndex,
                                 Animation = ((IEnumerable <StaticTile>)animatedTile.TileFrames).Select(frame => new TiledAnimationFrame()
                                 {
                                     TileId   = frame.TileIndex,
                                     Duration = (int)animatedTile.FrameInterval
                                 }).ToList()
                             });
                         }
                         else if (tiledTile1.Animation == null)
                         {
                             tiledTile1.Animation = ((IEnumerable <StaticTile>)animatedTile.TileFrames).Select(frame => new TiledAnimationFrame()
                             {
                                 TileId   = frame.TileIndex,
                                 Duration = (int)animatedTile.FrameInterval
                             }).ToList();
                         }
                     }
                 }
                 int num2 = 0;
                 if (tile != null)
                 {
                     int          tileIndex    = tile.TileIndex;
                     TiledTileSet tiledTileSet = tiledMap.TileSets.FirstOrDefault(tileSet => tileSet.SheetName == tile.TileSheet.Id);
                     int          num3         = tiledTileSet != null ? tiledTileSet.FirstGid : 1;
                     num2 = tileIndex + num3;
                 }
                 intList.Add(num2);
             }
         }
         tiledLayer2.Data.Data = string.Join(",", intList);
         if (layer.Description.Length > 0)
         {
             tiledLayer2.Properties.Add(new TiledProperty("@Description", layer.Description));
         }
         tiledMap.Layers.Add(tiledLayer2);
     }
 }