Table of Contents

Class ActionInfo

Namespace
TinyLife.Actions
Assembly
Tiny Life.dll

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

[DataContract]
public class ActionInfo : JsonTypeSafeGenericDataHolder, IGenericDataHolder
Inheritance
JsonTypeSafeGenericDataHolder
ActionInfo
Implements
IGenericDataHolder
Inherited Members
JsonTypeSafeGenericDataHolder.GetDataKeys()
Extension Methods

Fields

ActionLocation

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>(bool)'s location or an offset based on the ActionSpot.

[DataMember]
public readonly Vector2 ActionLocation

Field Value

Vector2

Properties

ActionSpot

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

public ActionSpot ActionSpot { get; set; }

Property Value

ActionSpot

Lot

The lot that this action's GetActionObject<T>(bool) is on, or the lot that the ActionLocation is on if there is no action object.

public Lot Lot { get; }

Property Value

Lot

Map

The Map that the action is executed on

public Map Map { get; }

Property Value

Map

Person

The Person that is currently executing the action

public Person Person { get; }

Property Value

Person

Methods

AddAuxiliaryLocation(Point)

Adds an additional location that, along with ActionLocation, is involved in this action. Adding an auxiliary location causes GetInvolvedLocations() to consider it.

public bool AddAuxiliaryLocation(Point location)

Parameters

location Point

The location to add.

Returns

bool

AddAuxiliaryLocation(Vector2)

Adds an additional location that, along with ActionLocation, is involved in this action. Adding an auxiliary location causes GetInvolvedLocations() to consider it.

public bool AddAuxiliaryLocation(Vector2 location)

Parameters

location Vector2

The location to add.

Returns

bool

AddAuxiliaryObject(MapObject, ActionSpot)

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, bool) to consider it, as well as ActionUpdate(Action, GameTime, TimeSpan, float, bool) to be called for it.

public bool AddAuxiliaryObject(MapObject o, 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)

Returns

bool

FromActionInfo(Person, ActionInfo, bool)

Returns a new ActionInfo based on the given person, as well as the given original ActionInfo, from which all data except the Person is copied.

public static ActionInfo FromActionInfo(Person person, ActionInfo original, bool addOriginalPersonAsAuxiliary = false)

Parameters

person Person

The person that this action info should be related to.

original ActionInfo

The original action info to copy data from.

addOriginalPersonAsAuxiliary bool

Whether the original's Person should be added as an auxiliary object to the returned ActionInfo.

Returns

ActionInfo

A new action info with the given data.

FromLocation(Person, Point)

Returns a new ActionInfo based on the given location (and no objects). This is a helper method that calls FromLocation(Person, Vector2) with the center of the given location.

public static ActionInfo FromLocation(Person person, Point location)

Parameters

person Person

The person that this action info should be related to

location Point

The location that this action info should have

Returns

ActionInfo

A new action info with the given data

FromLocation(Person, Vector2)

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

public static ActionInfo FromLocation(Person person, Vector2 location)

Parameters

person Person

The person that this action info should be related to

location Vector2

The location that this action info should have

Returns

ActionInfo

A new action info with the given data

FromObjectGeneric(Person, Guid, Vector2)

Returns a new ActionInfo basd on the given object's Id and Position, but no object spot.

public static ActionInfo FromObjectGeneric(Person person, Guid objectId, Vector2 objectPosition)

Parameters

person Person

The person that this action info should be related to.

objectId Guid

The Id of the object that this action info should have.

objectPosition Vector2

The Position of the object that this action info should have.

Returns

ActionInfo

A new action info with the given data.

FromObjectGeneric(Person, MapObject)

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

public static ActionInfo FromObjectGeneric(Person person, 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

FromSelf(Person)

Returns a new ActionInfo based on the given person, with the action object also being the person

public static ActionInfo FromSelf(Person person)

Parameters

person Person

The person to create an action info from

Returns

ActionInfo

A new action info based on the person

GetActionObject<T>(bool)

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>(bool alsoReturnFake = true)

Parameters

alsoReturnFake bool

Returns

T

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

Type Parameters

T

The type that the action object is expected to be of

GetInvolvedActionSpot(Furniture)

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

public ActionSpot GetInvolvedActionSpot(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

GetInvolvedLocations()

Returns all of the locations that are involved in this action information, including the ActionLocation and any auxiliary locations added by AddAuxiliaryLocation(Vector2) or AddAuxiliaryLocation(Point).

public IEnumerable<Vector2> GetInvolvedLocations()

Returns

IEnumerable<Vector2>

This action's involved locations.

GetInvolvedObject<T>(ObjectCategory, bool, bool, Func<T, bool>)

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

public T GetInvolvedObject<T>(ObjectCategory category = null, bool includeIndirectly = true, bool allowFake = true, Func<T, bool> predicate = null) where T : MapObject

Parameters

category ObjectCategory

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

includeIndirectly bool

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

allowFake bool

Whether fake items held by players (see SetHeldObject<T>(FurnitureType, int[], Guid?, bool)) should also be returned.

predicate Func<T, bool>

A predicate to match against objects. If this is non-null, the first object that matches this predicate is returned.

Returns

T

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

Type Parameters

T

The type that the objects returned should have

GetInvolvedObjectIds()

Returns a collection of all of the object Id values involved in this action info. Possible return values include the action object (GetActionObject<T>(bool)), as well as auxiliary objects (AddAuxiliaryObject(MapObject, ActionSpot)).

public IEnumerable<Guid> GetInvolvedObjectIds()

Returns

IEnumerable<Guid>

The involved object ids.

GetInvolvedObjects<T>(ObjectCategory, bool, bool)

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>(bool) and the auxiliary objects added using AddAuxiliaryObject(MapObject, ActionSpot).

public IEnumerable<T> GetInvolvedObjects<T>(ObjectCategory category = null, bool includeIndirectly = true, bool allowFake = true)

Parameters

category ObjectCategory

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

includeIndirectly bool

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

allowFake bool

Whether fake items held by players (see SetHeldObject<T>(FurnitureType, int[], Guid?, bool)) should also be returned.

Returns

IEnumerable<T>

A set of objects that match the above criteria

Type Parameters

T

The type that the objects returned should have

ToFreeActionSpot(ObjectCategory)

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

this
is returned.
public ActionInfo ToFreeActionSpot(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

Validate(Person)

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

public bool Validate(Person person)

Parameters

person Person

The person that this action info belongs to

Returns

bool