diff options
author | chai <215380520@qq.com> | 2024-06-03 10:15:45 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2024-06-03 10:15:45 +0800 |
commit | acea7b2e728787a0d83bbf83c8c1f042d2c32e7e (patch) | |
tree | 0bfec05c1ca2d71be2c337bcd110a0421f19318b /Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs | |
parent | 88febcb02bf127d961c6471d9e846c0e1315f5c3 (diff) |
+ plugins project
Diffstat (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs')
-rw-r--r-- | Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs new file mode 100644 index 0000000..76e2ba2 --- /dev/null +++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tiled/Serialization/TiledMapObjectContent.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace MonoGame.Extended.Tiled.Serialization +{ + // This content class is going to be a lot more complex than the others we use. + // Objects can reference a template file which has starting values for the + // object. The value in the object file overrides any value specified in the + // template. All values have to be able to store a null value so we know if the + // XML parser actually found a value for the property and not just a default + // value. Default values are used when the object and any templates don't + // specify a value. + public class TiledMapObjectContent + { + // TODO: HACK These shouldn't be public + public uint? _globalIdentifier; + public int? _identifier; + public float? _height; + public float? _rotation; + public bool? _visible; + public float? _width; + public float? _x; + public float? _y; + + [XmlAttribute(DataType = "int", AttributeName = "id")] + public int Identifier { get => _identifier ?? 0; set => _identifier = value; } + + [XmlAttribute(DataType = "string", AttributeName = "name")] + public string Name { get; set; } + + // Deprecated as of Tiled 1.9.0 (replaced by "class" attribute) + [XmlAttribute(DataType = "string", AttributeName = "type")] + public string Type { get; set; } + + [XmlAttribute(DataType = "string", AttributeName = "class")] + public string Class { get; set; } + + [XmlAttribute(DataType = "float", AttributeName = "x")] + public float X { get => _x ?? 0; set => _x = value; } + + [XmlAttribute(DataType = "float", AttributeName = "y")] + public float Y { get => _y ?? 0; set => _y = value; } + + [XmlAttribute(DataType = "float", AttributeName = "width")] + public float Width { get => _width ?? 0; set => _width = value; } + + [XmlAttribute(DataType = "float", AttributeName = "height")] + public float Height { get => _height ?? 0; set => _height = value; } + + [XmlAttribute(DataType = "float", AttributeName = "rotation")] + public float Rotation { get => _rotation ?? 0; set => _rotation = value; } + + [XmlAttribute(DataType = "boolean", AttributeName = "visible")] + public bool Visible { get => _visible ?? true; set => _visible = value; } + + [XmlArray("properties")] + [XmlArrayItem("property")] + public List<TiledMapPropertyContent> Properties { get; set; } + + [XmlAttribute(DataType = "unsignedInt", AttributeName = "gid")] + public uint GlobalIdentifier { get => _globalIdentifier??0; set => _globalIdentifier = value; } + + [XmlElement(ElementName = "ellipse")] + public TiledMapEllipseContent Ellipse { get; set; } + + [XmlElement(ElementName = "polygon")] + public TiledMapPolygonContent Polygon { get; set; } + + [XmlElement(ElementName = "polyline")] + public TiledMapPolylineContent Polyline { get; set; } + + [XmlAttribute(DataType = "string", AttributeName = "template")] + public string TemplateSource { get; set; } + + + } +}
\ No newline at end of file |