Table of Contents

Class FurniturePlacer

Namespace
TinyLife.Tools
Assembly
Tiny Life.dll

A helper class that represents a tool part which allows the placement and movement of furniture objects. This class is used by FurnitureTool and MoveTool.

public class FurniturePlacer
Inheritance
FurniturePlacer
Inherited Members
Extension Methods

Constructors

FurniturePlacer(Action<Furniture, UndoableAction>)

Creates a new furniture placer with the given settings

public FurniturePlacer(Action<Furniture, UndoableAction> onPlaced = null)

Parameters

onPlaced Action<Furniture, UndoableAction>

An action that is invoked when the given furniture is placed by this placer

Properties

SelectedColors

The color indices that are currently selected for the SelectedFurniture

public int[] SelectedColors { get; }

Property Value

int[]

SelectedFurniture

The FurnitureType that is currently selected for placement

public FurnitureType SelectedFurniture { get; }

Property Value

FurnitureType

SelectedPreview

An instance of the SelectedFurniture

public Furniture SelectedPreview { get; }

Property Value

Furniture

Methods

CanPlace()

Determines whether the currently selected furniture can be placed at the current position.

public CanPlaceResult CanPlace()

Returns

CanPlaceResult

Whether the currently selected furniture can be placed at the current position.

Draw(GameTime, SpriteBatch)

Draws the SelectedPreview of this furniture placer

public void Draw(GameTime time, SpriteBatch batch)

Parameters

time GameTime

The game's time

batch SpriteBatch

The sprite batch to use for drawing

GetCurrentCanPlaceResult()

Returns whether or not the tool should currently be considered to be able to place objects for a tooltip displayed to the player.

public CanPlaceResult GetCurrentCanPlaceResult()

Returns

CanPlaceResult

A CanPlaceResult that represents whether the tool should be considered to be able to place objects.

GetCustomPrice(Furniture)

Returns the custom price that the given Furniture should be sold with on the furniture tool. This is influenced by the CurrentHousehold's people's personalities, as well as the OnGetCustomPrice event.

public static float? GetCustomPrice(Furniture furniture)

Parameters

furniture Furniture

The furniture whose price to get

Returns

float?

The furniture's custom price, or null to use the default price

GetMouseCursor()

Returns the CursorType that this tool should currently display. By default, Default is returned.

public CursorType GetMouseCursor()

Returns

CursorType

The cursor type

PlaceFurniture()

Causes the currently selected furniture to be placed at the current position, and returned.

public Furniture PlaceFurniture()

Returns

Furniture

The placed furniture.

SelectFurniture(FurnitureType, Furniture, Action<Furniture>, Direction2, int[], bool)

Selects the given FurnitureType. If exact is enabled, the preview is the exact furniture instance that will be placed. If it is false, a new instance of the given furniture will be created upon placement.

public void SelectFurniture(FurnitureType furniture, Furniture preview, Action<Furniture> variation, Direction2 rotation, int[] colors, bool exact = false)

Parameters

furniture FurnitureType

The furniture type to select

preview Furniture

An instance of the given furniture

variation Action<Furniture>

A function that represents a furniture variation to place

rotation Direction2

The rotation to select

colors int[]

The colors to select

exact bool

Whether or not the preview is the exact instance that should be placed

ShouldHighlightSelectedObject(object)

Whether or not the SelectedObject should currently have a white highlight around it. This method defaults to return true if IsCursorOnUi() is false.

public bool ShouldHighlightSelectedObject(object obj)

Parameters

obj object

The selected object, which can be a MapObject or a WallLike.

Returns

bool

Whether or not the selected object should be highlighted

UnselectFurniture()

Unselects the currently SelectedFurniture

public void UnselectFurniture()

Update()

Updates this furniture placer. This should be called in Update(GameTime, bool) each frame.

public void Update()

Events

OnGetCustomPrice

An event that is invoked when GetCustomPrice(Furniture) is called. Use this event to change the custom price of a furniture item bought in the furniture tool.

public static event FurniturePlacer.GetCustomPriceDelegate OnGetCustomPrice

Event Type

FurniturePlacer.GetCustomPriceDelegate