ActionType_TypeSettings - Ellpeck/TinyLifeExampleMod Wiki

Original URL: https://github.com/Ellpeck/TinyLifeExampleMod/wiki/ActionType_TypeSettings

Tiny Life

TinyLife.Actions.ActionType

ActionType.TypeSettings Struct

A struct that contains information about an ActionType

public struct ActionType.TypeSettings :
MLEM.Misc.IGenericDataHolder

Implements MLEM.Misc.IGenericDataHolder

Constructors

ActionType.TypeSettings.TypeSettings(string, ObjectCategory, Type) Constructor

Creates a new type settings instance with the given values

public TypeSettings(string name, TinyLife.Objects.ObjectCategory context, System.Type constructedType);

Parameters

name System.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 AiSettings causes it to be invoked from the AI as if it had the Self category instead.

constructedType System.Type
The type that is constructed in Construct(ActionInfo, Nullable<ActionVariety>) to create a new action instance. If additional arguments are required, use ConstructorArguments

Fields

ActionType.TypeSettings.Ai Field

A set of settings for PersonAi invocation of this action.
This value defaults to default.

public AiSettings Ai;

Field Value

AiSettings

ActionType.TypeSettings.CanExecute Field

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 CanExecute(ActionInfo, bool), which also validates the RequiredSkill, the RequiredPersonality and the RequiredEmotion.

public CanExecuteDelegate CanExecute;

Field Value

CanExecuteDelegate(ActionInfo, bool)

ActionType.TypeSettings.ConstructedType Field

The type that is constructed in Construct(ActionInfo, Nullable<ActionVariety>) to create a new action instance.
If additional arguments are required, use ConstructorArguments.

public Type ConstructedType;

Field Value

System.Type

ActionType.TypeSettings.ConstructorArguments Field

A function that can, optionally, return a set of System.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

System.Func<ActionType,ActionInfo,System.Collections.Generic.IEnumerable<System.Object>>

ActionType.TypeSettings.Context Field

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 AiSettings causes it to be invoked from the AI as if it had the Self category instead.

public ObjectCategory Context;

Field Value

ObjectCategory

ActionType.TypeSettings.GetDisplayName Field

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.
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

System.Func<System.String,ActionInfo,System.String>

ActionType.TypeSettings.IconName Field

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 MLEM.Formatting.Codes.ImageCodeExtensions.AddImage(MLEM.Formatting.TextFormatter,System.String,MLEM.Textures.TextureRegion,System.Boolean).
To access an action's icon name, including automatically set icon names, use GetIconName() instead.

public string IconName;

Field Value

System.String

ActionType.TypeSettings.IsInappropriateElsewhere Field

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.

public bool IsInappropriateElsewhere;

Field Value

System.Boolean

ActionType.TypeSettings.Name Field

The name of this action type

public string Name;

Field Value

System.String

ActionType.TypeSettings.RequiredEmotion Field

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

ActionType.TypeSettings.RequiredPersonality Field

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

ActionType.TypeSettings.RequiredSkill Field

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,System.Int32>

ActionType.TypeSettings.Texture Field

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

MLEM.Textures.TextureRegion

ActionType.TypeSettings.Varieties Field

A set of ActionVariety 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 varieties as options to the user. If the returned collection is empty, the action is treated the same as if its CanExecute function returned Hidden.
When the PersonAi invokes an action with a variety, it chooses a variety randomly based on its PassivePriority

public Func<ActionInfo,IEnumerable<ActionVariety>> Varieties;

Field Value

System.Func<ActionInfo,System.Collections.Generic.IEnumerable<ActionVariety>>

Properties

ActionType.TypeSettings.Categories Property

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 string[] Categories { get; }

Property Value

System.String[]

ActionType.TypeSettings.NameWithoutCategory Property

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

public string NameWithoutCategory { get; }

Property Value

System.String

Methods

ActionType.TypeSettings.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)

ActionType.TypeSettings.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()

ActionType.TypeSettings.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)