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

ActionFloor

The floor that this action info's ActionLocation is on, on the GoalMap.

[DataMember]
public readonly float ActionFloor

Field Value

float

ActionLocation

The location on the GoalMap 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 actionObject exists.

public ActionSpot ActionSpot { get; set; }

Property Value

ActionSpot

CurrentMap

The Map that the action is currently being executed on, which returns the Person's Map.

public Map CurrentMap { get; }

Property Value

Map

GoalMap

The Map that this action's action object, action wall and other key action components are expected to be on. This is essentially the map that the Person should do most of the action on. If no explicit goal map is stored, CurrentMap is returned.

public Map GoalMap { get; set; }

Property Value

Map

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

Person

The Person that is currently executing the action

public Person Person { get; }

Property Value

Person

Methods

AddAuxiliaryLocation(Map, Point, int)

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(Map map, Point location, int floor)

Parameters

map Map

The map to add the location on.

location Point

The location to add.

floor int

The floor that the location is on.

Returns

bool

AddAuxiliaryLocation(Map, Vector2, float)

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(Map map, Vector2 location, float floor)

Parameters

map Map

The map to add the location on.

location Vector2

The location to add.

floor float

The floor that the location is on.

Returns

bool

AddAuxiliaryObject(MapObject, ActionSpot)

Adds an additional object that, along with the 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. Auxiliary objects can be on the GoalMap or any of its Neighborhood members.

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, Map, Point, float)

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

public static ActionInfo FromLocation(Person person, Map map, Point location, float floor)

Parameters

person Person

The person that this action info should be related to

map Map

The GoalMap that this action info should have.

location Point

The location that this action info should have

floor float

The floor the location is on.

Returns

ActionInfo

A new action info with the given data

FromLocation(Person, Map, Vector2, float)

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

public static ActionInfo FromLocation(Person person, Map map, Vector2 location, float floor)

Parameters

person Person

The person that this action info should be related to

map Map

The GoalMap that this action info should have.

location Vector2

The location that this action info should have

floor float

The floor the location is on.

Returns

ActionInfo

A new action info with the given data

FromObjectGeneric(Person, MapObject)

Returns a new ActionInfo based 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

FromObjectGeneric(Person, Map, Guid, Vector2, float)

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

public static ActionInfo FromObjectGeneric(Person person, Map map, Guid objectId, Vector2 objectPosition, float objectFloor)

Parameters

person Person

The person that this action info should be related to.

map Map

The GoalMap that this action info should have.

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.

objectFloor float

The floor the object is on.

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, or isn't on the GoalMap. If this action is related to a WallLike 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 on the GoalMap 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(Map, Vector2, float).

public IEnumerable<(Map Map, Vector2 Pos, float Floor)> GetInvolvedLocations()

Returns

IEnumerable<(Map Map, Vector2 Pos, float Floor)>

This action's involved locations.

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.

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, as well as the HoldingPerson of objects, 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

GetInvolvedObjects<T>(ObjectCategory, bool, bool)

Returns a set of (distinct) objects of the given type T that match the given category. The objects considered are the 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, as well as the HoldingPerson of objects, 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