EmotionModifier - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Emotions

EmotionModifier Class

An emotion modifier stores information about a Person's current or past actions or events that influenced their Emotion in some way.
Each emotion modifier contributes to the person's emotion, and the emotion modifier with the highest combined Amount determines the person's Emotion.
Emotion modifiers can be applied automatically using Condition or manually using AddEmotion(EmotionModifier, int, TimeSpan, bool).

public class EmotionModifier

Inheritance System.Object 🡒 EmotionModifier

Constructors

EmotionModifier.EmotionModifier(string, TextureRegion, EmotionType, Func<Person,int>) Constructor

Creates a new emotion modifier with the given settings

public EmotionModifier(string name, MLEM.Textures.TextureRegion icon, TinyLife.Emotions.EmotionType emotion, System.Func<TinyLife.Objects.Person,int> condition=null);

Parameters

name System.String
The modifier's name

icon MLEM.Textures.TextureRegion
The modifier's icon

emotion EmotionType
The modifier's resulting emotion type

condition System.Func<Person,System.Int32>
An optional condition for this modifier

Fields

EmotionModifier.Condition Field

An (optional) condition that has to be met for this emotion modifier to be applied to a person.
If this value is non-null, and the value returned by this function is greater than zero, this emotion modifier will be applied to a Person with the Amount set to the return value.
If this value is not set, the emotion modifier has to be applied manually using AddEmotion(EmotionModifier, int, TimeSpan, bool).

public readonly Func<Person,int> Condition;

Field Value

System.Func<Person,System.Int32>

EmotionModifier.Emotion Field

The EmotionType that this emotion modifier is set to cause (if the Amount is high enough).
To retrieve this value for a specific person, GetCausedEmotion(Person) should be used.

public readonly EmotionType Emotion;

Field Value

EmotionType

EmotionModifier.Icon Field

This emotion modifier's icon which will be displayed in the emotions menu

public readonly TextureRegion Icon;

Field Value

MLEM.Textures.TextureRegion

EmotionModifier.Name Field

This emotion modifier's name

public readonly string Name;

Field Value

System.String

EmotionModifier.Types Field

A registry that contains all EmotionModifier instances from the game and mods

public static readonly IDictionary<string,EmotionModifier> Types;

Field Value

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

Methods

EmotionModifier.GetCausedEmotion(Person) Method

Returns the emotion that is actually caused in the passed Person, which is either Emotion or a context-dependent override.
Specifically, this method returns TinyLife.Emotions.EmotionType.Happy instead of TinyLife.Emotions.EmotionType.Frisky for a person who IsAsexual.

public TinyLife.Emotions.EmotionType GetCausedEmotion(TinyLife.Objects.Person person);

Parameters

person Person

Returns

EmotionType

EmotionModifier.Register(EmotionModifier) Method

Registers the given emotion type into the Types registry

public static TinyLife.Emotions.EmotionModifier Register(TinyLife.Emotions.EmotionModifier modifier);

Parameters

modifier EmotionModifier
The modifier to register

Returns

EmotionModifier
The modifier, for chaining