Table of Contents

Class AutoTile

Namespace
TinyLife.World
Assembly
Tiny Life.dll

An auto-tile is a Tile that visually connects to other tiles around it, while leaving a border around tiles that it doesn't connect to. Implementors can override ConnectsToTile(Map, Point, int, int, int) to edit this behavior.

public class AutoTile : Tile
Inheritance
AutoTile
Derived
Inherited Members
Extension Methods

Constructors

AutoTile(string, string, int, Dictionary<Point, TextureRegion>, Dictionary<Direction2, Point[]>, ColorSettings, int[], bool, float, Category, TextureRegion, Func<Point, float>)

protected AutoTile(string baseName, string name, int price, Dictionary<Point, TextureRegion> textures, Dictionary<Direction2, Point[]> regions, ColorSettings colorSettings, int[] colors, bool canBuy, float pathCostModifier, Tile.Category categories, TextureRegion icon, Func<Point, float> regionWeights)

Parameters

baseName string
name string
price int
textures Dictionary<Point, TextureRegion>
regions Dictionary<Direction2, Point[]>
colorSettings ColorSettings
colors int[]
canBuy bool
pathCostModifier float
categories Tile.Category
icon TextureRegion
regionWeights Func<Point, float>

Methods

ConnectsToTile(Map, Point, int, int, int)

Override this method to determine what other tiles this auto-tile should connect to. By default, auto-tiles connect to other tiles of the same type.

protected virtual bool ConnectsToTile(Map map, Point pos, int floor, int x, int y)

Parameters

map Map

The map.

pos Point

The position of the tile.

floor int

The floor of the tile.

x int

The offset from pos in the x axis.

y int

The offset from pos in the y axis.

Returns

bool

Whether this tile should connect to the tile at the offset position.

Draw(GameTime, object, Map, Point, int, Vector2, float, float, ICollection<Item>, bool)

Draws this tile at the given position in the world using a Microsoft.Xna.Framework.Graphics.SpriteBatch or MLEM.Graphics.StaticSpriteBatch

public override bool Draw(GameTime time, object batch, Map map, Point pos, int floor, Vector2 drawPos, float scale, float depthOffset, ICollection<StaticSpriteBatch.Item> items, bool hasStaticContext)

Parameters

time GameTime

The game's current time.

batch object

The sprite batch to use for drawing, which can either be a Microsoft.Xna.Framework.Graphics.SpriteBatch or a MLEM.Graphics.StaticSpriteBatch.

map Map

The map that the tile is on.

pos Point

The position that the tile is on.

floor int

The floor that this tile is on.

drawPos Vector2

The position, in screen space, to draw at.

scale float

The scale to draw the tile with.

depthOffset float

A depth offset that can optionally be added to this tile's draw depth.

items ICollection<StaticSpriteBatch.Item>

The MLEM.Graphics.StaticSpriteBatch.Item collection that added items can optionally be added to.

hasStaticContext bool

Whether this tile also has a static context, that is, whether it will already be drawn using a MLEM.Graphics.StaticSpriteBatch.

Returns

bool

Whether this tile was fully drawn. If the batch is a MLEM.Graphics.StaticSpriteBatch and false is returned, this tile will be marked as an animated tile, causing it to draw every frame.

DrawBorder(object, Map, Point, int, Vector2, float, float, ICollection<Item>, (Func<int, TextureRegion> Texture, Color Color)?)

Draws the auto-tile border.

protected void DrawBorder(object batch, Map map, Point pos, int floor, Vector2 drawPos, float scale, float depthOffset, ICollection<StaticSpriteBatch.Item> items, (Func<int, TextureRegion> Texture, Color Color)? bestBorderTile = null)

Parameters

batch object

The sprite batch to use for drawing, which can either be a Microsoft.Xna.Framework.Graphics.SpriteBatch or a MLEM.Graphics.StaticSpriteBatch.

map Map

The map that the tile is on.

pos Point

The position that the tile is on.

floor int

The floor to draw at.

drawPos Vector2

The position, in screen space, to draw at.

scale float

The scale to draw the tile with.

depthOffset float

A depth offset that is optionally added to the calculated draw depth.

items ICollection<StaticSpriteBatch.Item>

The MLEM.Graphics.StaticSpriteBatch.Item collection that added items can optionally be added to.

bestBorderTile (Func<int, TextureRegion> Texture, Color Color)?

A function to return the best tile to use as this tile's border tile when rendering.

OnNeighborChanged(Map, Point, Point, int)

A method that is called when a neighboring Tile on the Map changes. This method does nothing by default, but is overriden by AutoTile to notify neighboring tiles of changes.

public override void OnNeighborChanged(Map map, Point pos, Point neighbor, int floor)

Parameters

map Map

The map that the tile is on.

pos Point

The position that the tile is on.

neighbor Point

The position of the tile that changed.

floor int

The floor that this tile and the neighbor are on.