Table of Contents

Class OpeningType

Namespace
TinyLife.World
Assembly
Tiny Life.dll

An opening is some sort of extrusion in a WallLike, like a window or a door. An opening type stores data that can be used to construct a Opening instance.

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

Constructors

OpeningType(string, TextureRegion, WallMode, int, ColorScheme, Func<OpeningType, int[], WallLike, Opening>, TextureRegion)

Creates a new opening type with the given settings.

public OpeningType(string name, TextureRegion textureRegion, WallMode wallMode, int price, ColorScheme color, Func<OpeningType, int[], WallLike, Opening> construct = null, TextureRegion icon = null)

Parameters

name string
textureRegion TextureRegion
wallMode WallMode
price int
color ColorScheme
construct Func<OpeningType, int[], WallLike, Opening>
icon TextureRegion

OpeningType(string, TextureRegion, WallMode, int, ColorScheme[], Func<OpeningType, int[], WallLike, Opening>, TextureRegion)

Creates a new opening type with the given settings

public OpeningType(string name, TextureRegion textureRegion, WallMode wallMode, int price, ColorScheme[] colors, Func<OpeningType, int[], WallLike, Opening> construct = null, TextureRegion icon = null)

Parameters

name string

The name

textureRegion TextureRegion

The texture to use for rendering

wallMode WallMode

The wall mode

price int

The price

colors ColorScheme[]

The color schemes for this opening

construct Func<OpeningType, int[], WallLike, Opening>

The function that is used for constructing an Opening from this opening type

icon TextureRegion

The build mode category icon of this object

Fields

Colors

The color schemes that opening instances can have when created from this type

public readonly ColorScheme[] Colors

Field Value

ColorScheme[]

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

Name

The name of this opening type

public readonly string Name

Field Value

string

Price

The price of this opening

public readonly int Price

Field Value

int

Types

A registry for all OpeningType instances from the game and mods. Use Register(OpeningType) to register custom opening types.

public static readonly ReadOnlyDictionary<string, OpeningType> Types

Field Value

ReadOnlyDictionary<string, OpeningType>

WallMode

The WallMode that Wall instances with this opening in it should use for rendering

public readonly WallMode WallMode

Field Value

WallMode

Methods

Construct(int[], WallLike)

Constructs a new Opening instance from this opening type

public Opening Construct(int[] colors, WallLike wall)

Parameters

colors int[]

The color indices to use

wall WallLike

The wall that this opening will be slotted into

Returns

Opening

A new opening instance based on this type

Draw(GameTime, SpriteBatch, Map, Point, Point, int, Vector2, bool, float, int[], Color?, float, Point)

Draws this opening in a wall

public void Draw(GameTime time, SpriteBatch batch, Map map, Point pos1, Point pos2, int floor, Vector2 drawPos, bool vertical, float scale, int[] colors, Color? overrideColor, float depthOffset = 0, Point textureOffset = default)

Parameters

time GameTime

The game's time

batch SpriteBatch

The sprite batch to render with

map Map

The map.

pos1 Point

The first position in the Positions array.

pos2 Point

The second position in the Positions array.

floor int

The floor.

drawPos Vector2

The position, in screen space, to draw at

vertical bool

Whether the underlying wall is vertical

scale float

The scale to render with

colors int[]

The color indices that should be used for rendering

overrideColor Color?

A color that this object should be rendered with, instead of its default color

depthOffset float

An offset that is optionally added to the draw depth.

textureOffset Point

An offset that should be applied to the texture region. This value is multiplied with the texture region's size.

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

Draws this opening in ui space rather than world space

public void DrawUi(Element e, SpriteBatch batch, GameTime time, Map map, int[] colors, float drawScale)

Parameters

e Element

The ui element to draw this opening onto

batch SpriteBatch

The sprite batch to use for drawing

time GameTime

The game time

map Map

The map.

colors int[]

The color indices to draw with

drawScale float

The scale to draw with. 0.3 by default.

Register(OpeningType)

Registers the given OpeningType to the Types registry

public static OpeningType Register(OpeningType type)

Parameters

type OpeningType

The type to register

Returns

OpeningType

The passed type, for chaining.