Table of Contents

Class AbstractSpot

Namespace
TinyLife.Objects
Assembly
Tiny Life.dll

An AbstractSpot is a base class for ObjectSpot and ActionSpot.

public abstract class AbstractSpot
Inheritance
AbstractSpot
Derived
Inherited Members
Extension Methods

Constructors

AbstractSpot(Vector2, Vector2, float, Direction2[])

Creates a new spot with the given data. This is called by ObjectSpot and ActionSpot.

protected AbstractSpot(Vector2 offset, Vector2 visualOffset, float yOffset, Direction2[] validDirections)

Parameters

offset Vector2

The offset on both the x and y axis that this spot has

visualOffset Vector2

The visual offset on both the x and y axis that this spot has

yOffset float

The offset on the visual y axis

validDirections Direction2[]

The directions that this spot can be accessed from

Fields

DrawLayer

The layer that a person slotted into this action spot using OccupyActionSpot(Furniture, ActionSpot, bool, Direction2?, bool) is drawn on. By default, this is set to return 0, meaning it will be drawn on top of the first layer of this furniture.

public Func<Furniture, float> DrawLayer

Field Value

Func<Furniture, float>

Offset

The offset on both the x and y axis that this spot has from the position of the Furniture it belongs to

protected Vector2 Offset

Field Value

Vector2

ValidDirections

The MLEM.Misc.Direction2 values that this spot can be accessed from. These directions are relative to the owning Furniture's MLEM.Misc.Direction2.Up direction.

protected readonly Direction2[] ValidDirections

Field Value

Direction2[]

VisualOffset

The visual offset on both the x and y axis that this spot has from the position of the Furniture it belongs to. By default, this gets set to the same value as Offset.

protected Vector2 VisualOffset

Field Value

Vector2

Properties

Group

The groups that this spot has, which is interpreted as a bit flag. Two action spots with overlapping groups ((g1 AND g2) != 0) cannot both be occupied by two different people. This is used by things lke ModernBed to stop people from sitting on a side there someone is already sleeping. By default, this is set to 0, meaning there is no group set.

public int Group { get; init; }

Property Value

int

IsOnGround

Returns whether this action spot is on the ground. This is a sort of heuristic that returns true when YOffset is 0 and the VisualOffset is the same as the Offset.

public bool IsOnGround { get; }

Property Value

bool

VisualDirection

The visual direction that this action spot has. The visual direction is the direction used by a PersonLike when occupying this action spot for actions like sitting. By default, this value is set to the first ValidDirections entry in the constructor.

public Direction2 VisualDirection { get; init; }

Property Value

Direction2

YOffset

The offset on the visual y axis that the Furniture or PersonLike slotted into this spot should render with

public float YOffset { get; }

Property Value

float

Methods

DoGroupsOverlap(AbstractSpot)

Returns whether the passed AbstractSpot's Group and this spot's Group overlap. Two overlapping groups are groups for which (g1 AND g2) != 0.

public bool DoGroupsOverlap(AbstractSpot other)

Parameters

other AbstractSpot

The action spot whose groups to compare

Returns

bool

Whether at least one group overlaps

GetLocation(Furniture, bool)

Returns the location that this spot has in world space, based on the given Furniture and its position and rotation.

public Vector2 GetLocation(Furniture furniture, bool visual)

Parameters

furniture Furniture

The furniture that this spot belongs to

visual bool

Whetehr the VisualOffset should be used instead of the Offset

Returns

Vector2

This spot's location in world space

GetValidDirections(Direction2)

Returns the ValidDirections of this spot, but rotated by the given MLEM.Misc.Direction2.

public IEnumerable<Direction2> GetValidDirections(Direction2 rotation)

Parameters

rotation Direction2

The rotation

Returns

IEnumerable<Direction2>

The rotations that are valid for this spot

GetVisualDirection(Direction2)

Returns the VisualDirection that this action spot has, rotated by the given rotation. The visual direction is the direction used by a PersonLike when occupying this action spot for actions like sitting.

public Direction2 GetVisualDirection(Direction2 rotation)

Parameters

rotation Direction2

The rotation of the containing furniture.

Returns

Direction2

The visual direction for this spot.

SortDrawLayers<T>(T[])

A helper method that sorts the given AbstractSpot instances by depth when drawing by modifying their DrawLayer. This method can be used for more complex objects like wide desks, that have smaller and bigger objects visually overlappying, to mitigate z-fighting.

public static T[] SortDrawLayers<T>(T[] spots) where T : AbstractSpot

Parameters

spots T[]

The spots to sort.

Returns

T[]

The same spots, for chaining.

Type Parameters

T

The type of spot.