Table of Contents

Struct ActionType.TypeSettings

Namespace
TinyLife.Actions
Assembly
Tiny Life.dll

A struct that contains information about an ActionType

public struct ActionType.TypeSettings : IGenericDataHolder
Implements
IGenericDataHolder
Inherited Members
Extension Methods

Constructors

TypeSettings()

Creates a new type settings instance with the default values.

public TypeSettings()

TypeSettings(string, ObjectCategory, Type)

Creates a new type settings instance with the given values, as well as the default settings from TypeSettings().

public TypeSettings(string name, ObjectCategory context, Type constructedType)

Parameters

name string

The name of this action type

context ObjectCategory

A combined ObjectCategory flag that represents all of the objects that this action can be executed on. Setting the context to Nothing and giving the action ActionType.AiSettings causes it to be invoked from the AI as if it had the Self category instead.

constructedType Type

The type that is constructed in Construct<T>(ActionInfo, params ActionArgument[]) to create a new action instance. If additional arguments are required, use ConstructorArguments

Fields

Ai

A set of settings for PersonAi invocation of this action. This value defaults to AiSettings().

public ActionType.AiSettings Ai

Field Value

ActionType.AiSettings

CanExecute

A delegate that returns a CanExecuteResult based on whether the given situation allows this action to be executed. This value is initialized always return Valid. To query this delegate effectively, use CanExecuteAction(ActionType, ActionInfo, bool), which also validates the RequiredSkill, the RequiredPersonality and the RequiredEmotion.

public ActionType.CanExecuteDelegate CanExecute

Field Value

ActionType.CanExecuteDelegate

ConstructedType

The type that is constructed in Construct<T>(ActionInfo, params ActionArgument[]) to create a new action instance. If additional arguments are required, use ConstructorArguments.

public Type ConstructedType

Field Value

Type

ConstructorArguments

A function that can, optionally, return a set of object instances that should be passed to this action type's ConstructedType's constructor. If this function is null, which is its default value, the two arguments it receives (the ActionType and an ActionInfo) are passed directly to the constructor.

public Func<ActionType, ActionInfo, IEnumerable<object>> ConstructorArguments

Field Value

Func<ActionType, ActionInfo, IEnumerable<object>>

Context

A combined ObjectCategory flag that represents all of the objects that this action can be executed on. Setting the context to Nothing and giving the action ActionType.AiSettings causes it to be invoked from the AI as if it had the Self category instead.

public ObjectCategory Context

Field Value

ObjectCategory

GetDisplayName

A function that determines this action's actual display name. The function is given the default display name (GetDisplayName(ActionInfo, bool)) and an ActionInfo for the current situation, the latter of which may be null. If this value is null (which it is by default), the default display name will be displayed.

public Func<string, ActionInfo, string> GetDisplayName

Field Value

Func<string, ActionInfo, string>

IconName

The name of the icon that this action type should display in front of its name. To make the icon work, its name needs to be added to the MLEM.Ui.UiSystem's MLEM.Formatting.TextFormatter using AddImage(TextFormatter, string, TextureRegion, bool). To access an action's icon name, including automatically set icon names, use GetIconName(ActionInfo) instead.

public Func<ActionInfo, string> IconName

Field Value

Func<ActionInfo, string>

IgnoreObjectConditions

A function that can return whether a given MapObject's action conditions should be ignored in a given case. This function is used in TryForceResult(CompletionType, CanExecuteResult?, MapObject) and CanExecuteAction(ActionType, ActionInfo, bool) to determine whether an action object should have a say in whether this action can be executed. By default, this function is null, meaning no action object conditions will be ignored.

public Func<(ActionInfo Info, bool Automatic, MapObject Object, bool IsAuxiliary, CanExecuteResult Reason), bool> IgnoreObjectConditions

Field Value

Func<(ActionInfo Info, bool Automatic, MapObject Object, bool IsAuxiliary, CanExecuteResult Reason), bool>

IsInappropriateElsewhere

If this value is true, this action will not automatically be invoked by PersonAi on lots that the person does not own. Additionally, when the player invokes an action with this value set to true, the lot's owner will come up to them and tell them to stop. To query this value effectively, you can use IsInappropriate(ActionType, ActionInfo).

public Func<ActionInfo, bool> IsInappropriateElsewhere

Field Value

Func<ActionInfo, bool>

MaximumArguments

The maximum amount of PossibleArguments that can be passed to the action's constructor at once. This value defaults to 1 and, if increased, the action selection menu will automatically switch to displaying a multi-select menu.

public int MaximumArguments

Field Value

int

Migrations

The migrations that will be applied for an instance of this action type when it is loaded from disk.

public List<Migration<Action>> Migrations

Field Value

List<Migration<Action>>

Name

The name of this action type

public string Name

Field Value

string

NoValidArgumentsResult

A CanExecuteResult that is returned and displayed if no valid valid argument is found in this settings' PossibleArguments. This value defaults to Hidden.

public CanExecuteResult NoValidArgumentsResult

Field Value

CanExecuteResult

PossibleArguments

A set of ActionArgument instances that represent different versions of this action. If this is set, and a non-null collection is returned, a menu pops up (like when cooking food) that displays all of the arguments as options to the user. If the returned collection is empty, the action is treated the same as if its CanExecute function returned the NoValidArgumentsResult. When the PersonAi invokes an action with a set of arguments, it chooses arguments randomly based on the amount of MaximumArguments and the arguments' PassivePriority. To query this function and do all of the appropriate error handling, use GetPossibleArguments(ActionInfo, bool) or GetRandomValidArguments(ActionType, ActionInfo, bool).

public Func<ActionInfo, bool, IEnumerable<ActionArgument>> PossibleArguments

Field Value

Func<ActionInfo, bool, IEnumerable<ActionArgument>>

RequiredAges

A combined flag of AgeGroup values that determines people of which ages can do this action. This defaults to ChildOrOlder.

public AgeGroup RequiredAges

Field Value

AgeGroup

RequiredEmotion

The EmotionType that is required for this action to be available. If the IconName is not set, the requird emotion's icon will automatically be used.

public EmotionType RequiredEmotion

Field Value

EmotionType

RequiredJob

The JobType that a person executing this action is required to have for this action to be available. If the IconName is not set, the required job type's icon will automatically be used.

public JobType RequiredJob

Field Value

JobType

RequiredPartnerAges

The AgeGroup values that an action partner can have for this action to become available to a person. By default, this value is 0, meaning all ages are allowed, and a partner is not required for the action.

public AgeGroup RequiredPartnerAges

Field Value

AgeGroup

RequiredPartnerEmployment

The LotType that this interaction's partner (GetActionObject<T>(bool)) has to be working on. This is useful for actions like OrderCoffee which require talking to a Cafe employee. If the IconName is not set, the required lot type's icon will automatically be used.

public LotEmployment RequiredPartnerEmployment

Field Value

LotEmployment

RequiredPartnerType

The type of PersonLike that this interaction's partner (GetActionObject<T>(bool)) is required to have to execute this action. This defaults to null, meaning no partner is required.

public Type RequiredPartnerType

Field Value

Type

RequiredPersonType

The type of PersonLike that is required to execute this action. This defaults to the Person type.

public Type RequiredPersonType

Field Value

Type

RequiredPersonality

The PersonalityType that is required for this action to be available. If the IconName is not set, the required personality type's icon will automatically be used.

public PersonalityType RequiredPersonality

Field Value

PersonalityType

RequiredSkill

The SkillType and level of the skill that is required for this action to become available, where otherwise it will be Hidden. When the required skill is leveled up, this action will also be displayed in the list of now-available actions. If the IconName is not set, the required skill's icon will automatically be used.

public (SkillType Type, int Level) RequiredSkill

Field Value

(SkillType Type, int Level)

RequiredUpgrade

The Upgrade that is required on the action object for this action to be available. If the IconName is not set, the required upgrade's icon will automatically be used.

public Upgrade RequiredUpgrade

Field Value

Upgrade

Texture

The texture region used in the top left action queue display in-game. If this value is null, GetIconObject() is used for the icon instead.

public TextureRegion Texture

Field Value

TextureRegion

Properties

Categories

The categories of this action type. The categories are strings at the start of this action type's Name delimited with a slash (/) character. This property automatically returns a substring of Name, converted to an array.

public readonly string[] Categories { get; }

Property Value

string[]

NameWithoutCategory

The Name of this action type, but without a possible category prefix. This property automatically returns a substring of Name.

public readonly string NameWithoutCategory { get; }

Property Value

string

Methods

GetDataKeys()

Returns all of the generic data that this object stores.

public readonly IEnumerable<string> GetDataKeys()

Returns

IEnumerable<string>

The generic data on this object

GetData<T>(string)

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

public readonly T GetData<T>(string key)

Parameters

key string

The key that the data is stored by

Returns

T

The data, or default if it doesn't exist

Type Parameters

T

The type of the data stored

SetData<T>(string, T)

Store a piece of generic data on this object.

public void SetData<T>(string key, T data)

Parameters

key string

The key to store the data by

data T

The data to store in the object

Type Parameters

T