summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapTilesetContent.cs
blob: fa04c31bcfd7765743a56184da4b186e326836ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System.Collections.Generic;
using System.Xml.Serialization;

namespace MonoGame.Extended.Tiled.Serialization
{
    [XmlRoot(ElementName = "tileset")]
    public class TiledMapTilesetContent
    {
        public TiledMapTilesetContent()
        {
            TileOffset = new TiledMapTileOffsetContent();
            Tiles = new List<TiledMapTilesetTileContent>();
            Properties = new List<TiledMapPropertyContent>();
        }

        [XmlAttribute(AttributeName = "firstgid")]
        public int FirstGlobalIdentifier { get; set; }

        [XmlAttribute(AttributeName = "source")]
        public string Source { get; set; }

        [XmlAttribute(AttributeName = "name")]
        public string Name { get; set; }

        // Deprecated as of Tiled 1.9.0 (replaced by "class" attribute)
        [XmlAttribute(DataType = "string", AttributeName = "type")]
        public string Type { get; set; }

        [XmlAttribute(DataType = "string", AttributeName = "class")]
        public string Class { get; set; }

        [XmlAttribute(AttributeName = "tilewidth")]
        public int TileWidth { get; set; }

        [XmlAttribute(AttributeName = "tileheight")]
        public int TileHeight { get; set; }

        [XmlAttribute(AttributeName = "spacing")]
        public int Spacing { get; set; }

        [XmlAttribute(AttributeName = "margin")]
        public int Margin { get; set; }

        [XmlAttribute(AttributeName = "columns")]
        public int Columns { get; set; }

        [XmlAttribute(AttributeName = "tilecount")]
        public int TileCount { get; set; }

        [XmlElement(ElementName = "tileoffset")]
        public TiledMapTileOffsetContent TileOffset { get; set; }

		[XmlElement(ElementName = "grid")]
		public TiledMapTilesetGridContent Grid { get; set; }

        [XmlElement(ElementName = "tile")]
        public List<TiledMapTilesetTileContent> Tiles { get; set; }

        [XmlArray("properties")]
        [XmlArrayItem("property")]
        public List<TiledMapPropertyContent> Properties { get; set; }

        [XmlElement(ElementName = "image")]
        public TiledMapImageContent Image { get; set; }

        public bool ContainsGlobalIdentifier(int globalIdentifier)
        {
            return globalIdentifier >= FirstGlobalIdentifier && globalIdentifier < FirstGlobalIdentifier + TileCount;
        }

        public override string ToString()
        {
            return $"{Name}: {Image}";
        }
    }
}