Class RoofType
A roof type stores settings and configurations for Roof instances. To register a new roof type, use Register(RoofType).
[JsonConverter(typeof(MigratingStaticJsonConverter<RoofType>), new object[] { typeof(RoofType), "PrivateTypes", true })]
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
stringThe name that this roof type should have
price
intThe price for a 1x1 area of this roof type
color
ColorSchemeThe color scheme that this roof type can have
style
RoofStyleThe RoofStyle that this roof has
textures
IReadOnlyDictionary<Point, TextureRegion>The textures that the
textureRegion
should read from.textureRegion
PointThe initial, top-left texture region of this roof, which will be gathered from
textures
.icon
TextureRegionThe icon that this roof should have in build mode
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[] colors, RoofStyle style, IReadOnlyDictionary<Point, TextureRegion> textures, Point textureRegion, TextureRegion icon = null)
Parameters
name
stringThe name that this roof type should have
price
intThe price for a 1x1 area of this roof type
colors
ColorScheme[]The color scheme that this roof type can have
style
RoofStyleThe RoofStyle that this roof has
textures
IReadOnlyDictionary<Point, TextureRegion>The textures that the
textureRegion
should read from.textureRegion
PointThe initial, top-left texture region of this roof, which will be gathered from
textures
.icon
TextureRegionThe icon that this roof should have in build mode
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
stringThe name that this roof type should have
price
intThe price for a 1x1 area of this roof type
colors
ColorSettingsThe color scheme that this roof type can have
style
RoofStyleThe RoofStyle that this roof has
textures
IReadOnlyDictionary<Point, TextureRegion>The textures that the
textureRegion
should read from.textureRegion
PointThe initial, top-left texture region of this roof, which will be gathered from
textures
.icon
TextureRegionThe icon that this roof should have in build mode
Fields
Colors
The color settings that this roof uses.
public readonly ColorSettings Colors
Field Value
FlatSheetMetal
public static readonly RoofType FlatSheetMetal
Field Value
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
Name
The name of this roof type, which is used to store it to disk
public readonly string Name
Field Value
OldStyleFlat
public static readonly RoofType OldStyleFlat
Field Value
Price
The price of a 1x1 rectangle of this roof type
public readonly int Price
Field Value
RoundedShingles
public static readonly RoofType RoundedShingles
Field Value
SheetMetal
public static readonly RoofType SheetMetal
Field Value
SquareShingles
public static readonly RoofType SquareShingles
Field Value
Style
The RoofStyle that this roof has. If Draw(GameTime, SpriteBatch, Map, Rectangle, int, Direction2, int[], Wallpaper, int, float, Color?, bool) 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
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
Types
A registry of all of the RoofType instances that are currently registered
public static readonly ReadOnlyDictionary<string, RoofType> Types
Field Value
Methods
Draw(GameTime, SpriteBatch, Map, Rectangle, int, Direction2, int[], Wallpaper, int, float, Color?, bool)
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, int roofHeightOffset, float depthOffset = 0, Color? overrideColor = null, bool isInWorld = true)
Parameters
time
GameTimeThe game's current time
batch
SpriteBatchThe sprite batch to use for drawing
map
MapThe map to draw on
area
RectangleThe area the roof covers
floor
intThe floor the roof is on.
rotation
Direction2The roof's rotation
colorIndices
int[]The color indices in this roof's Colors.
wallpaper
WallpaperThe wallpaper applied to the roof
roofHeightOffset
intAn offset that is added onto the GetGableOffset(Rectangle, Direction2, Point) for the roof.
depthOffset
floatThe 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.
isInWorld
boolWhether this roof is currently in the world (or being drawn as a preview).
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
SpriteBatchThe sprite batch to use for drawing
element
ElementThe element to draw the roof on
colorIndices
int[]The color indices in this roof's Colors.
drawScale
floatThe 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
RectangleThe area that the roof covers.
rotation
Direction2The roof's rotation.
innerPos
PointThe 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
RectangleThe 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
RoofTypeThe roof type to register
Returns
- RoofType
The roof type passed, for chaining