AbstractSpot - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Objects

AbstractSpot Class

An AbstractSpot is a base class for ObjectSpot and ActionSpot.

public abstract class AbstractSpot

Inheritance System.Object 🡒 AbstractSpot

Derived
ActionSpot
ObjectSpot

Constructors

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

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

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

Fields

AbstractSpot.DrawLayer Field

The layer that a person slotted into this action spot using OccupyActionSpot(Furniture, ActionSpot, bool, Nullable<Direction2>) 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,int> DrawLayer;

Field Value

System.Func<Furniture,System.Int32>

AbstractSpot.Group Field

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 TinyLife.Objects.FurnitureType.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;

Field Value

System.Int32

AbstractSpot.Offset Field

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

protected internal Vector2 Offset;

Field Value

Microsoft.Xna.Framework.Vector2

AbstractSpot.ValidDirections Field

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.
Note that, for a lot of actions, including Sit(Furniture, GameSpeed, ActionSpot), the first entry in this array will be chosen as the Person's rotation.

protected readonly Direction2[] ValidDirections;

Field Value

MLEM.Misc.Direction2[]

AbstractSpot.VisualOffset Field

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 internal Vector2 VisualOffset;

Field Value

Microsoft.Xna.Framework.Vector2

Properties

AbstractSpot.YOffset Property

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

public float YOffset { get; set; }

Property Value

System.Single

Methods

AbstractSpot.DoGroupsOverlap(AbstractSpot) Method

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(TinyLife.Objects.AbstractSpot other);

Parameters

other AbstractSpot
The action spot whose groups to compare

Returns

System.Boolean
Whether at least one group overlaps

AbstractSpot.GetLocation(Furniture, bool) Method

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

public Microsoft.Xna.Framework.Vector2 GetLocation(TinyLife.Objects.Furniture furniture, bool visual);

Parameters

furniture Furniture
The furniture that this spot belongs to

visual System.Boolean
Whetehr the VisualOffset should be used instead of the Offset

Returns

Microsoft.Xna.Framework.Vector2
This spot's location in world space

AbstractSpot.GetValidDirections(Direction2) Method

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

public System.Collections.Generic.IEnumerable<MLEM.Misc.Direction2> GetValidDirections(MLEM.Misc.Direction2 rotation);

Parameters

rotation MLEM.Misc.Direction2
The rotation

Returns

System.Collections.Generic.IEnumerable<MLEM.Misc.Direction2>
The rotations that are valid for this spot