ActionVariety - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Actions

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 :
MLEM.Misc.IGenericDataHolder

Implements MLEM.Misc.IGenericDataHolder

Constructors

ActionVariety.ActionVariety(string) Constructor

Creates a new action variety with the given name

public ActionVariety(string name);

Parameters

name System.String
The name of this action variety

Fields

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

System.Action<MLEM.Ui.Elements.Button>

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

System.Func<System.String>

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

System.Func<System.String>

ActionVariety.Name Field

The name of this action variety

public string Name;

Field Value

System.String

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

System.Func<Person,System.Int32>

Methods

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

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether the action is automatic

Returns

CanExecuteResult
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

T
The type of the data stored

Parameters

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

Returns

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

Returns

System.Collections.Generic.IReadOnlyCollection<System.String>
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();

Returns

System.String
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);

Parameters

person Person
The person for whom to return the passive priority

Returns

System.Int32
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));

Parameters

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

Returns

System.Action<MLEM.Ui.Elements.Button>
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);

Parameters

key System.String
The key to store the data by

data System.Object
The data to store in the object

Implements SetData(string, object)