Class ActionInfo
An action info is a set of information that is required to execute an action
[DataContract]
public class ActionInfo : JsonTypeSafeGenericDataHolder, IGenericDataHolder
- Inheritance
-
JsonTypeSafeGenericDataHolderActionInfo
- 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
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
CurrentMap
public Map CurrentMap { get; }
Property Value
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
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
Person
The Person that is currently executing the action
public PersonLike Person { get; }
Property Value
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
MapThe map to add the location on.
location
PointThe location to add.
floor
intThe floor that the location is on.
Returns
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
MapThe map to add the location on.
location
Vector2The location to add.
floor
floatThe floor that the location is on.
Returns
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
MapObjectThe object to add
spot
ActionSpotAn optional action spot to store with the object which can be retrieved later using GetInvolvedActionSpot(Furniture)
Returns
FromActionInfo(PersonLike, 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(PersonLike person, ActionInfo original, bool addOriginalPersonAsAuxiliary = false)
Parameters
person
PersonLikeThe person that this action info should be related to.
original
ActionInfoThe original action info to copy data from.
addOriginalPersonAsAuxiliary
boolWhether 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(PersonLike, Map, Point, float)
Returns a new ActionInfo based on the given location (and no objects).
This is a helper method that calls FromLocation(PersonLike, Map, Vector2, float) with the center of the given location
.
public static ActionInfo FromLocation(PersonLike person, Map map, Point location, float floor)
Parameters
person
PersonLikeThe person that this action info should be related to
map
MapThe GoalMap that this action info should have.
location
PointThe location that this action info should have
floor
floatThe floor the location is on.
Returns
- ActionInfo
A new action info with the given data
FromLocation(PersonLike, Map, Vector2, float)
Returns a new ActionInfo based on the given location (and no objects)
public static ActionInfo FromLocation(PersonLike person, Map map, Vector2 location, float floor)
Parameters
person
PersonLikeThe person that this action info should be related to
map
MapThe GoalMap that this action info should have.
location
Vector2The location that this action info should have
floor
floatThe floor the location is on.
Returns
- ActionInfo
A new action info with the given data
FromObjectGeneric(PersonLike, MapObject)
Returns a new ActionInfo based on the given object, but no object spot
public static ActionInfo FromObjectGeneric(PersonLike person, MapObject obj)
Parameters
person
PersonLikeThe person that this action info should be related to
obj
MapObjectThe object that this action info should have
Returns
- ActionInfo
A new action info with the given data
FromObjectGeneric(PersonLike, 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(PersonLike person, Map map, Guid objectId, Vector2 objectPosition, float objectFloor)
Parameters
person
PersonLikeThe person that this action info should be related to.
map
MapThe GoalMap that this action info should have.
objectId
GuidThe Id of the object that this action info should have.
objectPosition
Vector2The Position of the object that this action info should have.
objectFloor
floatThe floor the object is on.
Returns
- ActionInfo
A new action info with the given data.
FromSelf(PersonLike)
Returns a new ActionInfo based on the given person, with the action object also being the person
public static ActionInfo FromSelf(PersonLike person)
Parameters
person
PersonLikeThe 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
FurnitureThe 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
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
ObjectCategoryThe category that the objects should have. Defaults to Nothing, meaning all categories are considered.
includeIndirectly
boolWhether indirectly involved objects, like the ParentFurniture and GetChildren<T>() of furniture, as well as the HoldingPerson of objects, should be included
allowFake
boolWhether 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
ObjectCategoryThe category that the objects should have. Defaults to Nothing, meaning all categories are considered.
includeIndirectly
boolWhether indirectly involved objects, like the ParentFurniture and GetChildren<T>() of furniture, as well as the HoldingPerson of objects, should be included
allowFake
boolWhether 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)
Converts this action info into a set of free action spots that the Person can interact with, and returns the first result, or null if there are none.
Depending on the GetActionObject<T>(bool), this method will return the first entry of GetFreeActionSpotInfos(PersonLike, ObjectCategory), GetFreeActionSpotInfos(Map, PersonLike), or, for the Ground context
, this action info is returned.
public ActionInfo ToFreeActionSpot(ObjectCategory context = null)
Parameters
context
ObjectCategoryThe context for which to return free action spot, or null to return an action spot for any contexts.
Returns
- ActionInfo
The action info, or null if there are none.
ToFreeActionSpots(ObjectCategory)
Converts this action info into a set of free action spots that the Person can interact with, and returns the results.
Depending on the GetActionObject<T>(bool), this method will return GetFreeActionSpotInfos(PersonLike, ObjectCategory), GetFreeActionSpotInfos(Map, PersonLike), or, for the Ground context
, this action info is returned.
public IEnumerable<ActionInfo> ToFreeActionSpots(ObjectCategory context = null)
Parameters
context
ObjectCategoryThe context for which to return free action spots, or null to return action spots for any contexts.
Returns
- IEnumerable<ActionInfo>
The action infos.
Validate(PersonLike)
Validates this action info. This method should only be called when this action info is read from disk.
public bool Validate(PersonLike person)
Parameters
person
PersonLikeThe person that this action info belongs to