ActionSpot - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Objects

ActionSpot Class

An action spot is a AbstractSpot extension that is used by Furniture to declare a location that a Person can interact with the furniture at

public class ActionSpot : TinyLife.Objects.AbstractSpot

Inheritance System.Object 🡒 AbstractSpot 🡒 ActionSpot

Constructors

ActionSpot.ActionSpot(Vector2, float, Direction2[]) Constructor

Creates a new action spot with the given settings

public ActionSpot(Microsoft.Xna.Framework.Vector2 offset, float yOffset, params MLEM.Misc.Direction2[] validDirections);

Parameters

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

yOffset System.Single
The offset on the visual y axis

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

ActionSpot.ActionSpot(Vector2, Vector2, float, Direction2[]) Constructor

Creates a new action spot with the given settings

public ActionSpot(Microsoft.Xna.Framework.Vector2 offset, Microsoft.Xna.Framework.Vector2 visualOffset, float yOffset, 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

yOffset System.Single
The offset on the visual y axis

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

ActionSpot.ActionSpot(Vector2, Direction2[]) Constructor

Creates a new action spot with the given settings

public ActionSpot(Microsoft.Xna.Framework.Vector2 offset, params MLEM.Misc.Direction2[] validDirections);

Parameters

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

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

Fields

ActionSpot.CategoryRestriction Field

The categories that this ActionSpot is restricted to.
This is used by things like TinyLife.Objects.FurnitureType.ModernBed to declare separate spots for sitting on and sleeping on.
By default, this is set to null.

public ObjectCategory CategoryRestriction;

Field Value

ObjectCategory

Methods

ActionSpot.AllSpots(Point, ObjectCategory) Method

Returns an array of action spots with four valid directions for each location within the given size.
This is the default behavior for furniture that doesn't have manually set action spots.

public static TinyLife.Objects.ActionSpot[] AllSpots(Microsoft.Xna.Framework.Point size, TinyLife.Objects.ObjectCategory categoryRestriction=null);

Parameters

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

categoryRestriction ObjectCategory
An optional CategoryRestriction

Returns

ActionSpot[]
An array of all spots within the size

ActionSpot.BedSpots(bool) Method

A helper method that returns an array of ActionSpot instances at the locations that they have to be for a bed.
The spots returned also contain spots that a person can sit on if there's not already someone laying in the bed.
This method can be used for single and double beds.

public static TinyLife.Objects.ActionSpot[] BedSpots(bool single=false);

Parameters

single System.Boolean
Whether the bed in question is a single bed (or a double bed)

Returns

ActionSpot[]
A set of action spots for the bed

ActionSpot.BenchSpots() Method

A helper method that returns an array of ActionSpot instances at locations relevant for benches and sofas.
This is used by objects like TinyLife.Objects.FurnitureType.SimpleBench and TinyLife.Objects.FurnitureType.SimpleSofa.

public static TinyLife.Objects.ActionSpot[] BenchSpots();

Returns

ActionSpot[]
An array of action spots for benches and sofas

ActionSpot.GetFreeDirections(Furniture, Person) Method

Returns a set of MLEM.Misc.Direction2 values that this spot can be accessed from.
Valid directions will have an empty space that a Person can stand in, but not necessarily walk to.
The returned value is used by GetFreeActionSpots(Person, ObjectCategory) and GetFreeActionSpotInfo(Person, ObjectCategory) to find a location adjacent to this action spot that a Person can walk to.

public System.Collections.Generic.IEnumerable<MLEM.Misc.Direction2> GetFreeDirections(TinyLife.Objects.Furniture furniture, TinyLife.Objects.Person person);

Parameters

furniture Furniture
The furnituret that this action spot belongs to

person Person
The person trying to use this action spot

Returns

System.Collections.Generic.IEnumerable<MLEM.Misc.Direction2>
A set of directions that are considered free, or an empty set if there are none

ActionSpot.GetOccupants(Furniture, bool) Method

Returns a set of the Person instances that are currently occupying this action spot.
Note that an action spot is also marked as occupied if the person is currently on their way to it.

public System.Collections.Generic.IEnumerable<TinyLife.Objects.Person> GetOccupants(TinyLife.Objects.Furniture furniture, bool includeGroup=false);

Parameters

furniture Furniture
The furnituret that this action spot belongs to

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

Returns

System.Collections.Generic.IEnumerable<Person>
A set of people interacting with this action spot

ActionSpot.GetPicnicBenchDrawLayer(Furniture) Method

This is a helper method used by PicnicTableSpots(Point).
Since picnic tables have their benches attached, their DrawLayer needs to be based on the CameraRotation, which is what this method calculates.

public static int GetPicnicBenchDrawLayer(TinyLife.Objects.Furniture furniture);

Parameters

furniture Furniture
The object whose draw layer to get

Returns

System.Int32
The draw layer as required by DrawLayer

ActionSpot.PicnicTableSpots(Point) Method

A helper method that returns an array of ActionSpot 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.ActionSpot[] PicnicTableSpots(Microsoft.Xna.Framework.Point size);

Parameters

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

Returns

ActionSpot[]
An array of action spots for picnic tables