Merge pull request #19 from dcronqvist/remove-model

Remove .Model namespace as it is unnecessary
This commit is contained in:
dcronqvist 2024-08-30 20:13:31 +02:00 committed by GitHub
commit 398200c586
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
98 changed files with 111 additions and 170 deletions

View file

@ -4,40 +4,40 @@
## All classes that can contain properties ## All classes that can contain properties
All classes that can contain custom properties implement the interface <xref:DotTiled.Model.IHasProperties> in some way. Below is an exhaustive list of all classes that can contain custom properties: All classes that can contain custom properties implement the interface <xref:DotTiled.IHasProperties> in some way. Below is an exhaustive list of all classes that can contain custom properties:
- <xref:DotTiled.Model.BaseLayer> - <xref:DotTiled.BaseLayer>
- <xref:DotTiled.Model.TileLayer> - <xref:DotTiled.TileLayer>
- <xref:DotTiled.Model.ObjectLayer> - <xref:DotTiled.ObjectLayer>
- <xref:DotTiled.Model.ImageLayer> - <xref:DotTiled.ImageLayer>
- <xref:DotTiled.Model.Group> - <xref:DotTiled.Group>
- <xref:DotTiled.Model.ClassProperty> (allows for recursive property objects) - <xref:DotTiled.ClassProperty> (allows for recursive property objects)
- <xref:DotTiled.Model.CustomClassDefinition> (used to define custom Tiled property types) - <xref:DotTiled.CustomClassDefinition> (used to define custom Tiled property types)
- <xref:DotTiled.Model.Object> - <xref:DotTiled.Object>
- <xref:DotTiled.Model.EllipseObject> - <xref:DotTiled.EllipseObject>
- <xref:DotTiled.Model.PointObject> - <xref:DotTiled.PointObject>
- <xref:DotTiled.Model.PolygonObject> - <xref:DotTiled.PolygonObject>
- <xref:DotTiled.Model.PolylineObject> - <xref:DotTiled.PolylineObject>
- <xref:DotTiled.Model.RectangleObject> - <xref:DotTiled.RectangleObject>
- <xref:DotTiled.Model.TextObject> - <xref:DotTiled.TextObject>
- <xref:DotTiled.Model.TileObject> - <xref:DotTiled.TileObject>
- <xref:DotTiled.Model.Tileset> - <xref:DotTiled.Tileset>
- <xref:DotTiled.Model.Tile> - <xref:DotTiled.Tile>
- <xref:DotTiled.Model.WangTile> - <xref:DotTiled.WangTile>
- <xref:DotTiled.Model.WangColor> - <xref:DotTiled.WangColor>
## How to access properties ## How to access properties
To access the properties on one of the classes listed above, you will make use of the <xref:DotTiled.Model.IHasProperties> interface. To access the properties on one of the classes listed above, you will make use of the <xref:DotTiled.IHasProperties> interface.
In situations where you know that a property must exist, and you simply want to retrieve it, you can use the <xref:DotTiled.Model.IHasProperties.GetProperty``1(System.String)> method like so: In situations where you know that a property must exist, and you simply want to retrieve it, you can use the <xref:DotTiled.IHasProperties.GetProperty``1(System.String)> method like so:
```csharp ```csharp
var map = LoadMap(); var map = LoadMap();
var propertyValue = map.GetProperty<BoolProperty>("boolPropertyInMap").Value; var propertyValue = map.GetProperty<BoolProperty>("boolPropertyInMap").Value;
``` ```
If you are unsure whether a property exists, or you want to provide some kind of default behaviour if the property is not present, you can instead use the <xref:DotTiled.Model.IHasProperties.TryGetProperty``1(System.String,``0@)> method like so: If you are unsure whether a property exists, or you want to provide some kind of default behaviour if the property is not present, you can instead use the <xref:DotTiled.IHasProperties.TryGetProperty``1(System.String,``0@)> method like so:
```csharp ```csharp
var map = LoadMap(); var map = LoadMap();
@ -56,17 +56,17 @@ For both methods, you can replace `BoolProperty` with any of the property types
## All types of properties ## All types of properties
Tiled supports a variety of property types, which are represented in the DotTiled library as classes that implement the <xref:DotTiled.Model.IProperty`1> interface. Below is a list of all property types that Tiled supports and their corresponding classes in DotTiled: Tiled supports a variety of property types, which are represented in the DotTiled library as classes that implement the <xref:DotTiled.IProperty`1> interface. Below is a list of all property types that Tiled supports and their corresponding classes in DotTiled:
- `bool` - <xref:DotTiled.Model.BoolProperty> - `bool` - <xref:DotTiled.BoolProperty>
- `color` - <xref:DotTiled.Model.ColorProperty> - `color` - <xref:DotTiled.ColorProperty>
- `float` - <xref:DotTiled.Model.FloatProperty> - `float` - <xref:DotTiled.FloatProperty>
- `file` - <xref:DotTiled.Model.FileProperty> - `file` - <xref:DotTiled.FileProperty>
- `int` - <xref:DotTiled.Model.IntProperty> - `int` - <xref:DotTiled.IntProperty>
- `object` - <xref:DotTiled.Model.ObjectProperty> - `object` - <xref:DotTiled.ObjectProperty>
- `string` - <xref:DotTiled.Model.StringProperty> - `string` - <xref:DotTiled.StringProperty>
In addition to these primitive property types, [Tiled also supports more complex property types](https://doc.mapeditor.org/en/stable/manual/custom-properties/#custom-types). These custom property types are defined in Tiled according to the linked documentation, and to work with them in DotTiled, you *must* define their equivalences as a <xref:DotTiled.Model.ICustomTypeDefinition>. You must then provide a resolving function to a defined type given a custom type name, as it is defined in Tiled. In addition to these primitive property types, [Tiled also supports more complex property types](https://doc.mapeditor.org/en/stable/manual/custom-properties/#custom-types). These custom property types are defined in Tiled according to the linked documentation, and to work with them in DotTiled, you *must* define their equivalences as a <xref:DotTiled.ICustomTypeDefinition>. You must then provide a resolving function to a defined type given a custom type name, as it is defined in Tiled.
## Custom types ## Custom types
@ -74,7 +74,7 @@ Tiled allows you to define custom property types that can be used in your maps.
### Class properties ### Class properties
Whenever DotTiled encounters a property that is of type `class` in a Tiled file, it will use the supplied custom type resolver function to retrieve the custom type definition. It will then use that definition to know the default values of the properties of that class, and then override those defaults with the values found in the Tiled file when populating a <xref:DotTiled.Model.ClassProperty> instance. `class` properties allow you to create hierarchical structures of properties. Whenever DotTiled encounters a property that is of type `class` in a Tiled file, it will use the supplied custom type resolver function to retrieve the custom type definition. It will then use that definition to know the default values of the properties of that class, and then override those defaults with the values found in the Tiled file when populating a <xref:DotTiled.ClassProperty> instance. `class` properties allow you to create hierarchical structures of properties.
For example, if you have a `class` property in Tiled that looks like this: For example, if you have a `class` property in Tiled that looks like this:
@ -98,7 +98,7 @@ var monsterSpawnerDefinition = new CustomClassDefinition
### Enum properties ### Enum properties
Tiled also allows you to define custom property types that work as enums. Similarly to `class` properties, you must define the equivalent in DotTiled as a <xref:DotTiled.Model.CustomEnumDefinition>. You can then return the corresponding definition in the resolving function. Tiled also allows you to define custom property types that work as enums. Similarly to `class` properties, you must define the equivalent in DotTiled as a <xref:DotTiled.CustomEnumDefinition>. You can then return the corresponding definition in the resolving function.
For example, if you have a custom property type in Tiled that looks like this: For example, if you have a custom property type in Tiled that looks like this:
@ -125,9 +125,9 @@ var entityTypeDefinition = new CustomEnumDefinition
In the future, DotTiled will support automatically mapping custom property `class` types to C# classes. This will allow you to define a C# class that matches the structure of the `class` property in Tiled, and DotTiled will automatically map the properties of the `class` property to the properties of the C# class. This will make working with `class` properties much easier and more intuitive. In the future, DotTiled will support automatically mapping custom property `class` types to C# classes. This will allow you to define a C# class that matches the structure of the `class` property in Tiled, and DotTiled will automatically map the properties of the `class` property to the properties of the C# class. This will make working with `class` properties much easier and more intuitive.
The idea is to expand on the <xref:DotTiled.Model.IHasProperties> interface with a method like `GetMappedProperty<T>(string propertyName)`, where `T` is a class that matches the structure of the `class` property in Tiled. The idea is to expand on the <xref:DotTiled.IHasProperties> interface with a method like `GetMappedProperty<T>(string propertyName)`, where `T` is a class that matches the structure of the `class` property in Tiled.
This functionality would be accompanied by a way to automatically create a matching <xref:DotTiled.Model.ICustomTypeDefinition> given a C# class or enum. Something like this would then be possible: This functionality would be accompanied by a way to automatically create a matching <xref:DotTiled.ICustomTypeDefinition> given a C# class or enum. Something like this would then be possible:
```csharp ```csharp
class MonsterSpawner class MonsterSpawner
@ -156,6 +156,6 @@ var monsterSpawner = map.GetMappedProperty<MonsterSpawner>("monsterSpawnerProper
var entityType = map.GetMappedProperty<EntityType>("entityTypePropertyInMap"); var entityType = map.GetMappedProperty<EntityType>("entityTypePropertyInMap");
``` ```
Finally, it might be possible to also make some kind of exporting functionality for <xref:DotTiled.Model.ICustomTypeDefinition>. Given a collection of custom type definitions, DotTiled could generate a corresponding `propertytypes.json` file that you then can import into Tiled. This would make it so that you only have to define your custom property types once (in C#) and then import them into Tiled to use them in your maps. Finally, it might be possible to also make some kind of exporting functionality for <xref:DotTiled.ICustomTypeDefinition>. Given a collection of custom type definitions, DotTiled could generate a corresponding `propertytypes.json` file that you then can import into Tiled. This would make it so that you only have to define your custom property types once (in C#) and then import them into Tiled to use them in your maps.
Depending on implementation this might become something that can inhibit native AOT compilation due to potential reflection usage. Source generators could be used to mitigate this, but it is not yet clear how this will be implemented. Depending on implementation this might become something that can inhibit native AOT compilation due to potential reflection usage. Source generators could be used to mitigate this, but it is not yet clear how this will be implemented.

View file

@ -1,9 +1,9 @@
# Loading maps # Loading maps
Loading maps with DotTiled is straightforward and easy. The <xref:DotTiled.Model.Map> class is a representation of a Tiled map, mimicking the structure of a Tiled map file. Map files can either be in the [`.tmx`/XML](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/) or [`.tmj`/json](https://doc.mapeditor.org/en/stable/reference/json-map-format/) format. DotTiled supports **both** formats fully. Loading maps with DotTiled is straightforward and easy. The <xref:DotTiled.Map> class is a representation of a Tiled map, mimicking the structure of a Tiled map file. Map files can either be in the [`.tmx`/XML](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/) or [`.tmj`/json](https://doc.mapeditor.org/en/stable/reference/json-map-format/) format. DotTiled supports **both** formats fully.
> [!NOTE] > [!NOTE]
> Using the `.tmj` file format will result in <xref:DotTiled.Model.ImageLayer.Image> not having the same amount of information as for the `.tmx` format. This is due to the fact that the `.tmj` format does not include the full information that the `.tmx` format does. This is not a problem with DotTiled, but rather a limitation of the `.tmj` format. > Using the `.tmj` file format will result in <xref:DotTiled.ImageLayer.Image> not having the same amount of information as for the `.tmx` format. This is due to the fact that the `.tmj` format does not include the full information that the `.tmx` format does. This is not a problem with DotTiled, but rather a limitation of the `.tmj` format.
## External resolution ## External resolution
@ -13,7 +13,7 @@ Loading a map, tileset, or template will require you to specify **three** resolv
### `Func<string, Tileset>` - Tileset resolver ### `Func<string, Tileset>` - Tileset resolver
This function is used to resolve external tilesets by their source path. The function should return a <xref:DotTiled.Model.Tileset> instance given the source path of the tileset. If you just want to load tilesets from the file system, you can use something like this: This function is used to resolve external tilesets by their source path. The function should return a <xref:DotTiled.Tileset> instance given the source path of the tileset. If you just want to load tilesets from the file system, you can use something like this:
```csharp ```csharp
Tileset ResolveTileset(string source) Tileset ResolveTileset(string source)
@ -38,11 +38,11 @@ Tileset ResolveTileset(string source)
### `Func<string, Template>` - Template resolver ### `Func<string, Template>` - Template resolver
This function is used to resolve external object templates by their source path. The function should return a <xref:DotTiled.Model.Template> instance given the source path of the template. If you just want to load templates from the file system, you can use something very similar to the tileset resolver by replacing <xref:DotTiled.Serialization.TilesetReader> with <xref:DotTiled.Serialization.TemplateReader>. This function is used to resolve external object templates by their source path. The function should return a <xref:DotTiled.Template> instance given the source path of the template. If you just want to load templates from the file system, you can use something very similar to the tileset resolver by replacing <xref:DotTiled.Serialization.TilesetReader> with <xref:DotTiled.Serialization.TemplateReader>.
### `Func<string, CustomType>` - Custom type resolver ### `Func<string, CustomType>` - Custom type resolver
This function is used to resolve custom types that are defined in Tiled maps. Please refer to the [custom properties](custom-properties.md) documentation for more information on custom types. The function should return a <xref:DotTiled.Model.ICustomTypeDefinition> instance given the custom type's name. This function is used to resolve custom types that are defined in Tiled maps. Please refer to the [custom properties](custom-properties.md) documentation for more information on custom types. The function should return a <xref:DotTiled.ICustomTypeDefinition> instance given the custom type's name.
## Putting it all together ## Putting it all together

View file

@ -35,7 +35,7 @@ namespace DotTiled.Benchmark
[BenchmarkCategory("MapFromInMemoryTmxString")] [BenchmarkCategory("MapFromInMemoryTmxString")]
[Benchmark(Baseline = true, Description = "DotTiled")] [Benchmark(Baseline = true, Description = "DotTiled")]
public DotTiled.Model.Map LoadWithDotTiledFromInMemoryTmxString() public DotTiled.Map LoadWithDotTiledFromInMemoryTmxString()
{ {
using var stringReader = new StringReader(_tmxContents); using var stringReader = new StringReader(_tmxContents);
using var xmlReader = XmlReader.Create(stringReader); using var xmlReader = XmlReader.Create(stringReader);
@ -45,7 +45,7 @@ namespace DotTiled.Benchmark
[BenchmarkCategory("MapFromInMemoryTmjString")] [BenchmarkCategory("MapFromInMemoryTmjString")]
[Benchmark(Baseline = true, Description = "DotTiled")] [Benchmark(Baseline = true, Description = "DotTiled")]
public DotTiled.Model.Map LoadWithDotTiledFromInMemoryTmjString() public DotTiled.Map LoadWithDotTiledFromInMemoryTmjString()
{ {
using var mapReader = new DotTiled.Serialization.Tmj.TmjMapReader(_tmjContents, _ => throw new NotSupportedException(), _ => throw new NotSupportedException(), _ => throw new NotSupportedException()); using var mapReader = new DotTiled.Serialization.Tmj.TmjMapReader(_tmjContents, _ => throw new NotSupportedException(), _ => throw new NotSupportedException(), _ => throw new NotSupportedException());
return mapReader.ReadMap(); return mapReader.ReadMap();

View file

@ -1,5 +1,3 @@
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;
public static partial class DotTiledAssert public static partial class DotTiledAssert

View file

@ -1,5 +1,3 @@
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;
public static partial class DotTiledAssert public static partial class DotTiledAssert

View file

@ -1,5 +1,3 @@
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;
public static partial class DotTiledAssert public static partial class DotTiledAssert

View file

@ -1,6 +1,5 @@
using System.Collections; using System.Collections;
using System.Numerics; using System.Numerics;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,22 +1,22 @@
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;
public static partial class DotTiledAssert public static partial class DotTiledAssert
{ {
internal static void AssertObject(Model.Object expected, Model.Object actual) internal static void AssertObject(DotTiled.Object expected, DotTiled.Object actual)
{ {
// Attributes // Attributes
AssertEqual(expected.ID, actual.ID, nameof(Model.Object.ID)); #pragma warning disable IDE0002
AssertEqual(expected.Name, actual.Name, nameof(Model.Object.Name)); AssertEqual(expected.ID, actual.ID, nameof(DotTiled.Object.ID));
AssertEqual(expected.Type, actual.Type, nameof(Model.Object.Type)); AssertEqual(expected.Name, actual.Name, nameof(DotTiled.Object.Name));
AssertEqual(expected.X, actual.X, nameof(Model.Object.X)); AssertEqual(expected.Type, actual.Type, nameof(DotTiled.Object.Type));
AssertEqual(expected.Y, actual.Y, nameof(Model.Object.Y)); AssertEqual(expected.X, actual.X, nameof(DotTiled.Object.X));
AssertEqual(expected.Width, actual.Width, nameof(Model.Object.Width)); AssertEqual(expected.Y, actual.Y, nameof(DotTiled.Object.Y));
AssertEqual(expected.Height, actual.Height, nameof(Model.Object.Height)); AssertEqual(expected.Width, actual.Width, nameof(DotTiled.Object.Width));
AssertEqual(expected.Rotation, actual.Rotation, nameof(Model.Object.Rotation)); AssertEqual(expected.Height, actual.Height, nameof(DotTiled.Object.Height));
AssertEqual(expected.Visible, actual.Visible, nameof(Model.Object.Visible)); AssertEqual(expected.Rotation, actual.Rotation, nameof(DotTiled.Object.Rotation));
AssertEqual(expected.Template, actual.Template, nameof(Model.Object.Template)); AssertEqual(expected.Visible, actual.Visible, nameof(DotTiled.Object.Visible));
AssertEqual(expected.Template, actual.Template, nameof(DotTiled.Object.Template));
#pragma warning restore IDE0002
AssertProperties(expected.Properties, actual.Properties); AssertProperties(expected.Properties, actual.Properties);

View file

@ -1,5 +1,3 @@
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;
public static partial class DotTiledAssert public static partial class DotTiledAssert

View file

@ -1,5 +1,3 @@
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;
public static partial class DotTiledAssert public static partial class DotTiledAssert

View file

@ -1,4 +1,3 @@
using DotTiled.Model;
using DotTiled.Serialization; using DotTiled.Serialization;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,5 +1,4 @@
using System.Xml; using System.Xml;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,5 +1,3 @@
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;
public partial class TestData public partial class TestData

View file

@ -1,5 +1,4 @@
using System.Globalization; using System.Globalization;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,5 +1,4 @@
using System.Globalization; using System.Globalization;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,5 +1,4 @@
using System.Globalization; using System.Globalization;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,5 +1,4 @@
using System.Globalization; using System.Globalization;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,5 +1,4 @@
using System.Globalization; using System.Globalization;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,5 +1,4 @@
using System.Globalization; using System.Globalization;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,5 +1,4 @@
using System.Globalization; using System.Globalization;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,5 +1,4 @@
using System.Globalization; using System.Globalization;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,5 +1,4 @@
using System.Numerics; using System.Numerics;
using DotTiled.Model;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,4 +1,3 @@
using DotTiled.Model;
using DotTiled.Serialization.Tmj; using DotTiled.Serialization.Tmj;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -1,4 +1,3 @@
using DotTiled.Model;
using DotTiled.Serialization.Tmx; using DotTiled.Serialization.Tmx;
namespace DotTiled.Tests; namespace DotTiled.Tests;

View file

@ -2,7 +2,7 @@ using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a Tiled color. /// Represents a Tiled color.

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Base class for all layer types in a map. /// Base class for all layer types in a map.

View file

@ -1,6 +1,6 @@
using System; using System;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Specifies the encoding used to encode the tile layer data. /// Specifies the encoding used to encode the tile layer data.

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a group of layers, to form a hierarchy. /// Represents a group of layers, to form a hierarchy.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents an image layer in a map. /// Represents an image layer in a map.

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents the order in which objects can be drawn. /// Represents the order in which objects can be drawn.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// An ellipse object in a map. The existing <see cref="Object.X"/>, <see cref="Object.Y"/>, <see cref="Object.Width"/>, /// An ellipse object in a map. The existing <see cref="Object.X"/>, <see cref="Object.Y"/>, <see cref="Object.Width"/>,

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Base class for objects in object layers. /// Base class for objects in object layers.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// A point object in a map. The existing <see cref="Object.X"/> and <see cref="Object.Y"/> properties are used to /// A point object in a map. The existing <see cref="Object.X"/> and <see cref="Object.Y"/> properties are used to

View file

@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// A polygon object in a map. The existing <see cref="Object.X"/> and <see cref="Object.Y"/> properties are used as /// A polygon object in a map. The existing <see cref="Object.X"/> and <see cref="Object.Y"/> properties are used as

View file

@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// A polyline object in a map. The existing <see cref="Object.X"/> and <see cref="Object.Y"/> properties are used as /// A polyline object in a map. The existing <see cref="Object.X"/> and <see cref="Object.Y"/> properties are used as

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// A rectangle object in a map. The existing <see cref="Object.X"/>, <see cref="Object.Y"/>, <see cref="Object.Width"/>, /// A rectangle object in a map. The existing <see cref="Object.X"/>, <see cref="Object.Y"/>, <see cref="Object.Width"/>,

View file

@ -1,6 +1,6 @@
using System.Globalization; using System.Globalization;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// The horizontal alignment of text. /// The horizontal alignment of text.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// A tile object in a map. /// A tile object in a map.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a tile layer in a map. /// Represents a tile layer in a map.

View file

@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Map orientation enumeration. The map orientation determines the alignment of the tiles in the map. /// Map orientation enumeration. The map orientation determines the alignment of the tiles in the map.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a boolean property. /// Represents a boolean property.

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a class property. /// Represents a class property.
@ -14,7 +14,7 @@ public class ClassProperty : IHasProperties, IProperty<IList<IProperty>>
public required string Name { get; set; } public required string Name { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public PropertyType Type => Model.PropertyType.Class; public PropertyType Type => DotTiled.PropertyType.Class;
/// <summary> /// <summary>
/// The type of the class property. This will be the name of a custom defined /// The type of the class property. This will be the name of a custom defined

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a color property. /// Represents a color property.

View file

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents the types of objects that can use a custom class. /// Represents the types of objects that can use a custom class.

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents the storage type of a custom enum. /// Represents the storage type of a custom enum.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Base class for custom type definitions. /// Base class for custom type definitions.

View file

@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents an enum property. /// Represents an enum property.
@ -12,7 +12,7 @@ public class EnumProperty : IProperty<ISet<string>>
public required string Name { get; set; } public required string Name { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public PropertyType Type => Model.PropertyType.Enum; public PropertyType Type => DotTiled.PropertyType.Enum;
/// <summary> /// <summary>
/// The type of the class property. This will be the name of a custom defined /// The type of the class property. This will be the name of a custom defined

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a file property. /// Represents a file property.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a float property. /// Represents a float property.

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Interface for objects that have properties attached to them. /// Interface for objects that have properties attached to them.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Interface for properties that can be attached to objects, tiles, tilesets, maps etc. /// Interface for properties that can be attached to objects, tiles, tilesets, maps etc.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents an integer property. /// Represents an integer property.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents an object property. /// Represents an object property.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents the type of a property. /// Represents the type of a property.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a string property. /// Represents a string property.

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
using DotTiled.Model;
namespace DotTiled.Serialization; namespace DotTiled.Serialization;

View file

@ -1,5 +1,4 @@
using System; using System;
using DotTiled.Model;
namespace DotTiled.Serialization; namespace DotTiled.Serialization;

View file

@ -1,5 +1,4 @@
using System; using System;
using DotTiled.Model;
namespace DotTiled.Serialization; namespace DotTiled.Serialization;

View file

@ -1,5 +1,4 @@
using System; using System;
using DotTiled.Model;
namespace DotTiled.Serialization; namespace DotTiled.Serialization;

View file

@ -1,7 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
using DotTiled.Model;
using DotTiled.Serialization.Tmj; using DotTiled.Serialization.Tmj;
using DotTiled.Serialization.Tmx; using DotTiled.Serialization.Tmx;

View file

@ -1,7 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
using DotTiled.Model;
using DotTiled.Serialization.Tmj; using DotTiled.Serialization.Tmj;
using DotTiled.Serialization.Tmx; using DotTiled.Serialization.Tmx;

View file

@ -1,7 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
using DotTiled.Model;
using DotTiled.Serialization.Tmj; using DotTiled.Serialization.Tmj;
using DotTiled.Serialization.Tmx; using DotTiled.Serialization.Tmx;

View file

@ -1,5 +1,4 @@
using System; using System;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,5 +1,4 @@
using System; using System;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,7 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,6 +1,5 @@
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,5 +1,4 @@
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -2,7 +2,6 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Numerics; using System.Numerics;
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;
@ -34,7 +33,7 @@ public abstract partial class TmjReaderBase
_ => throw new JsonException($"Unknown draw order '{s}'.") _ => throw new JsonException($"Unknown draw order '{s}'.")
}, DrawOrder.TopDown); }, DrawOrder.TopDown);
var objects = element.GetOptionalPropertyCustom<List<Model.Object>>("objects", e => e.GetValueAsList<Model.Object>(el => ReadObject(el)), []); var objects = element.GetOptionalPropertyCustom<List<DotTiled.Object>>("objects", e => e.GetValueAsList<DotTiled.Object>(el => ReadObject(el)), []);
return new ObjectLayer return new ObjectLayer
{ {
@ -59,7 +58,7 @@ public abstract partial class TmjReaderBase
}; };
} }
internal Model.Object ReadObject(JsonElement element) internal DotTiled.Object ReadObject(JsonElement element)
{ {
uint? idDefault = null; uint? idDefault = null;
string nameDefault = ""; string nameDefault = "";

View file

@ -2,7 +2,6 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,5 +1,4 @@
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;
@ -9,7 +8,7 @@ public abstract partial class TmjReaderBase
{ {
var type = element.GetRequiredProperty<string>("type"); var type = element.GetRequiredProperty<string>("type");
var tileset = element.GetOptionalPropertyCustom<Tileset?>("tileset", ReadTileset, null); var tileset = element.GetOptionalPropertyCustom<Tileset?>("tileset", ReadTileset, null);
var @object = element.GetRequiredPropertyCustom<Model.Object>("object", ReadObject); var @object = element.GetRequiredPropertyCustom<DotTiled.Object>("object", ReadObject);
return new Template return new Template
{ {

View file

@ -1,6 +1,5 @@
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Text.Json; using System.Text.Json;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,5 +1,4 @@
using System; using System;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmj; namespace DotTiled.Serialization.Tmj;

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Xml; using System.Xml;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;

View file

@ -1,5 +1,3 @@
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;
public abstract partial class TmxReaderBase public abstract partial class TmxReaderBase

View file

@ -4,7 +4,6 @@ using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Xml; using System.Xml;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;
@ -36,7 +35,7 @@ public abstract partial class TmxReaderBase
// Elements // Elements
List<IProperty>? properties = null; List<IProperty>? properties = null;
List<Model.Object> objects = []; List<DotTiled.Object> objects = [];
_reader.ProcessChildren("objectgroup", (r, elementName) => elementName switch _reader.ProcessChildren("objectgroup", (r, elementName) => elementName switch
{ {
@ -68,11 +67,11 @@ public abstract partial class TmxReaderBase
}; };
} }
internal Model.Object ReadObject() internal DotTiled.Object ReadObject()
{ {
// Attributes // Attributes
var template = _reader.GetOptionalAttribute("template"); var template = _reader.GetOptionalAttribute("template");
Model.Object? obj = null; DotTiled.Object? obj = null;
if (template is not null) if (template is not null)
obj = _externalTemplateResolver(template).Object; obj = _externalTemplateResolver(template).Object;
@ -100,7 +99,7 @@ public abstract partial class TmxReaderBase
var visible = _reader.GetOptionalAttributeParseable<bool>("visible") ?? visibleDefault; var visible = _reader.GetOptionalAttributeParseable<bool>("visible") ?? visibleDefault;
// Elements // Elements
Model.Object? foundObject = null; DotTiled.Object? foundObject = null;
int propertiesCounter = 0; int propertiesCounter = 0;
List<IProperty>? properties = propertiesDefault; List<IProperty>? properties = propertiesDefault;
@ -138,7 +137,7 @@ public abstract partial class TmxReaderBase
return OverrideObject(obj, foundObject); return OverrideObject(obj, foundObject);
} }
internal static Model.Object OverrideObject(Model.Object? obj, Model.Object foundObject) internal static DotTiled.Object OverrideObject(DotTiled.Object? obj, DotTiled.Object foundObject)
{ {
if (obj is null) if (obj is null)
return foundObject; return foundObject;
@ -305,7 +304,7 @@ public abstract partial class TmxReaderBase
Tileset? tileset = null; Tileset? tileset = null;
// Should contain exactly one of // Should contain exactly one of
Model.Object? obj = null; DotTiled.Object? obj = null;
_reader.ProcessChildren("template", (r, elementName) => elementName switch _reader.ProcessChildren("template", (r, elementName) => elementName switch
{ {

View file

@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Xml; using System.Xml;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;

View file

@ -1,6 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;

View file

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Xml; using System.Xml;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Xml; using System.Xml;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Xml; using System.Xml;
using DotTiled.Model;
namespace DotTiled.Serialization.Tmx; namespace DotTiled.Serialization.Tmx;

View file

@ -1,7 +1,7 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a Tiled template. A template is a reusable object that can be placed in an <see cref="DotTiled.Model"/> inside the Tiled editor. /// Represents a Tiled template. A template is a reusable object that can be placed in an <see cref="DotTiled"/> inside the Tiled editor.
/// </summary> /// </summary>
public class Template public class Template
{ {

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// A single frame of an animated tile. /// A single frame of an animated tile.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Orientation of the grid for the tiles in this tileset. /// Orientation of the grid for the tiles in this tileset.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// The format of an image. /// The format of an image.

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a single tile in a tileset, when using a collection of images to represent the tileset. /// Represents a single tile in a tileset, when using a collection of images to represent the tileset.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Is used to specify an offset in pixels in tilesets, to be applied when drawing a tile from the related tileset. /// Is used to specify an offset in pixels in tilesets, to be applied when drawing a tile from the related tileset.

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// The alignment of tile objects. /// The alignment of tile objects.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents which transformations can be applied to a tile in a tileset. /// Represents which transformations can be applied to a tile in a tileset.

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a Wang color in a Wang set. /// Represents a Wang color in a Wang set.

View file

@ -1,4 +1,4 @@
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Represents a Wang tile in a Wang set. /// Represents a Wang tile in a Wang set.

View file

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace DotTiled.Model; namespace DotTiled;
/// <summary> /// <summary>
/// Defines a list of colors and any number of Wang tiles using these colors. /// Defines a list of colors and any number of Wang tiles using these colors.