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.

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(Person, Person, 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>

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(Person) 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<Person, float> PassivePriority

Field Value

Func<Person, 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, bool, Func<(ActionInfo Info, Person 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 Person 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, bool automatic, Func<(ActionInfo Info, Person Other, bool Automatic), CanExecuteResult> canExecute = null, bool showRelationship = true)

Parameters

info ActionInfo

The action info.

automatic bool

Whether the action variety was selected automatically.

canExecute Func<(ActionInfo Info, Person 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(Person)

Returns the passive priority of this action variety, which is based on PassivePriority.

public float GetPassivePriority(Person person)

Parameters

person Person

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(Person, Person, bool)

A helper method intended to be used with CustomLayout that creates a layout that includes the Portrait of the given Person in the center bottom.

public static Action<(Group Group, Button Button, Image Tickmark, Tooltip Tooltip)> PortraitLayout(Person person, Person otherPerson, bool showRelationship)

Parameters

person Person

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

otherPerson Person

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.