Class Wallpaper
A wallpaper is a single-instanced object that can be attached to a Wall, which makes the wall render a different texture. To register custom wallpapers, use Register(String, Int32, Dictionary<Point, TextureRegion>, Point, ColorScheme, TextureRegion, Nullable<Int32>, Type). Note that registered wallpapers need to use a texture generated by ApplyMasks(Texture2D, Int32, Int32, RuntimeTexturePacker, Action<Dictionary<Point, TextureRegion>>).
Inheritance
Implements
Inherited Members
Namespace: TinyLife.World
Assembly: Tiny Life.dll
Syntax
[JsonConverter(typeof(Wallpaper.Converter))]
public class Wallpaper : IPricedObject
Constructors
Wallpaper(String, String, Int32, Dictionary<Point, TextureRegion>, Point, Int32[], ColorScheme[], TextureRegion, Int32[])
Creates a new wallpaper with the given settings. To create an instance of a custom wallpaper class, use Register(String, Int32, Dictionary<Point, TextureRegion>, Point, ColorScheme, TextureRegion, Nullable<Int32>, Type).
Declaration
protected Wallpaper(string baseName, string name, int price, Dictionary<Point, TextureRegion> textures, Point textureRegion, int[] colors, ColorScheme[] colorSchemes, TextureRegion icon, int[] defaultColors)
Parameters
Type | Name | Description |
---|---|---|
System.String | baseName | |
System.String | name | |
System.Int32 | price | |
System.Collections.Generic.Dictionary<TKey, TValue><Microsoft.Xna.Framework.Point, MLEM.Textures.TextureRegion> | textures | |
Microsoft.Xna.Framework.Point | textureRegion | |
System.Int32[] | colors | |
ColorScheme[] | colorSchemes | |
MLEM.Textures.TextureRegion | icon | |
System.Int32[] | defaultColors |
Fields
BaseName
The name of this type of wallpaper. Whereas Name has the index of its color scheme appended to it, this one is just the type's name.
Declaration
public readonly string BaseName
Field Value
Type | Description |
---|---|
System.String |
Colors
The set of colors applied to this wallpaper instance. Each entry represents an index in the ColorSchemes of this wallpaper.
Declaration
public readonly int[] Colors
Field Value
Type | Description |
---|---|
System.Int32[] |
ColorSchemes
An array of ColorScheme that this wallpaper type uses. If this array has more than one entry, textures for the other layers will be gathered to the right of the texture region passed in the constructor.
Declaration
public readonly ColorScheme[] ColorSchemes
Field Value
Type | Description |
---|---|
ColorScheme[] |
DefaultColors
The colors that this wallpaper should have by default.
Declaration
public readonly int[] DefaultColors
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 wallpaper. This is comprised of the BaseName with its color scheme index attached to it.
Declaration
public readonly string Name
Field Value
Type | Description |
---|---|
System.String |
Price
The price of this wallpaper. Can be retrieved easily using GetPrice().
Declaration
public readonly int Price
Field Value
Type | Description |
---|---|
System.Int32 |
Wallpapers
The registry for all Wallpaper objects in the game and mods. Use Register(String, Int32, Dictionary<Point, TextureRegion>, Point, ColorScheme, TextureRegion, Nullable<Int32>, Type) to register custom wallpapers.
Declaration
public static readonly ReadOnlyDictionary<string, Wallpaper[]> Wallpapers
Field Value
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyDictionary<TKey, TValue><System.String, Wallpaper[]> |
Methods
Draw(GameTime, SpriteBatch, Vector2, WallMode, Boolean, Boolean, Single, Single, Boolean, Nullable<Color>)
Draws this wallpaper on the given wall with the given data.
Declaration
public virtual void Draw(GameTime time, SpriteBatch batch, Vector2 drawPos, WallMode mode, bool isDown, bool vertical, float scale, float depth, bool shadow, Color? overrideColor = null)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.GameTime | time | The current game time |
Microsoft.Xna.Framework.Graphics.SpriteBatch | batch | The sprite batch used for rendering |
Microsoft.Xna.Framework.Vector2 | drawPos | The position, in screen coordinates, that the wall should be drawn at |
WallMode | mode | The WallMode that the wall should be drawn with |
System.Boolean | isDown | Whether or not the wall is rendering with a reduced height |
System.Boolean | vertical | Whether or not the wall is vertical (or horizontal) in the world |
System.Single | scale | The scale that the wall should be rendered with |
System.Single | depth | The depth that the wall should be rendered with |
System.Boolean | shadow | Whether or not the shadow texture should be applied on top of the texture |
System.Nullable<T><Microsoft.Xna.Framework.Color> | overrideColor | A color that this object should be rendered with, instead of its default color |
DrawUi(Element, SpriteBatch, GameTime, Single)
Draws this wallpaper on the given MLEM.Ui.Elements.Element in ui space
Declaration
public virtual void DrawUi(Element e, SpriteBatch batch, GameTime time, float drawScale = 0.3F)
Parameters
Type | Name | Description |
---|---|---|
MLEM.Ui.Elements.Element | e | The element to draw on |
Microsoft.Xna.Framework.Graphics.SpriteBatch | batch | The batch to draw with |
Microsoft.Xna.Framework.GameTime | time | The current game time |
System.Single | drawScale | The scale to draw with. Defaults to 0.3. |
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 |
Register(String, Int32, Dictionary<Point, TextureRegion>, Point, ColorScheme, TextureRegion, Nullable<Int32>, Type)
Creates and registers a new wallpaper with the given settings.
Note that the textures
should be one generated using ApplyMasks(Texture2D, Int32, Int32, RuntimeTexturePacker, Action<Dictionary<Point, TextureRegion>>), as otherwise, graphical issues will occur.
Declaration
public static void Register(string name, int price, Dictionary<Point, TextureRegion> textures, Point textureRegion, ColorScheme color, TextureRegion icon = null, int? defaultColor = null, Type constructedType = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the wallpaper type |
System.Int32 | price | The price of a single wallpaper of this type |
System.Collections.Generic.Dictionary<TKey, TValue><Microsoft.Xna.Framework.Point, MLEM.Textures.TextureRegion> | textures | The texture that this wallpaper should use. This needs to have been generated using ApplyMasks(Texture2D, Int32, Int32, RuntimeTexturePacker, Action<Dictionary<Point, TextureRegion>>). |
Microsoft.Xna.Framework.Point | textureRegion | The top left texture region of this wallpaper (on the original texture, not the mask) |
ColorScheme | color | The color scheme of the wallpaper. |
MLEM.Textures.TextureRegion | icon | The build mode category icon of this object |
System.Nullable<T><System.Int32> | defaultColor | The color that this wallpaper should display with by default in the wallpaper tool. |
System.Type | constructedType | The System.Type that should be constructed to create this wallpaper. Defaults to Wallpaper. |
Register(String, Int32, Dictionary<Point, TextureRegion>, Point, ColorScheme[], TextureRegion, Int32[], Type)
Creates and registers a new wallpaper with the given settings.
Note that the textures
should be one generated using ApplyMasks(Texture2D, Int32, Int32, RuntimeTexturePacker, Action<Dictionary<Point, TextureRegion>>), as otherwise, graphical issues will occur.
Declaration
public static void Register(string name, int price, Dictionary<Point, TextureRegion> textures, Point textureRegion, ColorScheme[] colors, TextureRegion icon = null, int[] defaultColors = null, Type constructedType = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the wallpaper type |
System.Int32 | price | The price of a single wallpaper of this type |
System.Collections.Generic.Dictionary<TKey, TValue><Microsoft.Xna.Framework.Point, MLEM.Textures.TextureRegion> | textures | The texture that this wallpaper should use. This needs to have been generated using ApplyMasks(Texture2D, Int32, Int32, RuntimeTexturePacker, Action<Dictionary<Point, TextureRegion>>). |
Microsoft.Xna.Framework.Point | textureRegion | The top left texture region of this wallpaper (on the original texture, not the mask) |
ColorScheme[] | colors | The color schemes for each layer of the wallpaper. If there is more than one entry, additional layers will automatically be gathered to the right of the passed |
MLEM.Textures.TextureRegion | icon | The build mode category icon of this object |
System.Int32[] | defaultColors | The colors that this wallpaper should display with by default in the wallpaper tool. |
System.Type | constructedType | The System.Type that should be constructed to create this wallpaper. Defaults to Wallpaper. |