Class Furniture
A furniture is an instance of a FurnitureType which is placed in the world, or in a Person's hand. To register a custom furniture, use Register(TypeSettings).
public class Furniture : MapObject, IGenericDataHolder
- Inheritance
-
JsonTypeSafeGenericDataHolderFurniture
- Implements
-
IGenericDataHolder
- Derived
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
Furniture(Guid, FurnitureType, int[], Map, Vector2)
Creates a new furniture instance. By default, this is done using Construct<T>(int[], Map, Vector2, Guid?).
public Furniture(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos)
Parameters
id
GuidThe id to apply to the created furniture instance
type
FurnitureTypeThe type to create an instance of
colors
int[]The colors to apply to the furniture
map
MapThe map to create the furniture on
pos
Vector2The position that the furniture should have
Fields
Colors
The indices of the colors that this furniture has. Refer to ColorSchemes 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
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
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
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
Random
A Random instance that can be used by furniture items. This value has the default seed.
protected static readonly Random Random
Field Value
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
Properties
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
AreUtilitiesDisabled
Returns whether utilities are disabled on the current lot. This is a shorthand for AreUtilitiesDisabled(TimeSpan?).
public bool AreUtilitiesDisabled { get; }
Property Value
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
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
Creator
The Person that created this object in some capacity. This value is based on the underlying CreatorId.
public Person Creator { get; }
Property Value
CreatorId
The Guid of the Person that created this object in some capacity. This value defaults to Empty, meaning no creator. To easily access the creator Person, see Creator.
[DataMember(EmitDefaultValue = false)]
public Guid CreatorId { get; }
Property Value
Dirty
Whether this object is currently dirty. If CanBeDirty is false, this field is usually unused.
public bool Dirty { get; set; }
Property Value
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
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
ParentFurnitureId
The Id of this furniture's ParentFurniture.
[DataMember(EmitDefaultValue = false)]
public Guid ParentFurnitureId { get; }
Property Value
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
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
ParentObjectSpotId
The index of this furniture's ParentObjectSpot on this furniture's ParentFurniture.
[DataMember(EmitDefaultValue = false)]
public int ParentObjectSpotId { get; }
Property Value
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 and CameraRotation.
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
ActionThe action
time
GameTimeThe current game time
passedInGame
TimeSpanThe amount of time that has passed, in game time
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
isAuxiliary
boolWhether 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
FurnitureThe furniture to add as the child
rotation
Direction2The desired rotation of the child furniture. If the child furniture does not support the given rotation, GetBestRotation(Direction2) 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
FurnitureTypeThe type of furniture to construct as the child
rotation
Direction2The desired rotation of the child furniture. If the child furniture does not support the given rotation, GetBestRotation(Direction2) 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
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
ActionTypeThe action that is querying whether it can be executed.
info
ActionInfoThe action info.
automatic
boolWhether the action was started automatically.
isAuxiliary
boolWhether 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, Vector2, Color?, Direction2, int[], float, bool, ParentInfo, float, bool, 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, Vector2 drawPos, Color? overrideColor, Direction2 rotation, int[] colors, float drawScale, bool pivot, ParentInfo parent, float depthOffset, bool held, List<StaticSpriteBatch.Item> items)
Parameters
time
GameTimeThe game time
batch
objectThe sprite batch to draw with, which is either a Microsoft.Xna.Framework.Graphics.SpriteBatch or MLEM.Graphics.StaticSpriteBatch.
pos
Vector2The position, in world space, that the furniture is at
drawPos
Vector2The position, in draw space, to draw the furniture at
overrideColor
Color?An optional color to override the default colors of the furniture
rotation
Direction2The rotation of the furniture
colors
int[]The colors to draw the furniture with
drawScale
floatThe scale to draw the furniture with
pivot
boolWhether or not to move the furniture by its texture's pivot point
parent
ParentInfoThe object that this furniture is latched on to, or null if there is none
depthOffset
floatA value that is added onto the calculated depth of the object
held
boolWhether or not this item is currently being held by a Person
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, 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
GameTimeThe current time
batch
objectThe sprite batch to use for drawing, which is either a Microsoft.Xna.Framework.Graphics.SpriteBatch or MLEM.Graphics.StaticSpriteBatch.
drawPos
Vector2The 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.
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
GameTimeThe current game time
batch
SpriteBatchThe sprite batch to draw with
element
ElementThe element to calculate scaling based on
drawScale
floatThe scale to draw the furniture with
colors
int[]The colors to draw the furniture with
GetActionSpotInfo(Person, ActionSpot, Direction2)
Returns a ActionInfo that corresponds to the given ActionSpot and rotation
public ActionInfo GetActionSpotInfo(Person person, ActionSpot spot, Direction2 direction = Direction2.None)
Parameters
person
PersonThe person to query free action spots for
spot
ActionSpotThe action spot to return an info for
direction
Direction2The direction to offset the ActionLocation by. Defaults to MLEM.Misc.Direction2.None.
Returns
- ActionInfo
A new action info with the given settings
GetAiPriority(Person, 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.
public override int GetAiPriority(Person person, ObjectCategory categories)
Parameters
person
PersonThe person whose AI is attempting to interact with this object
categories
ObjectCategoryThe categories that are relevant for the ai interaction
Returns
- int
This object's priority
GetCategories(Person)
Returns a set of ObjectCategory flags that this object has, based on the given Person.
public override sealed ObjectCategory GetCategories(Person person)
Parameters
person
PersonThe 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
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 int GetDecorativeRating(Room room)
Parameters
room
RoomThe room that the object is in, or null if it is not in a room at all
Returns
- int
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
boolWhether this method is being called by GetHoverInfo(Tooltip) (or by build mode).
GetDirty(Person, 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(Person person, TimeSpan passedInGame)
Parameters
person
PersonThe person who is responsible for making this object more dirty.
passedInGame
TimeSpanThe amount of time that should be simulated in game.
GetEfficiencyModifier(Person, 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(Person person, ActionInfo info, bool isAuxiliary, SkillType skill, float levelModifier)
Parameters
person
PersonThe person whose efficiency should be influenced
info
ActionInfoThe action info
isAuxiliary
boolWhether this object is auxiliary (or the main action object)
skill
SkillTypeThe skill that should influence the efficiency
levelModifier
floatThe level modifier for the
skill
Returns
- float
The efficiency modifier for this object
GetFreeActionSpot(Person, ObjectCategory)
Returns the first free action spot from GetFreeActionSpots(Person, ObjectCategory).
public (ActionSpot Spot, Direction2 Dir) GetFreeActionSpot(Person person, ObjectCategory context = null)
Parameters
person
PersonThe person to query free action spots for
context
ObjectCategoryThe 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
GetFreeActionSpotInfo(Person, ObjectCategory)
Returns the first free action spot, packed into an ActionInfo.
public override ActionInfo GetFreeActionSpotInfo(Person person, ObjectCategory context = null)
Parameters
person
PersonThe person to query free action spots for
context
ObjectCategoryThe object category that this action spot needs to have
Returns
- ActionInfo
The first free action spot as an ActionInfo
GetFreeActionSpots(Person, 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(Person person, ObjectCategory context = null)
Parameters
person
PersonThe person to query free action spots for
context
ObjectCategoryThe object category that this action spot needs to have
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
FurnitureTypeThe 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 Person.
public override void GetHoverInfo(Tooltip tooltip)
Parameters
tooltip
TooltipThe tooltip that will be displayed.
GetOccupants(ObjectCategory, bool)
Returns a set of Person instances that are currently occupying any ActionSpot on this furniture item in some way.
public IEnumerable<Person> GetOccupants(ObjectCategory context = null, bool visualOnly = false)
Parameters
context
ObjectCategoryThe context for the ActionSpot to support for it to be included in the search.
visualOnly
boolWhether only occupants that occupy a spot visually, using VisuallyOccupiedSpot, should be returned.
Returns
- IEnumerable<Person>
A set of people that are currently occupying this furniture item in some way.
GetPrice()
public virtual float GetPrice()
Returns
GetRestoreNeedModifier(Person, 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(Person person, ActionInfo info, bool isAuxiliary, NeedType type)
Parameters
person
PersonThe person whose need restoration should be influenced.
info
ActionInfoThe action info.
isAuxiliary
boolWhether this object is auxiliary (or the main action object).
type
NeedTypeThe type of need that is being restored.
Returns
- float
The need restoration modifier for this object.
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
RectangleFThe area that should be checked for
Returns
- bool
true if this object intersects with the given rectangle
IsFreeSpot(Point)
Returns whether a Person 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) should be invoked for its previous and resulting Position.
public override bool IsFreeSpot(Point position)
Parameters
position
PointThe position whose path cost modifier is being calculated.
Returns
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
ActionTypeThe action type.
info
ActionInfoThe action info.
isAuxiliary
boolWhether this object is auxiliary.
categories
List<string>The categories.
MoveToMap(Map, Vector2)
Moves this object to the given map
, changing the current Map in the process.
public override bool MoveToMap(Map map, Vector2 position)
Parameters
map
MapThe map to move to.
position
Vector2The position on the new map to move to.
Returns
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
ActionThe action
type
CompletionTypeThe type of the action's completion
isAuxiliary
boolWhether 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
FurnitureThe 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
FurniturePlacerThe furniture placer used to place this object.
freshlyBought
boolWhether this item was freshly bought (or placed from storage).
OnPositionChanged(Vector2)
A method that is automatically called when this object's Position changes. By default, this method is overriden in Furniture to call TinyLife.Objects.Furniture.MarkDirtyForPathfinding(). Note that this method is also called if this object is not in the world (IsInWorld).
protected override void OnPositionChanged(Vector2 lastPosition)
Parameters
lastPosition
Vector2This object's previous position.
OnRemoved()
This method is called when this object is removed from a Map. By default, it does nothing.
public override void OnRemoved()
RemoveAndUnlink()
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
FurnitureThe 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
boolWhether a more thorough reset is expected, which usually involves normalizing additional data and cleaning up player data entirely.
custom
boolWhether 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
ObjectSpotThe spot to add the child to
item
FurnitureThe furniture to add to the spot
rotation
Direction2The desired rotation of the child furniture. If the child furniture does not support the given rotation, GetBestRotation(Direction2) 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
ObjectSpotThe spot to add the child to
type
FurnitureTypeThe type of furniture to construct as the child
rotation
Direction2The desired rotation of the child furniture. If the child furniture does not support the given rotation, GetBestRotation(Direction2) 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(Person, 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(Person person, bool triggerGoals = true)
Parameters
person
PersonThe person to set as the creator
triggerGoals
boolWhether 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
FurnitureThe parent furniture to slot into
spot
ObjectSpotThe 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 Person 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
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
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
OnGetDirty
An event that is fired when this furniture gets more dirty in GetDirty(Person, TimeSpan). This event can be subscribed to using OnEventsAttachable.
public event Action<Person, TimeSpan> OnGetDirty
Event Type
OnSetCreator
An event that is fired when SetCreator(Person, bool) is called. The arguments passed to this event are the same that are passed to SetCreator(Person, bool). This event can be subscribed to using OnEventsAttachable.
public event Action<Person, bool, EventPhase> OnSetCreator