diff --git a/MLEM.Extended/Tiled/TiledExtensions.cs b/MLEM.Extended/Tiled/TiledExtensions.cs
index 8f2fa7a..8a055d1 100644
--- a/MLEM.Extended/Tiled/TiledExtensions.cs
+++ b/MLEM.Extended/Tiled/TiledExtensions.cs
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended;
using MonoGame.Extended.Tiled;
+using static MonoGame.Extended.Tiled.TiledMapTileFlipFlags;
using ColorHelper = MLEM.Extensions.ColorHelper;
namespace MLEM.Extended.Tiled {
@@ -268,11 +269,18 @@ namespace MLEM.Extended.Tiled {
/// The object whose area to get
/// The map
/// The position to add to the object's position
+ /// The flipping of the tile that this object belongs to. If set, the returned area will be "flipped" in the tile's space so that it matches the flip flags.
/// The area that the tile covers
- public static RectangleF GetArea(this TiledMapObject obj, TiledMap map, Vector2? position = null) {
+ public static RectangleF GetArea(this TiledMapObject obj, TiledMap map, Vector2? position = null, TiledMapTileFlipFlags flipFlags = None) {
var tileSize = map.GetTileSize();
- var pos = position ?? Vector2.Zero;
- return new RectangleF(obj.Position / tileSize + pos, obj.Size / tileSize);
+ var area = new RectangleF(obj.Position / tileSize, obj.Size / tileSize);
+ if (flipFlags.HasFlag(FlipHorizontally))
+ area.X = 1 - area.X - area.Width;
+ if (flipFlags.HasFlag(FlipVertically))
+ area.Y = 1 - area.Y - area.Height;
+ if (position != null)
+ area.Offset(position.Value);
+ return area;
}
///
diff --git a/MLEM.Extended/Tiled/TiledMapCollisions.cs b/MLEM.Extended/Tiled/TiledMapCollisions.cs
index e899c78..67b3ff4 100644
--- a/MLEM.Extended/Tiled/TiledMapCollisions.cs
+++ b/MLEM.Extended/Tiled/TiledMapCollisions.cs
@@ -141,15 +141,8 @@ namespace MLEM.Extended.Tiled {
/// The list of collisions to add to
/// The tile's collision information
public static void DefaultCollectCollisions(List collisions, TileCollisionInfo tile) {
- foreach (var obj in tile.TilesetTile.Objects) {
- var area = obj.GetArea(tile.Map);
- if (tile.Tile.IsFlippedHorizontally)
- area.X = 1 - area.X - area.Width;
- if (tile.Tile.IsFlippedVertically)
- area.Y = 1 - area.Y - area.Height;
- area.Offset(tile.Position);
- collisions.Add(area);
- }
+ foreach (var obj in tile.TilesetTile.Objects)
+ collisions.Add(obj.GetArea(tile.Map, tile.Position, tile.Tile.Flags));
}
///