summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization')
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapContent.cs75
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapEllipseContent.cs6
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapGroupLayerContent.cs20
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapImageContent.cs44
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapImageLayerContent.cs30
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapLayerContent.cs61
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapLayerModelContent.cs139
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs78
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectDrawOrderContent.cs10
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectLayerContent.cs28
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectTemplateContent.cs17
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapOrientationContent.cs12
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPolygonContent.cs10
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPolylineContent.cs10
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPropertyContent.cs28
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapStaggerAxisContent.cs10
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapStaggerIndexContent.cs10
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileContent.cs9
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileDrawOrderContent.cs12
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerContent.cs30
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerDataChunkContent.cs26
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerDataContent.cs33
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileOffsetContent.cs17
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetContent.cs76
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetGridContent.cs16
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetTileAnimationFrameContent.cs18
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetTileContent.cs40
27 files changed, 865 insertions, 0 deletions
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapContent.cs
new file mode 100644
index 0000000..30ecbfd
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapContent.cs
@@ -0,0 +1,75 @@
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ [XmlRoot(ElementName = "map")]
+ public class TiledMapContent
+ {
+ public TiledMapContent()
+ {
+ Properties = new List<TiledMapPropertyContent>();
+ Tilesets = new List<TiledMapTilesetContent>();
+ Layers = new List<TiledMapLayerContent>();
+ }
+
+ [XmlIgnore]
+ public string Name { get; set; }
+
+ [XmlIgnore]
+ public string FilePath { get; set; }
+
+ // Deprecated as of Tiled 1.9.0 (replaced by "class" attribute)
+ [XmlAttribute(DataType = "string", AttributeName = "type")]
+ public string Type { get; set; }
+
+ [XmlAttribute(DataType = "string", AttributeName = "class")]
+ public string Class { get; set; }
+
+ [XmlAttribute(AttributeName = "version")]
+ public string Version { get; set; }
+
+ [XmlAttribute(AttributeName = "orientation")]
+ public TiledMapOrientationContent Orientation { get; set; }
+
+ [XmlAttribute(AttributeName = "renderorder")]
+ public TiledMapTileDrawOrderContent RenderOrder { get; set; }
+
+ [XmlAttribute(AttributeName = "backgroundcolor")]
+ public string BackgroundColor { get; set; }
+
+ [XmlAttribute(AttributeName = "width")]
+ public int Width { get; set; }
+
+ [XmlAttribute(AttributeName = "height")]
+ public int Height { get; set; }
+
+ [XmlAttribute(AttributeName = "tilewidth")]
+ public int TileWidth { get; set; }
+
+ [XmlAttribute(AttributeName = "tileheight")]
+ public int TileHeight { get; set; }
+
+ [XmlAttribute(AttributeName = "hexsidelength")]
+ public int HexSideLength { get; set; }
+
+ [XmlAttribute(AttributeName = "staggeraxis")]
+ public TiledMapStaggerAxisContent StaggerAxis { get; set; }
+
+ [XmlAttribute(AttributeName = "staggerindex")]
+ public TiledMapStaggerIndexContent StaggerIndex { get; set; }
+
+ [XmlElement(ElementName = "tileset")]
+ public List<TiledMapTilesetContent> Tilesets { get; set; }
+
+ [XmlElement(ElementName = "layer", Type = typeof(TiledMapTileLayerContent))]
+ [XmlElement(ElementName = "imagelayer", Type = typeof(TiledMapImageLayerContent))]
+ [XmlElement(ElementName = "objectgroup", Type = typeof(TiledMapObjectLayerContent))]
+ [XmlElement(ElementName = "group", Type = typeof(TiledMapGroupLayerContent))]
+ public List<TiledMapLayerContent> Layers { get; set; }
+
+ [XmlArray("properties")]
+ [XmlArrayItem("property")]
+ public List<TiledMapPropertyContent> Properties { get; set; }
+ }
+}
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapEllipseContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapEllipseContent.cs
new file mode 100644
index 0000000..78f7bdd
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapEllipseContent.cs
@@ -0,0 +1,6 @@
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapEllipseContent
+ {
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapGroupLayerContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapGroupLayerContent.cs
new file mode 100644
index 0000000..a72b276
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapGroupLayerContent.cs
@@ -0,0 +1,20 @@
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapGroupLayerContent : TiledMapLayerContent
+ {
+ protected TiledMapGroupLayerContent()
+ : base(TiledMapLayerType.GroupLayer)
+ {
+ }
+
+ [XmlElement(ElementName = "layer", Type = typeof(TiledMapTileLayerContent))]
+ [XmlElement(ElementName = "imagelayer", Type = typeof(TiledMapImageLayerContent))]
+ [XmlElement(ElementName = "objectgroup", Type = typeof(TiledMapObjectLayerContent))]
+ [XmlElement(ElementName = "group", Type = typeof(TiledMapGroupLayerContent))]
+ public List<TiledMapLayerContent> Layers { get; set; }
+
+ }
+}
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapImageContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapImageContent.cs
new file mode 100644
index 0000000..714da37
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapImageContent.cs
@@ -0,0 +1,44 @@
+using System.Xml.Serialization;
+using Microsoft.Xna.Framework;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapImageContent
+ {
+ //[XmlIgnore]
+ //public Texture2DContent Content { get; set; }
+
+ //[XmlIgnore]
+ //public ExternalReference<Texture2DContent> ContentRef { get; set; }
+
+ [XmlAttribute(AttributeName = "source")]
+ public string Source { get; set; }
+
+ [XmlAttribute(AttributeName = "width")]
+ public int Width { get; set; }
+
+ [XmlAttribute(AttributeName = "height")]
+ public int Height { get; set; }
+
+ [XmlAttribute(AttributeName = "format")]
+ public string Format { get; set; }
+
+ [XmlAttribute(AttributeName = "trans")]
+ public string RawTransparentColor { get; set; } = string.Empty;
+
+ [XmlIgnore]
+ public Color TransparentColor
+ {
+ get => RawTransparentColor == string.Empty ? Color.Transparent : ColorHelper.FromHex(RawTransparentColor);
+ set => RawTransparentColor = ColorHelper.ToHex(value);
+ }
+
+ [XmlElement(ElementName = "data")]
+ public TiledMapTileLayerDataContent Data { get; set; }
+
+ public override string ToString()
+ {
+ return Source;
+ }
+ }
+}
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapImageLayerContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapImageLayerContent.cs
new file mode 100644
index 0000000..f347d1e
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapImageLayerContent.cs
@@ -0,0 +1,30 @@
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapImageLayerContent : TiledMapLayerContent
+ {
+ [XmlAttribute(AttributeName = "x")]
+ public int X { get; set; }
+
+ [XmlAttribute(AttributeName = "y")]
+ public int Y { get; set; }
+
+ [XmlElement(ElementName = "image")]
+ public TiledMapImageContent Image { get; set; }
+
+ public TiledMapImageLayerContent()
+ : base(TiledMapLayerType.ImageLayer)
+ {
+ Opacity = 1.0f;
+ Visible = true;
+ Properties = new List<TiledMapPropertyContent>();
+ }
+
+ public override string ToString()
+ {
+ return $"{Name}: {Image}";
+ }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapLayerContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapLayerContent.cs
new file mode 100644
index 0000000..01d8a9d
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapLayerContent.cs
@@ -0,0 +1,61 @@
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ [XmlInclude(typeof(TiledMapTileLayerContent))]
+ [XmlInclude(typeof(TiledMapImageLayerContent))]
+ [XmlInclude(typeof(TiledMapObjectLayerContent))]
+ public abstract class TiledMapLayerContent
+ {
+ protected TiledMapLayerContent(TiledMapLayerType layerType)
+ {
+ LayerType = layerType;
+ Opacity = 1.0f;
+ ParallaxX = 1.0f;
+ ParallaxY = 1.0f;
+ Visible = true;
+ Properties = new List<TiledMapPropertyContent>();
+ }
+
+ [XmlAttribute(AttributeName = "name")]
+ public string Name { get; set; }
+
+ // Deprecated as of Tiled 1.9.0 (replaced by "class" attribute)
+ [XmlAttribute(DataType = "string", AttributeName = "type")]
+ public string Type { get; set; }
+
+ [XmlAttribute(DataType = "string", AttributeName = "class")]
+ public string Class { get; set; }
+
+ [XmlAttribute(AttributeName = "opacity")]
+ public float Opacity { get; set; }
+
+ [XmlAttribute(AttributeName = "visible")]
+ public bool Visible { get; set; }
+
+ [XmlAttribute(AttributeName = "offsetx")]
+ public float OffsetX { get; set; }
+
+ [XmlAttribute(AttributeName = "offsety")]
+ public float OffsetY { get; set; }
+
+ [XmlAttribute(AttributeName = "parallaxx")]
+ public float ParallaxX { get; set; }
+
+ [XmlAttribute(AttributeName = "parallaxy")]
+ public float ParallaxY { get; set; }
+
+ [XmlArray("properties")]
+ [XmlArrayItem("property")]
+ public List<TiledMapPropertyContent> Properties { get; set; }
+
+ [XmlIgnore]
+ public TiledMapLayerType LayerType { get; }
+
+ public override string ToString()
+ {
+ return Name;
+ }
+ }
+}
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapLayerModelContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapLayerModelContent.cs
new file mode 100644
index 0000000..4c2a761
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapLayerModelContent.cs
@@ -0,0 +1,139 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapLayerModelContent
+ {
+ private readonly List<VertexPositionTexture> _vertices;
+ private readonly List<ushort> _indices;
+
+ public string LayerName { get; }
+ public ReadOnlyCollection<VertexPositionTexture> Vertices { get; }
+ public ReadOnlyCollection<ushort> Indices { get; }
+ public Size2 ImageSize { get; }
+ public string TextureAssetName { get; }
+
+ public TiledMapLayerModelContent(string layerName, TiledMapImageContent image)
+ {
+ LayerName = layerName;
+ _vertices = new List<VertexPositionTexture>();
+ Vertices = new ReadOnlyCollection<VertexPositionTexture>(_vertices);
+ _indices = new List<ushort>();
+ Indices = new ReadOnlyCollection<ushort>(_indices);
+ ImageSize = new Size2(image.Width, image.Height);
+ TextureAssetName = Path.ChangeExtension(image.Source, null);
+ }
+
+ public TiledMapLayerModelContent(string layerName, TiledMapTilesetContent tileset)
+ : this(layerName, tileset.Image)
+ {
+ }
+
+ public void AddTileVertices(Point2 position, Rectangle? sourceRectangle = null, TiledMapTileFlipFlags flags = TiledMapTileFlipFlags.None)
+ {
+ float texelLeft, texelTop, texelRight, texelBottom;
+ var sourceRectangle1 = sourceRectangle ?? new Rectangle(0, 0, (int)ImageSize.Width, (int)ImageSize.Height);
+
+ if (sourceRectangle.HasValue)
+ {
+ var reciprocalWidth = 1f / ImageSize.Width;
+ var reciprocalHeight = 1f / ImageSize.Height;
+ texelLeft = sourceRectangle1.X * reciprocalWidth;
+ texelTop = sourceRectangle1.Y * reciprocalHeight;
+ texelRight = (sourceRectangle1.X + sourceRectangle1.Width) * reciprocalWidth;
+ texelBottom = (sourceRectangle1.Y + sourceRectangle1.Height) * reciprocalHeight;
+ }
+ else
+ {
+ texelLeft = 0;
+ texelTop = 0;
+ texelBottom = 1;
+ texelRight = 1;
+ }
+
+ VertexPositionTexture vertexTopLeft, vertexTopRight, vertexBottomLeft, vertexBottomRight;
+
+ vertexTopLeft.Position = new Vector3(position, 0);
+ vertexTopRight.Position = new Vector3(position + new Vector2(sourceRectangle1.Width, 0), 0);
+ vertexBottomLeft.Position = new Vector3(position + new Vector2(0, sourceRectangle1.Height), 0);
+ vertexBottomRight.Position =
+ new Vector3(position + new Vector2(sourceRectangle1.Width, sourceRectangle1.Height), 0);
+
+ vertexTopLeft.TextureCoordinate.Y = texelTop;
+ vertexTopLeft.TextureCoordinate.X = texelLeft;
+
+ vertexTopRight.TextureCoordinate.Y = texelTop;
+ vertexTopRight.TextureCoordinate.X = texelRight;
+
+ vertexBottomLeft.TextureCoordinate.Y = texelBottom;
+ vertexBottomLeft.TextureCoordinate.X = texelLeft;
+
+ vertexBottomRight.TextureCoordinate.Y = texelBottom;
+ vertexBottomRight.TextureCoordinate.X = texelRight;
+
+ var flipDiagonally = (flags & TiledMapTileFlipFlags.FlipDiagonally) != 0;
+ var flipHorizontally = (flags & TiledMapTileFlipFlags.FlipHorizontally) != 0;
+ var flipVertically = (flags & TiledMapTileFlipFlags.FlipVertically) != 0;
+
+ if (flipDiagonally)
+ {
+ FloatHelper.Swap(ref vertexTopRight.TextureCoordinate.X, ref vertexBottomLeft.TextureCoordinate.X);
+ FloatHelper.Swap(ref vertexTopRight.TextureCoordinate.Y, ref vertexBottomLeft.TextureCoordinate.Y);
+ }
+
+ if (flipHorizontally)
+ {
+ if (flipDiagonally)
+ {
+ FloatHelper.Swap(ref vertexTopLeft.TextureCoordinate.Y, ref vertexTopRight.TextureCoordinate.Y);
+ FloatHelper.Swap(ref vertexBottomLeft.TextureCoordinate.Y, ref vertexBottomRight.TextureCoordinate.Y);
+ }
+ else
+ {
+ FloatHelper.Swap(ref vertexTopLeft.TextureCoordinate.X, ref vertexTopRight.TextureCoordinate.X);
+ FloatHelper.Swap(ref vertexBottomLeft.TextureCoordinate.X, ref vertexBottomRight.TextureCoordinate.X);
+ }
+ }
+
+ if (flipVertically)
+ if (flipDiagonally)
+ {
+ FloatHelper.Swap(ref vertexTopLeft.TextureCoordinate.X, ref vertexBottomLeft.TextureCoordinate.X);
+ FloatHelper.Swap(ref vertexTopRight.TextureCoordinate.X, ref vertexBottomRight.TextureCoordinate.X);
+ }
+ else
+ {
+ FloatHelper.Swap(ref vertexTopLeft.TextureCoordinate.Y, ref vertexBottomLeft.TextureCoordinate.Y);
+ FloatHelper.Swap(ref vertexTopRight.TextureCoordinate.Y, ref vertexBottomRight.TextureCoordinate.Y);
+ }
+
+ _vertices.Add(vertexTopLeft);
+ _vertices.Add(vertexTopRight);
+ _vertices.Add(vertexBottomLeft);
+ _vertices.Add(vertexBottomRight);
+
+ Debug.Assert(Vertices.Count <= TiledMapHelper.MaximumVerticesPerModel);
+ }
+
+ public void AddTileIndices()
+ {
+ var indexOffset = Vertices.Count;
+
+ Debug.Assert(3 + indexOffset <= TiledMapHelper.MaximumVerticesPerModel);
+
+ _indices.Add((ushort)(0 + indexOffset));
+ _indices.Add((ushort)(1 + indexOffset));
+ _indices.Add((ushort)(2 + indexOffset));
+ _indices.Add((ushort)(1 + indexOffset));
+ _indices.Add((ushort)(3 + indexOffset));
+ _indices.Add((ushort)(2 + indexOffset));
+
+ Debug.Assert(Indices.Count <= TiledMapHelper.MaximumIndicesPerModel);
+ }
+ }
+}
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs
new file mode 100644
index 0000000..76e2ba2
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ // This content class is going to be a lot more complex than the others we use.
+ // Objects can reference a template file which has starting values for the
+ // object. The value in the object file overrides any value specified in the
+ // template. All values have to be able to store a null value so we know if the
+ // XML parser actually found a value for the property and not just a default
+ // value. Default values are used when the object and any templates don't
+ // specify a value.
+ public class TiledMapObjectContent
+ {
+ // TODO: HACK These shouldn't be public
+ public uint? _globalIdentifier;
+ public int? _identifier;
+ public float? _height;
+ public float? _rotation;
+ public bool? _visible;
+ public float? _width;
+ public float? _x;
+ public float? _y;
+
+ [XmlAttribute(DataType = "int", AttributeName = "id")]
+ public int Identifier { get => _identifier ?? 0; set => _identifier = value; }
+
+ [XmlAttribute(DataType = "string", AttributeName = "name")]
+ public string Name { get; set; }
+
+ // Deprecated as of Tiled 1.9.0 (replaced by "class" attribute)
+ [XmlAttribute(DataType = "string", AttributeName = "type")]
+ public string Type { get; set; }
+
+ [XmlAttribute(DataType = "string", AttributeName = "class")]
+ public string Class { get; set; }
+
+ [XmlAttribute(DataType = "float", AttributeName = "x")]
+ public float X { get => _x ?? 0; set => _x = value; }
+
+ [XmlAttribute(DataType = "float", AttributeName = "y")]
+ public float Y { get => _y ?? 0; set => _y = value; }
+
+ [XmlAttribute(DataType = "float", AttributeName = "width")]
+ public float Width { get => _width ?? 0; set => _width = value; }
+
+ [XmlAttribute(DataType = "float", AttributeName = "height")]
+ public float Height { get => _height ?? 0; set => _height = value; }
+
+ [XmlAttribute(DataType = "float", AttributeName = "rotation")]
+ public float Rotation { get => _rotation ?? 0; set => _rotation = value; }
+
+ [XmlAttribute(DataType = "boolean", AttributeName = "visible")]
+ public bool Visible { get => _visible ?? true; set => _visible = value; }
+
+ [XmlArray("properties")]
+ [XmlArrayItem("property")]
+ public List<TiledMapPropertyContent> Properties { get; set; }
+
+ [XmlAttribute(DataType = "unsignedInt", AttributeName = "gid")]
+ public uint GlobalIdentifier { get => _globalIdentifier??0; set => _globalIdentifier = value; }
+
+ [XmlElement(ElementName = "ellipse")]
+ public TiledMapEllipseContent Ellipse { get; set; }
+
+ [XmlElement(ElementName = "polygon")]
+ public TiledMapPolygonContent Polygon { get; set; }
+
+ [XmlElement(ElementName = "polyline")]
+ public TiledMapPolylineContent Polyline { get; set; }
+
+ [XmlAttribute(DataType = "string", AttributeName = "template")]
+ public string TemplateSource { get; set; }
+
+
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectDrawOrderContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectDrawOrderContent.cs
new file mode 100644
index 0000000..f441375
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectDrawOrderContent.cs
@@ -0,0 +1,10 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public enum TiledMapObjectDrawOrderContent : byte
+ {
+ [XmlEnum(Name = "topdown")] TopDown,
+ [XmlEnum(Name = "index")] Manual
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectLayerContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectLayerContent.cs
new file mode 100644
index 0000000..30669b5
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectLayerContent.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapObjectLayerContent : TiledMapLayerContent
+ {
+ public TiledMapObjectLayerContent()
+ : base(TiledMapLayerType.ObjectLayer)
+ {
+ Objects = new List<TiledMapObjectContent>();
+ }
+
+ [XmlAttribute(AttributeName = "color")]
+ public string Color { get; set; }
+
+ [XmlElement(ElementName = "object")]
+ public List<TiledMapObjectContent> Objects { get; set; }
+
+ [XmlAttribute(AttributeName = "draworder")]
+ public TiledMapObjectDrawOrderContent DrawOrder { get; set; }
+
+ public override string ToString()
+ {
+ return Name;
+ }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectTemplateContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectTemplateContent.cs
new file mode 100644
index 0000000..096f528
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectTemplateContent.cs
@@ -0,0 +1,17 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ [XmlRoot(ElementName = "template")]
+ public class TiledMapObjectTemplateContent
+ {
+ [XmlElement(ElementName = "tileset")]
+ public TiledMapTilesetContent Tileset { get; set; }
+
+ //[XmlIgnore]
+ //public ExternalReference<TiledMapTilesetContent> TilesetReference { get; set; }
+
+ [XmlElement(ElementName = "object")]
+ public TiledMapObjectContent Object { get; set; }
+ }
+}
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapOrientationContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapOrientationContent.cs
new file mode 100644
index 0000000..af83824
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapOrientationContent.cs
@@ -0,0 +1,12 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public enum TiledMapOrientationContent : byte
+ {
+ [XmlEnum(Name = "orthogonal")] Orthogonal,
+ [XmlEnum(Name = "isometric")] Isometric,
+ [XmlEnum(Name = "staggered")] Staggered,
+ [XmlEnum(Name = "hexagonal")] Hexagonal
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPolygonContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPolygonContent.cs
new file mode 100644
index 0000000..e4a3d5e
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPolygonContent.cs
@@ -0,0 +1,10 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapPolygonContent
+ {
+ [XmlAttribute(AttributeName = "points")]
+ public string Points { get; set; }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPolylineContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPolylineContent.cs
new file mode 100644
index 0000000..ba15f59
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPolylineContent.cs
@@ -0,0 +1,10 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapPolylineContent
+ {
+ [XmlAttribute(AttributeName = "points")]
+ public string Points { get; set; }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPropertyContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPropertyContent.cs
new file mode 100644
index 0000000..10cdfc1
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapPropertyContent.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapPropertyContent
+ {
+ [XmlAttribute(AttributeName = "name")]
+ public string Name { get; set; }
+
+ [XmlAttribute(AttributeName = "value")]
+ public string ValueAttribute { get; set; }
+
+ [XmlText]
+ public string ValueBody { get; set; }
+
+ [XmlArray("properties")]
+ [XmlArrayItem("property")]
+ public List<TiledMapPropertyContent> Properties { get; set; }
+
+ public string Value => ValueAttribute ?? ValueBody;
+
+ public override string ToString()
+ {
+ return $"{Name}: {Value}";
+ }
+ }
+}
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapStaggerAxisContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapStaggerAxisContent.cs
new file mode 100644
index 0000000..7a073f5
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapStaggerAxisContent.cs
@@ -0,0 +1,10 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public enum TiledMapStaggerAxisContent : byte
+ {
+ [XmlEnum("x")]X,
+ [XmlEnum("y")]Y
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapStaggerIndexContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapStaggerIndexContent.cs
new file mode 100644
index 0000000..834c3a6
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapStaggerIndexContent.cs
@@ -0,0 +1,10 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public enum TiledMapStaggerIndexContent : byte
+ {
+ [XmlEnum("even")]Even,
+ [XmlEnum("odd")]Odd
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileContent.cs
new file mode 100644
index 0000000..fcd7a69
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileContent.cs
@@ -0,0 +1,9 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public struct TiledMapTileContent
+ {
+ [XmlAttribute(AttributeName = "gid")] public uint GlobalIdentifier;
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileDrawOrderContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileDrawOrderContent.cs
new file mode 100644
index 0000000..4762afd
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileDrawOrderContent.cs
@@ -0,0 +1,12 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public enum TiledMapTileDrawOrderContent : byte
+ {
+ [XmlEnum(Name = "right-down")] RightDown,
+ [XmlEnum(Name = "right-up")] RightUp,
+ [XmlEnum(Name = "left-down")] LeftDown,
+ [XmlEnum(Name = "left-up")] LeftUp
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerContent.cs
new file mode 100644
index 0000000..49f5ccf
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerContent.cs
@@ -0,0 +1,30 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapTileLayerContent : TiledMapLayerContent
+ {
+ public TiledMapTileLayerContent()
+ : base(TiledMapLayerType.TileLayer)
+ {
+ }
+
+ [XmlAttribute(AttributeName = "x")]
+ public int X { get; set; }
+
+ [XmlAttribute(AttributeName = "y")]
+ public int Y { get; set; }
+
+ [XmlAttribute(AttributeName = "width")]
+ public int Width { get; set; }
+
+ [XmlAttribute(AttributeName = "height")]
+ public int Height { get; set; }
+
+ [XmlElement(ElementName = "data")]
+ public TiledMapTileLayerDataContent Data { get; set; }
+
+ [XmlIgnore]
+ public TiledMapTile[] Tiles { get; set; }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerDataChunkContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerDataChunkContent.cs
new file mode 100644
index 0000000..0ec10d9
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerDataChunkContent.cs
@@ -0,0 +1,26 @@
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapTileLayerDataChunkContent
+ {
+ [XmlAttribute(AttributeName = "x")]
+ public int X { get; set; }
+
+ [XmlAttribute(AttributeName = "y")]
+ public int Y { get; set; }
+
+ [XmlAttribute(AttributeName = "width")]
+ public int Width { get; set; }
+
+ [XmlAttribute(AttributeName = "height")]
+ public int Height { get; set; }
+
+ [XmlElement(ElementName = "tile")]
+ public List<TiledMapTileContent> Tiles { get; set; }
+
+ [XmlText]
+ public string Value { get; set; }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerDataContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerDataContent.cs
new file mode 100644
index 0000000..c19a02e
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileLayerDataContent.cs
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapTileLayerDataContent
+ {
+ public TiledMapTileLayerDataContent()
+ {
+ Tiles = new List<TiledMapTileContent>();
+ }
+
+ [XmlAttribute(AttributeName = "encoding")]
+ public string Encoding { get; set; }
+
+ [XmlAttribute(AttributeName = "compression")]
+ public string Compression { get; set; }
+
+ [XmlElement(ElementName = "tile")]
+ public List<TiledMapTileContent> Tiles { get; set; }
+
+ [XmlElement(ElementName = "chunk")]
+ public List<TiledMapTileLayerDataChunkContent> Chunks { get; set; }
+
+ [XmlText]
+ public string Value { get; set; }
+
+ public override string ToString()
+ {
+ return $"{Encoding} {Compression}";
+ }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileOffsetContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileOffsetContent.cs
new file mode 100644
index 0000000..7d2af87
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTileOffsetContent.cs
@@ -0,0 +1,17 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ [XmlRoot(ElementName = "tileoffset")]
+ public class TiledMapTileOffsetContent
+ {
+ [XmlAttribute(AttributeName = "x")] public int X;
+
+ [XmlAttribute(AttributeName = "y")] public int Y;
+
+ public override string ToString()
+ {
+ return $"{X}, {Y}";
+ }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetContent.cs
new file mode 100644
index 0000000..fa04c31
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetContent.cs
@@ -0,0 +1,76 @@
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ [XmlRoot(ElementName = "tileset")]
+ public class TiledMapTilesetContent
+ {
+ public TiledMapTilesetContent()
+ {
+ TileOffset = new TiledMapTileOffsetContent();
+ Tiles = new List<TiledMapTilesetTileContent>();
+ Properties = new List<TiledMapPropertyContent>();
+ }
+
+ [XmlAttribute(AttributeName = "firstgid")]
+ public int FirstGlobalIdentifier { get; set; }
+
+ [XmlAttribute(AttributeName = "source")]
+ public string Source { get; set; }
+
+ [XmlAttribute(AttributeName = "name")]
+ public string Name { get; set; }
+
+ // Deprecated as of Tiled 1.9.0 (replaced by "class" attribute)
+ [XmlAttribute(DataType = "string", AttributeName = "type")]
+ public string Type { get; set; }
+
+ [XmlAttribute(DataType = "string", AttributeName = "class")]
+ public string Class { get; set; }
+
+ [XmlAttribute(AttributeName = "tilewidth")]
+ public int TileWidth { get; set; }
+
+ [XmlAttribute(AttributeName = "tileheight")]
+ public int TileHeight { get; set; }
+
+ [XmlAttribute(AttributeName = "spacing")]
+ public int Spacing { get; set; }
+
+ [XmlAttribute(AttributeName = "margin")]
+ public int Margin { get; set; }
+
+ [XmlAttribute(AttributeName = "columns")]
+ public int Columns { get; set; }
+
+ [XmlAttribute(AttributeName = "tilecount")]
+ public int TileCount { get; set; }
+
+ [XmlElement(ElementName = "tileoffset")]
+ public TiledMapTileOffsetContent TileOffset { get; set; }
+
+ [XmlElement(ElementName = "grid")]
+ public TiledMapTilesetGridContent Grid { get; set; }
+
+ [XmlElement(ElementName = "tile")]
+ public List<TiledMapTilesetTileContent> Tiles { get; set; }
+
+ [XmlArray("properties")]
+ [XmlArrayItem("property")]
+ public List<TiledMapPropertyContent> Properties { get; set; }
+
+ [XmlElement(ElementName = "image")]
+ public TiledMapImageContent Image { get; set; }
+
+ public bool ContainsGlobalIdentifier(int globalIdentifier)
+ {
+ return globalIdentifier >= FirstGlobalIdentifier && globalIdentifier < FirstGlobalIdentifier + TileCount;
+ }
+
+ public override string ToString()
+ {
+ return $"{Name}: {Image}";
+ }
+ }
+}
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetGridContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetGridContent.cs
new file mode 100644
index 0000000..a9071b8
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetGridContent.cs
@@ -0,0 +1,16 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapTilesetGridContent
+ {
+ [XmlAttribute(AttributeName = "orientation")]
+ public TiledMapOrientationContent Orientation { get; set; }
+
+ [XmlAttribute(AttributeName = "width")]
+ public int Width { get; set; }
+
+ [XmlAttribute(AttributeName = "height")]
+ public int Height { get; set; }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetTileAnimationFrameContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetTileAnimationFrameContent.cs
new file mode 100644
index 0000000..5a17137
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetTileAnimationFrameContent.cs
@@ -0,0 +1,18 @@
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapTilesetTileAnimationFrameContent
+ {
+ [XmlAttribute(AttributeName = "tileid")]
+ public int TileIdentifier { get; set; }
+
+ [XmlAttribute(AttributeName = "duration")]
+ public int Duration { get; set; }
+
+ public override string ToString()
+ {
+ return $"TileID: {TileIdentifier}, Duration: {Duration}";
+ }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetTileContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetTileContent.cs
new file mode 100644
index 0000000..2a82197
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetTileContent.cs
@@ -0,0 +1,40 @@
+using System.Collections.Generic;
+using System.Xml.Serialization;
+
+namespace MonoGame.Extended.Tiled.Serialization
+{
+ public class TiledMapTilesetTileContent
+ {
+ public TiledMapTilesetTileContent()
+ {
+ Properties = new List<TiledMapPropertyContent>();
+ Type = string.Empty;
+ }
+
+ [XmlAttribute(AttributeName = "id")]
+ public int LocalIdentifier { get; set; }
+
+ [XmlAttribute(AttributeName = "type")]
+ public string Type { get; set; }
+
+ [XmlElement(ElementName = "image")]
+ public TiledMapImageContent Image { get; set; }
+
+ [XmlArray("objectgroup")]
+ [XmlArrayItem("object")]
+ public List<TiledMapObjectContent> Objects { get; set; }
+
+ [XmlArray("animation")]
+ [XmlArrayItem("frame")]
+ public List<TiledMapTilesetTileAnimationFrameContent> Frames { get; set; }
+
+ [XmlArray("properties")]
+ [XmlArrayItem("property")]
+ public List<TiledMapPropertyContent> Properties { get; set; }
+
+ public override string ToString()
+ {
+ return LocalIdentifier.ToString();
+ }
+ }
+} \ No newline at end of file