Search Results for

    Show / Hide Table of Contents

    Class Tile

    A tile is an object on a Map that represents the covering of the ground (or the ground itself). To register a tile, use Register(String, Int32, TextureRegion, ColorScheme[], Single, Boolean, Boolean, TextureRegion, Func<Direction2, TextureRegion>, Int32[], Type).

    Inheritance
    System.Object
    Tile
    GrassyAutoTile
    Implements
    IPricedObject
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: TinyLife.World
    Assembly: Tiny Life.dll
    Syntax
    [JsonConverter(typeof(Tile.Converter))]
    public class Tile : IPricedObject

    Constructors

    Tile(String, String, Int32, Dictionary<Direction2, TextureRegion[]>, ColorScheme[], Int32[], Boolean, Single, Boolean, TextureRegion, Int32[])

    Creates a new tile with the given settings. To create an instance of a custom tile class, use Register(String, Int32, TextureRegion, ColorScheme[], Single, Boolean, Boolean, TextureRegion, Func<Direction2, TextureRegion>, Int32[], Type).

    Declaration
    protected Tile(string baseName, string name, int price, Dictionary<Direction2, TextureRegion[]> textureRegions, ColorScheme[] colorSchemes, int[] colors, bool canBuy, float pathCostModifier, bool natural, TextureRegion icon, int[] defaultColors)
    Parameters
    Type Name Description
    System.String baseName
    System.String name
    System.Int32 price
    System.Collections.Generic.Dictionary<MLEM.Misc.Direction2, MLEM.Textures.TextureRegion[]> textureRegions
    ColorScheme[] colorSchemes
    System.Int32[] colors
    System.Boolean canBuy
    System.Single pathCostModifier
    System.Boolean natural
    MLEM.Textures.TextureRegion icon
    System.Int32[] defaultColors

    Fields

    BaseName

    The name of this type of tile. Whereas Name has the index of its Colors appended to it, this one is just the type's name.

    Declaration
    public readonly string BaseName
    Field Value
    Type Description
    System.String

    CanBuy

    A field that indicates whether this tile can be bought without the "ShowNonBuyable" cheat enabled

    Declaration
    public readonly bool CanBuy
    Field Value
    Type Description
    System.Boolean

    Colors

    The indices of the colors in each ColorSchemes entry that this tile has

    Declaration
    public readonly int[] Colors
    Field Value
    Type Description
    System.Int32[]

    ColorSchemes

    The color scheme that this tile can have

    Declaration
    public readonly ColorScheme[] ColorSchemes
    Field Value
    Type Description
    ColorScheme[]

    DefaultColors

    The colors that this tile should have by default.

    Declaration
    public readonly int[] DefaultColors
    Field Value
    Type Description
    System.Int32[]

    Height

    The height of each tile, in pixels

    Declaration
    public static readonly int Height
    Field Value
    Type Description
    System.Int32

    Icon

    The build mode icon for this object, which represents the category / theme / mod that it comes from. If this value is nonnull, the icon will be displayed in the corner of the build mode button for this object.

    Declaration
    public readonly TextureRegion Icon
    Field Value
    Type Description
    MLEM.Textures.TextureRegion

    Name

    The name of this specific tile. This is comprised of the BaseName with the Colors's index attached to it.

    Declaration
    public readonly string Name
    Field Value
    Type Description
    System.String

    Natural

    A field that indicates whether this tile is considered natural. A natural tile is a tile that objects with the NaturalGroundRequired category can be placed on.

    Declaration
    public readonly bool Natural
    Field Value
    Type Description
    System.Boolean

    PathCostModifier

    A field that indicates the "cost" for pathfinding of this tile. The default modifier is 1, and it should not be set to a value lower than that.

    Declaration
    public readonly float PathCostModifier
    Field Value
    Type Description
    System.Single

    Price

    The price of this tile

    Declaration
    public readonly int Price
    Field Value
    Type Description
    System.Int32

    ReferencePrice

    The reference price for tiles. Since Grass is replaced by Concrete in a newly created room, the two tiles have to cost the same. This is that price. This value is set to 5.

    Declaration
    public const int ReferencePrice = 5
    Field Value
    Type Description
    System.Int32

    TextureRegions

    The texture regions that this tile has, based on the MLEM.Misc.Direction2 that represents the CameraRotation. Each entry in any given value array is a variation that will be used randomly when drawing. If the array has one entry, there are no additional variations.

    Declaration
    public readonly Dictionary<Direction2, TextureRegion[]> TextureRegions
    Field Value
    Type Description
    System.Collections.Generic.Dictionary<MLEM.Misc.Direction2, MLEM.Textures.TextureRegion[]>

    Tiles

    A registry of all tiles that exist in the game and its mods

    Declaration
    public static readonly ReadOnlyDictionary<string, Tile[]> Tiles
    Field Value
    Type Description
    System.Collections.ObjectModel.ReadOnlyDictionary<System.String, Tile[]>

    Width

    The width of each tile, in pixels

    Declaration
    public static readonly int Width
    Field Value
    Type Description
    System.Int32

    Methods

    Draw(Object, Map, Point, Vector2, Single, Single, ICollection<StaticSpriteBatch.Item>)

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

    Declaration
    public virtual void Draw(object batch, Map map, Point pos, Vector2 drawPos, float depth, float scale, ICollection<StaticSpriteBatch.Item> items = null)
    Parameters
    Type Name Description
    System.Object batch

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

    Map map

    The map that the tile is on.

    Point pos

    The position that the tile is on.

    Vector2 drawPos

    The position, in screen space, to draw at.

    System.Single depth

    The depth to use for drawing.

    System.Single scale

    The scale to draw the tile with.

    System.Collections.Generic.ICollection<MLEM.Graphics.StaticSpriteBatch.Item> items

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

    DrawUi(Element, SpriteBatch, Single)

    Draws this tile on the given ui element, in ui space

    Declaration
    public virtual void DrawUi(Element e, SpriteBatch batch, float drawScale = 0.4F)
    Parameters
    Type Name Description
    MLEM.Ui.Elements.Element e

    The element to draw on

    SpriteBatch batch

    The sprite batch to use for drawing

    System.Single drawScale

    The scale to draw the tile with. Defaults to 0.4.

    GetPrice()

    Returns the price that this object can be bought or sold for. Note that, like in the case of the Painting, the returned price isn't necessarily the full price that the object can be sold for. Instead, the price returned here should be the price that this object has when bought or sold from the FurnitureTool or similar.

    Declaration
    public virtual float GetPrice()
    Returns
    Type Description
    System.Single

    The object's price

    GetVariationTexture(Direction2, Point)

    Returns a random texture that should be displayed at the given position, based on the TextureRegions variations that this tile has. If a tile only has one variation texture, this method always returns that texture.

    Declaration
    protected TextureRegion GetVariationTexture(Direction2 direction, Point pos)
    Parameters
    Type Name Description
    MLEM.Misc.Direction2 direction

    The camera rotation.

    Point pos

    The position that the tile is at.

    Returns
    Type Description
    MLEM.Textures.TextureRegion

    The texture to display at the location.

    OnNeighborChanged(Map, Point, Point)

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

    Declaration
    public virtual void OnNeighborChanged(Map map, Point pos, Point neighbor)
    Parameters
    Type Name Description
    Map map

    The map that the tile is on.

    Point pos

    The position that the tile is on.

    Point neighbor

    The position of the tile that changed.

    Register(String, Int32, TextureRegion, ColorScheme[], Single, Boolean, Boolean, TextureRegion, Func<Direction2, TextureRegion>, Int32[], Type)

    Registers a new tile with the given settings.

    Declaration
    public static void Register(string name, int price, TextureRegion textureRegion, ColorScheme[] colors, float pathCostModifier = 1F, bool canBuy = true, bool natural = false, TextureRegion icon = null, Func<Direction2, TextureRegion> variations = null, int[] defaultColors = null, Type constructedType = null)
    Parameters
    Type Name Description
    System.String name

    The name that the tile should have.

    System.Int32 price

    The tile's price.

    MLEM.Textures.TextureRegion textureRegion

    The texture region that this tile should use for rendering.

    ColorScheme[] colors

    The color scheme that this tile should have.

    System.Single pathCostModifier

    The path cost modifier, >= 1, that this tile should have.

    System.Boolean canBuy

    Whether or not the tile can be bought in the tile tool.

    System.Boolean natural

    Whether or not the tile is considered natural ground.

    MLEM.Textures.TextureRegion icon

    The build mode category icon of this object.

    System.Func<MLEM.Misc.Direction2, MLEM.Textures.TextureRegion> variations

    An optional set of variation textures that should be used based on the given camera rotation.

    System.Int32[] defaultColors

    The colors that this tile should display with in the tile tool by default.

    System.Type constructedType

    The type that tiles should be constructed from, or null to construct Tile instances.

    Register(String, Int32, TextureRegion[], ColorScheme[], Single, Boolean, Boolean, TextureRegion, Func<Direction2, TextureRegion[]>, Int32[], Type)

    Registers a new tile with the given settings.

    Declaration
    public static void Register(string name, int price, TextureRegion[] textureRegions, ColorScheme[] colors, float pathCostModifier = 1F, bool canBuy = true, bool natural = false, TextureRegion icon = null, Func<Direction2, TextureRegion[]> variations = null, int[] defaultColors = null, Type constructedType = null)
    Parameters
    Type Name Description
    System.String name

    The name that the tile should have.

    System.Int32 price

    The tile's price.

    MLEM.Textures.TextureRegion[] textureRegions

    The texture regions that this tile should use for rendering, from which a random value will be chosen for each tile.

    ColorScheme[] colors

    The color scheme that this tile should have.

    System.Single pathCostModifier

    The path cost modifier, >= 1, that this tile should have.

    System.Boolean canBuy

    Whether or not the tile can be bought in the tile tool.

    System.Boolean natural

    Whether or not the tile is considered natural ground.

    MLEM.Textures.TextureRegion icon

    The build mode category icon of this object.

    System.Func<MLEM.Misc.Direction2, MLEM.Textures.TextureRegion[]> variations

    An optional set of variation textures that should be used based on the given camera rotation.

    System.Int32[] defaultColors

    The colors that this tile should display with in the tile tool by default.

    System.Type constructedType

    The type that tiles should be constructed from, or null to construct Tile instances.

    Implements

    IPricedObject

    Extension Methods

    Extensions.JsonCopy<T>(T)
    ☀
    ☾
    In This Article
    Back to top
    © 2021-2022 Ellpeck – Impressum – Privacy – Status
    ☀
    ☾