Class Action
An action is something that a Person does. An action is always derived from an underlying ActionType that contains various action settings. Actions can be queued up for a person (ActionQueue) or currently active (CurrentActions). To create a more complex action, it is best to extend MultiAction. You can find a multitude of action-related events in Person, like OnActionsCompleted.
Inheritance
Implements
Inherited Members
Namespace: TinyLife.Actions
Assembly: Tiny Life.dll
Syntax
[DataContract]
public abstract class Action : JsonTypeSafeGenericDataHolder, IGenericDataHolder
Constructors
Action(ActionInfo)
Creates a new typeless action with the given action information.
Declaration
protected Action(ActionInfo info)
Parameters
Type | Name | Description |
---|---|---|
ActionInfo | info | The information for this action. |
Action(ActionType, ActionInfo)
Creates a new action with the given action information.
Declaration
protected Action(ActionType type, ActionInfo info)
Parameters
Type | Name | Description |
---|---|---|
ActionType | type | The type for this action. |
ActionInfo | info | The information for this action. |
Fields
ForceResult
This value can be set to a CompletionType to force IsCompleted() to return it. This is useful if there is an erroring calculation in your Update(GameTime, TimeSpan, Single) code, for example.
Declaration
protected CompletionType? ForceResult
Field Value
Type | Description |
---|---|
System.Nullable<CompletionType> |
Info
The ActionInfo for this action that contains the clicked (or otherwise targeted) objects and more
Declaration
[DataMember]
public readonly ActionInfo Info
Field Value
Type | Description |
---|---|
ActionInfo |
Random
A Random instance that can be used by actions. This value has the default seed.
Declaration
public static readonly Random Random
Field Value
Type | Description |
---|---|
System.Random |
Type
The ActionType that this action instance derives from
Declaration
[DataMember]
public readonly ActionType Type
Field Value
Type | Description |
---|---|
ActionType |
Properties
ElapsedTime
The amount of in-game time that has elapsed since this action has started
Declaration
[DataMember]
public TimeSpan ElapsedTime { get; protected set; }
Property Value
Type | Description |
---|---|
System.TimeSpan |
FullyInProgress
Returns whether this action is currently "properly" in progress. This is used by MultiAction and SocialAction and returns true only once the first actions are completed or the conversation has started, respectively. By default, this property is true if InProgressTime is greater than System.TimeSpan.Zero.
Declaration
public virtual bool FullyInProgress { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Whether this action is fully in progress |
InProgressTime
Represents the amount of time that this action has "properly" been in progress for. This is used by MultiAction and SocialAction and returns true only once the first actions are completed or the conversation has started, respectively. By default, ElapsedTime is returned.
Declaration
public virtual TimeSpan InProgressTime { get; }
Property Value
Type | Description |
---|---|
System.TimeSpan | The amount of time that this action has properly been in progress for |
Map
The Map that this action occurs on
Declaration
public Map Map { get; }
Property Value
Type | Description |
---|---|
Map |
Parent
The Action that created or otherwise owns this action. This is nonnull if this action is part of a UnderlyingActionHandler or MultiActionHandler.
Declaration
public Action Parent { get; }
Property Value
Type | Description |
---|---|
Action |
Person
The Person that this action is being executed by
Declaration
public Person Person { get; }
Property Value
Type | Description |
---|---|
Person |
PlayerPromptOpen
A property that stores whether a player prompt is currently open. A prompt can be opened using OpenPlayerPrompt(String, Predicate<Panel>, Action<Panel>, Boolean, Func<CoveringGroup, IEnumerable<Element>>, TextureRegion). This property can be used to ensure that an action is not paused or canceled while a player prompt is open, as, based on the implementation of the action, there might be certain update frames that still occur while the prompt is open.
Declaration
public bool PlayerPromptOpen { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
StartedAutomatically
If this value is true, this action was started using PersonAi or through another action rather than by the player
Declaration
[DataMember]
public bool StartedAutomatically { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
CanCancel(Action)
Returns whether or not this action can be canceled by the given outside source.
Note that the outside source can be null, and if it is, it means that the player canceled the action manually.
By default, actions can only be canceled if the cancelSource
is null.
Declaration
public virtual bool CanCancel(Action cancelSource)
Parameters
Type | Name | Description |
---|---|---|
Action | cancelSource | The source of the cancelation, or null if the player canceled it |
Returns
Type | Description |
---|---|
System.Boolean | true if the action can be canceled |
CancelIfEmotional(EmotionType[])
A helper method that returns Canceled if this action's Person has any of the given emotions
, and Active otherwise.
Declaration
public CompletionType CancelIfEmotional(params EmotionType[] emotions)
Parameters
Type | Name | Description |
---|---|---|
EmotionType[] | emotions | The emotions to cancel based on. |
Returns
Type | Description |
---|---|
CompletionType | A completion type based on whether any of the |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if the |
CanEnqueueConversation(Person, ActionType)
Returns true if the given person
can (automatically) enqueue a social action with the Person that is executing this action.
Note that enqueueing a social action manually is still possible even if this method returns false.
By default, only TinyLife.Actions.SleepAction returns false on this method.
Declaration
public virtual bool CanEnqueueConversation(Person person, ActionType type)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person that wants to converse with us. |
ActionType | type | The type of action that should be enqueued. Might be null, in which case a generic or unknown action is querying this function. |
Returns
Type | Description |
---|---|
System.Boolean | Whether or not enqueueing a social action is possible. |
CanMultitask(Action)
Return true on this method if this action can be multi-tasked along with the passed Action. To actually check this property, CanMultitask(Action, Action) should be used as it compares both objects. A multi-tasking is an action that is currently active along with another action. By default, multi-tasking is disallowed for any action.
Declaration
public virtual bool CanMultitask(Action other)
Parameters
Type | Name | Description |
---|---|---|
Action | other | The action to multi-task with |
Returns
Type | Description |
---|---|
System.Boolean | Whether this action can be multi-tasked |
CanMultitask(Action, Action)
A utility method that can be used whether the two Action instances can currently be invoked together. Internally, this checks if both actions return true on CanMultitask(Action).
Declaration
public static bool CanMultitask(Action a1, Action a2)
Parameters
Type | Name | Description |
---|---|---|
Action | a1 | The first action |
Action | a2 | The second action |
Returns
Type | Description |
---|---|
System.Boolean | Whether the two actions can be multi-tasked |
CausesExtremelyFastSpeed()
Returns true if this action, while it is currently active, should cause the ExtremelyFast speed to be available. By default, this method returns false.
Declaration
public virtual bool CausesExtremelyFastSpeed()
Returns
Type | Description |
---|---|
System.Boolean | Whether the extremely fast speed should be available |
CompleteIfNeedFull(NeedType)
Declaration
public CompletionType CompleteIfNeedFull(NeedType type)
Parameters
Type | Name | Description |
---|---|---|
NeedType | type | The need that should be completed |
Returns
Type | Description |
---|---|
CompletionType | The appropriate completion type |
CompleteIfTimeUp(TimeSpan, Boolean, SkillType, Single, Boolean)
A helper method that returns Completed if the given time
has passed.
This method makes use of GetEfficiencyModifier(Single, ActionInfo, SkillType, Single) to return true faster or slower based on the person's current mood and skill levels.
Declaration
public CompletionType CompleteIfTimeUp(TimeSpan time, bool efficiencyMatters = false, SkillType skill = null, float levelModifier = 0.1F, bool autoOnly = false)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | time | The (total!) amount of time after which this action should be completed |
System.Boolean | efficiencyMatters | Whether the person's efficiency modifier (GetEfficiencyModifier(Single, ActionInfo, SkillType, Single)) should be taken into account for the total time required |
SkillType | skill | A skill that optionally influences the completion time |
System.Single | levelModifier | The amount that each |
System.Boolean | autoOnly | Whether the action should only be completed in the given amount of time if it has been StartedAutomatically. If both this value and StartedAutomatically are true, this method always returns Active. |
Returns
Type | Description |
---|---|
CompletionType |
FacePartner(Person)
A utility method that causes this action's Person to face in the direction of the given partner
.
This method returns false if the Person is occupying a furniture object, or if they're standing in the same location as the partner
.
Declaration
public bool FacePartner(Person partner)
Parameters
Type | Name | Description |
---|---|---|
Person | partner |
Returns
Type | Description |
---|---|
System.Boolean | Whether it was possible to face in the partner's direction. |
FindAllActionObjects(Person, ActionType, Nullable<Vector2>)
Returns all ActionInfo objects that are available to the given Person for the given ActionType. The objects returned are the ones that would also be considered by the PersonAi when starting an action.
Declaration
public static IEnumerable<ActionInfo> FindAllActionObjects(Person person, ActionType type, Vector2? position = null)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person |
ActionType | type | The action to start |
System.Nullable<Microsoft.Xna.Framework.Vector2> | position | The position to focus around when finding action objects. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ActionInfo> | A set of action infos that the given action can be started with |
FindAllFreeFurniture(Person, ObjectCategory, FurnitureType, Boolean, Nullable<Vector2>, Nullable<Single>, Boolean, Boolean)
A helper method to find a set of all Furniture instances that are currently valid for interaction with the passed Person, ordered by their priority, where the first entry is the best possible Furniture object.
Declaration
public static IEnumerable<Furniture> FindAllFreeFurniture(Person person, ObjectCategory categories = null, FurnitureType objectSpotType = null, bool needsFreeActionSpot = true, Vector2? position = null, float? radius = null, bool allowBroken = false, bool ignoreVisibility = false)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person that wants to start the aciton |
ObjectCategory | categories | The categories that the furniture should have |
FurnitureType | objectSpotType | The type of item that an object spot should be available for, or null if this is not required |
System.Boolean | needsFreeActionSpot | Whether or not the furniture returned needs a non-occupied ActionSpot |
System.Nullable<Microsoft.Xna.Framework.Vector2> | position | The position that we should find people around, or null to use the passed person's position |
System.Nullable<System.Single> | radius | The radius that should be searched for people in, or 32 by default |
System.Boolean | allowBroken | Whether furniture that is Broken can be returned |
System.Boolean | ignoreVisibility | Whether the visibility (IsLotVisible(Lot)) of the object's lot should be ignored, or false by default |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Furniture> | A set of valid furniture |
FindAllFreeGround(Person, Nullable<Vector2>, Nullable<Single>, Boolean)
A helper method to find a set of all positions on the ground that are currently valid for interaction
Declaration
public static IEnumerable<Point> FindAllFreeGround(Person person, Vector2? position = null, float? radius = null, bool ignoreVisibility = false)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person that wants to start the aciton |
System.Nullable<Microsoft.Xna.Framework.Vector2> | position | The position that the ground should be around, or null to use the |
System.Nullable<System.Single> | radius | The radius that should be searched for ground positions in, or 32 by default |
System.Boolean | ignoreVisibility | Whether the visibility (IsLotVisible(Lot)) of the object's lot should be ignored, or false by default |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Microsoft.Xna.Framework.Point> | A set of valid locations |
FindAllFreePeople(Person, ActionType, Nullable<Vector2>, Nullable<Single>, Boolean)
A helper method to find a set of all Person instances that are currently valid for interaction with the passed Person, ordered by their priority, where the first entry is the best possible Person.
Declaration
public static IEnumerable<Person> FindAllFreePeople(Person person, ActionType type = null, Vector2? position = null, float? radius = null, bool ignoreVisibility = false)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person that wants to start the aciton |
ActionType | type | The type of action we want to start |
System.Nullable<Microsoft.Xna.Framework.Vector2> | position | The position that we should find people around, or null to use the passed person's position |
System.Nullable<System.Single> | radius | The radius that should be searched for people in, or 32 by default |
System.Boolean | ignoreVisibility | Whether the visibility (IsLotVisible(Lot)) of the object's lot should be ignored, or false by default |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Person> | A set of valid interaction partners |
FindAllFreeWalls(Person, Nullable<Vector2>, Nullable<Single>, Boolean)
A helper method to find a set of all Wall instances that are currently valid for interaction with the passed Person
Declaration
public static IEnumerable<Wall> FindAllFreeWalls(Person person, Vector2? position = null, float? radius = null, bool ignoreVisibility = false)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person that wants to start the aciton |
System.Nullable<Microsoft.Xna.Framework.Vector2> | position | The position that the walls should be around, or null to use the |
System.Nullable<System.Single> | radius | The radius that should be searched for walls in, or 32 by default |
System.Boolean | ignoreVisibility | Whether the visibility (IsLotVisible(Lot)) of the object's lot should be ignored, or false by default |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Wall> | A set of valid walls |
FindFreeFurniture(Person, ObjectCategory, FurnitureType, Nullable<Vector2>, Boolean, Boolean)
A helper method to find the best Furniture instance to interact with based on the given data. Note that this method always returns a ActionInfo related to the first result from FindAllFreeFurniture(Person, ObjectCategory, FurnitureType, Boolean, Nullable<Vector2>, Nullable<Single>, Boolean, Boolean).
Declaration
public static ActionInfo FindFreeFurniture(Person person, ObjectCategory categories, FurnitureType objectSpotType = null, Vector2? position = null, bool allowBroken = false, bool ignoreVisibility = false)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person that wants to start the aciton |
ObjectCategory | categories | The categories that the furniture should have |
FurnitureType | objectSpotType | The type of item that an object spot should be available for, or null if this is not required |
System.Nullable<Microsoft.Xna.Framework.Vector2> | position | The position that we should find people around, or null to use the passed person's position |
System.Boolean | allowBroken | Whether furniture that is Broken can be returned |
System.Boolean | ignoreVisibility | Whether the visibility (IsLotVisible(Lot)) of the object's lot should be ignored, or false by default |
Returns
Type | Description |
---|---|
ActionInfo | An action info for the best furniture, or null if there is none |
FindValidActionObjects(Person, ActionType, Boolean, Nullable<Vector2>, Boolean, Boolean)
Returns all ActionInfo objects that are available to the given Person for the given ActionType, and whose CanExecute(ActionInfo, Boolean) indicates that the actions are valid for execution. This method also checks IsInappropriateElsewhere.
Declaration
public static IEnumerable<ActionInfo> FindValidActionObjects(Person person, ActionType type, bool automatic, Vector2? position = null, bool allowInappropriate = false, bool allowInvalid = false)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person. |
ActionType | type | The action to start. |
System.Boolean | automatic | Whether the action is considered to start automatically. |
System.Nullable<Microsoft.Xna.Framework.Vector2> | position | The position to focus around when finding action objects. |
System.Boolean | allowInappropriate | Whether to ignore the IsInappropriateElsewhere flag. |
System.Boolean | allowInvalid |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ActionInfo> | A set of action infos that the given action can be started with. |
GetDisplayName()
Returns a localized string that explains this action in short. By default, this method returns GetDisplayName(ActionInfo, Boolean).
Declaration
public virtual string GetDisplayName()
Returns
Type | Description |
---|---|
System.String | This action's display name |
GetFreeChair(Person, Furniture)
A helper method that returns an ActionInfo for a ActionSpot on a Furniture with the Chair category that is closest to the given object which is on a desk or table.
The furniture returned is the one that the person should Sit(Furniture, Single, ActionSpot) on when interacting with the passed deskObject
.
This method will return the deskObject
's parent itself if it is a picnic-style table that has benches directly attached to it.
Declaration
public static (Furniture Chair, ActionSpot Spot, Direction2 Direction) GetFreeChair(Person person, Furniture deskObject)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person to get the free chair for |
Furniture | deskObject | The object that is sat on a desk |
Returns
Type | Description |
---|---|
System.ValueTuple<Furniture, ActionSpot, MLEM.Misc.Direction2> | The corresponding chair, ActionSpot and the action spot's rotation, or default if there is none |
GetFreeChairs(Person, Furniture, Func<Direction2, Boolean>)
Returns a set of free chair furniture paired with an ActionSpot and accessible direction.
This method is used by GetFreeChair(Person, Furniture).
This method will return the table
itself if it is a picnic-style table that has benches directly attached to it.
Declaration
public static IEnumerable<(Furniture Chair, ActionSpot Spot, Direction2 Direction)> GetFreeChairs(Person person, Furniture table, Func<Direction2, bool> canSitThisWay = null)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person to get the free chairs for |
Furniture | table | The table that the chairs should be connected to |
System.Func<MLEM.Misc.Direction2, System.Boolean> | canSitThisWay | A function that determines whether a person can sit the given way, or null to allow all seating directions |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.ValueTuple<Furniture, ActionSpot, MLEM.Misc.Direction2>> | A set of chairs, their action spots and their seating directions |
GetIconObject()
Returns the map object that is displayed in the action queue in the top left of the screen. Note that this value is ignored if this action's type has a Texture. By default, the GetActionObject<T>(Boolean) is returned.
Declaration
public virtual MapObject GetIconObject()
Returns
Type | Description |
---|---|
MapObject | The icon object |
GetNextAction(CompletionType)
Returns an action that should be queued up immediately after this action completes. The queued up action is immediately started in the slot that this action occupied. Can be null, and is null by default.
Declaration
public virtual Action GetNextAction(CompletionType completion)
Parameters
Type | Name | Description |
---|---|---|
CompletionType | completion | The type that this action completed with |
Returns
Type | Description |
---|---|
Action | The follow-up action |
GetRandomVariety(IEnumerable<ActionVariety>, ActionInfo)
Returns a random action variety from the given set of action varieties based on their GetPassivePriority(Person). The returned variety is guaranteed to be executable in this scenario (CanBeExecuted(ActionInfo, Boolean)).
Declaration
public static ActionVariety GetRandomVariety(IEnumerable<ActionVariety> varieties, ActionInfo info)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<ActionVariety> | varieties | The action varieties to choose from |
ActionInfo | info | The action infos |
Returns
Type | Description |
---|---|
ActionVariety | A random, executable action variety |
GetTableSpot(Furniture, ActionSpot)
A helper method that returns the ObjectSpot on the table or desk that the given chair is connected to. This is the object spot that should be used for interaction if a person sits on the given chair.
Declaration
public static (Furniture Table, ObjectSpot Spot) GetTableSpot(Furniture chair, ActionSpot actionSpot = null)
Parameters
Type | Name | Description |
---|---|---|
Furniture | chair | The chair to get the table spot for |
ActionSpot | actionSpot | The action spot on the |
Returns
Type | Description |
---|---|
System.ValueTuple<Furniture, ObjectSpot> | The table spot, or null if there is none |
Initialize()
This method is called when the action is first started by a Person. Note that it is not called when the action gets added to the ActionQueue, but when it is moved to CurrentActions.
Declaration
public virtual void Initialize()
InvokeForBoth(Person, Person, Action<Person, Person>)
Invokes the given action for two people while passing both of them, first as the main, and then as the second, parameter to the given action
.
Declaration
public static void InvokeForBoth(Person person, Person other, Action<Person, Person> action)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The first person. |
Person | other | The second person. |
System.Action<Person, Person> | action | The action to invoke for both people passed. |
IsCompleted()
This method is called every update frame by a Person if this action is currently active to check if it should be stopped. If this returns a result other than Completed, OnCompleted(CompletionType) will be called and the action is stopped. By default, only ForceResult modifies the completion type, otherwise Active is returned.
Declaration
public virtual CompletionType IsCompleted()
Returns
Type | Description |
---|---|
CompletionType | The current completion type of this action |
OnCompleted(CompletionType)
This method is called when this action IsCompleted(), or if it is canceled from an outside source. Note that, if this method is called as a result of IsCompleted(), the CompletionType passed will be the same. By default, only OnActionCompleted(Action, CompletionType, Boolean) is called.
Declaration
public virtual void OnCompleted(CompletionType type)
Parameters
Type | Name | Description |
---|---|---|
CompletionType | type | The type that this action completed with |
OpenChoicePrompt(ChoicePromptInfo)
Opens a text prompt (OpenTextPrompt(String, Action<String>, Predicate<String>, TextField.Rule, String, TextureRegion)) that uses the ChoicePromptInfo system to display a set of options to the player, one of which is randomly chosen to be "correct", causing a positive effect to happen.
Declaration
public CoveringGroup OpenChoicePrompt(ChoicePromptInfo info)
Parameters
Type | Name | Description |
---|---|---|
ChoicePromptInfo | info | The choice prompt information to display. |
Returns
Type | Description |
---|---|
CoveringGroup | The CoveringGroup that contains the choice prompt. |
OpenPlayerPrompt(String, Predicate<Panel>, Action<Panel>, Boolean, Func<CoveringGroup, IEnumerable<Element>>, TextureRegion)
Opens a prompt for the player with the given elements, also pausing the game. This behavior is used for things like the QuitJob action, where a confirmation panel pops up. To check whether a player prompt is currently opened, see PlayerPromptOpen.
Declaration
public CoveringGroup OpenPlayerPrompt(string title, Predicate<Panel> canFinish, Action<Panel> onFinished, bool canExit, Func<CoveringGroup, IEnumerable<Element>> children, TextureRegion portrait = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | title | The title that should be displayed in the box, has to be localized if required |
System.Predicate<MLEM.Ui.Elements.Panel> | canFinish | A function that determines whether the Okay button can be pressed. If the function is null, no button is displayed. |
System.Action<MLEM.Ui.Elements.Panel> | onFinished | A function that is called once the Okay button is pressed. Can be null. |
System.Boolean | canExit | Whether the user can exit the window without making a decision by clicking the background |
System.Func<CoveringGroup, System.Collections.Generic.IEnumerable<MLEM.Ui.Elements.Element>> | children | The elements that should be displayed in this prompt, along with the title and possibly the Okay button if |
MLEM.Textures.TextureRegion | portrait | The portrait to display. If this is null, the Person's portrait is used. |
Returns
Type | Description |
---|---|
CoveringGroup |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if this action's Person is not part of the CurrentHousehold. |
OpenTextPrompt(String, Action<String>, Predicate<String>, TextField.Rule, String, TextureRegion)
Opens a prompt with a text box that allows the player to input a string. To check whether a player prompt is currently opened, see PlayerPromptOpen.
Declaration
public CoveringGroup OpenTextPrompt(string title, Action<string> onFinished, Predicate<string> isNameValid = null, TextField.Rule rule = null, string defaultText = null, TextureRegion portrait = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | title | The text to display in the prompt |
System.Action<System.String> | onFinished | An action that is executed when the okay button is pressed, which contains the string that was input into the text box |
System.Predicate<System.String> | isNameValid | A function that determines whether the name is valid. If this is null, all text inputs (except an empty string) will be valid. |
MLEM.Ui.Elements.TextField.Rule | rule | A rule to use for the MLEM.Ui.Elements.TextField |
System.String | defaultText | The text that should be displayed in the text field by default, or null to display no default text |
MLEM.Textures.TextureRegion | portrait | The portrait to display. If this is null, the Person's portrait is used. |
Returns
Type | Description |
---|---|
CoveringGroup |
OpenYesNoPrompt(String, Action, Action, TextureRegion)
Opens a prompt for the player that contains a yes and a no button along with some text. This prompt can be used to ensure that a player selected the right option in an important decision. To check whether a player prompt is currently opened, see PlayerPromptOpen.
Declaration
public CoveringGroup OpenYesNoPrompt(string title, Action onYes, Action onNo = null, TextureRegion portrait = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | title | The text to display in the prompt |
System.Action | onYes | The action that should be executed when the yes button is pressed |
System.Action | onNo | The action that should be executed when the no button is pressed |
MLEM.Textures.TextureRegion | portrait | The portrait to display. If this is null, the Person's portrait is used. |
Returns
Type | Description |
---|---|
CoveringGroup |
PickUpAndGoTo(ActionInfo, Func<Furniture, Boolean>, Func<Furniture, Boolean>, Boolean)
A helper method that returns a set of actions which cause the info
's Person to set up a holdable item on an expected parent object in such a way that interacting with it is possible afterwards. This utility method is used for actions like Eat, where it is desired that a person picks up a food item from a counter and brings it to a table, if required.
CanPickUpOrIsHoldingForTarget(ActionInfo, ObjectCategory, Func<Furniture, Boolean>, Nullable<CanExecuteResult>, Boolean, Boolean) provides a ActionType.CanExecuteDelegate equivalent to this method.
Declaration
public static IEnumerable<Action> PickUpAndGoTo(ActionInfo info, Func<Furniture, bool> isParentValid, Func<Furniture, bool> isItemValid, bool putDown = true)
Parameters
Type | Name | Description |
---|---|---|
ActionInfo | info | The action info. |
System.Func<Furniture, System.Boolean> | isParentValid | A predicate that determines whether the given furniture item is a valid parent. |
System.Func<Furniture, System.Boolean> | isItemValid | A predicate that determines whether the given furniture item is a valid holdable and carryable item for this purpose. |
System.Boolean | putDown | Whether the holdable item should be put down. If this is false, the person will only go to the goal location, but not put the item down on it. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Action> | The actions to execute to cause this behavior. |
PickUpAndGoTo(ActionInfo, ObjectCategory, ObjectCategory, Boolean)
A helper method that returns a set of actions which cause the info
's Person to set up a holdable item on an expected parent object in such a way that interacting with it is possible afterwards. This utility method is used for actions like Eat, where it is desired that a person picks up a food item from a counter and brings it to a table, if required.
CanPickUpOrIsHoldingForTarget(ActionInfo, ObjectCategory, Func<Furniture, Boolean>, Nullable<CanExecuteResult>, Boolean, Boolean) provides a ActionType.CanExecuteDelegate equivalent to this method.
Declaration
public static IEnumerable<Action> PickUpAndGoTo(ActionInfo info, ObjectCategory expectedParent, ObjectCategory expectedItem, bool putDown = true)
Parameters
Type | Name | Description |
---|---|---|
ActionInfo | info | The action info. |
ObjectCategory | expectedParent | A set of object categories that the goal parent is expected to have. |
ObjectCategory | expectedItem | A set of object categories that the item to hold and carry is expected to have. |
System.Boolean | putDown | Whether the |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Action> | The actions to execute to cause this behavior. |
Sit(Furniture, Single, ActionSpot)
A helper method that causes the Person to sit on the given object. This method causes the action spot to be occupied and the person's CurrentPose to be changed to Sitting. Additionally, the Energy need is restored a little bit. Note that this method has to be called every Update(GameTime, TimeSpan, Single) frame for the person to stay sat down.
Declaration
public bool Sit(Furniture chair, float speedMultiplier, ActionSpot spot = null)
Parameters
Type | Name | Description |
---|---|---|
Furniture | chair | The chair to sit on |
System.Single | speedMultiplier | The game speed multiplier, which represents how fast things should happen, which is usually determined by Speed |
ActionSpot | spot | The action spot to sit on, or null to select one automatically |
Returns
Type | Description |
---|---|
System.Boolean | Whether or not the chair can be sat on |
SpeakAlone(GameTime, Single, EmoteCategory, SpeakStyle, Int32)
Displays emotes for this action's Person with the given settings as if they were talking to themselves out loud. This is used by actions like PracticeJokes and PracticeSpeech.
Declaration
public bool SpeakAlone(GameTime time, float speedMultiplier, EmoteCategory emoteCategories, SpeakStyle speakStyles, int totalAmount = 2147483647)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.GameTime | time | The game's current time |
System.Single | speedMultiplier | The game speed multiplier, which represents how fast things should happen, which is usually determined by Speed |
EmoteCategory | emoteCategories | The categories to pick emotes from, can be a combined flag |
SpeakStyle | speakStyles | The speak styles to use for speech sounds, can be a combined flag |
System.Int32 | totalAmount | The total amount of emotes to display, defaults to an infinite amount (System.Int32.MaxValue) |
Returns
Type | Description |
---|---|
System.Boolean | Whether all emotes were succesfully displayed. This method only returns true if |
SpeakInConversation(Person, GameTime, Single, EmoteCategory, SpeakStyle, Nullable<EmoteCategory>, Nullable<SpeakStyle>, Int32)
Helper method to display emotes over each conversation partner in a back and forth fashion to make it seem like they are conversing. When used in SocialAction, only the action that IsMain should call this method.
Declaration
public bool SpeakInConversation(Person partner, GameTime time, float speedMultiplier, EmoteCategory emoteCategories, SpeakStyle speakStyles, EmoteCategory? partnerEmoteCategories = null, SpeakStyle? partnerSpeakStyles = null, int totalAmount = 2147483647)
Parameters
Type | Name | Description |
---|---|---|
Person | partner | The partner to speak in conversation with. |
Microsoft.Xna.Framework.GameTime | time | The current game time |
System.Single | speedMultiplier | The game speed multiplier, which represents how fast things should happen, which is usually determined by Speed |
EmoteCategory | emoteCategories | A combined flag representing the categories that emotes can be picked from |
SpeakStyle | speakStyles | The speak styles to use for speech sounds, can be a combined flag |
System.Nullable<EmoteCategory> | partnerEmoteCategories | The emote categories for the interaction partner to use, or null to use |
System.Nullable<SpeakStyle> | partnerSpeakStyles | The speak styles for the interaction partner to use, or null to use |
System.Int32 | totalAmount | The total amount of emotes that should be shown (not per person, but in total) |
Returns
Type | Description |
---|---|
System.Boolean | If |
TryForceResult(CompletionType, Nullable<CanExecuteResult>, MapObject)
This is an external version of ForceResult which can be called from outside sources, like a BreakableFurniture object. A reason is provided that can be used to decide whether the external object can cause this action to fail. By default, this action sets ForceResult to true and returns true if IgnoreObjectConditions doesn't return true.
Declaration
public virtual bool TryForceResult(CompletionType result, CanExecuteResult? reason = null, MapObject source = null)
Parameters
Type | Name | Description |
---|---|---|
CompletionType | result | The result to force. |
System.Nullable<TinyLife.Actions.CanExecuteResult> | reason | The reason for this action to fail. Can be null. |
MapObject | source | The object that is trying to force this action to fail. Can be null. |
Returns
Type | Description |
---|---|
System.Boolean | Whether this action was successfully forced to fail (if returning true, ForceResult should also be set to true). |
Update(GameTime, TimeSpan, Single)
This method is called every update frame if this action is currently active. By default, only the ElapsedTime is modified in this method and ActionUpdate(Action, GameTime, TimeSpan, Single, Boolean) is called.
Declaration
public virtual void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.GameTime | time | The current game time |
System.TimeSpan | passedInGame | The amount of time that has passed, in game time |
System.Single | speedMultiplier | The game speed multiplier, which represents how fast things should happen, which is usually determined by Speed |
Validate(Person)
Validates this action's data. This is called when a map is loaded from disk. When returning false on this method, the action is removed from the Person.
Declaration
public virtual bool Validate(Person person)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person that this action belongs to |
Returns
Type | Description |
---|---|
System.Boolean | Whether or not the action is still valid (or if it has invalid data) |