Table of Contents

Class ActionArgument

Namespace
TinyLife.Actions
Assembly
Tiny Life.dll

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.

public class ActionArgument : GenericDataHolder, IGenericDataHolder
Inheritance
GenericDataHolder
ActionArgument
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

addedConstructorArgument object

An added constructor arugment that is passed to the Action.

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

name string

The name of this action variety.

addedConstructorArguments Func<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

name string

The name of this action variety.

addedConstructorArguments object[]

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

Func<ActionType, ActionInfo, IEnumerable<object>>

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

ActionType.CanExecuteDelegate

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

Action<(Group Group, Button Button, Image Tickmark, Tooltip Tooltip)>

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

Func<string>

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

Func<string>

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

Func<CanExecuteResult, bool>

Name

The name of this action variety

public string Name

Field Value

string

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

Func<PersonLike, float>

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

info ActionInfo

The action info

automatic bool

Whether 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

info ActionInfo

The action info.

canExecute Func<(ActionInfo Info, PersonLike Other, bool Automatic), CanExecuteResult>

A ActionType.CanExecuteDelegate-esque function that determines whether a given person should be included.

showRelationship bool

Whether 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

person PersonLike

The 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

height float

The height that each button should have

draw Element.DrawCallback

A MLEM.Ui.Elements.Element.DrawCallback that can be used to draw onto the button

padding Padding

The 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

person PersonLike

The person that will be interacting with the portrait layout, and subsequently the otherPerson.

otherPerson PersonLike

The person to create the portrait layout for

showRelationship bool

Whether the relationship level between the person and the otherPerson should 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

furniture IEnumerable<Furniture>

The furniture stored. If this is null, Empty<TResult>() is returned.

canExecute Func<(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.