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

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

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

Job

The Job that this person currently has.

[DataMember(EmitDefaultValue = false)]
[Obsolete("Use the new Jobs collection instead")]
public Job Job { get; protected set; }

Property Value

Job

LifeGoal

This person's current LifeGoal.Instance

public LifeGoal.Instance LifeGoal { get; set; }

Property Value

LifeGoal.Instance

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

generateMultipleOutfits bool

Whether to generate multiple outfits, rather than just one default 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)

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
animation SpriteAnimation
region TextureRegion
clothes WornClothes
layerIndex int
drawPos Vector2
depthPos Vector2
floor float
parent ParentInfo
color Color
scale float
depthOffset float

DrawUi(SpriteBatch, Vector2, float, Direction2, Outfit, Pose?, AgeGroup?)

Renders this person on a ui level rather than a world level

public override void DrawUi(SpriteBatch batch, Vector2 pos, float scale, Direction2 rotation = Direction2.Right, Outfit outfit = null, Pose? pose = null, AgeGroup? age = null)

Parameters

batch SpriteBatch

The sprite batch to use for drawing

pos Vector2

The position, in screen space, to draw at

scale float

The scale to draw with

rotation Direction2

The rotation that this person should be drawn with. Defaults to MLEM.Misc.Direction2.Right.

outfit Outfit
pose Pose?
age AgeGroup?

GenerateAnimationGroup(ClothesLayer, int, IReadOnlyDictionary<Point, TextureRegion>, Point)

Generates a MLEM.Animations.SpriteAnimationGroup for the given settings. This method is called in SetAnimationsFromLooks() for each clothes layer, as well as this person's shadow.

protected override SpriteAnimationGroup GenerateAnimationGroup(ClothesLayer clothesLayer, int layerAmount, IReadOnlyDictionary<Point, TextureRegion> textures, Point textureRegion)

Parameters

clothesLayer ClothesLayer

The clothes layer.

layerAmount int

The amount of layers the clothing item has.

textures IReadOnlyDictionary<Point, TextureRegion>

The textures to use.

textureRegion Point

The initial texture region to use.

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.

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

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.

GetPivot()

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

public override Vector2 GetPivot()

Returns

Vector2

This person's screen-space pivot position.

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.

SetJob(JobType, int)

Sets this person's current Jobs to the passed single value. If null is passed, the person's job gets removed.

[Obsolete("Use the new AddJob and RemoveJob instead")]
public virtual void SetJob(JobType type, int level = 0)

Parameters

type JobType

The job to start

level int

The level to start this job with

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

Validate()

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()

Returns

bool

false if the object is not valid, true otherwise

Events

OnDrawUi

public event Action<(SpriteBatch Batch, Vector2 Pos, float Scale, Direction2 Rotation, Outfit Outfit, Pose Pose, AgeGroup Age, EventPhase Phase)> OnDrawUi

Event Type

Action<(SpriteBatch Batch, Vector2 Pos, float Scale, Direction2 Rotation, Outfit Outfit, Pose Pose, AgeGroup Age, EventPhase Phase)>

OnGenerateAnimationGroup

public event Action<(ClothesLayer ClothesLayer, int LayerAmount, IReadOnlyDictionary<Point, TextureRegion> Textures, Point TextureRegion, SpriteAnimationGroup Group, EventPhase Phase)> OnGenerateAnimationGroup

Event Type

Action<(ClothesLayer ClothesLayer, int LayerAmount, IReadOnlyDictionary<Point, TextureRegion> Textures, Point TextureRegion, 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>