Files
MonoGame.Extended/Source/MonoGame.Extended.Tiled/TiledMapTileObject.cs
T
Lucas Girouard-StranksandDylan Wilson 9e359fb750 Tiled Rework (#331)
* Tiled Rework

* fix failing tests

* really fix failing tests
2017-01-18 20:46:38 +10:00

26 lines
827 B
C#

#region
using System.Linq;
using Microsoft.Xna.Framework.Content;
using MonoGame.Extended.Shapes;
#endregion
namespace MonoGame.Extended.Tiled
{
public sealed class TiledMapTileObject : TiledMapObject
{
public TiledMapTilesetTile TilesetTile { get; }
public TiledMapTileObject(ContentReader input, TiledMap map)
: base(input)
{
var globalTileIdentifierWithFlags = input.ReadUInt32();
var tile = new TiledMapTile(globalTileIdentifierWithFlags, 0, 0);
var tileset = map.GetTilesetByTileGlobalIdentifier(tile.GlobalIdentifier);
var localTileIdentifier = tile.GlobalIdentifier - tileset.FirstGlobalIdentifier;
TilesetTile = tileset.Tiles.FirstOrDefault(x => x.LocalTileIdentifier == localTileIdentifier);
}
}
}