Table of Contents

Class Person

Namespace
TinyLife.Objects
Assembly
Tiny Life.dll

Represents a human person, known in the game as a Tiny. This class extends PersonLike, but stores additional human-specific information, like Projects, Jobs, Pronouns, and more.

public class Person : PersonLike, IGenericDataHolder, IUpdatingObject
Inheritance
JsonTypeSafeGenericDataHolder
Person
Implements
IGenericDataHolder
Inherited Members
JsonTypeSafeGenericDataHolder.GetDataKeys()
Extension Methods

Constructors

Person(Map, Vector2, float)

Creates a new person with the given settings. To create a new person externally, use Create(Map, Random, AgeGroup, bool, bool, bool, bool, PersonLike[]).

[JsonConstructor]
protected Person(Map map, Vector2 position, float floor)

Parameters

map Map

The map.

position Vector2

The position.

floor float

The floor.

Fields

AgeTextures

The textures that are used for each AgeGroup. The key is the AgeGroup, and the value is the texture name.

public static readonly Dictionary<AgeGroup, string> AgeTextures

Field Value

Dictionary<AgeGroup, string>

DiaperDirty

Whether this person's diaper is dirty.

[DataMember(EmitDefaultValue = false)]
public bool DiaperDirty

Field Value

bool

Jobs

The jobs that this person currently has. Currently, multiple jobs are supported in-game, but not properly enforced, meaning if a person has multiple jobs whose work hours overlap, unexpected behaviors might occur. To modify this collection, please use AddJob(JobType, int) and RemoveJob(JobType) to raise the proper events.

[DataMember]
public readonly List<Job> Jobs

Field Value

List<Job>

LastBedSleptIn

The id of the last bed Furniture that this person has slept in, or Empty if no such bed exists

[DataMember(EmitDefaultValue = false)]
public Guid LastBedSleptIn

Field Value

Guid

LotEmployment

The LotEmployment.Instance that this person works in. If this value is non-null, it implicitly means that this person does not have a HomeLot or Household that they are a part of.

[DataMember(EmitDefaultValue = false)]
public LotEmployment.Instance LotEmployment

Field Value

LotEmployment.Instance

PhoneColors

This person's mobile phone colors.

[DataMember]
public int[] PhoneColors

Field Value

int[]

Projects

The Project instances that this person currently has. Use StartProject(Project), GetProject(string, string), GetProjects(string) and Remove() to modify this collection effectively.

[DataMember]
public readonly List<Project> Projects

Field Value

List<Project>

Pronouns

This person's pronouns.

[DataMember]
public string Pronouns

Field Value

string

RotationOrder

The order of MLEM.Maths.Direction2 that the texture atlas for PersonLike has for its textures, from left to right

public static readonly Direction2[] RotationOrder

Field Value

Direction2[]

RotationOrderIndices

public static readonly Dictionary<Direction2, int> RotationOrderIndices

Field Value

Dictionary<Direction2, int>

Properties

CurrentRoomDecorativeRating

The decorative rating of the CurrentRoom, resulting from the DecorativeRating of the contained furniture

public int CurrentRoomDecorativeRating { get; }

Property Value

int

DrawSize

The size, in draw space pixels, that a person's texture takes up.

public override Point DrawSize { get; }

Property Value

Point

FullNamePronouns

This person's full name and pronouns, which is a concatenation of their FullName, and their pronouns in parentheses for Person types.

public override string FullNamePronouns { get; }

Property Value

string

IsRegularVisitor

A property that computes whether this person is a regular visitor. A person is considered a regular visitor if they have no Household, but also have no LotEmployment, and are not dead (IsDead).

public override bool IsRegularVisitor { get; }

Property Value

bool

LifeGoal

This person's current LifeGoal.Instance

public LifeGoal.Instance LifeGoal { get; set; }

Property Value

LifeGoal.Instance

Pivot

Returns this person's screen-space pivot position, based on the current animation frame.

public override Vector2 Pivot { get; }

Property Value

Vector2

Methods

AddJob(JobType, int)

Adds an instance of the given JobType to this person's list of Jobs and raises the OnJobChanged event.

public virtual bool AddJob(JobType type, int level = 0)

Parameters

type JobType

The type of job to add.

level int

The level to start the job at, defaults to 0.

Returns

bool

Whether the job could be added. If this is false, then this person already has a job of the given type.

CanExecuteAction(ActionType, ActionInfo, bool)

Returns the given action type's CanExecute delegate's result and also checks additional conditions like RequiredSkill, RequiredEmotion, CanExecuteAction and CanExecuteAction(ActionType, ActionInfo, bool, bool). This method additionally catches and handles any exceptions by printing them out as a Notifications notification to the player.

public override CanExecuteResult CanExecuteAction(ActionType type, ActionInfo info, bool automatic)

Parameters

type ActionType

The action to execute.

info ActionInfo

The action info

automatic bool

Whether the action is automatically executed

Returns

CanExecuteResult

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

Create(Map, Random, AgeGroup, bool, bool, bool, bool, PersonLike[])

Creates a new person with the given settings, optionally randomly generating the returned person's FirstName, LastName, Age, Outfits and more.

public static Person Create(Map map, Random random, AgeGroup allowedAges = (AgeGroup)-1, bool markRandomlyGenerated = true, bool initializeName = true, bool initializePersonality = true, bool generateOutfits = true, PersonLike[] geneticInfluences = null)

Parameters

map Map

The map to create the person for.

random Random

The Random instance to use for generating the person.

allowedAges AgeGroup

A set of AgeGroup flags that the person is allowed to have.

markRandomlyGenerated bool

Whether to mark the person as RandomlyGenerated.

initializeName bool

Whether to initialize the person's FirstName, LastName and Pronouns.

initializePersonality bool

Whether to initialize the person's PersonalityTypes.

generateOutfits bool

Whether to generate fitting outfits beyond the required default everyday one.

geneticInfluences PersonLike[]

A set of people that count as genetic influences, from which hair, eye and skin colors will randomly be chosen.

Returns

Person

The generated person.

DrawLooksLayer(SpriteBatch, SpriteAnimation, TextureRegion, WornClothes, int, Vector2, Vector2, float, ParentInfo, Color, float, float)

Draws the given layer of this person's looks in the world. This method is invoked several times in DrawLooks(SpriteBatch, Vector2, Vector2, float, ParentInfo, Color?, float).

protected override void DrawLooksLayer(SpriteBatch batch, SpriteAnimation animation, TextureRegion region, WornClothes clothes, int layerIndex, Vector2 drawPos, Vector2 depthPos, float floor, ParentInfo parent, Color color, float scale, float depthOffset)

Parameters

batch SpriteBatch

The sprite batch to use for drawing.

animation SpriteAnimation

The animation to draw.

region TextureRegion

The texture region of the animation to draw.

clothes WornClothes

The clothes to draw.

layerIndex int

The index that this layer is on.

drawPos Vector2

The draw position in screen space.

depthPos Vector2

The position to use for calculating depth.

floor float

The floor to draw on.

parent ParentInfo

This person's parent info.

color Color

The color to draw with.

scale float

The scale to draw with.

depthOffset float

The depth offset to draw with.

DrawUiLayer(SpriteBatch, Vector2, float, Direction2, Outfit, Pose, AgeGroup, WornClothes, ClothesLayer, int, int)

protected override void DrawUiLayer(SpriteBatch batch, Vector2 pos, float scale, Direction2 rotation, Outfit outfit, Pose pose, AgeGroup age, WornClothes clothes, ClothesLayer layer, int colorIndex, int layerIndex)

Parameters

batch SpriteBatch
pos Vector2
scale float
rotation Direction2
outfit Outfit
pose Pose
age AgeGroup
clothes WornClothes
layer ClothesLayer
colorIndex int
layerIndex int

GenerateAnimationGroup(ClothesLayer, Clothes)

Generates a MLEM.Animations.SpriteAnimationGroup for the given settings. This method is called when a person's Animations are generated, for each clothes layer.

protected override SpriteAnimationGroup GenerateAnimationGroup(ClothesLayer clothesLayer, Clothes clothes)

Parameters

clothesLayer ClothesLayer

The clothes layer.

clothes Clothes

Returns

SpriteAnimationGroup

The generated MLEM.Animations.SpriteAnimationGroup.

GenerateShadowAnimation()

Generates a MLEM.Animations.SpriteAnimationGroup for this person's shadow. This method is called when a person's Animations are generated.

protected override SpriteAnimationGroup GenerateShadowAnimation()

Returns

SpriteAnimationGroup

The generated MLEM.Animations.SpriteAnimationGroup.

GetAiPriorityForObject(MapObject, ObjectCategory)

Returns the AI priority for the given obj and the given categories. This method checks the GetAiPriority(PersonLike, ObjectCategory) method, as well as any LotEmployment-speciifc AI priorities, and invokes the OnGetAiPriorityForObject event.

public override float GetAiPriorityForObject(MapObject obj, ObjectCategory categories)

Parameters

obj MapObject

The object.

categories ObjectCategory

The categories.

Returns

float

The AI priority for the object.

GetBodyArea(Pose, Direction2)

public override Rectangle GetBodyArea(Pose pose, Direction2 rotation)

Parameters

pose Pose
rotation Direction2

Returns

Rectangle

GetCurrentGoals()

Returns a set of GoalSet objects that this person is currently working on. To add more current goals, use OnGetCurrentGoals.

public override List<IGoalTriggerable> GetCurrentGoals()

Returns

List<IGoalTriggerable>

This person's current goals

GetHeadArea(Pose, Direction2)

public override Rectangle GetHeadArea(Pose pose, Direction2 rotation)

Parameters

pose Pose
rotation Direction2

Returns

Rectangle

GetHeldItemDrawOffset(bool)

Returns this person's held item's draw offset, which is used by ParentInfo for drawing.

public override Vector2 GetHeldItemDrawOffset(bool includeItemOffsets)

Parameters

includeItemOffsets bool

Returns

Vector2

This person's held item's draw offset.

GetHoverInfo(Tooltip)

Allows adding a set of paragraphs and other ui elements to the given tooltip, which is then displayed when this object is hovered over using the cursor in the world. By default, this method raises OnGetHoverInfo for MapObject, and adds additional information for Furniture and PersonLike.

public override void GetHoverInfo(Tooltip tooltip)

Parameters

tooltip Tooltip

The tooltip that will be displayed.

GetPassiveActionPriority(ActionType)

Returns the passive priority for the given ActionType. This method evaluates the action's own PassivePriority and adds additional factors like Extroverted and Introverted modifiers for social actions. You can use OnGetPassiveActionPriority to change the return value of this method.

public override float GetPassiveActionPriority(ActionType type)

Parameters

type ActionType

The type of action to get the passive priority for

Returns

float

The action's passive priority

GetPassiveNeedReduction(NeedType)

Returns the given need's current passive reduction for this person. The return value is a combination of PassiveReduction and the OnGetPassiveNeedReduction event, as well as PersonalityType modifiers and the like.

public override float GetPassiveNeedReduction(NeedType need)

Parameters

need NeedType

The need.

Returns

float

The passive need reduction.

GetProject(string, string)

Returns a project of the given Type with the given Name.

public Project GetProject(string type, string name)

Parameters

type string

The Type of the project to return

name string

The Name of the project to return

Returns

Project

The matching project, or null if there is none

GetProjects(string)

Returns all of the projects of the given Type that this person has. To access all projects regardless of type, iterate the Projects list instead.

public IEnumerable<Project> GetProjects(string type)

Parameters

type string

The Type of project to return

Returns

IEnumerable<Project>

A set of projects that match the given type

GoToExitRoad(Vector2)

Teleports this person to the nearest exit road using GetClosestFreeExitPoint(Vector2).

public override void GoToExitRoad(Vector2 closestPosition)

Parameters

closestPosition Vector2

OnAgeChanged(AgeGroup)

A method that is called by Age.set when this person's Age has just changed. Their previous age is stored in lastAge.

protected override void OnAgeChanged(AgeGroup lastAge)

Parameters

lastAge AgeGroup

This person's previous age.

OnRoomCheck()

A method that is invoked in Update(GameTime, TimeSpan, float) when the timer to check information about the CurrentRoom has elapsed in Update(GameTime, TimeSpan, float). By default, various emotion modifiers are applied based on various conditions.

protected override void OnRoomCheck()

RemoveJob(JobType)

Removes instances of the given JobType from this person's list of Jobs and raises the OnJobChanged event.

public virtual bool RemoveJob(JobType type)

Parameters

type JobType

The type to remove.

Returns

bool

Whether this person has a job of the given type.

ResetToStatic(bool, bool)

Resets this map object to a static state when the Map that is on is exported.

public override bool ResetToStatic(bool thorough, bool custom)

Parameters

thorough bool

Whether a more thorough reset is expected, which usually involves normalizing additional data and cleaning up player data entirely.

custom bool

Whether the static reset is happening in a custom context, that is, a Household being exported normally rather than through cheats, or a custom Map being exported.

Returns

bool

Whether this object should stay on the map after the static reset. If false is returned, this object is removed.

StartProject(Project)

Starts a new project, adding it to the Projects list of this person

public virtual Project StartProject(Project project)

Parameters

project Project

The project to start

Returns

Project

The project that was passed, for chaining

Update(GameTime, TimeSpan, float)

The update method, which is called every update frame by the underlying Map, as well as additional places like the FurnitureStorage. Because of this, some actions might only want to be invoked if an object IsInWorld. To call this method while invoking all required events, use DoUpdate(GameTime, TimeSpan, float).

public override void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)

Parameters

time GameTime

The game's time

passedInGame TimeSpan

The amount of time that has passed since the last call

speedMultiplier float

The game speed multiplier, which represents how fast things should happen, which is usually determined by Speed

UpdateJobs(TimeSpan)

A method invoked in Update(GameTime, TimeSpan, float) to update this person's Jobs.

protected virtual void UpdateJobs(TimeSpan passedInGame)

Parameters

passedInGame TimeSpan

The amount of time that has passed since the last call

UpdatePose()

A method invoked in Update(GameTime, TimeSpan, float) that updates this person's CurrentPose based on their held object or person.

protected override void UpdatePose()

Validate(AppliedMigrations)

This method is called when this object is loaded from disk. Returning false on this method causes the object to be removed from the map. By default, this method invokes OnValidated and OnEventsAttachable.

public override bool Validate(AppliedMigrations appliedMigrations)

Parameters

appliedMigrations AppliedMigrations

Returns

bool

false if the object is not valid, true otherwise

Events

OnCreate

An event that is invoked in Create(Map, Random, AgeGroup, bool, bool, bool, bool, PersonLike[]), which allows modifying the random generation of a new person.

public static event Action<(Person Person, Random Random, AgeGroup AllowedAges, bool InitializeName, bool InitializePersonality, bool GenerateOutfits, PersonLike[] GeneticInfluences, StylePreference Style, EventPhase Phase)> OnCreate

Event Type

Action<(Person Person, Random Random, AgeGroup AllowedAges, bool InitializeName, bool InitializePersonality, bool GenerateOutfits, PersonLike[] GeneticInfluences, StylePreference Style, EventPhase Phase)>

OnGenerateAnimationGroup

An event that is invoked when an animation group is created for this person in GenerateAnimationGroup(ClothesLayer, Clothes). This event can be subscribed to using OnEventsAttachable.

public event Action<(ClothesLayer ClothesLayer, Clothes Clothes, SpriteAnimationGroup Group, EventPhase Phase)> OnGenerateAnimationGroup

Event Type

Action<(ClothesLayer ClothesLayer, Clothes Clothes, SpriteAnimationGroup Group, EventPhase Phase)>

OnJobChanged

An event that is invoked when the Jobs collection changes. This event can be subscribed to using OnEventsAttachable.

public event Action<PersonLike> OnJobChanged

Event Type

Action<PersonLike>

OnLifeGoalChanged

An event that is invoked when a person's current LifeGoal is changed. This event can be subscribed to using OnEventsAttachable.

public event Action<LifeGoal.Instance> OnLifeGoalChanged

Event Type

Action<LifeGoal.Instance>