ObjectSpot - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Objects

ObjectSpot Class

An object spot is a AbstractSpot extension that is used by Furniture to declare a location that another Furniture object can be slotted into.
This behavior is used for things like plates on counters, flower pots on bedside tables etc.

public class ObjectSpot : TinyLife.Objects.AbstractSpot

Inheritance System.Object 🡒 AbstractSpot 🡒 ObjectSpot

Constructors

ObjectSpot.ObjectSpot(Vector2, Vector2, Predicate<FurnitureType>, float, Direction2[]) Constructor

Creates a new object spot with the given settings

public ObjectSpot(Microsoft.Xna.Framework.Vector2 offset, Microsoft.Xna.Framework.Vector2 visualOffset, System.Predicate<TinyLife.Objects.FurnitureType> isFurnitureAllowed, float yOffset=0f, params MLEM.Misc.Direction2[] validDirections);

Parameters

offset Microsoft.Xna.Framework.Vector2
The offset on both the x and y axis that this spot has

visualOffset Microsoft.Xna.Framework.Vector2
The visual offset on both the x and y axis that this spot has

isFurnitureAllowed System.Predicate<FurnitureType>
A predicate that determines if the given FurnitureType is allowed to be put into this spot

yOffset System.Single
The offset on the visual y axis

validDirections MLEM.Misc.Direction2[]
The directions that this spot can be accessed from

ObjectSpot.ObjectSpot(Vector2, Predicate<FurnitureType>, float, Direction2[]) Constructor

Creates a new object spot with the given settings

public ObjectSpot(Microsoft.Xna.Framework.Vector2 offset, System.Predicate<TinyLife.Objects.FurnitureType> isFurnitureAllowed, float yOffset=0f, params MLEM.Misc.Direction2[] validDirections);

Parameters

offset Microsoft.Xna.Framework.Vector2
The offset on both the x and y axis that this spot has

isFurnitureAllowed System.Predicate<FurnitureType>
A predicate that determines if the given FurnitureType is allowed to be put into this spot

yOffset System.Single
The offset on the visual y axis

validDirections MLEM.Misc.Direction2[]
The directions that this spot can be accessed from

Fields

ObjectSpot.IsFurnitureAllowed Field

A predicate that determines if the given FurnitureType is allowed to be put into this object spot

public readonly Predicate<FurnitureType> IsFurnitureAllowed;

Field Value

System.Predicate<FurnitureType>

Methods

ObjectSpot.BarSpots() Method

A helper method to create a set of ObjectSpot instances for bars

public static TinyLife.Objects.ObjectSpot[] BarSpots();

Returns

ObjectSpot[]
A set of object spots for bars

ObjectSpot.CounterSpots(bool) Method

A helper method to create a set of ObjectSpot instnaces for counters and stoves.
The resulting set contains a single object spot for SmallObject and CounterObject object, or TinyLife.Objects.FurnitureType.PreparedFood and TinyLife.Objects.FurnitureType.Pot if stove is true.

public static TinyLife.Objects.ObjectSpot[] CounterSpots(bool stove=false);

Parameters

stove System.Boolean
Whether the object is a stove (or a counter)

Returns

ObjectSpot[]
A set of object spots for the stove or counter

ObjectSpot.DeskSpots(float, bool) Method

A helper method to create a set of ObjectSpot instances for a desk spot and two chair attachment spots on both sides of the desk

public static TinyLife.Objects.ObjectSpot[] DeskSpots(float yOffset=-0.625f, bool chairs=true);

Parameters

yOffset System.Single

chairs System.Boolean

Returns

ObjectSpot[]
A set of object spots for desks

ObjectSpot.DoubleShelfSpots(float) Method

A helper method to create a set of ObjectSpot instances for things that can store two objects side by side (or one big object in the center).
This method is used by furniture like the TinyLife.Objects.FurnitureType.SimpleDrawer.

public static TinyLife.Objects.ObjectSpot[] DoubleShelfSpots(float height=1f);

Parameters

height System.Single
The height of the object's spots. Defaults to 1.

Returns

ObjectSpot[]
A set of object spots for shelf-like objects

ObjectSpot.GetContents<T>(Furniture, bool) Method

Returns the Furniture objects that are currently slotted into this spot

public System.Collections.Generic.IEnumerable<T> GetContents<T>(TinyLife.Objects.Furniture furniture, bool includeGroup=false)
    where T : TinyLife.Objects.Furniture;

Type parameters

T
The type the child furnitures are expected to be

Parameters

furniture Furniture
The furniture that this spot belongs to

includeGroup System.Boolean
Whether to include other object spots that have at least one of the same Group

Returns

System.Collections.Generic.IEnumerable<T>
A set of children of this spot, or an empty set if there are none

ObjectSpot.PicnicTableSpots(Point) Method

A helper method that returns an array of ObjectSpot instances at locations relevant for picnic-style tables that have attached benches.
This is used by objects like TinyLife.Objects.FurnitureType.SimplePicnicTable.

public static TinyLife.Objects.ObjectSpot[] PicnicTableSpots(Microsoft.Xna.Framework.Point size);

Parameters

size Microsoft.Xna.Framework.Point
The size of the picnic table furniture

Returns

ObjectSpot[]
An array of object spots for picnic tables

ObjectSpot.TableSpots(Point) Method

A helper method to create a set of ObjectSpot instances for a table of the given size.
The resulting set of object spots will have spots for Chair objects on each side as well as SmallObject objects on each tile position.

public static TinyLife.Objects.ObjectSpot[] TableSpots(Microsoft.Xna.Framework.Point size);

Parameters

size Microsoft.Xna.Framework.Point
The size that the table has in tiles

Returns

ObjectSpot[]
A set of object spots for the table