Table of Contents

Class AutoTiling

Namespace
MLEM.Graphics
Assembly
MLEM.dll
public static class AutoTiling
Inheritance
AutoTiling
Inherited Members

Methods

AddAutoTile(StaticSpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float, ICollection<Item>)

This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.

For auto-tiling in this way to work, the tiles have to be laid out as follows: five tiles aligned horizontally within the texture file, with the following information:

  1. The texture used for filling big areas
  2. The texture used for straight, horizontal borders, with the borders facing away from the center
  3. The texture used for outer corners, with the corners facing away from the center
  4. The texture used for straight, vertical borders, with the borders facing away from the center
  5. The texture used for inner corners, with the corners facing away from the center
For more information and an example, see https://github.com/Ellpeck/MLEM/blob/main/Demos/AutoTilingDemo.cs and its source texture https://github.com/Ellpeck/MLEM/blob/main/Demos/Content/Textures/AutoTiling.png.
public static void AddAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion texture, AutoTiling.ConnectsTo connectsTo, Color color, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, ICollection<StaticSpriteBatch.Item> items = null)

Parameters

batch StaticSpriteBatch

The sprite batch to use for drawing.

pos Vector2

The position to draw at.

texture TextureRegion

The texture to use for drawing, with the area set to the first texture region, as described in the summary.

connectsTo AutoTiling.ConnectsTo

A function that determines whether two positions should connect.

color Color

The color to draw with.

origin Vector2?

The origin to draw from.

scale Vector2?

The scale to draw with.

layerDepth float

The layer depth to draw with.

items ICollection<StaticSpriteBatch.Item>

AddExtendedAutoTile(StaticSpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float, ICollection<Item>)

This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.

This method is a more complex version of DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float) that overlays separate border textures on a background texture region, which also allows for non-rectangular texture areas to be used easily. For auto-tiling in this way to work, the overlay sections have to be laid out as follows: 16 sections aligned horizontally within the texture file, with the following information:

  1. The texture used for straight, horizontal borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  2. The texture used for outer corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  3. The texture used for straight, vertical borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  4. The texture used for inner corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
For more information and an example, see https://github.com/Ellpeck/MLEM/blob/main/Demos/AutoTilingDemo.cs and its source texture https://github.com/Ellpeck/MLEM/blob/main/Demos/Content/Textures/AutoTiling.png.
public static void AddExtendedAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, TextureRegion overlayTexture, AutoTiling.ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0, ICollection<StaticSpriteBatch.Item> items = null)

Parameters

batch StaticSpriteBatch

The sprite batch to use for drawing.

pos Vector2

The position to draw at.

backgroundTexture TextureRegion

The background region, or null to skip drawing a background.

overlayTexture TextureRegion

The first overlay region, as described in the summary.

connectsTo AutoTiling.ConnectsTo

A function that determines whether two positions should connect.

backgroundColor Color

The color to draw the texture used for filling big areas with.

overlayColor Color

The color to draw border and corner textures with.

origin Vector2?

The origin to draw from.

scale Vector2?

The scale to draw with.

layerDepth float

The layer depth to draw with.

overlayDepthOffset float

An optional depth offset from layerDepth that the overlay should be drawn with

items ICollection<StaticSpriteBatch.Item>

AddExtendedAutoTile(StaticSpriteBatch, Vector2, TextureRegion, Func<int, TextureRegion>, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float, ICollection<Item>)

This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.

This method is a more complex version of DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float) that overlays separate border textures on a background texture region, which also allows for non-rectangular texture areas to be used easily. For auto-tiling in this way to work, the overlay sections have to be laid out as follows: 16 sections aligned horizontally within the texture file, with the following information:

  1. The texture used for straight, horizontal borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  2. The texture used for outer corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  3. The texture used for straight, vertical borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  4. The texture used for inner corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
For more information and an example, see https://github.com/Ellpeck/MLEM/blob/main/Demos/AutoTilingDemo.cs and its source texture https://github.com/Ellpeck/MLEM/blob/main/Demos/Content/Textures/AutoTiling.png.
public static void AddExtendedAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, Func<int, TextureRegion> overlayTextures, AutoTiling.ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0, ICollection<StaticSpriteBatch.Item> items = null)

Parameters

batch StaticSpriteBatch

The sprite batch to use for drawing.

pos Vector2

The position to draw at.

backgroundTexture TextureRegion

The background region, or null to skip drawing a background.

overlayTextures Func<int, TextureRegion>
connectsTo AutoTiling.ConnectsTo

A function that determines whether two positions should connect.

backgroundColor Color

The color to draw the texture used for filling big areas with.

overlayColor Color

The color to draw border and corner textures with.

origin Vector2?

The origin to draw from.

scale Vector2?

The scale to draw with.

layerDepth float

The layer depth to draw with.

overlayDepthOffset float

An optional depth offset from layerDepth that the overlay should be drawn with

items ICollection<StaticSpriteBatch.Item>

AddExtendedAutoTileCorner(StaticSpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Direction2, Vector2?, Vector2?, float, ICollection<Item>)

This method allows for a single corner of a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.

For more information, and to draw all four corners at once, see DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)

public static void AddExtendedAutoTileCorner(StaticSpriteBatch batch, Vector2 pos, TextureRegion overlayTexture, AutoTiling.ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, ICollection<StaticSpriteBatch.Item> items = null)

Parameters

batch StaticSpriteBatch

The sprite batch to use for drawing.

pos Vector2

The position to draw at.

overlayTexture TextureRegion

The first overlay region, as described in the summary.

connectsTo AutoTiling.ConnectsTo

A function that determines whether two positions should connect.

overlayColor Color

The color to draw border and corner textures with.

corner Direction2

The corner of the auto-tile to draw. Can be UpLeft, UpRight, DownLeft or DownRight.

origin Vector2?

The origin to draw from.

scale Vector2?

The scale to draw with.

layerDepth float

The layer depth to draw with.

items ICollection<StaticSpriteBatch.Item>

AddExtendedAutoTileCorner(StaticSpriteBatch, Vector2, Func<int, TextureRegion>, ConnectsTo, Color, Direction2, Vector2?, Vector2?, float, ICollection<Item>)

This method allows for a single corner of a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.

For more information, and to draw all four corners at once, see DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)

public static void AddExtendedAutoTileCorner(StaticSpriteBatch batch, Vector2 pos, Func<int, TextureRegion> overlayTextures, AutoTiling.ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, ICollection<StaticSpriteBatch.Item> items = null)

Parameters

batch StaticSpriteBatch

The sprite batch to use for drawing.

pos Vector2

The position to draw at.

overlayTextures Func<int, TextureRegion>
connectsTo AutoTiling.ConnectsTo

A function that determines whether two positions should connect.

overlayColor Color

The color to draw border and corner textures with.

corner Direction2

The corner of the auto-tile to draw. Can be UpLeft, UpRight, DownLeft or DownRight.

origin Vector2?

The origin to draw from.

scale Vector2?

The scale to draw with.

layerDepth float

The layer depth to draw with.

items ICollection<StaticSpriteBatch.Item>

DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float)

This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.

For auto-tiling in this way to work, the tiles have to be laid out as follows: five tiles aligned horizontally within the texture file, with the following information:

  1. The texture used for filling big areas
  2. The texture used for straight, horizontal borders, with the borders facing away from the center
  3. The texture used for outer corners, with the corners facing away from the center
  4. The texture used for straight, vertical borders, with the borders facing away from the center
  5. The texture used for inner corners, with the corners facing away from the center
For more information and an example, see https://github.com/Ellpeck/MLEM/blob/main/Demos/AutoTilingDemo.cs and its source texture https://github.com/Ellpeck/MLEM/blob/main/Demos/Content/Textures/AutoTiling.png.
public static void DrawAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion texture, AutoTiling.ConnectsTo connectsTo, Color color, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0)

Parameters

batch SpriteBatch

The sprite batch to use for drawing.

pos Vector2

The position to draw at.

texture TextureRegion

The texture to use for drawing, with the area set to the first texture region, as described in the summary.

connectsTo AutoTiling.ConnectsTo

A function that determines whether two positions should connect.

color Color

The color to draw with.

origin Vector2?

The origin to draw from.

scale Vector2?

The scale to draw with.

layerDepth float

The layer depth to draw with.

DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)

This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.

This method is a more complex version of DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float) that overlays separate border textures on a background texture region, which also allows for non-rectangular texture areas to be used easily. For auto-tiling in this way to work, the overlay sections have to be laid out as follows: 16 sections aligned horizontally within the texture file, with the following information:

  1. The texture used for straight, horizontal borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  2. The texture used for outer corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  3. The texture used for straight, vertical borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  4. The texture used for inner corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
For more information and an example, see https://github.com/Ellpeck/MLEM/blob/main/Demos/AutoTilingDemo.cs and its source texture https://github.com/Ellpeck/MLEM/blob/main/Demos/Content/Textures/AutoTiling.png.
public static void DrawExtendedAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, TextureRegion overlayTexture, AutoTiling.ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0)

Parameters

batch SpriteBatch

The sprite batch to use for drawing.

pos Vector2

The position to draw at.

backgroundTexture TextureRegion

The background region, or null to skip drawing a background.

overlayTexture TextureRegion

The first overlay region, as described in the summary.

connectsTo AutoTiling.ConnectsTo

A function that determines whether two positions should connect.

backgroundColor Color

The color to draw the texture used for filling big areas with.

overlayColor Color

The color to draw border and corner textures with.

origin Vector2?

The origin to draw from.

scale Vector2?

The scale to draw with.

layerDepth float

The layer depth to draw with.

overlayDepthOffset float

An optional depth offset from layerDepth that the overlay should be drawn with

DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, Func<int, TextureRegion>, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)

This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.

This method is a more complex version of DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float) that overlays separate border textures on a background texture region, which also allows for non-rectangular texture areas to be used easily. For auto-tiling in this way to work, the overlay sections have to be laid out as follows: 16 sections aligned horizontally within the texture file, with the following information:

  1. The texture used for straight, horizontal borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  2. The texture used for outer corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  3. The texture used for straight, vertical borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
  4. The texture used for inner corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
For more information and an example, see https://github.com/Ellpeck/MLEM/blob/main/Demos/AutoTilingDemo.cs and its source texture https://github.com/Ellpeck/MLEM/blob/main/Demos/Content/Textures/AutoTiling.png.
public static void DrawExtendedAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, Func<int, TextureRegion> overlayTextures, AutoTiling.ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0)

Parameters

batch SpriteBatch

The sprite batch to use for drawing.

pos Vector2

The position to draw at.

backgroundTexture TextureRegion

The background region, or null to skip drawing a background.

overlayTextures Func<int, TextureRegion>
connectsTo AutoTiling.ConnectsTo

A function that determines whether two positions should connect.

backgroundColor Color

The color to draw the texture used for filling big areas with.

overlayColor Color

The color to draw border and corner textures with.

origin Vector2?

The origin to draw from.

scale Vector2?

The scale to draw with.

layerDepth float

The layer depth to draw with.

overlayDepthOffset float

An optional depth offset from layerDepth that the overlay should be drawn with

DrawExtendedAutoTileCorner(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Direction2, Vector2?, Vector2?, float)

This method allows for a single corner of a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.

For more information, and to draw all four corners at once, see DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)

public static void DrawExtendedAutoTileCorner(SpriteBatch batch, Vector2 pos, TextureRegion overlayTexture, AutoTiling.ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0)

Parameters

batch SpriteBatch

The sprite batch to use for drawing.

pos Vector2

The position to draw at.

overlayTexture TextureRegion

The first overlay region, as described in the summary.

connectsTo AutoTiling.ConnectsTo

A function that determines whether two positions should connect.

overlayColor Color

The color to draw border and corner textures with.

corner Direction2

The corner of the auto-tile to draw. Can be UpLeft, UpRight, DownLeft or DownRight.

origin Vector2?

The origin to draw from.

scale Vector2?

The scale to draw with.

layerDepth float

The layer depth to draw with.

DrawExtendedAutoTileCorner(SpriteBatch, Vector2, Func<int, TextureRegion>, ConnectsTo, Color, Direction2, Vector2?, Vector2?, float)

This method allows for a single corner of a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.

For more information, and to draw all four corners at once, see DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)

public static void DrawExtendedAutoTileCorner(SpriteBatch batch, Vector2 pos, Func<int, TextureRegion> overlayTextures, AutoTiling.ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0)

Parameters

batch SpriteBatch

The sprite batch to use for drawing.

pos Vector2

The position to draw at.

overlayTextures Func<int, TextureRegion>
connectsTo AutoTiling.ConnectsTo

A function that determines whether two positions should connect.

overlayColor Color

The color to draw border and corner textures with.

corner Direction2

The corner of the auto-tile to draw. Can be UpLeft, UpRight, DownLeft or DownRight.

origin Vector2?

The origin to draw from.

scale Vector2?

The scale to draw with.

layerDepth float

The layer depth to draw with.