Table of Contents

Class NeedType

Namespace
TinyLife
Assembly
Tiny Life.dll

A need is a desire that a Person can have to a given extent. To register a custom need type, use Register(NeedType).

[JsonConverter(typeof(NeedType.Converter))]
public class NeedType : IEmotionSource
Inheritance
NeedType
Implements
Inherited Members
Extension Methods

Constructors

NeedType(string, Func<Person, float>, Func<Person, ActionType>, Func<Person, TimeSpan>, float, float)

Instantiates a new need type with the given settings

public NeedType(string name, Func<Person, float> passiveReduction, Func<Person, ActionType> needLowAction = null, Func<Person, TimeSpan> needLowTime = null, float solveImportance = 0, float solvePercentage = 0.5)

Parameters

name string

The name of this need

passiveReduction Func<Person, float>

The amount that this need instance's Value is reduced by automatically every update frame

needLowAction Func<Person, ActionType>

The action that is executed when this need's value is very low

needLowTime Func<Person, TimeSpan>

The amount of in-game time until needLowAction is enqueued

solveImportance float

The priority for solving this need over other needs, where higher numbers are more urgent

solvePercentage float

The percentage that this need has to be at or below for it to be auto-solved based on SolvedNeeds.

Fields

Energy

public static readonly NeedType Energy

Field Value

NeedType

Entertainment

public static readonly NeedType Entertainment

Field Value

NeedType

Hunger

public static readonly NeedType Hunger

Field Value

NeedType

Hygiene

public static readonly NeedType Hygiene

Field Value

NeedType

Name

The name of this need. Used for Localization purposes and saving to disk.

public readonly string Name

Field Value

string

NeedLowAction

The ActionType that is constructed and executed when this need type's Value is very low

public readonly Func<Person, ActionType> NeedLowAction

Field Value

Func<Person, ActionType>

NeedLowTime

The amount of in-game time that needs to pass until NeedLowAction is constructed and enqueued

public readonly Func<Person, TimeSpan> NeedLowTime

Field Value

Func<Person, TimeSpan>

PassiveReduction

The amount that a need instance's Value is reduced by automatically every update frame. To access this function's returned value, as well as the associated events, use GetPassiveReduction(Person).

public readonly Func<Person, float> PassiveReduction

Field Value

Func<Person, float>

Social

public static readonly NeedType Social

Field Value

NeedType

SolveImportance

The priority for solving this need over other needs, where higher numbers represent a more urgent need. This value defaults to 0, meaning it has no special importance.

public readonly float SolveImportance

Field Value

float

SolvePercentage

The percentage that this need has to be at or below for it to be auto-solved based on SolvedNeeds.

public readonly float SolvePercentage

Field Value

float

Toilet

public static readonly NeedType Toilet

Field Value

NeedType

Types

A list of all of the need types that are currently registered. Register custom need types using Register(NeedType).

public static readonly ReadOnlyCollection<NeedType> Types

Field Value

ReadOnlyCollection<NeedType>

Properties

SourceString

A (localized) string that is displayed when hovering over an EmotionModifier that has this source

public string SourceString { get; }

Property Value

string

Methods

GetPassiveReduction(Person)

Returns this need's current passive reduction for the given person. The return value is a combination of PassiveReduction and the OnGetPassiveReduction event.

public float GetPassiveReduction(Person person)

Parameters

person Person

The person.

Returns

float

The passive need reduction.

Register(NeedType)

Register the NeedType specified to the Types dictionary

public static NeedType Register(NeedType type)

Parameters

type NeedType

The need type to register

Returns

NeedType

The need type passed, for chaining

Events

OnGetPassiveReduction

An event that is raised when GetPassiveReduction(Person) is called. This event can be used to modify the passive need reduction of a need.

public static event NeedType.PassiveReductionDelegate OnGetPassiveReduction

Event Type

NeedType.PassiveReductionDelegate