Table of Contents

Class TiledExtensions

Namespace
MLEM.Extended.Tiled
Assembly
MLEM.Extended.dll

A set of extensions for dealing with MonoGame.Extended tiled maps

public static class TiledExtensions
Inheritance
TiledExtensions
Inherited Members

Methods

Get(TiledMapProperties, string)

Gets the property with the given key, or null if there is none.

public static string Get(this TiledMapProperties properties, string key)

Parameters

properties TiledMapProperties

The set of properties

key string

The key by which to get a property

Returns

string

The property, or null if there is none

GetArea(TiledMapObject, TiledMap, Vector2?, TiledMapTileFlipFlags)

Returns the area that a tiled map object covers. The area returned is in percent, meaning that an area that covers a full tile has a size of 1,1.

public static RectangleF GetArea(this TiledMapObject obj, TiledMap map, Vector2? position = null, TiledMapTileFlipFlags flipFlags = TiledMapTileFlipFlags.None)

Parameters

obj TiledMapObject

The object whose area to get

map TiledMap

The map

position Vector2?

The position to add to the object's position

flipFlags TiledMapTileFlipFlags

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.

Returns

RectangleF

The area that the tile covers

GetBool(TiledMapProperties, string)

Gets a boolean property with the given key, or null if there is none.

public static bool GetBool(this TiledMapProperties properties, string key)

Parameters

properties TiledMapProperties

The set of properties

key string

The key by which to get a property

Returns

bool

The boolean property, or false if there is none

GetColor(TiledMapProperties, string)

Gets a Color property with the given key, or null if there is none.

public static Color GetColor(this TiledMapProperties properties, string key)

Parameters

properties TiledMapProperties

The set of properties

key string

The key by which to get a property

Returns

Color

The color property

GetFloat(TiledMapProperties, string)

Gets a float property with the given key, or null if there is none.

public static float GetFloat(this TiledMapProperties properties, string key)

Parameters

properties TiledMapProperties

The set of properties

key string

The key by which to get a property

Returns

float

The float property, or 0 if there is none

GetGlobalIdentifier(TiledMapTilesetTile, TiledMapTileset, TiledMap)

Gets the global tile identifier for the given tiled map tileset tile. The global tile identifier is the identifier within all of the tile sets that the map has.

public static int GetGlobalIdentifier(this TiledMapTilesetTile tile, TiledMapTileset tileset, TiledMap map)

Parameters

tile TiledMapTilesetTile

The tile whose global identifier to get

tileset TiledMapTileset

The tileset the tile is from

map TiledMap

The map the tile is on

Returns

int

The global identifier

GetInt(TiledMapProperties, string)

Gets an int property with the given key, or null if there is none.

public static int GetInt(this TiledMapProperties properties, string key)

Parameters

properties TiledMapProperties

The set of properties

key string

The key by which to get a property

Returns

int

The int property, or 0 if there is none

GetLocalIdentifier(TiledMapTile, TiledMapTileset, TiledMap)

Gets the local tile identifier for the given tiled map tile. The local tile identifier is the identifier within the tile's tileset.

public static int GetLocalIdentifier(this TiledMapTile tile, TiledMapTileset tileset, TiledMap map)

Parameters

tile TiledMapTile

The tile whose identifier to get

tileset TiledMapTileset

The tileset the tile is from

map TiledMap

The map the tile is on

Returns

int

The local identifier

GetObjects(TiledMap, string, bool, bool)

Returns all of the objects by the given name, or by the given type, on the given map.

public static IEnumerable<TiledMapObject> GetObjects(this TiledMap map, string id, bool searchName = true, bool searchType = false)

Parameters

map TiledMap

The layer whose objects to search

id string

The name or type name of the objects to find

searchName bool

Whether to search object names

searchType bool

Whether to search object types

Returns

IEnumerable<TiledMapObject>

An enumerable of tiled map objects that match the search

GetObjects(TiledMapObjectLayer, string, bool, bool)

Returns all of the objects by the given name, or by the given type, in an object layer.

public static IEnumerable<TiledMapObject> GetObjects(this TiledMapObjectLayer layer, string id, bool searchName = true, bool searchType = false)

Parameters

layer TiledMapObjectLayer

The layer whose objects to search

id string

The name or type name of the objects to find

searchName bool

Whether to search object names

searchType bool

Whether to search object types

Returns

IEnumerable<TiledMapObject>

An enumerable of tiled map objects that match the search

GetSpriteEffects(TiledMapTile)

Converts a tile's flip settings into Microsoft.Xna.Framework.Graphics.SpriteEffects.

public static SpriteEffects GetSpriteEffects(this TiledMapTile tile)

Parameters

tile TiledMapTile

The tile whose flip settings to convert

Returns

SpriteEffects

The tile's flip settings as sprite effects

GetTextureRegion(TiledMapTileset, TiledMapTilesetTile)

Returns the texture region, as a rectangle, that the given tile uses for rendering.

public static Rectangle GetTextureRegion(this TiledMapTileset tileset, TiledMapTilesetTile tile)

Parameters

tileset TiledMapTileset

The tileset the tile is on

tile TiledMapTilesetTile

The tile

Returns

Rectangle

The tile's texture region, in pixels.

GetTile(TiledMap, LayerPosition)

Returns the tiled map tile at the given location on the layer with the given name.

public static TiledMapTile GetTile(this TiledMap map, LayerPosition pos)

Parameters

map TiledMap

The map

pos LayerPosition

The layer position to get the tile at

Returns

TiledMapTile

The tile at the given location, or default if the layer does not exist

GetTile(TiledMap, string, int, int)

Returns the tiled map tile at the given location on the layer with the given name.

public static TiledMapTile GetTile(this TiledMap map, string layerName, int x, int y)

Parameters

map TiledMap

The map

layerName string

The name of the layer the tile is on

x int

The x coordinate of the tile

y int

The y coordinate of the tile

Returns

TiledMapTile

The tile at the given location, or default if the layer does not exist

GetTile(TiledMapTileLayer, int, int)

Returns the tiled map at the given location on the given layer

public static TiledMapTile GetTile(this TiledMapTileLayer layer, int x, int y)

Parameters

layer TiledMapTileLayer

The layer to get the tile from

x int

The tile's x coordinate

y int

The tile's y coordinate

Returns

TiledMapTile

The tiled map tile at the location, or default if the location is out of bounds

GetTileLayerIndex(TiledMap, string)

Gets the layer index of the layer with the given name in the MonoGame.Extended.Tiled.TiledMap.Layers array.

public static int GetTileLayerIndex(this TiledMap map, string layerName)

Parameters

map TiledMap

The map

layerName string

The name of the layer

Returns

int

The resulting index

GetTileSize(TiledMap)

Returns the width and height of a tile on the given map, as a vector.

public static Vector2 GetTileSize(this TiledMap map)

Parameters

map TiledMap

The map

Returns

Vector2

The width and height of a tile

GetTiles(TiledMap, int, int)

For an x and y coordinate, returns an enumerable of all of the tiles on each of the map's MonoGame.Extended.Tiled.TiledMap.TileLayers.

public static IEnumerable<TiledMapTile> GetTiles(this TiledMap map, int x, int y)

Parameters

map TiledMap

The map

x int

The x coordinate

y int

The y coordinate

Returns

IEnumerable<TiledMapTile>

All of the tiles on the map at the given location

GetTileset(TiledMapTile, TiledMap)

Gets the tileset for the given map tile on the given map.

public static TiledMapTileset GetTileset(this TiledMapTile tile, TiledMap map)

Parameters

tile TiledMapTile

The tile

map TiledMap

The map the tile is on

Returns

TiledMapTileset

The tileset that the tile came from

GetTilesetTile(TiledMapTile, TiledMap, bool)

Gets the tileset tile on the given tileset for the given tile. If the tileset is already known, you should use GetTilesetTile(TiledMapTileset, TiledMapTile, TiledMap, bool) instead for performance.

public static TiledMapTilesetTile GetTilesetTile(this TiledMapTile tile, TiledMap map, bool createStub = true)

Parameters

tile TiledMapTile

The tile

map TiledMap

The map the tile is on

createStub bool

If a tileset tile has no special properties, there is no pre-made object for it. If this boolean is true, a stub object with no extra data will be created instead of returning null.

Returns

TiledMapTilesetTile

null if the tile is blank or the tileset tile if there is one or createStub is true

GetTilesetTile(TiledMapTileset, TiledMapTile, TiledMap, bool)

Gets the tileset tile on the given tileset for the given tile.

public static TiledMapTilesetTile GetTilesetTile(this TiledMapTileset tileset, TiledMapTile tile, TiledMap map, bool createStub = true)

Parameters

tileset TiledMapTileset

The tileset

tile TiledMapTile

The tile

map TiledMap

The map the tile is on

createStub bool

If a tileset tile has no special properties, there is no pre-made object for it. If this boolean is true, a stub object with no extra data will be created instead of returning null.

Returns

TiledMapTilesetTile

null if the tile is blank or the tileset tile if there is one or createStub is true

GetTilesetTile(TiledMapTileset, int, bool)

Gets the tileset tile on the given tileset for the given local id.

public static TiledMapTilesetTile GetTilesetTile(this TiledMapTileset tileset, int localId, bool createStub = true)

Parameters

tileset TiledMapTileset

The tileset

localId int

The tile's local id

createStub bool

If a tileset tile has no special properties, there is no pre-made object for it. If this boolean is true, a stub object with no extra data will be created instead of returning null.

Returns

TiledMapTilesetTile

null if the tile is blank or the tileset tile if there is one or createStub is true

IsInBounds(TiledMapTileLayer, int, int)

Returns whether the given position is in the bounds of the layer (that is, if each coordinate is >= 0 and if they are both smaller than the layer's width and height).

public static bool IsInBounds(this TiledMapTileLayer layer, int x, int y)

Parameters

layer TiledMapTileLayer

The layer

x int

The x coordinate

y int

The y coordinate

Returns

bool

Whether the position is in bounds of the layer

SetTile(TiledMap, LayerPosition, TiledMapTileset, TiledMapTilesetTile)

Sets the tiled map tile at the given location to the given tile from the given tileset. If the passed tileset or tile is null, the tile at the location is removed instead.

public static void SetTile(this TiledMap map, LayerPosition pos, TiledMapTileset tileset, TiledMapTilesetTile tile)

Parameters

map TiledMap

The map

pos LayerPosition

The layer position

tileset TiledMapTileset

The tileset to use, or null to remove the tile

tile TiledMapTilesetTile

The tile to place, from the given tileset, or null to remove the tile

SetTile(TiledMap, LayerPosition, int)

Sets the tiled map tile at the given location to the given global tile identifier.

public static void SetTile(this TiledMap map, LayerPosition pos, int globalTile)

Parameters

map TiledMap

The map

pos LayerPosition

The layer position

globalTile int

The tile's global identifier to set

SetTile(TiledMap, string, int, int, TiledMapTileset, TiledMapTilesetTile)

Sets the tiled map tile at the given location to the given tile from the given tileset. If the passed tileset or tile is null, the tile at the location is removed instead.

public static void SetTile(this TiledMap map, string layerName, int x, int y, TiledMapTileset tileset, TiledMapTilesetTile tile)

Parameters

map TiledMap

The map

layerName string

The name of the layer

x int

The x coordinate

y int

The y coordinate

tileset TiledMapTileset

The tileset to use, or null to remove the tile

tile TiledMapTilesetTile

The tile to place, from the given tileset, or null to remove the tile

SetTile(TiledMap, string, int, int, int)

Sets the tiled map tile at the given location to the given global tile identifier.

public static void SetTile(this TiledMap map, string layerName, int x, int y, int globalTile)

Parameters

map TiledMap

The map

layerName string

The name of the layer

x int

The x coordinate

y int

The y coordinate

globalTile int

The tile's global identifier to set