Class ActionArgument
An action variety is a modification to a ActionType that represents a slightly changed version of the generic action type. Action varieties are used, for example, by PrepareFood to determine the kind of food that should be prepared. Whereas action information that can only be selected by the player can also be queried using OpenPlayerPrompt(string, Predicate<Panel>, Action<Panel>, bool, Action<CoveringGroup, Panel>, TextureRegion, float, bool) and its derivatives, action arguments can be randomly chosen by the AI based on their PassivePriority.
public class ActionArgument : GenericDataHolder, IGenericDataHolder
- Inheritance
-
GenericDataHolderActionArgument
- Implements
-
IGenericDataHolder
- Inherited Members
-
GenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
ActionArgument(object)
Creates a new action variety with the given settings.
The Name is set to the string representation of the addedConstructorArgument.
public ActionArgument(object addedConstructorArgument)
Parameters
ActionArgument(string, Func<ActionType, ActionInfo, IEnumerable<object>>)
Creates a new action variety with the given settings.
public ActionArgument(string name, Func<ActionType, ActionInfo, IEnumerable<object>> addedConstructorArguments)
Parameters
namestringThe name of this action variety.
addedConstructorArgumentsFunc<ActionType, ActionInfo, IEnumerable<object>>A set of added constructor arugments that are passed to the Action.
ActionArgument(string, params object[])
Creates a new action variety with the given settings.
public ActionArgument(string name, params object[] addedConstructorArguments)
Parameters
namestringThe name of this action variety.
addedConstructorArgumentsobject[]A set of added constructor arugments that are passed to the Action.
Fields
AddedConstructorArguments
A set of additional arguments passed to the Action contructor by this variety. This is used in Construct<T>(ActionInfo, params ActionArgument[]).
public Func<ActionType, ActionInfo, IEnumerable<object>> AddedConstructorArguments
Field Value
CanExecute
A function that returns whether or not this action variety can currently be chosen. This is an extension of CanExecute. To query this delegate effectively, use CanBeExecuted(ActionInfo, bool).
public ActionType.CanExecuteDelegate CanExecute
Field Value
CustomLayout
An action that is invoked when this action variety is added to a play mode ui. If this action is set, the MLEM.Ui.Elements.Group or its main MLEM.Ui.Elements.Button can be modified to look different (or removed) based on this variety. Predefined custom layouts such as ImageLayout(float, DrawCallback, Padding) and PortraitLayout(PersonLike, PersonLike, bool) can be found statically in this class.
public Action<(Group Group, Button Button, Image Tickmark, Tooltip Tooltip)> CustomLayout
Field Value
Description
A function that is called to describe this action variety in more detail. This is used in the menu that pops up when the underlying ActionType is picked.
public Func<string> Description
Field Value
DisplayName
A function that is called to describe this action variety. This is used in the menu that pops up when the underlying ActionType is picked.
public Func<string> DisplayName
Field Value
MarkSeen
Whether to use the SeenObjects system for this action argument based on its Name. If this returns true, a green dot will display next to this action argument's button if it hasn't been seen by the player yet, and hovering over it will mark it as seen.
public Func<CanExecuteResult, bool> MarkSeen
Field Value
Name
The name of this action variety
public string Name
Field Value
PassivePriority
A function that returns the passive priority of this action variety. If this function is null (which it is by default), GetPassivePriority(PersonLike) will return 1. If this function returns 0, this variety will not be chosen by the AI. This is an extension of PassivePriority
public Func<PersonLike, float> PassivePriority
Field Value
Methods
CanBeExecuted(ActionInfo, bool)
Returns whether this action variety can be executed using the provided ActionInfo. This returns the result of CanExecute, or Valid if it is null.
public CanExecuteResult CanBeExecuted(ActionInfo info, bool automatic)
Parameters
infoActionInfoThe action info
automaticboolWhether the action is automatic
Returns
- CanExecuteResult
Whether this variety can currently be executed
FreePeople(ActionInfo, Func<(ActionInfo Info, PersonLike Other, bool Automatic), CanExecuteResult>, bool)
A helper method that returns a set of ActionArgument instances that represents a set of people that are currently around and able to be interacted with. Each action variety contains passes the PersonLike instance in question as an AddedConstructorArguments rather than passing itself. This method is used for actions like AskToTaste, where a person can be selected to interact with from a variety menu.
public static IEnumerable<ActionArgument> FreePeople(ActionInfo info, Func<(ActionInfo Info, PersonLike Other, bool Automatic), CanExecuteResult> canExecute = null, bool showRelationship = true)
Parameters
infoActionInfoThe action info.
canExecuteFunc<(ActionInfo Info, PersonLike Other, bool Automatic), CanExecuteResult>A ActionType.CanExecuteDelegate-esque function that determines whether a given person should be included.
showRelationshipboolWhether the relationship level between the
info's Person and the free people should be displayed.
Returns
- IEnumerable<ActionArgument>
A set of action varieties that represents the free people around.
GetDisplayName()
Returns the display name of this action varietiy, which is either the value returned by DisplayName or a default localized display name
public string GetDisplayName()
Returns
- string
This action variety's display name
GetPassivePriority(PersonLike)
Returns the passive priority of this action variety, which is based on PassivePriority.
public float GetPassivePriority(PersonLike person)
Parameters
personPersonLikeThe person for whom to return the passive priority
Returns
- float
The passive priority of this action variety
ImageLayout(float, DrawCallback, Padding)
A helper method intended to be used with CustomLayout that creates a layout with large, rectangular variety buttons that can draw something on themselves. This layout is used by actions like GetIngredientsSingle and ChangeOutfit.
public static Action<(Group Group, Button Button, Image Tickmark, Tooltip Tooltip)> ImageLayout(float height, Element.DrawCallback draw, Padding padding = default)
Parameters
heightfloatThe height that each button should have
drawElement.DrawCallbackA MLEM.Ui.Elements.Element.DrawCallback that can be used to draw onto the button
paddingPaddingThe padding that the group that the image is displayed on should have, defaults to no padding
Returns
- Action<(Group Group, Button Button, Image Tickmark, Tooltip Tooltip)>
An action that can be fed into CustomLayout
PortraitLayout(PersonLike, PersonLike, bool)
A helper method intended to be used with CustomLayout that creates a layout that includes the Portrait of the given PersonLike in the center bottom.
public static Action<(Group Group, Button Button, Image Tickmark, Tooltip Tooltip)> PortraitLayout(PersonLike person, PersonLike otherPerson, bool showRelationship)
Parameters
personPersonLikeThe person that will be interacting with the portrait layout, and subsequently the
otherPerson.otherPersonPersonLikeThe person to create the portrait layout for
showRelationshipboolWhether the relationship level between the
personand theotherPersonshould be displayed.
Returns
- Action<(Group Group, Button Button, Image Tickmark, Tooltip Tooltip)>
An action that can be fed into CustomLayout
StoredFurniture(IEnumerable<Furniture>, Func<(ActionInfo Info, Furniture Furniture, bool Automatic), CanExecuteResult>)
A helper method that returns a set of ActionArgument instances that represents a set of furniture that is currently stored in an object. Each action variety contains passes the Furniture instance in question as an AddedConstructorArguments rather than passing itself.
public static IEnumerable<ActionArgument> StoredFurniture(IEnumerable<Furniture> furniture, Func<(ActionInfo Info, Furniture Furniture, bool Automatic), CanExecuteResult> canExecute = null)
Parameters
furnitureIEnumerable<Furniture>The furniture stored. If this is null, Empty<TResult>() is returned.
canExecuteFunc<(ActionInfo Info, Furniture Furniture, bool Automatic), CanExecuteResult>A ActionType.CanExecuteDelegate-esque function that determines whether a furniture item should be included.
Returns
- IEnumerable<ActionArgument>
A set of action varieties that represents the furniture stored in an object.