ActionVariety - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life


ActionVariety Struct

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 TinyLife.Actions.ActionType.PrepareFood to determine the kind of food that should be prepared.

public struct ActionVariety :

Implements MLEM.Misc.IGenericDataHolder


ActionVariety.ActionVariety(string) Constructor

Creates a new action variety with the given name

public ActionVariety(string name);


name System.String
The name of this action variety


ActionVariety.CanExecute Field

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 CanExecuteDelegate CanExecute;

Field Value

CanExecuteDelegate(ActionInfo, bool)

ActionVariety.CustomLayout Field

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.Button that is passed can be modified to look different based on this variety.
Predefined custom layouts such as ImageLayout(float, DrawCallback, Padding) can be found statically in this class.

public Action<Button> CustomLayout;

Field Value


ActionVariety.Description Field

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


ActionVariety.DisplayName Field

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


ActionVariety.Name Field

The name of this action variety

public string Name;

Field Value


ActionVariety.PassivePriority Field

A function that returns the passive priority of this action variety.
This is an extension of PassivePriority

public Func<Person,int> PassivePriority;

Field Value



ActionVariety.CanBeExecuted(ActionInfo, bool) Method

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 TinyLife.Actions.ActionType.CanExecuteResult CanBeExecuted(TinyLife.Actions.ActionInfo info, bool automatic);


info ActionInfo
The action info

automatic System.Boolean
Whether the action is automatic


Whether this variety can currently be executed

ActionVariety.GetData<T>(string) Method

Returns a piece of generic data of the given type on this object.

public T GetData<T>(string key);

Type parameters

The type of the data stored


key System.String
The key that the data is stored by


The data, or default if it doesn't exist

Implements GetData(string)

ActionVariety.GetDataKeys() Method

Returns all of the generic data that this object stores.

public System.Collections.Generic.IReadOnlyCollection<string> GetDataKeys();


The generic data on this object

Implements GetDataKeys()

ActionVariety.GetDisplayName() Method

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();


This action variety's display name

ActionVariety.GetPassivePriority(Person) Method

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

public int GetPassivePriority(TinyLife.Objects.Person person);


person Person
The person for whom to return the passive priority


The passive priority of this action variety

ActionVariety.ImageLayout(float, DrawCallback, Padding) Method

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 TinyLife.Actions.ActionType.GetIngredientsSingle and TinyLife.Actions.ActionType.ChangeOutfit.

public static System.Action<MLEM.Ui.Elements.Button> ImageLayout(float height, MLEM.Ui.Elements.Element.DrawCallback draw, MLEM.Misc.Padding padding=default(MLEM.Misc.Padding));


height System.Single
The height that each button should have

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

padding MLEM.Misc.Padding
The padding that the group that the image is displayed on should have, defaults to no padding


An action that can be fed into CustomLayout

ActionVariety.SetData(string, object) Method

Store a piece of generic data on this object.

public void SetData(string key, object data);


key System.String
The key to store the data by

data System.Object
The data to store in the object

Implements SetData(string, object)