Table of Contents

Class BreakableFurniture

Namespace
TinyLife.Objects
Assembly
Tiny Life.dll

Breakable furniture is Furniture that can be Broken and then repaired. An object of this class is automatically returned in Construct<T>(int[], Map, Vector2, float, Guid?) if no ConstructedType is set.

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

Constructors

BreakableFurniture(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 BreakableFurniture(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.

Properties

Broken

A field that stores whether this furniture is currently broken

[DataMember]
public virtual bool Broken { get; set; }

Property Value

bool

RepairProgress

The progress that has been made on repairing this object, between 0 and 1.

[DataMember]
public virtual float RepairProgress { get; set; }

Property Value

float

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)

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.

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 override 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 override 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).

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 override float GetPrice()

Returns

float

This furniture item's price.

OnRemoved()

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

public override void OnRemoved()

Update(GameTime, TimeSpan, float)

The update method, which is called every update frame by the underlying Map, as well as additional places like the FurnitureStorage. Because of this, some actions might only want to be invoked if an object IsInWorld. To call this method while invoking all required events, use DoUpdate(GameTime, TimeSpan, float).

public virtual void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)

Parameters

time GameTime

The game's time

passedInGame TimeSpan

The amount of time that has passed since the last call

speedMultiplier float

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

WearDown(TimeSpan)

Causes this furniture to wear down, increasing the likelihood of it becoming Broken and randomly breaking it

public virtual void WearDown(TimeSpan passedInGame)

Parameters

passedInGame TimeSpan

The amount of in-game time that this furniture should be worn down by

Events

OnBreak

An event that is invoked when this breakable furniture breaks. This event can be subscribed to using OnEventsAttachable.

public event Action OnBreak

Event Type

Action

OnWearDown

An event that is invoked when this breakable furniture is worn down in WearDown(TimeSpan). This event can be subscribed to using OnEventsAttachable.

public event BreakableFurniture.WearDownDelegate OnWearDown

Event Type

BreakableFurniture.WearDownDelegate