private static TiledMapTilesetTile ReadTiledMapTilesetTile(ContentReader reader, TiledMapTileset tileset, Func <TiledMapObject[], TiledMapTilesetTile> createTile)
        {
            var objectCount = reader.ReadInt32();
            var objects     = new TiledMapObject[objectCount];

            for (var i = 0; i < objectCount; i++)
            {
                objects[i] = ReadTiledMapObject(reader, tileset);
            }

            return(createTile(objects));
        }
        private static TiledMapLayer ReadObjectLayer(ContentReader reader, string name, Vector2 offset, float opacity, bool isVisible, TiledMap map)
        {
            var color       = reader.ReadColor();
            var drawOrder   = (TiledMapObjectDrawOrder)reader.ReadByte();
            var objectCount = reader.ReadInt32();
            var objects     = new TiledMapObject[objectCount];

            for (var i = 0; i < objectCount; i++)
            {
                objects[i] = ReadTiledMapObject(reader, map);
            }

            return(new TiledMapObjectLayer(name, objects, color, drawOrder, offset, opacity, isVisible));
        }
        internal TiledMapTilesetTile(int localTileIdentifier, ContentReader input)
        {
            var objectCount = input.ReadInt32();

            var objects = new TiledMapObject[objectCount];

            for (var i = 0; i < objectCount; i++)
            {
                TiledMapObject @object;

                var objectType = (TiledMapObjectType)input.ReadByte();
                switch (objectType)
                {
                case TiledMapObjectType.Rectangle:
                    @object = new TiledMapRectangleObject(input);
                    break;

                case TiledMapObjectType.Ellipse:
                    @object = new TiledMapEllipseObject(input);
                    break;

                case TiledMapObjectType.Polygon:
                    @object = new TiledMapPolygonObject(input);
                    break;

                case TiledMapObjectType.Polyline:
                    @object = new TiledMapPolylineObject(input);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                objects[i] = @object;
            }

            Objects             = objects;
            LocalTileIdentifier = localTileIdentifier;
            Properties          = new TiledMapProperties();
        }