TiledMapTile.cs 1.2 KB

12345678910111213141516171819202122232425262728
  1. namespace MonoGame.Extended.Tiled
  2. {
  3. public struct TiledMapTile
  4. {
  5. public readonly ushort X;
  6. public readonly ushort Y;
  7. public readonly uint GlobalTileIdentifierWithFlags;
  8. public int GlobalIdentifier => (int)(GlobalTileIdentifierWithFlags & ~(uint)TiledMapTileFlipFlags.All);
  9. public bool IsFlippedHorizontally => (GlobalTileIdentifierWithFlags & (uint)TiledMapTileFlipFlags.FlipHorizontally) != 0;
  10. public bool IsFlippedVertically => (GlobalTileIdentifierWithFlags & (uint)TiledMapTileFlipFlags.FlipVertically) != 0;
  11. public bool IsFlippedDiagonally => (GlobalTileIdentifierWithFlags & (uint)TiledMapTileFlipFlags.FlipDiagonally) != 0;
  12. public bool IsBlank => GlobalIdentifier == 0;
  13. public TiledMapTileFlipFlags Flags => (TiledMapTileFlipFlags)(GlobalTileIdentifierWithFlags & (uint)TiledMapTileFlipFlags.All);
  14. public TiledMapTile(uint globalTileIdentifierWithFlags, ushort x, ushort y)
  15. {
  16. GlobalTileIdentifierWithFlags = globalTileIdentifierWithFlags;
  17. X = x;
  18. Y = y;
  19. }
  20. public override string ToString()
  21. {
  22. return $"GlobalIdentifier: {GlobalIdentifier}, Flags: {Flags}";
  23. }
  24. }
  25. }