diff --git a/Makefile b/Makefile
index 66cf561..a65d55f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,17 @@
-test:
- dotnet test src/DotTiled.sln
-
-docs-serve: docs-build
- docfx docs/docfx.json --serve
-
-docs-build:
- cp README.md docs/index.md
- docfx docs/docfx.json
-
-BENCHMARK_SOURCES = DotTiled.Benchmark/Program.cs DotTiled.Benchmark/DotTiled.Benchmark.csproj
-BENCHMARK_OUTPUTDIR = DotTiled.Benchmark/BenchmarkDotNet.Artifacts
-.PHONY: benchmark
-benchmark: $(BENCHMARK_OUTPUTDIR)/results/MyBenchmarks.MapLoading-report-github.md
-
-$(BENCHMARK_OUTPUTDIR)/results/MyBenchmarks.MapLoading-report-github.md: $(BENCHMARK_SOURCES)
+test:
+ dotnet test src/DotTiled.sln
+
+docs-serve:
+ docfx docs/docfx.json --serve
+
+docs-build:
+ cp README.md docs/index.md
+ docfx docs/docfx.json
+
+BENCHMARK_SOURCES = DotTiled.Benchmark/Program.cs DotTiled.Benchmark/DotTiled.Benchmark.csproj
+BENCHMARK_OUTPUTDIR = DotTiled.Benchmark/BenchmarkDotNet.Artifacts
+.PHONY: benchmark
+benchmark: $(BENCHMARK_OUTPUTDIR)/results/MyBenchmarks.MapLoading-report-github.md
+
+$(BENCHMARK_OUTPUTDIR)/results/MyBenchmarks.MapLoading-report-github.md: $(BENCHMARK_SOURCES)
dotnet run --project DotTiled.Benchmark/DotTiled.Benchmark.csproj -c Release -- $(BENCHMARK_OUTPUTDIR)
\ No newline at end of file
diff --git a/src/DotTiled.Tests/Assert/AssertObject.cs b/src/DotTiled.Tests/Assert/AssertObject.cs
index 93a5c45..d982ebd 100644
--- a/src/DotTiled.Tests/Assert/AssertObject.cs
+++ b/src/DotTiled.Tests/Assert/AssertObject.cs
@@ -4,19 +4,19 @@ namespace DotTiled.Tests;
public static partial class DotTiledAssert
{
- internal static void AssertObject(Model.Layers.Objects.Object expected, Model.Layers.Objects.Object actual)
+ internal static void AssertObject(Model.Object expected, Model.Object actual)
{
// Attributes
- AssertEqual(expected.ID, actual.ID, nameof(Model.Layers.Objects.Object.ID));
- AssertEqual(expected.Name, actual.Name, nameof(Model.Layers.Objects.Object.Name));
- AssertEqual(expected.Type, actual.Type, nameof(Model.Layers.Objects.Object.Type));
- AssertEqual(expected.X, actual.X, nameof(Model.Layers.Objects.Object.X));
- AssertEqual(expected.Y, actual.Y, nameof(Model.Layers.Objects.Object.Y));
- AssertEqual(expected.Width, actual.Width, nameof(Model.Layers.Objects.Object.Width));
- AssertEqual(expected.Height, actual.Height, nameof(Model.Layers.Objects.Object.Height));
- AssertEqual(expected.Rotation, actual.Rotation, nameof(Model.Layers.Objects.Object.Rotation));
- AssertEqual(expected.Visible, actual.Visible, nameof(Model.Layers.Objects.Object.Visible));
- AssertEqual(expected.Template, actual.Template, nameof(Model.Layers.Objects.Object.Template));
+ AssertEqual(expected.ID, actual.ID, nameof(Model.Object.ID));
+ AssertEqual(expected.Name, actual.Name, nameof(Model.Object.Name));
+ AssertEqual(expected.Type, actual.Type, nameof(Model.Object.Type));
+ AssertEqual(expected.X, actual.X, nameof(Model.Object.X));
+ AssertEqual(expected.Y, actual.Y, nameof(Model.Object.Y));
+ AssertEqual(expected.Width, actual.Width, nameof(Model.Object.Width));
+ AssertEqual(expected.Height, actual.Height, nameof(Model.Object.Height));
+ AssertEqual(expected.Rotation, actual.Rotation, nameof(Model.Object.Rotation));
+ AssertEqual(expected.Visible, actual.Visible, nameof(Model.Object.Visible));
+ AssertEqual(expected.Template, actual.Template, nameof(Model.Object.Template));
AssertProperties(expected.Properties, actual.Properties);
diff --git a/src/DotTiled/Model/Layers/BaseLayer.cs b/src/DotTiled/Model/Layers/BaseLayer.cs
index f73c760..aa78191 100644
--- a/src/DotTiled/Model/Layers/BaseLayer.cs
+++ b/src/DotTiled/Model/Layers/BaseLayer.cs
@@ -2,20 +2,65 @@ using System.Collections.Generic;
namespace DotTiled.Model;
+///
+/// Base class for all layer types in a map.
+/// To check the type of a layer, use C# pattern matching ,
+/// or some other mechanism to determine the type of the layer at runtime.
+///
public abstract class BaseLayer
{
- // Attributes
+ ///
+ /// Unique ID of the layer. Each layer that is added to a map gets a unique ID. Even if a layer is deleted, no layer ever gets the same ID.
+ ///
public required uint ID { get; set; }
+
+ ///
+ /// The name of the layer.
+ ///
public string Name { get; set; } = "";
+
+ ///
+ /// The class of the layer.
+ ///
public string Class { get; set; } = "";
+
+ ///
+ /// The opacity of the layer as a value from 0 (fully transparent) to 1 (fully opaque).
+ ///
public float Opacity { get; set; } = 1.0f;
+
+ ///
+ /// Whether the layer is shown (true) or hidden (false).
+ ///
public bool Visible { get; set; } = true;
+
+ ///
+ /// A tint color that is multiplied with any tiles drawn by this layer.
+ ///
public Color? TintColor { get; set; }
+
+ ///
+ /// Horizontal offset for this layer in pixels.
+ ///
public float OffsetX { get; set; } = 0.0f;
+
+ ///
+ /// Vertical offset for this layer in pixels.
+ ///
public float OffsetY { get; set; } = 0.0f;
+
+ ///
+ /// Horizontal parallax factor for this layer.
+ ///
public float ParallaxX { get; set; } = 1.0f;
+
+ ///
+ /// Vertical parallax factor for this layer.
+ ///
public float ParallaxY { get; set; } = 1.0f;
- // At most one of
+ ///
+ /// Layer properties.
+ ///
public Dictionary? Properties { get; set; }
}
diff --git a/src/DotTiled/Model/Layers/Data.cs b/src/DotTiled/Model/Layers/Data.cs
index 7388828..d2a9686 100644
--- a/src/DotTiled/Model/Layers/Data.cs
+++ b/src/DotTiled/Model/Layers/Data.cs
@@ -2,50 +2,143 @@ using System;
namespace DotTiled.Model;
+///
+/// Specifies the encoding used to encode the tile layer data.
+///
public enum DataEncoding
{
+ ///
+ /// The data is stored as comma-separated values.
+ ///
Csv,
+
+ ///
+ /// The data is stored as base64-encoded binary data.
+ ///
Base64
}
+///
+/// Specifies the compression algorithm used to compress the tile layer data.
+///
public enum DataCompression
{
+ ///
+ /// GZip compression.
+ ///
GZip,
+
+ ///
+ /// ZLib compression.
+ ///
ZLib,
+
+ ///
+ /// ZStandard compression. Currently not supported by DotTiled and will throw an exception if encountered.
+ ///
ZStd
}
+///
+/// The flipping flags for a tile. These can be used to check how a tile is flipped or rotated. Uses the
+/// FlagsAttribute, for which there is plenty of documentation.
+///
[Flags]
public enum FlippingFlags : uint
{
+ ///
+ /// No flipping.
+ ///
None = 0,
+
+ ///
+ /// The tile is flipped horizontally.
+ ///
FlippedHorizontally = 0x80000000u,
+
+ ///
+ /// The tile is flipped vertically.
+ ///
FlippedVertically = 0x40000000u,
+
+ ///
+ /// The tile is flipped diagonally.
+ ///
FlippedDiagonally = 0x20000000u,
+
+ ///
+ /// In hexagonal maps, the tile is rotated 120 degrees clockwise.
+ ///
RotatedHexagonal120 = 0x10000000u
}
+///
+/// Represents part of a tile layer of a map that is infinite.
+///
public class Chunk
{
- // Attributes
+ ///
+ /// The X coordinate of the chunk in tiles.
+ ///
public required int X { get; set; }
+
+ ///
+ /// The Y coordinate of the chunk in tiles.
+ ///
public required int Y { get; set; }
+
+ ///
+ /// The width of the chunk in tiles.
+ ///
public required uint Width { get; set; }
+
+ ///
+ /// The height of the chunk in tiles.
+ ///
public required uint Height { get; set; }
- // Data
+ ///
+ /// The parsed chunk data, as a list of tile GIDs.
+ /// To get an actual tile ID, you map it to a local tile ID using the correct tileset. Please refer to
+ /// the documentation on how to do this .
+ ///
public required uint[] GlobalTileIDs { get; set; }
+
+ ///
+ /// The parsed flipping flags for each tile in the chunk. Appear in the same order as the tiles in the layer in .
+ ///
public required FlippingFlags[] FlippingFlags { get; set; }
}
+///
+/// Represents the data of a tile layer.
+///
public class Data
{
- // Attributes
+ ///
+ /// The encoding used to encode the tile layer data.
+ ///
public DataEncoding? Encoding { get; set; }
+
+ ///
+ /// The compression method used to compress the tile layer data.
+ ///
public DataCompression? Compression { get; set; }
- // Data
+ ///
+ /// The parsed tile layer data, as a list of tile GIDs.
+ /// To get an actual tile ID, you map it to a local tile ID using the correct tileset. Please refer to
+ /// the documentation on how to do this .
+ ///
public uint[]? GlobalTileIDs { get; set; }
+
+ ///
+ /// The parsed flipping flags for each tile in the layer. Appear in the same order as the tiles in the layer in .
+ ///
public FlippingFlags[]? FlippingFlags { get; set; }
+
+ ///
+ /// If the map is infinite, it will instead contain a list of chunks.
+ ///
public Chunk[]? Chunks { get; set; }
}
diff --git a/src/DotTiled/Model/Layers/Group.cs b/src/DotTiled/Model/Layers/Group.cs
index 9fa68da..f770c63 100644
--- a/src/DotTiled/Model/Layers/Group.cs
+++ b/src/DotTiled/Model/Layers/Group.cs
@@ -2,10 +2,13 @@ using System.Collections.Generic;
namespace DotTiled.Model;
+///
+/// Represents a group of layers, to form a hierarchy.
+///
public class Group : BaseLayer
{
- // Uses same attributes as BaseLayer
-
- // Any number of
+ ///
+ /// The contained sub-layers in the group.
+ ///
public List Layers { get; set; } = [];
}
diff --git a/src/DotTiled/Model/Layers/ImageLayer.cs b/src/DotTiled/Model/Layers/ImageLayer.cs
index fbdf54e..e0bb110 100644
--- a/src/DotTiled/Model/Layers/ImageLayer.cs
+++ b/src/DotTiled/Model/Layers/ImageLayer.cs
@@ -1,13 +1,32 @@
namespace DotTiled.Model;
+///
+/// Represents an image layer in a map.
+///
public class ImageLayer : BaseLayer
{
- // Attributes
+ ///
+ /// The X position of the image layer in pixels.
+ ///
public uint X { get; set; } = 0;
+
+ ///
+ /// The Y position of the image layer in pixels.
+ ///
public uint Y { get; set; } = 0;
+
+ ///
+ /// Whether the image drawn by this layer is repeated along the X axis.
+ ///
public bool RepeatX { get; set; } = false;
+
+ ///
+ /// Whether the image drawn by this layer is repeated along the Y axis.
+ ///
public bool RepeatY { get; set; } = false;
- // At most one of
+ ///
+ /// The image to be drawn by this image layer.
+ ///
public Image? Image { get; set; }
}
diff --git a/src/DotTiled/Model/Layers/ObjectLayer.cs b/src/DotTiled/Model/Layers/ObjectLayer.cs
index 04f97dd..60acc13 100644
--- a/src/DotTiled/Model/Layers/ObjectLayer.cs
+++ b/src/DotTiled/Model/Layers/ObjectLayer.cs
@@ -2,22 +2,59 @@ using System.Collections.Generic;
namespace DotTiled.Model;
+///
+/// Represents the order in which objects can be drawn.
+///
public enum DrawOrder
{
+ ///
+ /// Objects are drawn sorted by their Y coordinate.
+ ///
TopDown,
+
+ ///
+ /// Objects are drawn in the order of appearance in the object layer.
+ ///
Index
}
+///
+/// Represents an object layer in a map. In Tiled documentation, it is often called an "object group".
+///
public class ObjectLayer : BaseLayer
{
- // Attributes
+ ///
+ /// The X coordinate of the object layer in tiles.
+ ///
public uint X { get; set; } = 0;
+
+ ///
+ /// The Y coordinate of the object layer in tiles.
+ ///
public uint Y { get; set; } = 0;
+
+ ///
+ /// The width of the object layer in tiles. Meaningless.
+ ///
public uint? Width { get; set; }
+
+ ///
+ /// The height of the object layer in tiles. Meaningless.
+ ///
public uint? Height { get; set; }
+
+ ///
+ /// A color that is multiplied with any tile objects drawn by this layer.
+ ///
public Color? Color { get; set; }
+
+ ///
+ /// Whether the objects are drawn according to the order of appearance ( ) or sorted by their Y coordinate ( ).
+ ///
public DrawOrder DrawOrder { get; set; } = DrawOrder.TopDown;
- // Elements
+ ///
+ /// The objects in the object layer.
+ ///
public required List Objects { get; set; }
}
diff --git a/src/DotTiled/Model/Layers/Objects/EllipseObject.cs b/src/DotTiled/Model/Layers/Objects/EllipseObject.cs
index 8e75338..7e777de 100644
--- a/src/DotTiled/Model/Layers/Objects/EllipseObject.cs
+++ b/src/DotTiled/Model/Layers/Objects/EllipseObject.cs
@@ -1,3 +1,7 @@
namespace DotTiled.Model;
+///
+/// An ellipse object in a map. The existing , , ,
+/// and properties are used to determine the size of the ellipse.
+///
public class EllipseObject : Object { }
diff --git a/src/DotTiled/Model/Layers/Objects/Object.cs b/src/DotTiled/Model/Layers/Objects/Object.cs
index 98935b1..fad05db 100644
--- a/src/DotTiled/Model/Layers/Objects/Object.cs
+++ b/src/DotTiled/Model/Layers/Objects/Object.cs
@@ -2,20 +2,63 @@ using System.Collections.Generic;
namespace DotTiled.Model;
+///
+/// Base class for objects in object layers.
+///
public abstract class Object
{
- // Attributes
+ ///
+ /// Unique ID of the objects. Each object that is placed on a map gets a unique ID. Even if an object was deleted, no object gets the same ID.
+ ///
public uint? ID { get; set; }
+
+ ///
+ /// The name of the object. An arbitrary string.
+ ///
public string Name { get; set; } = "";
+
+ ///
+ /// The class of the object. An arbitrary string.
+ ///
public string Type { get; set; } = "";
+
+ ///
+ /// The X coordinate of the object in pixels.
+ ///
public float X { get; set; } = 0f;
+
+ ///
+ /// The Y coordinate of the object in pixels.
+ ///
public float Y { get; set; } = 0f;
+
+ ///
+ /// The width of the object in pixels.
+ ///
public float Width { get; set; } = 0f;
+
+ ///
+ /// The height of the object in pixels.
+ ///
public float Height { get; set; } = 0f;
+
+ ///
+ /// The rotation of the object in degrees clockwise around (X, Y).
+ ///
public float Rotation { get; set; } = 0f;
+
+ ///
+ /// Whether the object is shown (true) or hidden (false).
+ ///
public bool Visible { get; set; } = true;
+
+ ///
+ /// A reference to a template file.
+ ///
public string? Template { get; set; }
- // Elements
+ ///
+ /// Object properties.
+ ///
public Dictionary? Properties { get; set; }
}
diff --git a/src/DotTiled/Model/Layers/Objects/PointObject.cs b/src/DotTiled/Model/Layers/Objects/PointObject.cs
index e606c37..44eada8 100644
--- a/src/DotTiled/Model/Layers/Objects/PointObject.cs
+++ b/src/DotTiled/Model/Layers/Objects/PointObject.cs
@@ -1,3 +1,7 @@
namespace DotTiled.Model;
+///
+/// A point object in a map. The existing and properties are used to
+/// determine the position of the point.
+///
public class PointObject : Object { }
diff --git a/src/DotTiled/Model/Layers/Objects/PolygonObject.cs b/src/DotTiled/Model/Layers/Objects/PolygonObject.cs
index 6a58592..09805d8 100644
--- a/src/DotTiled/Model/Layers/Objects/PolygonObject.cs
+++ b/src/DotTiled/Model/Layers/Objects/PolygonObject.cs
@@ -3,8 +3,15 @@ using System.Numerics;
namespace DotTiled.Model;
+///
+/// A polygon object in a map. The existing and properties are used as
+/// the origin of the polygon.
+///
public class PolygonObject : Object
{
- // Attributes
+ ///
+ /// The points that make up the polygon.
+ /// and are used as the origin of the polygon.
+ ///
public required List Points { get; set; }
}
diff --git a/src/DotTiled/Model/Layers/Objects/PolylineObject.cs b/src/DotTiled/Model/Layers/Objects/PolylineObject.cs
index e97d017..d267c07 100644
--- a/src/DotTiled/Model/Layers/Objects/PolylineObject.cs
+++ b/src/DotTiled/Model/Layers/Objects/PolylineObject.cs
@@ -3,8 +3,14 @@ using System.Numerics;
namespace DotTiled.Model;
+///
+/// A polyline object in a map. The existing and properties are used as
+/// the origin of the polyline.
+///
public class PolylineObject : Object
{
- // Attributes
+ ///
+ /// The points that make up the polyline. and are used as the origin of the polyline.
+ ///
public required List Points { get; set; }
}
diff --git a/src/DotTiled/Model/Layers/Objects/RectangleObject.cs b/src/DotTiled/Model/Layers/Objects/RectangleObject.cs
index 4fad428..99c6cff 100644
--- a/src/DotTiled/Model/Layers/Objects/RectangleObject.cs
+++ b/src/DotTiled/Model/Layers/Objects/RectangleObject.cs
@@ -1,3 +1,7 @@
namespace DotTiled.Model;
+///
+/// A rectangle object in a map. The existing , , ,
+/// and properties are used to determine the size of the rectangle.
+///
public class RectangleObject : Object { }
diff --git a/src/DotTiled/Model/Layers/Objects/TextObject.cs b/src/DotTiled/Model/Layers/Objects/TextObject.cs
index 2072c7f..9c5ed2d 100644
--- a/src/DotTiled/Model/Layers/Objects/TextObject.cs
+++ b/src/DotTiled/Model/Layers/Objects/TextObject.cs
@@ -2,36 +2,115 @@ using System.Globalization;
namespace DotTiled.Model;
+///
+/// The horizontal alignment of text.
+///
public enum TextHorizontalAlignment
{
+ ///
+ /// The text is aligned to the left.
+ ///
Left,
+
+ ///
+ /// The text is aligned to the center.
+ ///
Center,
+
+ ///
+ /// The text is aligned to the right.
+ ///
Right,
+
+ ///
+ /// The text is justified.
+ ///
Justify
}
+///
+/// The vertical alignment of text.
+///
public enum TextVerticalAlignment
{
+ ///
+ /// The text is aligned to the top.
+ ///
Top,
+
+ ///
+ /// The text is aligned to the center.
+ ///
Center,
+
+ ///
+ /// The text is aligned to the bottom.
+ ///
Bottom
}
+///
+/// A text object in a map.
+///
public class TextObject : Object
{
- // Attributes
+ ///
+ /// The font family used for the text.
+ ///
public string FontFamily { get; set; } = "sans-serif";
+
+ ///
+ /// The size of the font in pixels.
+ ///
public int PixelSize { get; set; } = 16;
+
+ ///
+ /// Whether word wrapping is enabled.
+ ///
public bool Wrap { get; set; } = false;
+
+ ///
+ /// The color of the text.
+ ///
public Color Color { get; set; } = Color.Parse("#000000", CultureInfo.InvariantCulture);
+
+ ///
+ /// Whether the text is bold.
+ ///
public bool Bold { get; set; } = false;
+
+ ///
+ /// Whether the text is italic.
+ ///
public bool Italic { get; set; } = false;
+
+ ///
+ /// Whether a line should be drawn below the text.
+ ///
public bool Underline { get; set; } = false;
+
+ ///
+ /// Whether a line should be drawn through the text.
+ ///
public bool Strikeout { get; set; } = false;
+
+ ///
+ /// Whether kerning should be used while rendering the text.
+ ///
public bool Kerning { get; set; } = true;
+
+ ///
+ /// The horizontal alignment of the text.
+ ///
public TextHorizontalAlignment HorizontalAlignment { get; set; } = TextHorizontalAlignment.Left;
+
+ ///
+ /// The vertical alignment of the text.
+ ///
public TextVerticalAlignment VerticalAlignment { get; set; } = TextVerticalAlignment.Top;
- // Elements
+ ///
+ /// The text to be displayed.
+ ///
public string Text { get; set; } = "";
}
diff --git a/src/DotTiled/Model/Layers/Objects/TileObject.cs b/src/DotTiled/Model/Layers/Objects/TileObject.cs
index dc52100..fe44c50 100644
--- a/src/DotTiled/Model/Layers/Objects/TileObject.cs
+++ b/src/DotTiled/Model/Layers/Objects/TileObject.cs
@@ -1,6 +1,12 @@
namespace DotTiled.Model;
+///
+/// A tile object in a map.
+///
public class TileObject : Object
{
+ ///
+ /// A reference to a tile.
+ ///
public uint GID { get; set; }
}
diff --git a/src/DotTiled/Model/Layers/TileLayer.cs b/src/DotTiled/Model/Layers/TileLayer.cs
index f314c1c..600f7c0 100644
--- a/src/DotTiled/Model/Layers/TileLayer.cs
+++ b/src/DotTiled/Model/Layers/TileLayer.cs
@@ -1,13 +1,32 @@
namespace DotTiled.Model;
+///
+/// Represents a tile layer in a map.
+///
public class TileLayer : BaseLayer
{
- // Attributes
+ ///
+ /// The X coordinate of the layer in tiles.
+ ///
public uint X { get; set; } = 0;
+
+ ///
+ /// The Y coordinate of the layer in tiles.
+ ///
public uint Y { get; set; } = 0;
+
+ ///
+ /// The width of the layer in tiles. Always the same as the map width for fixed-size maps.
+ ///
public required uint Width { get; set; }
+
+ ///
+ /// The height of the layer in tiles. Always the same as the map height for fixed-size maps.
+ ///
public required uint Height { get; set; }
- // At most one of
+ ///
+ /// The tile layer data.
+ ///
public Data? Data { get; set; }
}
diff --git a/src/DotTiled/Model/Properties/BoolProperty.cs b/src/DotTiled/Model/Properties/BoolProperty.cs
index af57a91..bc60a87 100644
--- a/src/DotTiled/Model/Properties/BoolProperty.cs
+++ b/src/DotTiled/Model/Properties/BoolProperty.cs
@@ -1,11 +1,22 @@
namespace DotTiled.Model;
+///
+/// Represents a boolean property.
+///
public class BoolProperty : IProperty
{
+ ///
public required string Name { get; set; }
+
+ ///
public PropertyType Type => PropertyType.Bool;
+
+ ///
+ /// The boolean value of the property.
+ ///
public required bool Value { get; set; }
+ ///
public IProperty Clone() => new BoolProperty
{
Name = Name,
diff --git a/src/DotTiled/Model/Properties/ClassProperty.cs b/src/DotTiled/Model/Properties/ClassProperty.cs
index 8117e7f..50d65ba 100644
--- a/src/DotTiled/Model/Properties/ClassProperty.cs
+++ b/src/DotTiled/Model/Properties/ClassProperty.cs
@@ -3,13 +3,29 @@ using System.Linq;
namespace DotTiled.Model;
+///
+/// Represents a class property.
+///
public class ClassProperty : IProperty
{
+ ///
public required string Name { get; set; }
- public PropertyType Type => Model.Properties.PropertyType.Class;
+
+ ///
+ public PropertyType Type => Model.PropertyType.Class;
+
+ ///
+ /// The type of the class property. This will be the name of a custom defined
+ /// type in Tiled.
+ ///
public required string PropertyType { get; set; }
+
+ ///
+ /// The properties of the class property.
+ ///
public required Dictionary Properties { get; set; }
+ ///
public IProperty Clone() => new ClassProperty
{
Name = Name,
diff --git a/src/DotTiled/Model/Properties/ColorProperty.cs b/src/DotTiled/Model/Properties/ColorProperty.cs
index 83e5852..aec43f6 100644
--- a/src/DotTiled/Model/Properties/ColorProperty.cs
+++ b/src/DotTiled/Model/Properties/ColorProperty.cs
@@ -1,11 +1,22 @@
namespace DotTiled.Model;
+///
+/// Represents a color property.
+///
public class ColorProperty : IProperty
{
+ ///
public required string Name { get; set; }
+
+ ///
public PropertyType Type => PropertyType.Color;
+
+ ///
+ /// The color value of the property.
+ ///
public required Color Value { get; set; }
+ ///
public IProperty Clone() => new ColorProperty
{
Name = Name,
diff --git a/src/DotTiled/Model/Properties/CustomTypes/CustomClassDefinition.cs b/src/DotTiled/Model/Properties/CustomTypes/CustomClassDefinition.cs
index 888d268..b5aa0ec 100644
--- a/src/DotTiled/Model/Properties/CustomTypes/CustomClassDefinition.cs
+++ b/src/DotTiled/Model/Properties/CustomTypes/CustomClassDefinition.cs
@@ -3,25 +3,87 @@ using System.Collections.Generic;
namespace DotTiled.Model;
+///
+/// Represents the types of objects that can use a custom class.
+/// Uses the FlagsAttribute, for which there is plenty of documentation.
+///
[Flags]
public enum CustomClassUseAs
{
+ ///
+ /// Any property on any kind of object.
+ ///
Property,
+
+ ///
+ /// A map.
+ ///
Map,
+
+ ///
+ /// A layer.
+ ///
Layer,
+
+ ///
+ /// An object.
+ ///
Object,
+
+ ///
+ /// A tile.
+ ///
Tile,
+
+ ///
+ /// A tileset.
+ ///
Tileset,
+
+ ///
+ /// A Wang color.
+ ///
WangColor,
+
+ ///
+ /// A Wangset.
+ ///
Wangset,
+
+ ///
+ /// A project.
+ ///
Project,
+
+ ///
+ /// All types.
+ ///
All = Property | Map | Layer | Object | Tile | Tileset | WangColor | Wangset | Project
}
+///
+/// Represents a custom class definition in Tiled. Refer to the
+/// documentation of custom types to understand how they work .
+///
public class CustomClassDefinition : CustomTypeDefinition
{
+ ///
+ /// The color of the custom class inside the Tiled editor.
+ ///
public Color? Color { get; set; }
+
+ ///
+ /// Whether the custom class should be drawn with a fill color.
+ ///
public bool DrawFill { get; set; }
+
+ ///
+ /// What the custom class can be used as, or rather, what types of objects can use it.
+ ///
public CustomClassUseAs UseAs { get; set; }
+
+ ///
+ /// The members of the custom class, with their names, types and default values.
+ ///
public List Members { get; set; } = [];
}
diff --git a/src/DotTiled/Model/Properties/CustomTypes/CustomEnumDefinition.cs b/src/DotTiled/Model/Properties/CustomTypes/CustomEnumDefinition.cs
index 602eef0..ee40be0 100644
--- a/src/DotTiled/Model/Properties/CustomTypes/CustomEnumDefinition.cs
+++ b/src/DotTiled/Model/Properties/CustomTypes/CustomEnumDefinition.cs
@@ -2,15 +2,40 @@ using System.Collections.Generic;
namespace DotTiled.Model;
+///
+/// Represents the storage type of a custom enum.
+///
public enum CustomEnumStorageType
{
+ ///
+ /// The backing value is an integer.
+ ///
Int,
+
+ ///
+ /// The backing value is a string.
+ ///
String
}
+///
+/// Represents a custom enum definition in Tiled. Refer to the
+/// documentation of custom types to understand how they work .
+///
public class CustomEnumDefinition : CustomTypeDefinition
{
+ ///
+ /// The storage type of the custom enum.
+ ///
public CustomEnumStorageType StorageType { get; set; }
+
+ ///
+ /// The values of the custom enum.
+ ///
public List Values { get; set; } = [];
+
+ ///
+ /// Whether the value should be treated as flags.
+ ///
public bool ValueAsFlags { get; set; }
}
diff --git a/src/DotTiled/Model/Properties/CustomTypes/CustomTypeDefinition.cs b/src/DotTiled/Model/Properties/CustomTypes/CustomTypeDefinition.cs
index 5670ebe..3a91b0a 100644
--- a/src/DotTiled/Model/Properties/CustomTypes/CustomTypeDefinition.cs
+++ b/src/DotTiled/Model/Properties/CustomTypes/CustomTypeDefinition.cs
@@ -1,7 +1,17 @@
namespace DotTiled.Model;
+///
+/// Base class for custom type definitions.
+///
public abstract class CustomTypeDefinition
{
+ ///
+ /// The ID of the custom type.
+ ///
public uint ID { get; set; }
+
+ ///
+ /// The name of the custom type.
+ ///
public string Name { get; set; } = "";
}
diff --git a/src/DotTiled/Model/Properties/FileProperty.cs b/src/DotTiled/Model/Properties/FileProperty.cs
index f6b1314..4ed8642 100644
--- a/src/DotTiled/Model/Properties/FileProperty.cs
+++ b/src/DotTiled/Model/Properties/FileProperty.cs
@@ -1,11 +1,22 @@
namespace DotTiled.Model;
+///
+/// Represents a file property.
+///
public class FileProperty : IProperty
{
+ ///
public required string Name { get; set; }
+
+ ///
public PropertyType Type => PropertyType.File;
+
+ ///
+ /// The value of the property.
+ ///
public required string Value { get; set; }
+ ///
public IProperty Clone() => new FileProperty
{
Name = Name,
diff --git a/src/DotTiled/Model/Properties/FloatProperty.cs b/src/DotTiled/Model/Properties/FloatProperty.cs
index fbbc797..4c6b51f 100644
--- a/src/DotTiled/Model/Properties/FloatProperty.cs
+++ b/src/DotTiled/Model/Properties/FloatProperty.cs
@@ -1,11 +1,22 @@
namespace DotTiled.Model;
+///
+/// Represents a float property.
+///
public class FloatProperty : IProperty
{
+ ///
public required string Name { get; set; }
+
+ ///
public PropertyType Type => PropertyType.Float;
+
+ ///
+ /// The float value of the property.
+ ///
public required float Value { get; set; }
+ ///
public IProperty Clone() => new FloatProperty
{
Name = Name,
diff --git a/src/DotTiled/Model/Properties/IProperty.cs b/src/DotTiled/Model/Properties/IProperty.cs
index 925eff0..262ee09 100644
--- a/src/DotTiled/Model/Properties/IProperty.cs
+++ b/src/DotTiled/Model/Properties/IProperty.cs
@@ -1,9 +1,24 @@
namespace DotTiled.Model;
+///
+/// Interface for properties that can be attached to objects, tiles, tilesets, maps etc.
+///
public interface IProperty
{
+ ///
+ /// The name of the property.
+ ///
public string Name { get; set; }
+
+ ///
+ /// The type of the property.
+ ///
public PropertyType Type { get; }
+ ///
+ /// Clones the property, only used for copying properties when performing overriding
+ /// with templates.
+ ///
+ /// An identical, but non-reference-equal, instance of the same property.
IProperty Clone();
}
diff --git a/src/DotTiled/Model/Properties/IntProperty.cs b/src/DotTiled/Model/Properties/IntProperty.cs
index cb4fe43..29f7a1d 100644
--- a/src/DotTiled/Model/Properties/IntProperty.cs
+++ b/src/DotTiled/Model/Properties/IntProperty.cs
@@ -1,11 +1,22 @@
namespace DotTiled.Model;
+///
+/// Represents an integer property.
+///
public class IntProperty : IProperty
{
+ ///
public required string Name { get; set; }
+
+ ///
public PropertyType Type => PropertyType.Int;
+
+ ///
+ /// The integer value of the property.
+ ///
public required int Value { get; set; }
+ ///
public IProperty Clone() => new IntProperty
{
Name = Name,
diff --git a/src/DotTiled/Model/Properties/ObjectProperty.cs b/src/DotTiled/Model/Properties/ObjectProperty.cs
index ee2b02d..04b15ba 100644
--- a/src/DotTiled/Model/Properties/ObjectProperty.cs
+++ b/src/DotTiled/Model/Properties/ObjectProperty.cs
@@ -1,11 +1,22 @@
namespace DotTiled.Model;
+///
+/// Represents an object property.
+///
public class ObjectProperty : IProperty
{
+ ///
public required string Name { get; set; }
+
+ ///
public PropertyType Type => PropertyType.Object;
+
+ ///
+ /// The object identifier referenced by the property.
+ ///
public required uint Value { get; set; }
+ ///
public IProperty Clone() => new ObjectProperty
{
Name = Name,
diff --git a/src/DotTiled/Model/Properties/PropertyType.cs b/src/DotTiled/Model/Properties/PropertyType.cs
index 88a1cda..d6057cc 100644
--- a/src/DotTiled/Model/Properties/PropertyType.cs
+++ b/src/DotTiled/Model/Properties/PropertyType.cs
@@ -1,13 +1,47 @@
namespace DotTiled.Model;
+///
+/// Represents the type of a property.
+///
public enum PropertyType
{
+ ///
+ /// A string property.
+ ///
String,
+
+ ///
+ /// An integer property.
+ ///
Int,
+
+ ///
+ /// A float property.
+ ///
Float,
+
+ ///
+ /// A boolean property.
+ ///
Bool,
+
+ ///
+ /// A color property.
+ ///
Color,
+
+ ///
+ /// A file property.
+ ///
File,
+
+ ///
+ /// An object property.
+ ///
Object,
+
+ ///
+ /// A class property.
+ ///
Class
}
diff --git a/src/DotTiled/Model/Properties/StringProperty.cs b/src/DotTiled/Model/Properties/StringProperty.cs
index 965d08b..49d7aec 100644
--- a/src/DotTiled/Model/Properties/StringProperty.cs
+++ b/src/DotTiled/Model/Properties/StringProperty.cs
@@ -1,11 +1,22 @@
namespace DotTiled.Model;
+///
+/// Represents a string property.
+///
public class StringProperty : IProperty
{
+ ///
public required string Name { get; set; }
+
+ ///
public PropertyType Type => PropertyType.String;
+
+ ///
+ /// The string value of the property.
+ ///
public required string Value { get; set; }
+ ///
public IProperty Clone() => new StringProperty
{
Name = Name,
diff --git a/src/DotTiled/Model/Tilesets/Frame.cs b/src/DotTiled/Model/Tilesets/Frame.cs
index f57f579..7e48aa0 100644
--- a/src/DotTiled/Model/Tilesets/Frame.cs
+++ b/src/DotTiled/Model/Tilesets/Frame.cs
@@ -1,8 +1,17 @@
namespace DotTiled.Model;
+///
+/// A single frame of an animated tile.
+///
public class Frame
{
- // Attributes
+ ///
+ /// The local tile ID within the parent tileset.
+ ///
public required uint TileID { get; set; }
+
+ ///
+ /// How long (in milliseconds) this frame should be displayed before advancing to the next frame.
+ ///
public required uint Duration { get; set; }
}
diff --git a/src/DotTiled/Model/Tilesets/Grid.cs b/src/DotTiled/Model/Tilesets/Grid.cs
index d98ad6f..e8acfac 100644
--- a/src/DotTiled/Model/Tilesets/Grid.cs
+++ b/src/DotTiled/Model/Tilesets/Grid.cs
@@ -1,15 +1,38 @@
namespace DotTiled.Model;
+///
+/// Orientation of the grid for the tiles in this tileset.
+///
public enum GridOrientation
{
+ ///
+ /// The grid is orthogonal.
+ ///
Orthogonal,
+
+ ///
+ /// The grid is isometric.
+ ///
Isometric
}
+///
+/// Used to specify how tile overlays for terrain and collision information are rendered in isometric maps.
+///
public class Grid
{
- // Attributes
+ ///
+ /// Orientation of the grid for the tiles in this tileset.
+ ///
public GridOrientation Orientation { get; set; } = GridOrientation.Orthogonal;
+
+ ///
+ /// Width of a grid cell.
+ ///
public required uint Width { get; set; }
+
+ ///
+ /// Height of a grid cell.
+ ///
public required uint Height { get; set; }
}
diff --git a/src/DotTiled/Model/Tilesets/Image.cs b/src/DotTiled/Model/Tilesets/Image.cs
index d776bb8..418d5f4 100644
--- a/src/DotTiled/Model/Tilesets/Image.cs
+++ b/src/DotTiled/Model/Tilesets/Image.cs
@@ -1,19 +1,58 @@
namespace DotTiled.Model;
+///
+/// The format of an image.
+///
public enum ImageFormat
{
+ ///
+ /// Portable Network Graphics.
+ ///
Png,
+
+ ///
+ /// Graphics Interchange Format.
+ ///
Gif,
+
+ ///
+ /// Joint Photographic Experts Group.
+ ///
Jpg,
+
+ ///
+ /// Windows Bitmap.
+ ///
Bmp
}
+///
+/// Represents an image that is used by a tileset.
+///
public class Image
{
- // Attributes
+ ///
+ /// The format of the image.
+ ///
public ImageFormat? Format { get; set; }
+
+ ///
+ /// The reference to the image file.
+ ///
public string? Source { get; set; }
+
+ ///
+ /// Defines a specific color that is treated as transparent.
+ ///
public Color? TransparentColor { get; set; }
+
+ ///
+ /// The image width in pixels, used for tile index correction when the image changes.
+ ///
public uint? Width { get; set; }
+
+ ///
+ /// The image height in pixels, used for tile index correction when the image changes.
+ ///
public uint? Height { get; set; }
}
diff --git a/src/DotTiled/Model/Tilesets/Tile.cs b/src/DotTiled/Model/Tilesets/Tile.cs
index 26c6057..c6b964d 100644
--- a/src/DotTiled/Model/Tilesets/Tile.cs
+++ b/src/DotTiled/Model/Tilesets/Tile.cs
@@ -2,20 +2,64 @@ using System.Collections.Generic;
namespace DotTiled.Model;
+///
+/// Represents a single tile in a tileset, when using a collection of images to represent the tileset.
+/// Tiled documentation for Tileset tiles
+///
public class Tile
{
- // Attributes
+ ///
+ /// The local tile ID within its tileset.
+ ///
public required uint ID { get; set; }
+
+ ///
+ /// The class of the tile. Is inherited by tile objects
+ ///
public string Type { get; set; } = "";
+
+ ///
+ /// A percentage indicating the probability that this tile is chosen when it competes with others while editing with the terrain tool.
+ ///
public float Probability { get; set; } = 0f;
+
+ ///
+ /// The X position of the sub-rectangle representing this tile within the tileset image.
+ ///
public uint X { get; set; } = 0;
+
+ ///
+ /// The Y position of the sub-rectangle representing this tile within the tileset image.
+ ///
public uint Y { get; set; } = 0;
+
+ ///
+ /// The width of the sub-rectangle representing this tile within the tileset image.
+ ///
public required uint Width { get; set; }
+
+ ///
+ /// The height of the sub-rectangle representing this tile within the tileset image.
+ ///
public required uint Height { get; set; }
- // Elements
+ ///
+ /// Tile properties.
+ ///
public Dictionary? Properties { get; set; }
+
+ ///
+ /// The image representing this tile. Only used for tilesets that composed of a collection of images.
+ ///
public Image? Image { get; set; }
+
+ ///
+ /// Unclear what this is for.
+ ///
public ObjectLayer? ObjectLayer { get; set; }
+
+ ///
+ /// The animation frames for this tile.
+ ///
public List ? Animation { get; set; }
}
diff --git a/src/DotTiled/Model/Tilesets/TileOffset.cs b/src/DotTiled/Model/Tilesets/TileOffset.cs
index 2b2e620..6030f39 100644
--- a/src/DotTiled/Model/Tilesets/TileOffset.cs
+++ b/src/DotTiled/Model/Tilesets/TileOffset.cs
@@ -1,8 +1,17 @@
namespace DotTiled.Model;
+///
+/// Is used to specify an offset in pixels in tilesets, to be applied when drawing a tile from the related tileset.
+///
public class TileOffset
{
- // Attributes
+ ///
+ /// The horizontal offset in pixels.
+ ///
public float X { get; set; } = 0f;
+
+ ///
+ /// The vertical offset in pixels.
+ ///
public float Y { get; set; } = 0f;
}
diff --git a/src/DotTiled/Model/Tilesets/Tileset.cs b/src/DotTiled/Model/Tilesets/Tileset.cs
index 639fe62..147f3d2 100644
--- a/src/DotTiled/Model/Tilesets/Tileset.cs
+++ b/src/DotTiled/Model/Tilesets/Tileset.cs
@@ -2,60 +2,208 @@ using System.Collections.Generic;
namespace DotTiled.Model;
+///
+/// The alignment of tile objects.
+///
public enum ObjectAlignment
{
+ ///
+ /// The alignment is unspecified. Tile objects will use in orthogonal maps, and in isometric maps.
+ ///
Unspecified,
+
+ ///
+ /// The tile object is aligned to the top left of the tile.
+ ///
TopLeft,
+
+ ///
+ /// The tile object is aligned to the top of the tile.
+ ///
Top,
+
+ ///
+ /// The tile object is aligned to the top right of the tile.
+ ///
TopRight,
+
+ ///
+ /// The tile object is aligned to the left of the tile.
+ ///
Left,
+
+ ///
+ /// The tile object is aligned to the center of the tile.
+ ///
Center,
+
+ ///
+ /// The tile object is aligned to the right of the tile.
+ ///
Right,
+
+ ///
+ /// The tile object is aligned to the bottom left of the tile.
+ ///
BottomLeft,
+
+ ///
+ /// The tile object is aligned to the bottom of the tile.
+ ///
Bottom,
+
+ ///
+ /// The tile object is aligned to the bottom right of the tile.
+ ///
BottomRight
}
+///
+/// The size to use when rendering tiles from a tileset on a tile layer.
+///
public enum TileRenderSize
{
+ ///
+ /// The tile is drawn at the size of the tile in the tileset.
+ ///
Tile,
+
+ ///
+ /// The tile is drawn at the tile grid size of the map.
+ ///
Grid
}
+///
+/// Determines how a tile is rendered in a tile set.
+///
public enum FillMode
{
+ ///
+ /// The tile is stretched to fill the tile size, possibly distorting the tile.
+ ///
Stretch,
+
+ ///
+ /// The tile's aspect ratio is preserved, and it is scaled to fit within the tile size.
+ ///
PreserveAspectFit
}
+///
+/// A tileset is a collection of tiles that can be used in a tile layer, or by tile objects.
+///
public class Tileset
{
- // Attributes
+ ///
+ /// The TMX format version. Is incremented to match minor Tiled releases.
+ ///
public string? Version { get; set; }
+
+ ///
+ /// The Tiled version used to save the file in case it was loaded from an external tileset file.
+ ///
public string? TiledVersion { get; set; }
+
+ ///
+ /// The first global tile ID of this tileset (this global ID maps to the first tile in this tileset).
+ ///
public uint? FirstGID { get; set; }
+
+ ///
+ /// If this tileset is stored in an external TSX (Tile Set XML) file, this attribute refers to that file.
+ ///
public string? Source { get; set; }
+
+ ///
+ /// The name of this tileset.
+ ///
public string? Name { get; set; }
+
+ ///
+ /// The class of this tileset.
+ ///
public string Class { get; set; } = "";
+
+ ///
+ /// The width of the tiles in this tileset, which should be at least 1 (non-zero) except in the case of image collection tilesets (in which case it stores the maximum tile width).
+ ///
public uint? TileWidth { get; set; }
+
+ ///
+ /// The height of the tiles in this tileset, which should be at least 1 (non-zero) except in the case of image collection tilesets (in which case it stores the maximum tile height).
+ ///
public uint? TileHeight { get; set; }
+
+ ///
+ /// The spacing in pixels between the tiles in this tileset (applies to the tileset image). Irrelevant for image collection tilesets.
+ ///
public float? Spacing { get; set; } = 0f;
+
+ ///
+ /// The margin around the tiles in this tileset (applies to the tileset image). Irrelevant for image collection tilesets.
+ ///
public float? Margin { get; set; } = 0f;
+
+ ///
+ /// The number of tiles in this tileset.
+ ///
public uint? TileCount { get; set; }
+
+ ///
+ /// The number of tile columns in the tileset.
+ ///
public uint? Columns { get; set; }
+
+ ///
+ /// Controls the aligntment for tile objects.
+ ///
public ObjectAlignment ObjectAlignment { get; set; } = ObjectAlignment.Unspecified;
+
+ ///
+ /// The size to use when rendering tiles from thie tileset on a tile layer. When set to , the tile is drawn at the tile grid size of the map.
+ ///
public TileRenderSize RenderSize { get; set; } = TileRenderSize.Tile;
+
+ ///
+ /// The fill mode to use when rendering tiles from this tileset.
+ ///
public FillMode FillMode { get; set; } = FillMode.Stretch;
- // At most one of
+ ///
+ /// If the tileset is based on a single image, which is cut into tiles based on the given attributes of the tileset, then this is that image.
+ ///
public Image? Image { get; set; }
+
+ ///
+ /// This is used to specify an offset in pixels, to be applied when drawing a tile from the related tileset. When not present, no offset is applied.
+ ///
public TileOffset? TileOffset { get; set; }
+
+ ///
+ /// Ths is only used in case of isometric orientation, and determines how tile overlays for terrain and collision information are rendered.
+ ///
public Grid? Grid { get; set; }
+
+ ///
+ /// Tileset properties.
+ ///
public Dictionary? Properties { get; set; }
+
// public List? TerrainTypes { get; set; } TODO: Implement Terrain -> Wangset conversion during deserialization
+
+ ///
+ /// Contains the list of Wang sets defined for this tileset.
+ ///
public List? Wangsets { get; set; }
+
+ ///
+ /// Used to describe which transformations can be applied to the tiles (e.g. to extend a Wang set by transforming existing tiles).
+ ///
public Transformations? Transformations { get; set; }
- // Any number of
+ ///
+ /// If this tileset is based on a collection of images, then this list of tiles will contain the individual images that make up the tileset.
+ ///
public List Tiles { get; set; } = [];
}
diff --git a/src/DotTiled/Model/Tilesets/Transformations.cs b/src/DotTiled/Model/Tilesets/Transformations.cs
index 1a84549..b6cf6bf 100644
--- a/src/DotTiled/Model/Tilesets/Transformations.cs
+++ b/src/DotTiled/Model/Tilesets/Transformations.cs
@@ -1,10 +1,27 @@
namespace DotTiled.Model;
+///
+/// Represents which transformations can be applied to a tile in a tileset.
+///
public class Transformations
{
- // Attributes
+ ///
+ /// Whether the file in this can set be flipped horizontally.
+ ///
public bool HFlip { get; set; } = false;
+
+ ///
+ /// Whether the file in this can set be flipped vertically.
+ ///
public bool VFlip { get; set; } = false;
+
+ ///
+ /// Whether the file in this set can be rotated in 90 degree increments.
+ ///
public bool Rotate { get; set; } = false;
+
+ ///
+ /// Whether untransformed tiles remain preferred, otherwise transformed tiles are used to produce more vartiations.
+ ///
public bool PreferUntransformed { get; set; } = false;
}
diff --git a/src/DotTiled/Model/Tilesets/WangColor.cs b/src/DotTiled/Model/Tilesets/WangColor.cs
index d3a0328..20678cb 100644
--- a/src/DotTiled/Model/Tilesets/WangColor.cs
+++ b/src/DotTiled/Model/Tilesets/WangColor.cs
@@ -2,15 +2,38 @@ using System.Collections.Generic;
namespace DotTiled.Model;
+///
+/// Represents a Wang color in a Wang set.
+///
public class WangColor
{
- // Attributes
+ ///
+ /// The name of this color.
+ ///
public required string Name { get; set; }
+
+ ///
+ /// The class of the Wang color.
+ ///
public string Class { get; set; } = "";
+
+ ///
+ /// The color of the Wang color.
+ ///
public required Color Color { get; set; }
+
+ ///
+ /// The tile ID of the tile representing this color.
+ ///
public required int Tile { get; set; }
+
+ ///
+ /// The relative probability that this color is chosen over others in case of multiple options.
+ ///
public float Probability { get; set; } = 0f;
- // Elements
+ ///
+ /// The Wang color properties.
+ ///
public Dictionary? Properties { get; set; }
}
diff --git a/src/DotTiled/Model/Tilesets/WangTile.cs b/src/DotTiled/Model/Tilesets/WangTile.cs
index d526d71..2347b91 100644
--- a/src/DotTiled/Model/Tilesets/WangTile.cs
+++ b/src/DotTiled/Model/Tilesets/WangTile.cs
@@ -1,8 +1,17 @@
namespace DotTiled.Model;
+///
+/// Represents a Wang tile in a Wang set.
+///
public class WangTile
{
- // Attributes
+ ///
+ /// The tile ID associated with this Wang tile.
+ ///
public required uint TileID { get; set; }
+
+ ///
+ /// The Wang ID of this Wang tile.
+ ///
public required byte[] WangID { get; set; }
}
diff --git a/src/DotTiled/Model/Tilesets/Wangset.cs b/src/DotTiled/Model/Tilesets/Wangset.cs
index 653f43f..1a6f7c3 100644
--- a/src/DotTiled/Model/Tilesets/Wangset.cs
+++ b/src/DotTiled/Model/Tilesets/Wangset.cs
@@ -2,20 +2,39 @@ using System.Collections.Generic;
namespace DotTiled.Model;
+///
+/// Defines a list of colors and any number of Wang tiles using these colors.
+///
public class Wangset
{
- // Attributes
+ ///
+ /// The name of the Wang set.
+ ///
public required string Name { get; set; }
+
+ ///
+ /// The class of the Wang set.
+ ///
public string Class { get; set; } = "";
+
+ ///
+ /// The tile ID of the tile representing the Wang set.
+ ///
public required int Tile { get; set; }
- // Elements
- // At most one of
+ ///
+ /// The Wang set properties.
+ ///
public Dictionary? Properties { get; set; }
// Up to 254 Wang colors
+ ///
+ /// The Wang colors in the Wang set.
+ ///
public List? WangColors { get; set; } = [];
- // Any number of
+ ///
+ /// The Wang tiles in the Wang set.
+ ///
public List WangTiles { get; set; } = [];
}
diff --git a/src/DotTiled/Serialization/Tmj/Tmj.ObjectLayer.cs b/src/DotTiled/Serialization/Tmj/Tmj.ObjectLayer.cs
index af0449b..ba01791 100644
--- a/src/DotTiled/Serialization/Tmj/Tmj.ObjectLayer.cs
+++ b/src/DotTiled/Serialization/Tmj/Tmj.ObjectLayer.cs
@@ -38,7 +38,7 @@ internal partial class Tmj
_ => throw new JsonException($"Unknown draw order '{s}'.")
}, DrawOrder.TopDown);
- var objects = element.GetOptionalPropertyCustom>("objects", e => e.GetValueAsList(el => ReadObject(el, externalTemplateResolver, customTypeDefinitions)), []);
+ var objects = element.GetOptionalPropertyCustom>("objects", e => e.GetValueAsList(el => ReadObject(el, externalTemplateResolver, customTypeDefinitions)), []);
return new ObjectLayer
{
@@ -63,7 +63,7 @@ internal partial class Tmj
};
}
- internal static Model.Layers.Objects.Object ReadObject(
+ internal static Model.Object ReadObject(
JsonElement element,
Func externalTemplateResolver,
IReadOnlyCollection customTypeDefinitions)
diff --git a/src/DotTiled/Serialization/Tmj/Tmj.Template.cs b/src/DotTiled/Serialization/Tmj/Tmj.Template.cs
index a9a8766..100aaa2 100644
--- a/src/DotTiled/Serialization/Tmj/Tmj.Template.cs
+++ b/src/DotTiled/Serialization/Tmj/Tmj.Template.cs
@@ -17,7 +17,7 @@ internal partial class Tmj
{
var type = element.GetRequiredProperty("type");
var tileset = element.GetOptionalPropertyCustom("tileset", el => ReadTileset(el, externalTilesetResolver, externalTemplateResolver, customTypeDefinitions), null);
- var @object = element.GetRequiredPropertyCustom("object", el => ReadObject(el, externalTemplateResolver, customTypeDefinitions));
+ var @object = element.GetRequiredPropertyCustom("object", el => ReadObject(el, externalTemplateResolver, customTypeDefinitions));
return new Template
{
diff --git a/src/DotTiled/Serialization/Tmx/Tmx.ObjectLayer.cs b/src/DotTiled/Serialization/Tmx/Tmx.ObjectLayer.cs
index 523b224..7c04edf 100644
--- a/src/DotTiled/Serialization/Tmx/Tmx.ObjectLayer.cs
+++ b/src/DotTiled/Serialization/Tmx/Tmx.ObjectLayer.cs
@@ -40,7 +40,7 @@ internal partial class Tmx
// Elements
Dictionary? properties = null;
- List objects = [];
+ List objects = [];
reader.ProcessChildren("objectgroup", (r, elementName) => elementName switch
{
@@ -72,14 +72,14 @@ internal partial class Tmx
};
}
- internal static Model.Layers.Objects.Object ReadObject(
+ internal static Model.Object ReadObject(
XmlReader reader,
Func externalTemplateResolver,
IReadOnlyCollection customTypeDefinitions)
{
// Attributes
var template = reader.GetOptionalAttribute("template");
- Model.Layers.Objects.Object? obj = null;
+ Model.Object? obj = null;
if (template is not null)
obj = externalTemplateResolver(template).Object;
@@ -107,7 +107,7 @@ internal partial class Tmx
var visible = reader.GetOptionalAttributeParseable("visible") ?? visibleDefault;
// Elements
- Model.Layers.Objects.Object? foundObject = null;
+ Model.Object? foundObject = null;
int propertiesCounter = 0;
Dictionary? properties = propertiesDefault;
@@ -145,7 +145,7 @@ internal partial class Tmx
return OverrideObject(obj, foundObject);
}
- internal static Model.Layers.Objects.Object OverrideObject(Model.Layers.Objects.Object? obj, Model.Layers.Objects.Object foundObject)
+ internal static Model.Object OverrideObject(Model.Object? obj, Model.Object foundObject)
{
if (obj is null)
return foundObject;
@@ -316,7 +316,7 @@ internal partial class Tmx
Tileset? tileset = null;
// Should contain exactly one of
- Model.Layers.Objects.Object? obj = null;
+ Model.Object? obj = null;
reader.ProcessChildren("template", (r, elementName) => elementName switch
{