Table of Contents

Class RoofType

Namespace
TinyLife.World
Assembly
Tiny Life.dll

A roof type stores settings and configurations for Roof instances. To register a new roof type, use Register(RoofType).

[JsonConverter(typeof(StaticJsonConverter<RoofType>), new object[] { typeof(RoofType), "PrivateTypes" })]
public class RoofType
Inheritance
RoofType
Inherited Members
Extension Methods

Constructors

RoofType(string, int, ColorScheme, RoofStyle, IReadOnlyDictionary<Point, TextureRegion>, Point, TextureRegion)

Creates a new roof type with the given settings

public RoofType(string name, int price, ColorScheme color, RoofStyle style, IReadOnlyDictionary<Point, TextureRegion> textures, Point textureRegion, TextureRegion icon = null)

Parameters

name string

The name that this roof type should have

price int

The price for a 1x1 area of this roof type

color ColorScheme

The color scheme that this roof type can have

style RoofStyle

The RoofStyle that this roof has

textures IReadOnlyDictionary<Point, TextureRegion>

The textures that the textureRegion should read from.

textureRegion Point

The initial, top-left texture region of this roof, which will be gathered from textures.

icon TextureRegion

The icon that this roof should have in build mode

RoofType(string, int, ColorScheme[], RoofStyle, IReadOnlyDictionary<Point, TextureRegion>, Point, TextureRegion)

public RoofType(string name, int price, ColorScheme[] colors, RoofStyle style, IReadOnlyDictionary<Point, TextureRegion> textures, Point textureRegion, TextureRegion icon = null)

Parameters

name string
price int
colors ColorScheme[]
style RoofStyle
textures IReadOnlyDictionary<Point, TextureRegion>
textureRegion Point
icon TextureRegion

RoofType(string, int, ColorSettings, RoofStyle, IReadOnlyDictionary<Point, TextureRegion>, Point, TextureRegion)

Creates a new roof type with the given settings

public RoofType(string name, int price, ColorSettings colors, RoofStyle style, IReadOnlyDictionary<Point, TextureRegion> textures, Point textureRegion, TextureRegion icon = null)

Parameters

name string

The name that this roof type should have

price int

The price for a 1x1 area of this roof type

colors ColorSettings

The color scheme that this roof type can have

style RoofStyle

The RoofStyle that this roof has

textures IReadOnlyDictionary<Point, TextureRegion>

The textures that the textureRegion should read from.

textureRegion Point

The initial, top-left texture region of this roof, which will be gathered from textures.

icon TextureRegion

The icon that this roof should have in build mode

Fields

Colors

public readonly ColorSettings Colors

Field Value

ColorSettings

FlatSheetMetal

public static readonly RoofType FlatSheetMetal

Field Value

RoofType

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.

public readonly TextureRegion Icon

Field Value

TextureRegion

ModernFlat

public static readonly RoofType ModernFlat

Field Value

RoofType

Name

The name of this roof type, which is used to store it to disk

public readonly string Name

Field Value

string

OldStyleFlat

public static readonly RoofType OldStyleFlat

Field Value

RoofType

Price

The price of a 1x1 rectangle of this roof type

public readonly int Price

Field Value

int

RoundedShingles

public static readonly RoofType RoundedShingles

Field Value

RoofType

SheetMetal

public static readonly RoofType SheetMetal

Field Value

RoofType

SquareShingles

public static readonly RoofType SquareShingles

Field Value

RoofType

Style

The RoofStyle that this roof has. If Draw(GameTime, SpriteBatch, Map, Rectangle, int, Direction2, int[], Wallpaper, float, Color?) has completely custom behavior, the roof style is ignored, but can be set to Custom to signal this behavior to other mods.

public readonly RoofStyle Style

Field Value

RoofStyle

TextureRegion

The initial, top-left texture region of this roof, which will be gathered from Textures.

public readonly Point TextureRegion

Field Value

Point

Textures

The textures that the TextureRegion should read from.

public readonly IReadOnlyDictionary<Point, TextureRegion> Textures

Field Value

IReadOnlyDictionary<Point, TextureRegion>

Thatch

public static readonly RoofType Thatch

Field Value

RoofType

Types

A registry of all of the RoofType instances that are currently registered

public static readonly ReadOnlyDictionary<string, RoofType> Types

Field Value

ReadOnlyDictionary<string, RoofType>

Methods

Draw(GameTime, SpriteBatch, Map, Rectangle, int, Direction2, int[], Wallpaper, float, Color?)

Draws the given Roof in world space

public virtual void Draw(GameTime time, SpriteBatch batch, Map map, Rectangle area, int floor, Direction2 rotation, int[] colorIndices, Wallpaper wallpaper, float depthOffset = 0, Color? overrideColor = null)

Parameters

time GameTime

The game's current time

batch SpriteBatch

The sprite batch to use for drawing

map Map

The map to draw on

area Rectangle

The area the roof covers

floor int

The floor the roof is on.

rotation Direction2

The roof's rotation

colorIndices int[]

The color indices in this roof's Colors.

wallpaper Wallpaper

The wallpaper applied to the roof

depthOffset float

The value that should be added to the depth of this roof

overrideColor Color?

An override color that should be used instead of this roof's color, or null to use the roof's color.

DrawUi(SpriteBatch, Element, int[], float)

Draws a Roof in ui space, only drawing a 1x1 area of it

public virtual void DrawUi(SpriteBatch batch, Element element, int[] colorIndices, float drawScale)

Parameters

batch SpriteBatch

The sprite batch to use for drawing

element Element

The element to draw the roof on

colorIndices int[]

The color indices in this roof's Colors.

drawScale float

The scale to draw the roof with

GetGableOffset(Rectangle, Direction2, Point)

Returns the gable offset that Furniture attached to this roof should be displayed with. By default, this method returns an offset for roofs with the Gable Style.

public virtual int GetGableOffset(Rectangle area, Direction2 rotation, Point innerPos)

Parameters

area Rectangle

The area that the roof covers.

rotation Direction2

The roof's rotation.

innerPos Point

The position in the roof's area that the object sits on.

Returns

int

The gable offset that this roof should have, in half tiles.

GetPrice(Rectangle)

Returns the price of this roof type for the given area. This returns Price, multiplied by the area's size.

public virtual int GetPrice(Rectangle area)

Parameters

area Rectangle

The area of roofing to get the price for

Returns

int

The price of the area

Register(RoofType)

Registers a new roof type with the given settings into the Types registry

public static RoofType Register(RoofType type)

Parameters

type RoofType

The roof type to register

Returns

RoofType

The roof type passed, for chaining