Table of Contents

Class Furniture

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 Furniture : MapObject, IGenericDataHolder
Inheritance
JsonTypeSafeGenericDataHolder
Furniture
Implements
IGenericDataHolder
Derived
Inherited Members
JsonTypeSafeGenericDataHolder.GetDataKeys()
Extension Methods

Constructors

Furniture(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 Furniture(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

AppliedUpgrades

A collection of the upgrades that are currently applied to this furniture upgrade. To query and modify this collection effectively, use ApplyUpgrade(AppliedUpgrade), GetAppliedUpgrade(Upgrade) and HasFullUpgrade(Upgrade).

[DataMember]
public readonly Dictionary<string, AppliedUpgrade> AppliedUpgrades

Field Value

Dictionary<string, AppliedUpgrade>

Colors

The indices of the colors that this furniture has. Refer to Colors for the actual colors that these indices represent.

[DataMember]
public int[] Colors

Field Value

int[]

CustomPrice

An optional custom price that this furniture item has over its regular price (GetPrice()). If this field has a value, the regularly calculated price from GetPrice() will be ignored and this value will be used as the object's price instead.

[DataMember(EmitDefaultValue = false)]
public float? CustomPrice

Field Value

float?

DevaluedThroughUse

A field that gets set to true in ActionUpdate(Action, GameTime, TimeSpan, float, bool). If this value is true, the GetPrice() of this object is greatly reduced.

[DataMember(EmitDefaultValue = false)]
public bool DevaluedThroughUse

Field Value

bool

IsStatic

A field that is true for objects that are part of the exported base map that the current map is created from

[DataMember(EmitDefaultValue = false)]
public bool IsStatic

Field Value

bool

Quality

The quality of this object, which defaults to null, meaning no quality. The quality is used by Food, Painting, and items crafted on the woodworking table. If this value is nonnull, the quality is displayed in the furniture item's description (GetDescription(List<string>, bool)) and it influences the furniture's price (GetPrice()) using GetPriceModifier(Quality).

[DataMember(EmitDefaultValue = false)]
public Quality? Quality

Field Value

Quality?

Random

A Random instance that can be used by furniture items. This value has the default seed.

protected static readonly Random Random

Field Value

Random

Rotation

The current rotation of this furniture. Since furniture has a wide variety of looks, the specific value of the rotation doesn't necessarily have much practical meaning.

[DataMember]
public Direction2 Rotation

Field Value

Direction2

Type

The FurnitureType that this furniture has

[DataMember]
public readonly FurnitureType Type

Field Value

FurnitureType

Properties

AreUtilitiesDisabled

Returns whether utilities are disabled on the current lot. This is a shorthand for AreUtilitiesDisabled(TimeSpan?).

public bool AreUtilitiesDisabled { get; }

Property Value

bool

Area

A MLEM.Misc.RectangleF that represents the area that this furniture piece is currently taking up, based on its GetSize(Direction2) and its Position

public RectangleF Area { get; }

Property Value

RectangleF

AttachedWall

The Wall that this object is attached to. Note that this will return a wall regardless of whether this object is actually attached to a wall, or is even a wall-hanging object.

public Wall AttachedWall { get; }

Property Value

Wall

CanBeDirty

A property that queries whether this object can be made dirty. If this property is false, Dirty will not automatically be set to true.

public bool CanBeDirty { get; }

Property Value

bool

CoveredTiles

The tiles that are currently being covered by this furniture item. This differs from Area in that it calculates the full covered tiles in integer coordinates, rather than the exact area covered by the object.

public Rectangle CoveredTiles { get; }

Property Value

Rectangle

Creator

The PersonLike that created this object in some capacity. This value is based on the underlying CreatorId.

public PersonLike Creator { get; }

Property Value

PersonLike

CreatorId

The Guid of the PersonLike that created this object in some capacity. This value defaults to Empty, meaning no creator. To easily access the creator PersonLike, see Creator.

[DataMember(EmitDefaultValue = false)]
public Guid CreatorId { get; }

Property Value

Guid

Dirty

Whether this object is currently dirty. If CanBeDirty is false, this field is usually unused.

public bool Dirty { get; set; }

Property Value

bool

DisplayName

Returns the display name of this furniture item. By default, GetDisplayName(Furniture) is returned.

public virtual string DisplayName { get; }

Property Value

string

This furniture item's display name.

HideFromDraw

Returns whether this object should currently be hidden from drawing.

public bool HideFromDraw { get; }

Property Value

bool

ParentFurniture

The Furniture that this furniture is currently latched on to. If this value is non-null, ParentObjectSpot returns the object spot that this furniture is in.

public Furniture ParentFurniture { get; }

Property Value

Furniture

ParentFurnitureId

The Id of this furniture's ParentFurniture.

[DataMember(EmitDefaultValue = false)]
public Guid ParentFurnitureId { get; }

Property Value

Guid

ParentInfo

Returns a ParentInfo for this object in its current context. By default, this method returns default, and Furniture returns a ParentInfo based on its current attachments.

public override ParentInfo ParentInfo { get; }

Property Value

ParentInfo

ParentObjectSpot

The ObjectSpot that this furniture is currently in. If this value is non-null, ParentFurniture returns the furniture that this object spot belongs to.

public ObjectSpot ParentObjectSpot { get; }

Property Value

ObjectSpot

ParentObjectSpotId

The index of this furniture's ParentObjectSpot on this furniture's ParentFurniture.

[DataMember(EmitDefaultValue = false)]
public int ParentObjectSpotId { get; }

Property Value

int

Visibility

Returns the visibility settings of this object. By default, WhenVisible is returned. For Furniture, its Visibility is returned instead.

public override Visibility Visibility { get; }

Property Value

Visibility

This object's visibility settings

VisualRotation

The rotation that this furniture item currently has from the camera's perspective. This is a combination of Rotation, CameraRotation and GetBestRotationForDrawing(Direction2).

public Direction2 VisualRotation { get; }

Property Value

Direction2

Methods

ActionUpdate(Action, GameTime, TimeSpan, float, bool)

This method is called when an Action that this object is involved in updates, which is every Microsoft.Xna.Framework.Game.Update(Microsoft.Xna.Framework.GameTime) frame. Note that this includes actions that are underlying (see Parent) and actions that aren't fully in progress yet (FullyInProgress). This object counts as involved in the action if its ActionInfo's GetInvolvedObjects<T>(ObjectCategory, bool, bool) includes this object. In general, the base method should be called for Furniture objects, since it sets deals with Dirty objects.

public override void ActionUpdate(Action action, GameTime time, TimeSpan passedInGame, float speedMultiplier, bool isAuxiliary)

Parameters

action Action

The action

time GameTime

The current game time

passedInGame TimeSpan

The amount of time that has passed, in game time

speedMultiplier float

The game speed multiplier, which represents how fast things should happen, which is usually determined by Speed

isAuxiliary bool

Whether this object counts as an auxiliary object. If this value is false, the object is th eGetActionObject<T>(bool)

AddChild(Furniture, Direction2, Vector2?)

Adds a child to this furniture, setting its parent (SetParent(Furniture, ObjectSpot)) to this furniture and adding it to this furniture's Map. The object spot selected is the first available object spot. Note that the given item has to be on the same map as this furniture item's Map when this method is called.

public bool AddChild(Furniture item, Direction2 rotation, Vector2? position = null)

Parameters

item Furniture

The furniture to add as the child

rotation Direction2

The desired rotation of the child furniture. If the child furniture does not support the given rotation, FurnitureType.GetBestRotation is used automatically.

position Vector2?

The position that the object spot to add this child to should be closest too. If null, no position will be preferred. Defaults to null.

Returns

bool

If there was a free object spot to add the furniture to

AddChild<T>(FurnitureType, Direction2, int[], Guid?, Vector2?)

Adds a child to this furniture, setting its parent (SetParent(Furniture, ObjectSpot)) to this furniture.

public T AddChild<T>(FurnitureType type, Direction2 rotation, int[] colors = null, Guid? id = null, Vector2? position = null) where T : Furniture

Parameters

type FurnitureType

The type of furniture to construct as the child

rotation Direction2

The desired rotation of the child furniture. If the child furniture does not support the given rotation, FurnitureType.GetBestRotation is used automatically.

colors int[]

The colors that the child should have

id Guid?

The id that the child should have, random by default

position Vector2?

The position that the object spot to add this child to should be closest too. If null, no position will be preferred. Defaults to null.

Returns

T

The child that was added, or null if there is no space for it.

Type Parameters

T

The type of furniture that the child is

ApplyUpgrade(AppliedUpgrade)

Adds the given AppliedUpgrade to this furniture item's collection of AppliedUpgrades and invokes the OnAppliedUpgrade event.

public virtual bool ApplyUpgrade(AppliedUpgrade upgrade)

Parameters

upgrade AppliedUpgrade

The upgrade to apply.

Returns

bool

Whether the upgrade was successfully applied. If this is false, it means the upgrade is either not compatible, or already applied.

CanExecuteAction(ActionType, ActionInfo, bool, bool)

Returns whether the given action can be executed at this map object. By default, this method returns Valid for all actions, but Furniture additionally returns custom results based on whether the furniture is Broken or based on AreUtilitiesDisabled.

public override CanExecuteResult CanExecuteAction(ActionType action, ActionInfo info, bool automatic, bool isAuxiliary)

Parameters

action ActionType

The action that is querying whether it can be executed.

info ActionInfo

The action info.

automatic bool

Whether the action was started automatically.

isAuxiliary bool

Whether this object is auxiliary (or the main action object).

Returns

CanExecuteResult

Whether this object allows the action to be executed at it.

Draw(GameTime, object, Vector2, Color?, List<Item>)

Draws this object on the current Map, at the current Position. To draw a map object while invoking all the required events, use DoDraw(GameTime, object, Color?, bool, List<Item>).

public override sealed void Draw(GameTime time, object batch, Vector2 drawPos, Color? overrideColor, List<StaticSpriteBatch.Item> items)

Parameters

time GameTime

The current time

batch object

The sprite batch to use for drawing, which is either a Microsoft.Xna.Framework.Graphics.SpriteBatch or MLEM.Graphics.StaticSpriteBatch.

drawPos Vector2

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

overrideColor Color?

The color that should be used instead of this object's actual color. If null, the object's regular color should be used.

items List<StaticSpriteBatch.Item>

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

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 virtual 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.

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

Draws this furniture in a ui context, rather than a world context. Scale is determined based on the element that is passed.

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

Parameters

time GameTime

The current game time

batch SpriteBatch

The sprite batch to draw with

element Element

The element to calculate scaling based on

drawScale float

The scale to draw the furniture with

colors int[]

The colors to draw the furniture with

GetActionSpotInfo(PersonLike, ActionSpot, Direction2)

Returns a ActionInfo that corresponds to the given ActionSpot and rotation

public ActionInfo GetActionSpotInfo(PersonLike person, ActionSpot spot, Direction2 direction = Direction2.None)

Parameters

person PersonLike

The person to query free action spots for

spot ActionSpot

The action spot to return an info for

direction Direction2

The direction to offset the ActionLocation by. Defaults to MLEM.Misc.Direction2.None.

Returns

ActionInfo

A new action info with the given settings

GetAiPriority(PersonLike, ObjectCategory)

Returns an integer that represents a priority for the PersonAi's interaction with this object. A higher priority means that this object will be picked over other objects (with lower priority). The default return value is 0, meaning that no special priority is assigned to this object. For any Furniture with the SingleBed or DoubleBed category that is the person's LastBedSleptIn, 10 is returned. This is invoked by a person in GetAiPriorityForObject(MapObject, ObjectCategory) with additional events being invoked.

public override float GetAiPriority(PersonLike person, ObjectCategory categories)

Parameters

person PersonLike

The person whose AI is attempting to interact with this object

categories ObjectCategory

The categories that are relevant for the ai interaction

Returns

float

This object's priority

GetAppliedUpgrade(Upgrade)

Returns the AppliedUpgrade instance that this furniture item has for the given Upgrade. If the upgrade is not applied, null is returned.

public virtual AppliedUpgrade GetAppliedUpgrade(Upgrade upgrade)

Parameters

upgrade Upgrade

The upgrade to query.

Returns

AppliedUpgrade

The applied upgrade, or null if the upgrade is not applied.

GetCategories(PersonLike)

Returns a set of ObjectCategory flags that this object has, based on the given PersonLike.

public override ObjectCategory GetCategories(PersonLike person)

Parameters

person PersonLike

The person to query categories for

Returns

ObjectCategory

A set of categories that this object has

GetChildren<T>()

Returns a list of all of the children of this furniture. Children are all furnitures in the world that have their ParentFurniture set to this furniture instance.

public IEnumerable<T> GetChildren<T>() where T : MapObject

Returns

IEnumerable<T>

A list of this furniture's children

Type Parameters

T

GetDebugLines(GameImpl, List<string>)

Returns the debug lines that should be displayed in Debug when hovering over this object. By default, OnGetDebugLines is invoked, and the id and position of this object are appended to the list of lines.

public override void GetDebugLines(GameImpl game, List<string> lines)

Parameters

game GameImpl

The game.

lines List<string>

The list of lines to append debug lines to.

GetDecorativeRating(Room)

Returns the decorative rating of this object in the given room. By default, the underlying Type's DecorativeRating, influeced by whether this object is Dirty, is returned.

public virtual float GetDecorativeRating(Room room)

Parameters

room Room

The room that the object is in, or null if it is not in a room at all

Returns

float

The decorative rating of this object

GetDescription(List<string>, bool)

This method allows adding a set of strings to the description list that get displayed when the object is hovered over in the build mode or household storage UIs. By default, this method adds various strings related to the ElectricityRating, Quality, Creator, and also invokes the OnGetDescription event.

public virtual void GetDescription(List<string> description, bool forHoverInfo)

Parameters

description List<string>

The description to add to.

forHoverInfo bool

Whether this method is being called by GetHoverInfo(Tooltip) (or by build mode).

GetDirty(PersonLike, TimeSpan)

Causes this object to get "more dirty" by increasing a timer and randomly, based on the amount of time that the timer has, turns Dirty to true. If this object cannot be dirty (CanBeDirty), or it is already Dirty, this method has no effect. By default, this method is called in ActionUpdate(Action, GameTime, TimeSpan, float, bool) every update frame if this object isn't already Dirty.

public virtual void GetDirty(PersonLike person, TimeSpan passedInGame)

Parameters

person PersonLike

The person who is responsible for making this object more dirty.

passedInGame TimeSpan

The amount of time that should be simulated in game.

GetEfficiencyModifier(PersonLike, ActionInfo, bool, SkillType, float)

Returns the efficiency modifier that this object multiplies the person's productivity with. This method is automatically called in GetEfficiencyModifier(float, ActionInfo, SkillType, float). This action is invoked for all GetInvolvedObjects<T>(ObjectCategory, bool, bool) of the passed ActionInfo. By default, this method returns 1, meaning the person's efficiency will not be influenced.

public override float GetEfficiencyModifier(PersonLike person, ActionInfo info, bool isAuxiliary, SkillType skill, float levelModifier)

Parameters

person PersonLike

The person whose efficiency should be influenced

info ActionInfo

The action info

isAuxiliary bool

Whether this object is auxiliary (or the main action object)

skill SkillType

The skill that should influence the efficiency

levelModifier float

The level modifier for the skill

Returns

float

The efficiency modifier for this object

GetFreeActionSpot(PersonLike, ObjectCategory)

Returns the first free action spot from GetFreeActionSpots(PersonLike, ObjectCategory).

public (ActionSpot Spot, Direction2 Dir) GetFreeActionSpot(PersonLike person, ObjectCategory context = null)

Parameters

person PersonLike

The person to query free action spots for

context ObjectCategory

The object category that this action spot needs to have

Returns

(ActionSpot Spot, Direction2 Dir)

A free action spot and the direction it's free in, or an empty tuple if there is no free action spot

GetFreeActionSpotInfos(PersonLike, ObjectCategory)

public override IEnumerable<ActionInfo> GetFreeActionSpotInfos(PersonLike person, ObjectCategory context = null)

Parameters

person PersonLike
context ObjectCategory

Returns

IEnumerable<ActionInfo>

GetFreeActionSpots(PersonLike, ObjectCategory)

Returns a list of ActionSpot instances that are part of this furniture, which are considered free. Free, in this instance, is any spot that has the given category and is not currently occupied by another person.

public IEnumerable<(ActionSpot Spot, Direction2 Dir)> GetFreeActionSpots(PersonLike person, ObjectCategory context = null)

Parameters

person PersonLike

The person to query free action spots for

context ObjectCategory

The object category that this action spot needs to have. Note that, if this is null, the spots' CategoryRestriction will not be applied.

Returns

IEnumerable<(ActionSpot Spot, Direction2 Dir)>

A set of action spots and the directions which they're free in

GetFreeObjectSpot(FurnitureType, Vector2?)

Returns the first free ObjectSpot on this furniture. Free, in this case, is any object spot that isn't already occupied by a different furniture.

public ObjectSpot GetFreeObjectSpot(FurnitureType type, Vector2? position = null)

Parameters

type FurnitureType

The furniture type to find a free object spot for

position Vector2?

The position that the object spot should be closest too. If null, no position will be preferred. Defaults to null.

Returns

ObjectSpot

A free object spot, or null if there is none

GetHoverInfo(Tooltip)

Allows adding a set of paragraphs and other ui elements to the given tooltip, which is then displayed when this object is hovered over using the cursor in the world. By default, this method raises OnGetHoverInfo for MapObject, and adds additional information for Furniture and PersonLike.

public override void GetHoverInfo(Tooltip tooltip)

Parameters

tooltip Tooltip

The tooltip that will be displayed.

GetOccupants(ObjectCategory, bool)

Returns a set of PersonLike instances that are currently occupying any ActionSpot on this furniture item in some way.

public IEnumerable<PersonLike> GetOccupants(ObjectCategory context = null, bool visualOnly = false)

Parameters

context ObjectCategory

The context for the ActionSpot to support for it to be included in the search. Note that, if this is null, the spots' CategoryRestriction will not be applied.

visualOnly bool

Whether only occupants that occupy a spot visually, using VisuallyOccupiedSpot, should be returned.

Returns

IEnumerable<PersonLike>

A set of people that are currently occupying this furniture item in some way.

GetPrice()

Returns the price of this furniture item, including its CustomPrice or its Type's base price, whether it was devalued through use, whether it is dirty, its Quality, and more.

public virtual float GetPrice()

Returns

float

This furniture item's price.

GetRestoreNeedModifier(PersonLike, ActionInfo, bool, NeedType)

Returns the modifier that this object multiplies the person's restored need with. This method is automatically called in RestoreNeed(NeedType, float, ActionInfo, float). This action is invoked for all GetInvolvedObjects<T>(ObjectCategory, bool, bool) of the passed ActionInfo. By default, this method returns 1, meaning the need restoration modifier will not be influenced.

public override float GetRestoreNeedModifier(PersonLike person, ActionInfo info, bool isAuxiliary, NeedType type)

Parameters

person PersonLike

The person whose need restoration should be influenced.

info ActionInfo

The action info.

isAuxiliary bool

Whether this object is auxiliary (or the main action object).

type NeedType

The type of need that is being restored.

Returns

float

The need restoration modifier for this object.

GetRoofingInTheWay(Vector2, int, Direction2, float, ICollection<Roof>)

Returns a set of roofing that would be in the way if this furniture type was placed at the given position with the given rotation. Note that, if this furniture type does not have the ObstructedByRoofs category, no roofs will be returned.

public virtual IEnumerable<Roof> GetRoofingInTheWay(Vector2 pos, int floor, Direction2 rotation, float distanceFromObstructions = 0, ICollection<Roof> possibleAdditionalRoofs = null)

Parameters

pos Vector2

The position that the furniture should be placed at, or is already at.

floor int

The floor that the furniture should be placed at, or is already at.

rotation Direction2

The rotation that the furniture should have

distanceFromObstructions float

The maximum distance from obstructions.

possibleAdditionalRoofs ICollection<Roof>

A set of roofs that have not been placed yet, but might also be in the way.

Returns

IEnumerable<Roof>

A set of roofing that would be in the way

GetWallsInTheWay<T>(Vector2, float, Direction2, float, ICollection<WallLike>)

Returns a set of walls that would be in the way if this furniture type was placed at the given position with the given rotation

public virtual IEnumerable<T> GetWallsInTheWay<T>(Vector2 pos, float floor, Direction2 rotation, float distanceFromObstructions = 0, ICollection<WallLike> possibleAdditionalWalls = null) where T : WallLike

Parameters

pos Vector2

The position that the furniture should be placed at

floor float

The floor to query.

rotation Direction2

The rotation that the furniture should have

distanceFromObstructions float

The maximum distance from obstructions.

possibleAdditionalWalls ICollection<WallLike>

A set of walls that have not been placed yet, but might also be in the way.

Returns

IEnumerable<T>

A set of walls that would be in the way

Type Parameters

T

HasFullUpgrade(Upgrade)

Returns whether this furniture item has a Upgrade applied that also has a Progress of 1. This method should be used to check for whether an upgrade should currently have an effect on a furniture item.

public virtual bool HasFullUpgrade(Upgrade upgrade)

Parameters

upgrade Upgrade

The upgrade to query.

Returns

bool

Whether the upgrade is fully applied.

Intersects(RectangleF)

Returns whether this map object intersects with the given rectangle. This is used for GetObjects<T>(RectangleF)

public override bool Intersects(RectangleF rectangle)

Parameters

rectangle RectangleF

The area that should be checked for

Returns

bool

true if this object intersects with the given rectangle

IsFreeSpot(Point)

Returns whether a PersonLike should be allowed to occupy or pass the given position, which is contained in this object's intersection area (Intersects(RectangleF)). By default, Furniture objects return whether they have the NonColliding category, and all other objects return true. Note that, if this object moves, MarkDirtyForPathfinding(Point, int) should be invoked for its previous and resulting Position.

public override bool IsFreeSpot(Point position)

Parameters

position Point

The position whose path cost modifier is being calculated.

Returns

bool

Whether a PersonLike can occupy the given position.

ModifyActionCategories(ActionType, ActionInfo, bool, List<string>)

A method that allows changing the Categories of an action when displaying it in the ring menu. This is used by objects like the LandlinePhone to remove the "Phone..." category if the action is not invoked on Self.

public override void ModifyActionCategories(ActionType type, ActionInfo info, bool isAuxiliary, List<string> categories)

Parameters

type ActionType

The action type.

info ActionInfo

The action info.

isAuxiliary bool

Whether this object is auxiliary.

categories List<string>

The categories.

MoveToMap(Map, Vector2, float)

Moves this object to the given map, changing the current Map in the process.

public override bool MoveToMap(Map map, Vector2 position, float floor)

Parameters

map Map

The map to move to.

position Vector2

The position on the new map to move to.

floor float

The floor to move to.

Returns

bool

Whether moving to the map was successful, which is false if this object is already on the map.

NotifyNeighbors()

Notifies all of the neighboring Furniture objects of a change by calling their OnNeighborChanged(Furniture) methods. This is used by things like fences, which change their orientation if their neighbors are added or removed.

public void NotifyNeighbors()

OnActionCompleted(Action, CompletionType, bool)

This method is called when an Action that this object is involved in is completed. Note that this includes actions that are underlying (see Parent). This object counts as involved in the action if its ActionInfo's GetInvolvedObjects<T>(ObjectCategory, bool, bool) includes this object. In general, the base method should be called for Furniture objects, since it sets DevaluedThroughUse.

public override void OnActionCompleted(Action action, CompletionType type, bool isAuxiliary)

Parameters

action Action

The action

type CompletionType

The type of the action's completion

isAuxiliary bool

Whether this object counts as an auxiliary object. If this value is false, the object is th eGetActionObject<T>(bool)

OnAdded()

This method is called when this object is added to a Map. By default, it does nothing.

public override void OnAdded()

OnNeighborChanged(Furniture)

This method gets called when any neighboring furniture changes in NotifyNeighbors(). The neighboring furniture is passed. By default, this method does nothing, so calling base is not necessary.

protected virtual void OnNeighborChanged(Furniture neighbor)

Parameters

neighbor Furniture

The neighbor furniture that changed

OnPlacedInBuildMode(FurniturePlacer, bool)

This method is called when this furniture item is placed using the FurniturePlacer. It can be used to award emotion modifiers or other information based on whether this item was freshlyBought. By default, this method awards emotion modifiers based on the CurrentLot's Household's members' PersonalityType.

public virtual void OnPlacedInBuildMode(FurniturePlacer placer, bool freshlyBought)

Parameters

placer FurniturePlacer

The furniture placer used to place this object.

freshlyBought bool

Whether this item was freshly bought (or placed from storage).

OnPositionChanged(Vector2, float)

A method that is automatically called when this object's Position changes. By default, this method is overriden in Furniture to call MarkDirtyForPathfinding(Vector2, float). Note that this method is also called if this object is not in the world (IsInWorld).

protected override void OnPositionChanged(Vector2 lastPosition, float lastFloor)

Parameters

lastPosition Vector2

This object's previous position.

lastFloor float

This object's previous floor.

OnRandomQuality(PersonLike, ActionInfo, bool, SkillType, Random, bool, Dictionary<Quality, float>)

A method that is invoked when a random quality is determined based on an action and skill in GetRandomQuality(PersonLike, Random, ActionInfo, bool, IEmotionSource, bool). This method is invoked for all GetInvolvedObjects<T>(ObjectCategory, bool, bool) of the passed ActionInfo.

public override void OnRandomQuality(PersonLike person, ActionInfo info, bool isAuxiliary, SkillType skill, Random random, bool alwaysAllowAverage, Dictionary<Quality, float> weights)

Parameters

person PersonLike

The person.

info ActionInfo

The action info.

isAuxiliary bool

Whether this object is auxiliary (or the main action object).

skill SkillType

The skill.

random Random

The Random instance used for determining the quality.

alwaysAllowAverage bool

Whether the Average quality should always be available as an option.

weights Dictionary<Quality, float>

The weights for each quality. This collection contains keys for all Quality values, and entries should not be removed, only modified.

OnRemoved()

This method is called when this object is removed from a Map. By default, it does nothing.

public override void OnRemoved()

A compound helper method that calls RemoveObject(MapObject) and UnlinkParentsAndChildren(). For furniture that is being removed from the world entirely, this method is usually preferred over RemoveObject(MapObject).

public void RemoveAndUnlink()

RemoveChild(Furniture)

Removes the given child from the world and sets its ParentFurniture and ParentObjectSpot to their default values, unlinking it from this object

public bool RemoveChild(Furniture child)

Parameters

child Furniture

The child to remove

Returns

bool

Whether the object was actually a child of this furniture (true) or not (false)

ResetToStatic(bool, bool)

Resets this map object to a static state when the Map that is on is exported.

public override bool ResetToStatic(bool thorough, bool custom)

Parameters

thorough bool

Whether a more thorough reset is expected, which usually involves normalizing additional data and cleaning up player data entirely.

custom bool

Whether the static reset is happening in a custom context, that is, a Household being exported normally rather than through cheats, or a custom Map being exported.

Returns

bool

Whether this object should stay on the map after the static reset. If false is returned, this object is removed.

SetChild(ObjectSpot, Furniture, Direction2)

Sets the child element in the given object spot to the given furniture. Note that the given item has to be on the same map as this furniture item's Map when this method is called.

public void SetChild(ObjectSpot spot, Furniture item, Direction2 rotation)

Parameters

spot ObjectSpot

The spot to add the child to

item Furniture

The furniture to add to the spot

rotation Direction2

The desired rotation of the child furniture. If the child furniture does not support the given rotation, FurnitureType.GetBestRotation is used automatically.

SetChild<T>(ObjectSpot, FurnitureType, Direction2, int[], Guid?)

Sets the child element in the given object spot to the given furniture and adds it to this furniture's Map.

public T SetChild<T>(ObjectSpot spot, FurnitureType type, Direction2 rotation, int[] colors = null, Guid? id = null) where T : Furniture

Parameters

spot ObjectSpot

The spot to add the child to

type FurnitureType

The type of furniture to construct as the child

rotation Direction2

The desired rotation of the child furniture. If the child furniture does not support the given rotation, FurnitureType.GetBestRotation is used automatically.

colors int[]

The colors that the child should have

id Guid?

The id that the child should have, random by default

Returns

T

Type Parameters

T

SetCreator(PersonLike, bool)

Sets the CreatorId (and thus, the Creator) of this furniture item, optionally triggering goals that react to the FurnitureCreated goal trigger

public virtual void SetCreator(PersonLike person, bool triggerGoals = true)

Parameters

person PersonLike

The person to set as the creator

triggerGoals bool

Whether FurnitureCreated goal triggers should be triggered

SetNewId(IEnumerable<Furniture>)

Assigns a new, randomly generated Guid to this furniture item's Id and additionally updates the ParentFurniture relation of any objects passed that might be children of this object. When assigning a new id, it usually makes sense to pass all of the objects in this furniture item's vicinity, or all of the objects that might otherwise be attached to it. Note that objects which are passed as possibleChildren that aren't children of this object are ignored.

public void SetNewId(IEnumerable<Furniture> possibleChildren = null)

Parameters

possibleChildren IEnumerable<Furniture>

A set of furniture items that might (but do not have to be) children of this furniture

SetParent(Furniture, ObjectSpot)

Sets the parent of this furniture, changing its Position and settings its ParentObjectSpot value. Note that this does not add the object to the map (AddObject(MapObject)). When modifying furniture in the world, it is preferred to use SetChild(ObjectSpot, Furniture, Direction2) on the parent furniture instead.

public void SetParent(Furniture parent, ObjectSpot spot)

Parameters

parent Furniture

The parent furniture to slot into

spot ObjectSpot

The object spot to slot into

UnlinkParentsAndChildren()

Unlinks this object from its parents and its children by setting its ParentFurniture and ParentObjectSpot to their default values and doing the same for all of its children (GetChildren<T>()) as well as any PersonLike that is holding this object.

public void UnlinkParentsAndChildren()

Validate()

This method is called when this object is loaded from disk. Returning false on this method causes the object to be removed from the map. By default, this method invokes OnValidated and OnEventsAttachable.

public override bool Validate()

Returns

bool

false if the object is not valid, true otherwise

Events

OnAppliedUpgrade

An event that is fired when an upgrade is freshly applied to this item in ApplyUpgrade(AppliedUpgrade). Please note that the upgrade may not be fully completed when this event is fired, see Progress. An event that is fired when this furniture's Dirty value is changed.

public event Action<AppliedUpgrade> OnAppliedUpgrade

Event Type

Action<AppliedUpgrade>

OnDirty

An event that is fired when this furniture's Dirty value is changed. This event can be subscribed to using OnEventsAttachable.

public event Action OnDirty

Event Type

Action

OnFurnitureTypeConstructed

An event that is invoked when a FurnitureType instance is constructed using the private constructor invoked in Register(TypeSettings). This event can be used to modify the FurnitureType.TypeSettings of the furniture type before they are made readonly.

public static event Furniture.FurnitureTypeConstructedDelegate OnFurnitureTypeConstructed

Event Type

Furniture.FurnitureTypeConstructedDelegate

OnGetDescription

An event that is fired when GetDescription(List<string>, bool) is called. This event can be used to change the description of furniture instances by adding to the provided List<T>. This event can be subscribed to using OnEventsAttachable.

public event Action<List<string>, bool> OnGetDescription

Event Type

Action<List<string>, bool>

OnGetDirty

An event that is fired when this furniture gets more dirty in GetDirty(PersonLike, TimeSpan). This event can be subscribed to using OnEventsAttachable.

public event Action<PersonLike, TimeSpan> OnGetDirty

Event Type

Action<PersonLike, TimeSpan>

OnSetCreator

An event that is fired when SetCreator(PersonLike, bool) is called. The arguments passed to this event are the same that are passed to SetCreator(PersonLike, bool). This event can be subscribed to using OnEventsAttachable.

public event Action<PersonLike, bool, EventPhase> OnSetCreator

Event Type

Action<PersonLike, bool, EventPhase>