ActionInfo - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Actions

ActionInfo Class

An action info is a set of information that is required to execute an action

public class ActionInfo : MLEM.Misc.GenericDataHolder

Inheritance System.Object 🡒 MLEM.Misc.GenericDataHolder 🡒 ActionInfo

Fields

ActionInfo.ActionLocation Field

The location that this action should be executed in.
Note that, for manually executed actions, this is always the world position that the mouse was in.
For automatically executed actions, this is often the GetActionObject<T>()'s location or an offset based on the ActionSpot.

public readonly Vector2 ActionLocation;

Field Value

Microsoft.Xna.Framework.Vector2

Properties

ActionInfo.ActionSpot Property

c
The ActionSpot that this action is related to. Can be null, even if the TinyLife.Actions.ActionInfo.actionObject exists.

public TinyLife.Objects.ActionSpot ActionSpot { get; set; }

Property Value

ActionSpot

ActionInfo.Map Property

The Map that the action is executed on

public TinyLife.World.Map Map { get; }

Property Value

Map

ActionInfo.Person Property

The Person that is currently executing the action

public TinyLife.Objects.Person Person { get; set; }

Property Value

Person

Methods

ActionInfo.AddAuxiliaryObject(MapObject, ActionSpot) Method

Adds an additional object that, along with the TinyLife.Actions.ActionInfo.actionObject, is involved in this action.
Adding an auxiliary object causes GetInvolvedObjects<T>(ObjectCategory, bool) to consider it, as well as ActionUpdate(Action, GameTime, TimeSpan, GameSpeed, bool) to be called for it.

public void AddAuxiliaryObject(TinyLife.Objects.MapObject o, TinyLife.Objects.ActionSpot spot=null);

Parameters

o MapObject
The object to add

spot ActionSpot
An optional action spot to store with the object which can be retrieved later using GetInvolvedActionSpot(Furniture)

ActionInfo.FromLocation(Person, Vector2) Method

Returns a new ActionInfo based on the given location (and no objects)

public static TinyLife.Actions.ActionInfo FromLocation(TinyLife.Objects.Person person, Microsoft.Xna.Framework.Vector2 location);

Parameters

person Person
The person that this action info should be related to

location Microsoft.Xna.Framework.Vector2
The location that this action info should have

Returns

ActionInfo
A new action info with the given data

ActionInfo.FromObjectGeneric(Person, MapObject) Method

Returns a new ActionInfo basd on the given object, but no object spot

public static TinyLife.Actions.ActionInfo FromObjectGeneric(TinyLife.Objects.Person person, TinyLife.Objects.MapObject obj);

Parameters

person Person
The person that this action info should be related to

obj MapObject
The object that this action info should have

Returns

ActionInfo
A new action info with the given data

ActionInfo.GetActionObject<T>() Method

Returns the object that this action is related to, or null if there is none or the object isn't of the given type.
If this action is related to a Wall and T is Wall, the wall is returned. Otherwise, the involved MapObject is returned, if it matches T.

public T GetActionObject<T>();

Type parameters

T
The type that the action object is expected to be of

Returns

T
The action object, or null if there is none or the type does not match

ActionInfo.GetInvolvedActionSpot(Furniture) Method

Returns the involved action spot for the given involved Furniture.
If the furniture passed is the GetActionObject<T>(), the ActionSpot will be returned.
Otherwise, the action spot of the involved furniture stored using AddAuxiliaryObject(MapObject, ActionSpot) is returned.

public TinyLife.Objects.ActionSpot GetInvolvedActionSpot(TinyLife.Objects.Furniture involved);

Parameters

involved Furniture
The involved object whose action spot to return

Returns

ActionSpot
The involved action spot, or null if there is none

ActionInfo.GetInvolvedObject<T>(ObjectCategory, bool) Method

A helper method that returns the first available entry from GetInvolvedObjects<T>(ObjectCategory, bool) or null if there is none

public T GetInvolvedObject<T>(TinyLife.Objects.ObjectCategory category=null, bool includeIndirectly=true)
    where T : TinyLife.Objects.MapObject;

Type parameters

T
The type that the objects returned should have

Parameters

category ObjectCategory
The category that the objects should have. Defaults to Nothing, meaning all categories are considered.

includeIndirectly System.Boolean
Whether indirectly involved objects, like the ParentFurniture and GetChildren<T>() of furniture should be included

Returns

T
The first object that matches the criteria described in GetInvolvedObjects<T>(ObjectCategory, bool)

ActionInfo.GetInvolvedObjects<T>(ObjectCategory, bool) Method

Returns a set of objects of the given type T that match the given category.
The objects considered are the TinyLife.Actions.ActionInfo.actionObject, its ParentFurniture, its GetChildren<T>(), the Person's GetHeldObject<T>() and the auxiliary objects added using AddAuxiliaryObject(MapObject, ActionSpot).

public System.Collections.Generic.IEnumerable<T> GetInvolvedObjects<T>(TinyLife.Objects.ObjectCategory category=null, bool includeIndirectly=true);

Type parameters

T
The type that the objects returned should have

Parameters

category ObjectCategory
The category that the objects should have. Defaults to Nothing, meaning all categories are considered.

includeIndirectly System.Boolean
Whether indirectly involved objects, like the ParentFurniture and GetChildren<T>() of furniture should be included

Returns

System.Collections.Generic.IEnumerable<T>
A set of objects that match the above criteria

ActionInfo.OccupyFreeActionSpot(ObjectCategory, bool, Nullable<Direction2>) Method

This is a shorthand method for OccupyFreeActionSpot(Furniture, ObjectCategory, bool, Nullable<Direction2>).
Note that this method needs to be called every update frame for the person to keep occupying the action spot.

public bool OccupyFreeActionSpot(TinyLife.Objects.ObjectCategory context=null, bool enter=false, System.Nullable<MLEM.Misc.Direction2> rotation=null);

Parameters

context ObjectCategory
The category that the action spot should have

enter System.Boolean
Whether or not the action spot should be entered

rotation System.Nullable<MLEM.Misc.Direction2>
The rotation that the person should have, or the action spot's rotation by default

Returns

System.Boolean
Whether or not we were able to occupy a free action spot

ActionInfo.ToFreeActionSpot(ObjectCategory) Method

Returns the first free action spot that matches the given ObjectCategory flag for this action's GetActionObject<T>().
If this action has no action object and context contains Ground, csharp this is returned.

public TinyLife.Actions.ActionInfo ToFreeActionSpot(TinyLife.Objects.ObjectCategory context=null);

Parameters

context ObjectCategory
The category that the action spot should have

Returns

ActionInfo
The corresponding action info, or null if there is none

ActionInfo.Validate(Person) Method

Validates this action info.
This method should only be called when this action info is read from disk.

public void Validate(TinyLife.Objects.Person person);

Parameters

person Person
The person that this action info belongs to