Search Results for

    Show / Hide Table of Contents

    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(FurnitureType.TypeSettings).

    Inheritance
    System.Object
    MLEM.Data.Json.JsonTypeSafeGenericDataHolder
    MapObject
    Furniture
    BreakableFurniture
    Chimney
    CornerFurniture
    Fence
    FoodTypedItem
    Fridge
    Gravestone
    LightFurniture
    Newspaper
    OverlayWallHanging
    Painting
    TrashBag
    TrashCan
    UnfinishedWoodwork
    Implements
    MLEM.Misc.IGenericDataHolder
    IPricedObject
    Inherited Members
    MapObject.PersonRotationOrder
    MapObject.OnCreated
    MapObject.OnValidated
    MapObject.OnEventsAttachable
    MapObject.OnDraw
    MapObject.OnUpdate
    MapObject.OnGetHoverInfo
    MapObject.Position
    MapObject.Id
    MapObject.Map
    MapObject.CurrentLot
    MapObject.CurrentRoom
    MapObject.IsInWorld
    MapObject.OnCameraRotationChanged(Direction2, Direction2)
    MapObject.SetMapAndValidate(Map)
    MapObject.HasCategory(Person, ObjectCategory)
    MapObject.GetPathCostModifier(Point)
    MapObject.DoDraw(GameTime, Object, Nullable<Color>, Boolean, List<StaticSpriteBatch.Item>)
    MapObject.DoUpdate(GameTime, TimeSpan, Single)
    MapObject.DrawColumns(Map, Vector2, Object, Vector2, TextureRegion, Color, Single, Point, List<StaticSpriteBatch.Item>, Boolean, ParentInfo, Single, SpriteEffects, Boolean, Boolean, Boolean)
    MapObject.GetModCategory(String)
    MLEM.Data.Json.JsonTypeSafeGenericDataHolder.SetData(System.String, System.Object)
    MLEM.Data.Json.JsonTypeSafeGenericDataHolder.SetData<T>(System.String, T)
    MLEM.Data.Json.JsonTypeSafeGenericDataHolder.GetData<T>(System.String)
    MLEM.Data.Json.JsonTypeSafeGenericDataHolder.GetDataKeys()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: TinyLife.Objects
    Assembly: Tiny Life.dll
    Syntax
    public class Furniture : MapObject, IGenericDataHolder, IPricedObject

    Constructors

    Furniture(Guid, FurnitureType, Int32[], Map, Vector2)

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

    Declaration
    public Furniture(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos)
    Parameters
    Type Name Description
    System.Guid id

    The id to apply to the created furniture instance

    FurnitureType type

    The type to create an instance of

    System.Int32[] colors

    The colors to apply to the furniture

    Map map

    The map to create the furniture on

    Microsoft.Xna.Framework.Vector2 pos

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

    Declaration
    [DataMember]
    public int[] Colors
    Field Value
    Type Description
    System.Int32[]

    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.

    Declaration
    [DataMember(EmitDefaultValue = false)]
    public float? CustomPrice
    Field Value
    Type Description
    System.Nullable<T><System.Single>

    DevaluedThroughUse

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

    Declaration
    [DataMember(EmitDefaultValue = false)]
    public bool DevaluedThroughUse
    Field Value
    Type Description
    System.Boolean

    Dirty

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

    Declaration
    [DataMember(EmitDefaultValue = false)]
    public bool Dirty
    Field Value
    Type Description
    System.Boolean

    IsStatic

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

    Declaration
    [DataMember(EmitDefaultValue = false)]
    public bool IsStatic
    Field Value
    Type Description
    System.Boolean

    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>, Boolean)) and it influences the furniture's price (GetPrice()) using GetPriceModifier(Quality).

    Declaration
    [DataMember(EmitDefaultValue = false)]
    public Quality? Quality
    Field Value
    Type Description
    System.Nullable<T><Quality>

    Random

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

    Declaration
    protected static readonly Random Random
    Field Value
    Type Description
    System.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.

    Declaration
    [DataMember]
    public Direction2 Rotation
    Field Value
    Type Description
    MLEM.Misc.Direction2

    Type

    The FurnitureType that this furniture has

    Declaration
    [DataMember]
    public readonly FurnitureType Type
    Field Value
    Type Description
    FurnitureType

    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

    Declaration
    public RectangleF Area { get; }
    Property Value
    Type Description
    MLEM.Misc.RectangleF

    AreUtilitiesDisabled

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

    Declaration
    public bool AreUtilitiesDisabled { get; }
    Property Value
    Type Description
    System.Boolean

    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.

    Declaration
    public Wall AttachedWall { get; }
    Property Value
    Type Description
    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.

    Declaration
    public bool CanBeDirty { get; }
    Property Value
    Type Description
    System.Boolean

    Creator

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

    Declaration
    public Person Creator { get; }
    Property Value
    Type Description
    Person

    CreatorId

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

    Declaration
    [DataMember(EmitDefaultValue = false)]
    public Guid CreatorId { get; }
    Property Value
    Type Description
    System.Guid

    DisplayName

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

    Declaration
    public virtual string DisplayName { get; }
    Property Value
    Type Description
    System.String

    This furniture item's display name.

    HasParent

    Returns whether a ParentFurniture for this furniture exists. Note that, if this object is not in the world, or the ParentFurniture is not currently in the world, this property will still be true.

    Declaration
    public bool HasParent { get; }
    Property Value
    Type Description
    System.Boolean

    HideFromDraw

    Returns whether this object should currently be hidden from drawing.

    Declaration
    public bool HideFromDraw { get; }
    Property Value
    Type Description
    System.Boolean

    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.

    Declaration
    public Furniture ParentFurniture { get; }
    Property Value
    Type Description
    Furniture

    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.

    Declaration
    public override ParentInfo ParentInfo { get; }
    Property Value
    Type Description
    ParentInfo
    Overrides
    MapObject.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.

    Declaration
    public ObjectSpot ParentObjectSpot { get; }
    Property Value
    Type Description
    ObjectSpot

    Visibility

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

    Declaration
    public override Visibility Visibility { get; }
    Property Value
    Type Description
    Visibility

    This object's visibility settings

    Overrides
    MapObject.Visibility

    VisualRotation

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

    Declaration
    public Direction2 VisualRotation { get; }
    Property Value
    Type Description
    MLEM.Misc.Direction2

    Methods

    ActionUpdate(Action, GameTime, TimeSpan, Single, Boolean)

    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, Boolean, Boolean) includes this object. In general, the base method should be called for Furniture objects, since it sets deals with Dirty objects.

    Declaration
    public override void ActionUpdate(Action action, GameTime time, TimeSpan passedInGame, float speedMultiplier, bool isAuxiliary)
    Parameters
    Type Name Description
    Action action

    The action

    Microsoft.Xna.Framework.GameTime time

    The current game time

    System.TimeSpan passedInGame

    The amount of time that has passed, in game time

    System.Single speedMultiplier

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

    System.Boolean isAuxiliary

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

    Overrides
    MapObject.ActionUpdate(Action, GameTime, TimeSpan, Single, Boolean)

    AddChild(Furniture, Direction2, Nullable<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.

    Declaration
    public bool AddChild(Furniture item, Direction2 rotation, Vector2? position = null)
    Parameters
    Type Name Description
    Furniture item

    The furniture to add as the child

    MLEM.Misc.Direction2 rotation

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

    System.Nullable<T><Microsoft.Xna.Framework.Vector2> position

    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
    Type Description
    System.Boolean

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

    AddChild<T>(FurnitureType, Direction2, Int32[], Nullable<Guid>, Nullable<Vector2>)

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

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

    The type of furniture to construct as the child

    MLEM.Misc.Direction2 rotation

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

    System.Int32[] colors

    The colors that the child should have

    System.Nullable<T><System.Guid> id

    The id that the child should have, random by default

    System.Nullable<T><Microsoft.Xna.Framework.Vector2> position

    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
    Type Description
    T

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

    Type Parameters
    Name Description
    T

    The type of furniture that the child is

    CanExecuteAction(ActionType, ActionInfo, Boolean, Boolean)

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

    Declaration
    public override CanExecuteResult CanExecuteAction(ActionType action, ActionInfo info, bool automatic, bool isAuxiliary)
    Parameters
    Type Name Description
    ActionType action

    The action that is querying whether it can be executed.

    ActionInfo info

    The action info.

    System.Boolean automatic

    Whether the action was started automatically.

    System.Boolean isAuxiliary

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

    Returns
    Type Description
    TinyLife.Actions.CanExecuteResult

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

    Overrides
    MapObject.CanExecuteAction(ActionType, ActionInfo, Boolean, Boolean)

    Draw(GameTime, Object, Vector2, Vector2, Nullable<Color>, Direction2, Int32[], Single, Boolean, ParentInfo, Single, Boolean, List<StaticSpriteBatch.Item>)

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

    Declaration
    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
    Type Name Description
    Microsoft.Xna.Framework.GameTime time

    The game time

    System.Object batch

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

    Microsoft.Xna.Framework.Vector2 pos

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

    Microsoft.Xna.Framework.Vector2 drawPos

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

    System.Nullable<T><Microsoft.Xna.Framework.Color> overrideColor

    An optional color to override the default colors of the furniture

    MLEM.Misc.Direction2 rotation

    The rotation of the furniture

    System.Int32[] colors

    The colors to draw the furniture with

    System.Single drawScale

    The scale to draw the furniture with

    System.Boolean pivot

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

    ParentInfo parent

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

    System.Single depthOffset

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

    System.Boolean held

    Whether or not this item is currently being held by a Person

    System.Collections.Generic.List<T><StaticSpriteBatch.Item> items

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

    Draw(GameTime, Object, Vector2, Nullable<Color>, List<StaticSpriteBatch.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, Nullable<Color>, Boolean, List<StaticSpriteBatch.Item>).

    Declaration
    public sealed override void Draw(GameTime time, object batch, Vector2 drawPos, Color? overrideColor, List<StaticSpriteBatch.Item> items)
    Parameters
    Type Name Description
    Microsoft.Xna.Framework.GameTime time

    The current time

    System.Object batch

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

    Microsoft.Xna.Framework.Vector2 drawPos

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

    System.Nullable<T><Microsoft.Xna.Framework.Color> overrideColor

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

    System.Collections.Generic.List<T><StaticSpriteBatch.Item> items

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

    Overrides
    MapObject.Draw(GameTime, Object, Vector2, Nullable<Color>, List<StaticSpriteBatch.Item>)

    DrawUi(GameTime, SpriteBatch, Element, Single, Int32[])

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

    Declaration
    public void DrawUi(GameTime time, SpriteBatch batch, Element element, float drawScale, int[] colors)
    Parameters
    Type Name Description
    Microsoft.Xna.Framework.GameTime time

    The current game time

    Microsoft.Xna.Framework.Graphics.SpriteBatch batch

    The sprite batch to draw with

    MLEM.Ui.Elements.Element element

    The element to calculate scaling based on

    System.Single drawScale

    The scale to draw the furniture with

    System.Int32[] colors

    The colors to draw the furniture with

    GetActionSpotInfo(Person, ActionSpot, Direction2)

    Returns a ActionInfo that corresponds to the given ActionSpot and rotation

    Declaration
    public ActionInfo GetActionSpotInfo(Person person, ActionSpot spot, Direction2 direction = Direction2.None)
    Parameters
    Type Name Description
    Person person

    The person to query free action spots for

    ActionSpot spot

    The action spot to return an info for

    MLEM.Misc.Direction2 direction

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

    Returns
    Type Description
    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.

    Declaration
    public override int GetAiPriority(Person person, ObjectCategory categories)
    Parameters
    Type Name Description
    Person person

    The person whose AI is attempting to interact with this object

    ObjectCategory categories

    The categories that are relevant for the ai interaction

    Returns
    Type Description
    System.Int32

    This object's priority

    Overrides
    MapObject.GetAiPriority(Person, ObjectCategory)

    GetCategories(Person)

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

    Declaration
    public sealed override ObjectCategory GetCategories(Person person)
    Parameters
    Type Name Description
    Person person

    The person to query categories for

    Returns
    Type Description
    ObjectCategory

    A set of categories that this object has

    Overrides
    MapObject.GetCategories(Person)

    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.

    Declaration
    public IEnumerable<T> GetChildren<T>()
        where T : MapObject
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T><T>

    A list of this furniture's children

    Type Parameters
    Name Description
    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.

    Declaration
    public virtual int GetDecorativeRating(Room room)
    Parameters
    Type Name Description
    Room room

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

    Returns
    Type Description
    System.Int32

    The decorative rating of this object

    GetDescription(List<String>, Boolean)

    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.

    Declaration
    public virtual void GetDescription(List<string> description, bool forHoverInfo)
    Parameters
    Type Name Description
    System.Collections.Generic.List<T><System.String> description

    The description to add to.

    System.Boolean forHoverInfo

    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, Single, Boolean) every update frame if this object isn't already Dirty.

    Declaration
    public virtual void GetDirty(Person person, TimeSpan passedInGame)
    Parameters
    Type Name Description
    Person person

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

    System.TimeSpan passedInGame

    The amount of time that should be simulated in game.

    GetEfficiencyModifier(Person, ActionInfo, Boolean, SkillType, Single)

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

    Declaration
    public override float GetEfficiencyModifier(Person person, ActionInfo info, bool isAuxiliary, SkillType skill, float levelModifier)
    Parameters
    Type Name Description
    Person person

    The person whose efficiency should be influenced

    ActionInfo info

    The action info

    System.Boolean isAuxiliary

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

    SkillType skill

    The skill that should influence the efficiency

    System.Single levelModifier

    The level modifier for the skill

    Returns
    Type Description
    System.Single

    The efficiency modifier for this object

    Overrides
    MapObject.GetEfficiencyModifier(Person, ActionInfo, Boolean, SkillType, Single)

    GetFreeActionSpot(Person, ObjectCategory)

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

    Declaration
    public (ActionSpot Spot, Direction2 Dir) GetFreeActionSpot(Person person, ObjectCategory context = null)
    Parameters
    Type Name Description
    Person person

    The person to query free action spots for

    ObjectCategory context

    The object category that this action spot needs to have

    Returns
    Type Description
    System.ValueTuple<T1, T2><ActionSpot, MLEM.Misc.Direction2>

    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.

    Declaration
    public override ActionInfo GetFreeActionSpotInfo(Person person, ObjectCategory context = null)
    Parameters
    Type Name Description
    Person person

    The person to query free action spots for

    ObjectCategory context

    The object category that this action spot needs to have

    Returns
    Type Description
    ActionInfo

    The first free action spot as an ActionInfo

    Overrides
    MapObject.GetFreeActionSpotInfo(Person, ObjectCategory)

    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.

    Declaration
    public IEnumerable<(ActionSpot Spot, Direction2 Dir)> GetFreeActionSpots(Person person, ObjectCategory context = null)
    Parameters
    Type Name Description
    Person person

    The person to query free action spots for

    ObjectCategory context

    The object category that this action spot needs to have

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T><System.ValueTuple<T1, T2><ActionSpot, MLEM.Misc.Direction2>>

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

    GetFreeObjectSpot(FurnitureType, Nullable<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.

    Declaration
    public ObjectSpot GetFreeObjectSpot(FurnitureType type, Vector2? position = null)
    Parameters
    Type Name Description
    FurnitureType type

    The furniture type to find a free object spot for

    System.Nullable<T><Microsoft.Xna.Framework.Vector2> position

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

    Returns
    Type Description
    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.

    Declaration
    public override void GetHoverInfo(Tooltip tooltip)
    Parameters
    Type Name Description
    MLEM.Ui.Elements.Tooltip tooltip

    The tooltip that will be displayed.

    Overrides
    MapObject.GetHoverInfo(Tooltip)

    GetOccupants(ObjectCategory, Boolean)

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

    Declaration
    public IEnumerable<Person> GetOccupants(ObjectCategory context = null, bool visualOnly = false)
    Parameters
    Type Name Description
    ObjectCategory context

    The context for the ActionSpot to support for it to be included in the search.

    System.Boolean visualOnly

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

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T><Person>

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

    GetPrice()

    Returns the price that this object can be bought or sold for. Note that, like in the case of the Painting, the returned price isn't necessarily the full price that the object can be sold for. Instead, the price returned here should be the price that this object has when bought or sold from the FurnitureTool or similar.

    Declaration
    public virtual float GetPrice()
    Returns
    Type Description
    System.Single

    The object's price

    GetRestoreNeedModifier(Person, ActionInfo, Boolean, NeedType)

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

    Declaration
    public override float GetRestoreNeedModifier(Person person, ActionInfo info, bool isAuxiliary, NeedType type)
    Parameters
    Type Name Description
    Person person

    The person whose need restoration should be influenced.

    ActionInfo info

    The action info.

    System.Boolean isAuxiliary

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

    NeedType type

    The type of need that is being restored.

    Returns
    Type Description
    System.Single

    The need restoration modifier for this object.

    Overrides
    MapObject.GetRestoreNeedModifier(Person, ActionInfo, Boolean, NeedType)

    Intersects(RectangleF)

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

    Declaration
    public override bool Intersects(RectangleF rectangle)
    Parameters
    Type Name Description
    MLEM.Misc.RectangleF rectangle

    The area that should be checked for

    Returns
    Type Description
    System.Boolean

    true if this object intersects with the given rectangle

    Overrides
    MapObject.Intersects(RectangleF)

    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.

    Declaration
    public override bool IsFreeSpot(Point position)
    Parameters
    Type Name Description
    Microsoft.Xna.Framework.Point position

    The position whose path cost modifier is being calculated.

    Returns
    Type Description
    System.Boolean

    Whether a Person can occupy the given position.

    Overrides
    MapObject.IsFreeSpot(Point)

    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.

    Declaration
    public void NotifyNeighbors()

    OnActionCompleted(Action, CompletionType, Boolean)

    This method is called when an System.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, Boolean, Boolean) includes this object. In general, the base method should be called for Furniture objects, since it sets DevaluedThroughUse.

    Declaration
    public override void OnActionCompleted(Action action, CompletionType type, bool isAuxiliary)
    Parameters
    Type Name Description
    Action action

    The action

    CompletionType type

    The type of the action's completion

    System.Boolean isAuxiliary

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

    Overrides
    MapObject.OnActionCompleted(Action, CompletionType, Boolean)

    OnAdded()

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

    Declaration
    public override void OnAdded()
    Overrides
    MapObject.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.

    Declaration
    protected virtual void OnNeighborChanged(Furniture neighbor)
    Parameters
    Type Name Description
    Furniture neighbor

    The neighbor furniture that changed

    OnPlacedInBuildMode(FurniturePlacer, Boolean)

    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.

    Declaration
    public virtual void OnPlacedInBuildMode(FurniturePlacer placer, bool freshlyBought)
    Parameters
    Type Name Description
    FurniturePlacer placer

    The furniture placer used to place this object.

    System.Boolean freshlyBought

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

    OnRemoved()

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

    Declaration
    public override void OnRemoved()
    Overrides
    MapObject.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).

    Declaration
    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

    Declaration
    public bool RemoveChild(Furniture child)
    Parameters
    Type Name Description
    Furniture child

    The child to remove

    Returns
    Type Description
    System.Boolean

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

    RemoveChildren<T>(Predicate<T>)

    Removes all of the children from this furniture that match the given predicate. Children are all furnitures in the world that have their ParentFurniture set to this furniture instance.

    Declaration
    public IEnumerable<T> RemoveChildren<T>(Predicate<T> predicate = null)
        where T : Furniture
    Parameters
    Type Name Description
    System.Predicate<T><T> predicate

    The predicate to check children against. If null, all children will be removed.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T><T>

    The children that were removed from this furniture

    Type Parameters
    Name Description
    T

    The type of children to remove

    ResetToStatic(Boolean)

    Declaration
    public override bool ResetToStatic(bool thorough)
    Parameters
    Type Name Description
    System.Boolean thorough
    Returns
    Type Description
    System.Boolean
    Overrides
    MapObject.ResetToStatic(Boolean)

    SetChild(ObjectSpot, Furniture, Direction2)

    Sets the child element in the given object spot to the given furniture and adds it to this furniture's Map. If there are already children in the given object spot, those are removed prior to adding the new child.

    Declaration
    public void SetChild(ObjectSpot spot, Furniture item, Direction2 rotation)
    Parameters
    Type Name Description
    ObjectSpot spot

    The spot to add the child to

    Furniture item

    The furniture to add to the spot

    MLEM.Misc.Direction2 rotation

    The 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, Int32[], Nullable<Guid>)

    Sets the child element in the given object spot to the given furniture and adds it to this furniture's Map. If there are already children in the given object spot, those are removed prior to adding the new child.

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

    The spot to add the child to

    FurnitureType type

    The type of furniture to construct as the child

    MLEM.Misc.Direction2 rotation

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

    System.Int32[] colors

    The colors that the child should have

    System.Nullable<T><System.Guid> id

    The id that the child should have, random by default

    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    SetCreator(Person, Boolean)

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

    Declaration
    public virtual void SetCreator(Person person, bool triggerGoals = true)
    Parameters
    Type Name Description
    Person person

    The person to set as the creator

    System.Boolean triggerGoals

    Whether FurnitureCreated goal triggers should be triggered

    SetNewId(IEnumerable<Furniture>)

    Assigns a new, randomly generated System.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.

    Declaration
    public void SetNewId(IEnumerable<Furniture> possibleChildren = null)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T><Furniture> possibleChildren

    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.

    Declaration
    public void SetParent(Furniture parent, ObjectSpot spot)
    Parameters
    Type Name Description
    Furniture parent

    The parent furniture to slot into

    ObjectSpot spot

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

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

    Declaration
    public override bool Validate()
    Returns
    Type Description
    System.Boolean

    false if the object is not valid, true otherwise

    Overrides
    MapObject.Validate()

    Events

    OnDirty

    An event that is fired when this furniture gets dirty, meaning its Dirty value is set to true. This event can be subscribed to using OnEventsAttachable.

    Declaration
    public event Action OnDirty
    Event Type
    Type Description
    System.Action

    OnGetDescription

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

    Declaration
    public event Action<List<string>, bool> OnGetDescription
    Event Type
    Type Description
    System.Action<T1, T2><System.Collections.Generic.List<T><System.String>, System.Boolean>

    OnGetDirty

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

    Declaration
    public event Action<Person, TimeSpan> OnGetDirty
    Event Type
    Type Description
    System.Action<T1, T2><Person, System.TimeSpan>

    OnSetCreator

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

    Declaration
    public event Action<Person, bool, EventPhase> OnSetCreator
    Event Type
    Type Description
    System.Action<T1, T2, T3><Person, System.Boolean, EventPhase>

    Implements

    MLEM.Misc.IGenericDataHolder
    IPricedObject

    Extension Methods

    Extensions.JsonCopy<T>(T)
    ☀
    ☾
    In This Article
    Back to top
    © 2021-2023 Ellpeck Games, Top Hat Studios – Impressum – Privacy – Status
    ☀
    ☾