Table of Contents

Class ScreenObject

Namespace
TinyLife.Objects
Assembly
Tiny Life.dll

A furniture is an instance of a FurnitureType which is placed in the world, or in a PersonLike's hand. To register a custom furniture, use Register(TypeSettings).

public class ScreenObject : BreakableFurniture, IGenericDataHolder, IUpdatingObject
Inheritance
JsonTypeSafeGenericDataHolder
ScreenObject
Implements
IGenericDataHolder
Derived
Inherited Members
JsonTypeSafeGenericDataHolder.GetDataKeys()
Extension Methods

Constructors

ScreenObject(Guid, FurnitureType, int[], Map, Vector2, float)

Creates a new furniture instance. By default, this is done using Construct<T>(int[], Map, Vector2, float, Guid?).

public ScreenObject(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos, float floor)

Parameters

id Guid

The id to apply to the created furniture instance

type FurnitureType

The type to create an instance of

colors int[]

The colors to apply to the furniture

map Map

The map to create the furniture on

pos Vector2

The position that the furniture should have

floor float

The floor that this object is on.

Fields

DrawScreenContentOverrides

A set of overrides for which directions a given object should draw with which Microsoft.Xna.Framework.Graphics.SpriteEffects on, or whether it should draw there at all.

public static readonly Dictionary<FurnitureType, Func<Direction2, SpriteEffects?>> DrawScreenContentOverrides

Field Value

Dictionary<FurnitureType, Func<Direction2, SpriteEffects?>>

ScreenContentOverrides

A set of predicates and overrides that determine what screen content textures certain furniture items should display. If your furniture item has a specific screen width, height or location, you can add an item to this collection that determines the names of the textures used.

public static readonly List<(Func<Furniture, bool> Predicate, Func<Furniture, string, string> Override)> ScreenContentOverrides

Field Value

List<(Func<Furniture, bool> Predicate, Func<Furniture, string, string> Override)>

Examples

For example, the OldComputer adds the following entry:

(t => t.Type == FurnitureType.OldComputer, (_, s) => $"Square{s}")

Properties

Content

The current content of this screen object's screen. The screen content set here determines the texture to display on this screen object's screen. To set this value, use TurnOn(string) and TurnOff().

[DataMember]
public string Content { get; }

Property Value

string

IsOn

A property that determines whether this screen object is currently on. A screen object is on if it has a current Content.

public virtual bool IsOn { get; }

Property Value

bool

Methods

Draw(GameTime, object, Vector2, float, Vector2, Color?, Direction2, int[], float, bool, ParentInfo, float, List<Item>)

Draws this furniture in the world with the given settings. This is a more generalized version of Draw(GameTime, object, Vector2, Color?, List<Item>)

public override void Draw(GameTime time, object batch, Vector2 pos, float floor, Vector2 drawPos, Color? overrideColor, Direction2 rotation, int[] colors, float drawScale, bool pivot, ParentInfo parent, float depthOffset, List<StaticSpriteBatch.Item> items)

Parameters

time GameTime

The game time

batch object

The sprite batch to draw with, which is either a Microsoft.Xna.Framework.Graphics.SpriteBatch or MLEM.Graphics.StaticSpriteBatch.

pos Vector2

The position, in world space, that the furniture is at

floor float

The floor to draw at.

drawPos Vector2

The position, in draw space, to draw the furniture at

overrideColor Color?

An optional color to override the default colors of the furniture

rotation Direction2

The rotation that the furniture should be drawn with, which is usually derived from TextureRotation.

colors int[]

The colors to draw the furniture with

drawScale float

The scale to draw the furniture with

pivot bool

Whether or not to move the furniture by its texture's pivot point

parent ParentInfo

The object that this furniture is latched on to, or null if there is none

depthOffset float

A value that is added onto the calculated depth of the object

items List<StaticSpriteBatch.Item>

A list of sprite batch items that items should be added to if the batch is a MLEM.Graphics.StaticSpriteBatch.

TurnOff()

Turns this screen object off

public virtual void TurnOff()

TurnOn(string)

Turns this screen object on, setting its Content to the given content. The screen content set here determines the texture to display on this screen object's screen.

public virtual void TurnOn(string content)

Parameters

content string