ActionType - Ellpeck/TinyLifeExampleMod Wiki

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

Tiny Life

TinyLife.Actions

ActionType Class

Action types are blueprints for Action instances which can be registered using Register(TypeSettings).
An action type contains information about its action and can create an instance using ConstructedType.

public class ActionType

Inheritance System.Object 🡒 ActionType

Fields

ActionType.Types Field

A list of all available action types.
To register your own action types, use the Register(TypeSettings) method.

public static readonly IDictionary<string,ActionType> Types;

Field Value

System.Collections.Generic.IDictionary<System.String,ActionType>

Properties

ActionType.Settings Property

The TypeSettings for this action type, which actually contain this type's properties.

public TinyLife.Actions.ActionType.TypeSettings Settings { get; }

Property Value

TypeSettings

Methods

ActionType.AreDating(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines whether the person and the interaction partner are currently dating

public static TinyLife.Actions.ActionType.CanExecuteResult AreDating(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether the action is automatic (unused)

Returns

CanExecuteResult
Valid if they are dating, Hidden otherwise

ActionType.CanBeSexual(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines whether a person can invoke a sexual activity.
A Person can invoke such an activity iff automatic is false, or the person is not asexual (IsAsexual).

public static TinyLife.Actions.ActionType.CanExecuteResult CanBeSexual(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether this action is automatic

Returns

CanExecuteResult
Hidden if the person cannot be sexual, Valid otherwise

ActionType.CanDoImportantAction(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines whether an important action can be executed.
An important action can be executed if it is manual, not in the current household, or the per-save option AiImportantActions is true.

public static TinyLife.Actions.ActionType.CanExecuteResult CanDoImportantAction(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether the action is automatic

Returns

CanExecuteResult
Valid if an important action can be executed, Hidden otherwise

ActionType.CanExecute(ActionInfo, bool) Method

Returns this action's CanExecute delegate's result.
This method additionally catches and handles any exceptions by printing them out as a Notifications notification to the player.

public TinyLife.Actions.ActionType.CanExecuteResult CanExecute(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether the action is automatically executed

Returns

CanExecuteResult
A CanExecuteResult that represents whether the action can be executed right now

ActionType.CanExecuteAll(ActionInfo, bool, CanExecuteDelegate[]) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines if all of the passed CanExecuteDelegate(ActionInfo, bool) checks pass.
If one of the passed checks does not pass, its result is returned. If all of them pass, Valid is returned.
This method is designed to be used with the other helper methods in this class, for example:

  
CanExecuteAll(info, automatic, HasChair, IsFunctional, IsEmptyHanded)  
public static TinyLife.Actions.ActionType.CanExecuteResult CanExecuteAll(TinyLife.Actions.ActionInfo info, bool automatic, params TinyLife.Actions.ActionType.CanExecuteDelegate[] conditions);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether this action is automatic

conditions CanExecuteDelegate(ActionInfo, bool)[]
The conditions that should be checked

Returns

CanExecuteResult
Valid if all of the conditions are valid, else the first invalid result

ActionType.CanPlaceHeldItem(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines whether or not the item that is currently held by the given person can be placed in an object spot on the given object.

public static TinyLife.Actions.ActionType.CanExecuteResult CanPlaceHeldItem(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether or not this action is started automatically. This property is unused, but present for ease of use with CanExecute

Returns

CanExecuteResult
Valid if the object has a free object spot, otherwise Hidden

ActionType.CanWorkAtDeskObject(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines if the action object (which is expected to be a desk object like a computer) meets all of the criteria for working at it

public static TinyLife.Actions.ActionType.CanExecuteResult CanWorkAtDeskObject(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether this action is automatic (unused)

Returns

CanExecuteResult
Valid if the desk object can be worked at, several possible results like NoChair and HoldingItem otherwise

ActionType.Construct(ActionInfo, Nullable<ActionVariety>) Method

Creates a new Action instance of this ActionType.

public TinyLife.Actions.Action Construct(TinyLife.Actions.ActionInfo info, System.Nullable<TinyLife.Actions.ActionVariety> variety=null);

Parameters

info ActionInfo
The info that this action should be constructed with

variety System.Nullable<ActionVariety>
The variety, or null if this action has no varieties

Returns

Action
A new action instance with the given information

ActionType.GetDisplayName(ActionInfo, bool) Method

Returns a localized string that explains this action type in short.
Note that, for instantiated actions, GetDisplayName() should be used.

public string GetDisplayName(TinyLife.Actions.ActionInfo info, bool includeIcon=true);

Parameters

info ActionInfo
The action info, can be null if no action info is present

includeIcon System.Boolean
Whether the GetIconName() texture should be included at the start of the name

Returns

System.String
This action type's display name

ActionType.GetIconName() Method

Returns the name of this action type's icon, which is either the manually assigned icon (IconName), or an automatically assigned icon based on this action type's requirements, including RequiredSkill, RequiredEmotion and RequiredPersonality.
The icon name can be used in a MLEM.Ui.Elements.Paragraph as a MLEM.Formatting.Codes.ImageCode as follows: <c IconName>

public string GetIconName();

Returns

System.String
The name of this action type's icon

ActionType.GetSkillPriorityMod(Person, SkillType) Method

Returns a modifier that can be used for PassivePriority if an action involves a skill building activity.
Actions like TinyLife.Actions.ActionType.PracticeWriting and TinyLife.Actions.ActionType.PracticeProgramming use this to make sure that they are only executed if AiSkillBuilding is enabled.
The modifier returned can be multiplied with a constant, default passive priority.

public static float GetSkillPriorityMod(TinyLife.Objects.Person person, TinyLife.Skills.SkillType skill);

Parameters

person Person
The person to execute an action

skill SkillType
The skill whose building is involved in the action

Returns

System.Single
A modifier that is between 0 and 1, based on whether the person's personality or existing skills boost the passed skill

ActionType.HasChairOrIsStandingDesk(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines if the given object is sat on a table or desk that has a chair or sat on a standing desk that doesn't need a chair

public static TinyLife.Actions.ActionType.CanExecuteResult HasChairOrIsStandingDesk(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether or not this action is started automatically. This property is unused, but present for ease of use with CanExecute

Returns

CanExecuteResult
Valid if there is a chair, NoChair if there is no valid chair

ActionType.IsActionType(Type) Method

Returns whether this action type's ConstructedType is or extends the passed type t.
This method is equivalent to Settings.ConstructedType.IsAssignableTo(t).

public bool IsActionType(System.Type t);

Parameters

t System.Type
The type to compare this action's constructed type to

Returns

System.Boolean
true if the passed type is a supertype of, or the same type as, this action's constructed type

ActionType.IsComfortable(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines if the person is comfortable enough to execute an action.
A comfortable person is one that doesn't have the TinyLife.Emotions.EmotionType.Uncomfortable or TinyLife.Emotions.EmotionType.Sad emotions.
To check only for the TinyLife.Emotions.EmotionType.Uncomfortable emotion, use IsNotUncomfortable(ActionInfo, bool).

public static TinyLife.Actions.ActionType.CanExecuteResult IsComfortable(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether this action is automatic (unused)

Returns

CanExecuteResult
Valid if the person is comfortable, TooUncomfortable otherwise

ActionType.IsDislikedOrMean(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines if the action is executed manually, the given ActionInfo's person has the TinyLife.PersonalityType.Mean personality type, or if the interaction partner has the Disliked relationship type (or lower).
If the person's current Emotion is TinyLife.Emotions.EmotionType.Angry, this method also returns Valid.

public static TinyLife.Actions.ActionType.CanExecuteResult IsDislikedOrMean(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether this action is automatic

Returns

CanExecuteResult
Valid if any of the conditions are met, otherwise Hidden

ActionType.IsEmptyHanded(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines if the person is not holding an item.

public static TinyLife.Actions.ActionType.CanExecuteResult IsEmptyHanded(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether this action is automatic (unused)

Returns

CanExecuteResult
Valid if the person's hands are empty, HoldingItem otherwise

ActionType.IsFunctional(ActionInfo, bool) Method

A helper method inteded to be used with CanExecuteDelegate(ActionInfo, bool) that determines if the action object is broken or if utilities are disabled (AreUtilitiesDisabled(Nullable<TimeSpan>)) for the lot that the object is on

public static TinyLife.Actions.ActionType.CanExecuteResult IsFunctional(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether this action is automatic (unused)

Returns

CanExecuteResult
ObjectBroken if the object is broken, UtilitiesDisabled if utilities are disabled, or otherwise Valid

ActionType.IsHoldingOrValidParent(ActionInfo, ObjectCategory, Predicate<Furniture>, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that returns Valid in the following cases:
The held object and the action object matches the category The held object is null and the action objectt
This helper method is useful in cases like TinyLife.Actions.ActionType.Eat, where the action should be allowed if the person is holding a food plate and clicking a chair, or if a person is clicking the food plate itself.

public static TinyLife.Actions.ActionType.CanExecuteResult IsHoldingOrValidParent(TinyLife.Actions.ActionInfo info, TinyLife.Objects.ObjectCategory goalParent, System.Predicate<TinyLife.Objects.Furniture> isAllowed, bool parentHasToExist=false);

Parameters

info ActionInfo
The action info

goalParent ObjectCategory
The object that the required item should be a child of

isAllowed System.Predicate<Furniture>
A predicate that checks if the given item is the one searched for

parentHasToExist System.Boolean
Whether the parent furniture has to be visible somewhere, even if the action object is being held. This is checked using FindFreeFurniture(Person, ObjectCategory, FurnitureType, Nullable<Vector2>, bool).

Returns

CanExecuteResult
A result that represents the validity of the action

ActionType.IsNotEmbarrassed(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines if the person is TinyLife.Emotions.EmotionType.Embarrassed or not

public static TinyLife.Actions.ActionType.CanExecuteResult IsNotEmbarrassed(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether this action is automatic (unused)

Returns

CanExecuteResult
Valid if the person is not embarrassed, TooEmbarrassed otherwise

ActionType.IsNotExpired(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines whether the action object is expired, and returns Expired if it is

public static TinyLife.Actions.ActionType.CanExecuteResult IsNotExpired(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether the action is automatic (unused)

Returns

CanExecuteResult
Valid if the action object is not expired, Expired otherwise

ActionType.IsNotUncomfortable(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines whether a person is uncomfortable.
This method differs from IsComfortable(ActionInfo, bool) in that only the TinyLife.Emotions.EmotionType.Uncomfortable emotion is queried.

public static TinyLife.Actions.ActionType.CanExecuteResult IsNotUncomfortable(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether this action is automatic (unused)

Returns

CanExecuteResult
Valid if the person is not uncomfortable, else TooUncomfortable

ActionType.IsReadyForRomance(ActionInfo, bool) Method

A helper method intended to be used with CanExecuteDelegate(ActionInfo, bool) that determines if the Person and their interaction partner are Unrelated and whether the action is executed manually or their RomanceLevel is higher than 0.
This method will also return TooSad if the person is currently feeling TinyLife.Emotions.EmotionType.Sad.
This method should be used for SocialAction actions that are romantic in nature.

public static TinyLife.Actions.ActionType.CanExecuteResult IsReadyForRomance(TinyLife.Actions.ActionInfo info, bool automatic);

Parameters

info ActionInfo
The action info

automatic System.Boolean
Whether this action is automatic

Returns

CanExecuteResult
Valid if any of the conditions are met, otherwise Hidden

ActionType.Register(TypeSettings) Method

Registers a new action type with the given TypeSettings

public static TinyLife.Actions.ActionType Register(TinyLife.Actions.ActionType.TypeSettings settings);

Parameters

settings TypeSettings
The settings that the action type should have

Returns

ActionType
The resulting action type instance

ActionType.RegisterAll(IEnumerable<TypeSettings>) Method

A helper method that is a mass registering version of Register(TypeSettings)

public static TinyLife.Actions.ActionType[] RegisterAll(System.Collections.Generic.IEnumerable<TinyLife.Actions.ActionType.TypeSettings> settings);

Parameters

settings System.Collections.Generic.IEnumerable<TypeSettings>
The settings that the action types should have

Returns

ActionType[]
The registered action type instances