Person - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Objects

Person Class

A person is a MapObject placed on a Map that represents a person.
It stores its actions, clothes, data and movement.

public class Person : TinyLife.Objects.MapObject,
TinyLife.Objects.IUpdatingObject

Inheritance System.Object 🡒 MLEM.Misc.GenericDataHolder 🡒 MapObject 🡒 Person

Implements IUpdatingObject

Constructors

Person.Person(Map, Vector2) Constructor

Creates a new person with the given settings

public Person(TinyLife.World.Map map, Microsoft.Xna.Framework.Vector2 position);

Parameters

map Map
The map to place this person on

position Microsoft.Xna.Framework.Vector2
The position to place this person on

Fields

Person.ActionQueue Field

The actions that are currently enqueued to be executed by this person.
Each entry is the action that is enqueued along with a boolean value that represents whether this action was started automatically (true) or manually (false).
Use EnqueueAction(ActionType, ActionInfo, bool, Nullable<ActionVariety>, bool, bool) and CancelAction(Action, Action, bool) to modify this list.

public readonly List<(Action,bool)> ActionQueue;

Field Value

System.Collections.Generic.List<<Action,System.Boolean>>

Person.AnimateHeldObject Field

Whether or not the GetHeldObject<T>() should be animated with this person's movement animation.
Note that this value is not saved to disk, and is reset to true every Update(GameTime, TimeSpan, GameSpeed) frame.

public bool AnimateHeldObject;

Field Value

System.Boolean

Person.AnimationSpeed Field

The speed that this person's animation should run with.
Note that this value is not saved to disk, and is reset to null every Update(GameTime, TimeSpan, GameSpeed) frame.

public float AnimationSpeed;

Field Value

System.Single

Person.CurrentActions Field

The actions that are currently being executed by this person.
Use EnqueueAction(ActionType, ActionInfo, bool, Nullable<ActionVariety>, bool, bool) and CancelAction(Action, Action, bool) to modify this list.

public readonly List<Action> CurrentActions;

Field Value

System.Collections.Generic.List<Action>

Person.CurrentPose Field

This person's current Pose.
Note that this value is reset to Standing every Update(GameTime, TimeSpan, GameSpeed) frame.

public Pose CurrentPose;

Field Value

Pose

Person.EmotionModifiers Field

The Instance objects that are currently applied to this person.
To access this collection efficiently, use AddEmotion(EmotionModifier, int, TimeSpan, bool), RemoveEmotion(EmotionModifier) and LowerEmotion(EmotionType, float, GameSpeed).

public readonly List<Instance> EmotionModifiers;

Field Value

System.Collections.Generic.List<Instance>

Person.FirstName Field

This person's first name

public string FirstName;

Field Value

System.String

Person.HeldObjectRotation Field

The rotation that the GetHeldObject<T>() should assume in this person's hand.
If this value is set to null, the held object's rotation will be set to the person's Rotation.
Note that this value is not saved to disk, and is reset to null every Update(GameTime, TimeSpan, GameSpeed) frame.

public Nullable<Direction2> HeldObjectRotation;

Field Value

System.Nullable<MLEM.Misc.Direction2>

Person.IsAromantic Field

A field that stores whether this person is aromantic

public bool IsAromantic;

Field Value

System.Boolean

Person.IsAsexual Field

A field that stores whether this person is asexual

public bool IsAsexual;

Field Value

System.Boolean

Person.LastBedSleptIn Field

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

public Guid LastBedSleptIn;

Field Value

System.Guid

Person.LastName Field

This person's last name

public string LastName;

Field Value

System.String

Person.LotEmployment Field

The 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.

public Instance LotEmployment;

Field Value

Instance

Person.MaxRecentActionsAmount Field

The maximum amount of recent actions that is stored in RecentActions

public const int MaxRecentActionsAmount = 200;

Field Value

System.Int32

Person.Needs Field

This person's Need data. When this person is instantiated, all of their needs are gathered from Types automatically.
To access this collection efficiently, use GetNeed(NeedType) and GetNeedPercentage(NeedType).

public readonly Dictionary<string,Need> Needs;

Field Value

System.Collections.Generic.Dictionary<System.String,Need>

Person.Outfits Field

A list of the outfits that this person has, gathered by the CharacterCreator.
Each outfit is a dictionary that matches a WornClothes item to its layer.

public readonly List<Dictionary<ClothesLayer,WornClothes>> Outfits;

Field Value

System.Collections.Generic.List<System.Collections.Generic.Dictionary<ClothesLayer,WornClothes>>

Person.PersonalityTypes Field

The names of the PersonalityType values that this person has.
To access this collection efficiently, use HasPersonality(PersonalityType).

public readonly HashSet<string> PersonalityTypes;

Field Value

System.Collections.Generic.HashSet<System.String>

Person.Portrait Field

The Microsoft.Xna.Framework.Graphics.RenderTarget2D that this person's portrait is rendered onto.
This will automatically be updated and can be used for rendering of any kind.

public readonly RenderTarget2D Portrait;

Field Value

Microsoft.Xna.Framework.Graphics.RenderTarget2D

Person.Projects Field

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

public readonly List<Project> Projects;

Field Value

System.Collections.Generic.List<Project>

Person.RecentActions Field

The ActionType of actions that this person has done recently, in order that they have been done in, with the most recent action being at the end of the list.
Note that the size of this list never exceeds MaxRecentActionsAmount.
Completed actions are added to this queue automatically.

public readonly List<ActionType> RecentActions;

Field Value

System.Collections.Generic.List<ActionType>

Person.Relationships Field

This person's Relationship data.
To access this collection efficiently, use GetRelationship(Person, bool) and ChangeFriendship(Person, float).

public readonly List<Relationship> Relationships;

Field Value

System.Collections.Generic.List<Relationship>

Person.Skills Field

This person's Skill data.
To access this collection efficiently, use GetSkillLevel(SkillType) and GainSkill(SkillType, float, GameSpeed).

public readonly Dictionary<string,Skill> Skills;

Field Value

System.Collections.Generic.Dictionary<System.String,Skill>

Person.Tint Field

A color that this person should render with.
Note that this value is not saved to disk, and is reset to null every Update(GameTime, TimeSpan, GameSpeed) frame.

public Nullable<Color> Tint;

Field Value

System.Nullable<Microsoft.Xna.Framework.Color>

Person.VoicePitch Field

The pitch of this person's voice, used for speaking (Speak(SpeakStyle, float, float)).
The voice pitch should be between -1 and 1, but the character creator only sets it between -0.5 and 0.5.

public float VoicePitch;

Field Value

System.Single

Person.WornLayers Field

The ClothesLayer flags that represent what layers this person is currently wearing.
Note that this value is reset to ~0 (every layer) every Update(GameTime, TimeSpan, GameSpeed) frame.

public ClothesLayer WornLayers;

Field Value

ClothesLayer

Properties

Person.AllActions Property

A concatenation of CurrentActions and ActionQueue that represents all actions that the current person has knowledge about

public System.Collections.Generic.IEnumerable<TinyLife.Actions.Action> AllActions { get; }

Property Value

System.Collections.Generic.IEnumerable<Action>

Person.CurrentEmote Property

The Emote that this person is currently displaying.
Use DisplayEmote(EmoteCategory, float, float) to modify this property.

public TinyLife.Actions.Emote CurrentEmote { get; set; }

Property Value

Emote

Person.CurrentOutfit Property

Returns the outfit that this person is currently wearing, which is the Outfits entry at the CurrentOutfitIndex.

public System.Collections.Generic.Dictionary<TinyLife.Objects.ClothesLayer,TinyLife.Objects.WornClothes> CurrentOutfit { get; }

Property Value

System.Collections.Generic.Dictionary<ClothesLayer,WornClothes>

Person.CurrentOutfitIndex Property

The index of the outfit, in the Outfits list, that this person is currently wearing.
To change this value, use SetCurrentOutfit(ClothesIntention, float) or SetCurrentOutfit(int).

public int CurrentOutfitIndex { get; set; }

Property Value

System.Int32

Person.CurrentRoom Property

The Room that this person is currently in

public TinyLife.World.Room CurrentRoom { get; set; }

Property Value

Room

Person.CurrentRoomDecorativeRating Property

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

public int CurrentRoomDecorativeRating { get; set; }

Property Value

System.Int32

Person.CurrentSpeakStyle Property

The current speak styles that speaking sounds are chosen from.
Use Speak(SpeakStyle, float, float) to modify this property.

public System.Nullable<TinyLife.Objects.SpeakStyle> CurrentSpeakStyle { get; set; }

Property Value

System.Nullable<SpeakStyle>

Person.DrawSize Property

The size, in draw space pixels, that this person's texture takes up.
This is gathered from the Body layer of its texture data.

public Microsoft.Xna.Framework.Point DrawSize { get; }

Property Value

Microsoft.Xna.Framework.Point

Person.Emotion Property

The EmotionType that this person currently has, resulting from their current EmotionModifiers

public TinyLife.Emotions.EmotionType Emotion { get; }

Property Value

EmotionType

Person.FullName Property

This person's full name, which is a concatenation of their FirstName and LastName.

public string FullName { get; }

Property Value

System.String

Person.HomeLot Property

The Lot that this household lives on.
For exported households, this might be null.

public TinyLife.World.Lot HomeLot { get; }

Property Value

Lot

Person.Household Property

The Household that this person is a part of

public TinyLife.World.Household Household { get; }

Property Value

Household

Person.IsCurrentHousehold Property

A property that indicates whether or not this household is the same as CurrentHousehold

public bool IsCurrentHousehold { get; }

Property Value

System.Boolean

Person.IsMoving Property

This property stores whether this person is currently moving.
A person is considered moving when their Position has changed since the last update frame.

public bool IsMoving { get; set; }

Property Value

System.Boolean

Person.Job Property

The Job that this person currently has.
To edit this value, use SetJob(JobType).

public TinyLife.Goals.Job Job { get; set; }

Property Value

Job

Person.LastVisitedLot Property

The Lot that was last visited by this person.
A visited lot is a lot that was actively moved to using TinyLife.Actions.VisitLotAction, TinyLife.Actions.GoHomeAction or if the person is currently occupying this lot.
To modify this value, use VisitLot(Lot).

public TinyLife.World.Lot LastVisitedLot { get; }

Property Value

Lot

Person.LotVisitCooldown Property

The amount of time that has to pass before this person can visit another lot.
If LastVisitedLot is set using VisitLot(Lot), this value will be set to 2 hours or 4 hours of in-game time, based on whether the visited lot is their home lot or not.

public System.TimeSpan LotVisitCooldown { get; set; }

Property Value

System.TimeSpan

Person.Money Property

The money that this household has, rounded by two digits after the decimal point

public float Money { get; set; }

Property Value

System.Single

Person.OccupiedActionSpot Property

The ActionSpot of the OccupiedFurniture that this person is currently occupying.
Note that this value is not saved to disk, and is reset to null every Update(GameTime, TimeSpan, GameSpeed) frame.
To edit this value, use OccupyActionSpot(Furniture, ActionSpot, bool, Nullable<Direction2>).

public TinyLife.Objects.ActionSpot OccupiedActionSpot { get; set; }

Property Value

ActionSpot

Person.OccupiedFurniture Property

The Furniture that this person is currently occupying.
Note that this value is not saved to disk, and is reset to null every Update(GameTime, TimeSpan, GameSpeed) frame.
To edit this value, use OccupyActionSpot(Furniture, ActionSpot, bool, Nullable<Direction2>).

public TinyLife.Objects.Furniture OccupiedFurniture { get; set; }

Property Value

Furniture

Person.Rotation Property

The MLEM.Misc.Direction2 that this person is currently facing in

public MLEM.Misc.Direction2 Rotation { get; set; }

Property Value

MLEM.Misc.Direction2

Person.VisualPosition Property

The visual position of this person, which is influenced by their Position and a visual override that can be set using OccupyActionSpot(Furniture, ActionSpot, bool, Nullable<Direction2>).
Note that, if changed using OccupyActionSpot(Furniture, ActionSpot, bool, Nullable<Direction2>), this value is reset to Position every Update(GameTime, TimeSpan, GameSpeed) frame.
Also note that the visual position does not affect collision detection or most interactions.

public Microsoft.Xna.Framework.Vector2 VisualPosition { get; }

Property Value

Microsoft.Xna.Framework.Vector2

Person.WornClothes Property

This dictionary is obsolete. Use CurrentOutfit instead.

public System.Collections.Generic.Dictionary<TinyLife.Objects.ClothesLayer,TinyLife.Objects.WornClothes> WornClothes { get; set; }

Property Value

System.Collections.Generic.Dictionary<ClothesLayer,WornClothes>

Methods

Person.~Person() Method

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

~Person();

Person.AddEmotion(EmotionModifier, int, TimeSpan, bool) Method

Adds the given EmotionModifier with the given intensity and time

public bool AddEmotion(TinyLife.Emotions.EmotionModifier type, int amount, System.TimeSpan time, bool increaseExisting=false);

Parameters

type EmotionModifier
The type of emotion to add

amount System.Int32
The intensity of the emotion to add

time System.TimeSpan
The amount of in-game time the emotion should last for

increaseExisting System.Boolean
Whether existing emotion modifiers of the same type should be increased by the given time and amount. If this is false, existing emotions get removed instead.

Returns

System.Boolean
Whether the emotion could be added or it was already applied. If increaseExisting is true, this method always returns true.

Person.CancelAction(Action, Action, bool) Method

Tries to cancel the given action, removing it from CurrentActions or ActionQueue in the process.
If the action in question cannot be canceled, this method returns false.

public bool CancelAction(TinyLife.Actions.Action action, TinyLife.Actions.Action cancelSource=null, bool force=false);

Parameters

action Action
The action to cancel

cancelSource Action
The action that is responsible for this cancelation, or null by default

force System.Boolean
Whether to cancel the action even if CanCancel(Action) returns false

Returns

System.Boolean
Whether the action could be canceled successfully

Person.ChangeFriendship(Person, float) Method

Changes the FriendLevelRelationship wit the given person by the given amount.
Additionally, a friendship Particle is displayed and a Notifications is displayed if the friendship type changes.

public void ChangeFriendship(TinyLife.Objects.Person person, float amount);

Parameters

person Person
The person to change friendship with

amount System.Single
The amount to change friendship by, can be negative

Person.ChangeRomance(Person, float) Method

Changes the RomanceLevelRelationship wit the given person by the given amount.
Additionally, a romance Particle is displayed.

public void ChangeRomance(TinyLife.Objects.Person person, float amount);

Parameters

person Person
The person to change romance with

amount System.Single
The amount to change romance by, can be negative

Person.DepleteNeed(NeedType, float, GameSpeed) Method

Depletes this person's Need with the given NeedType by the given amount
Note that, when the "NoNeed" cheat is active, this method does nothing.

public void DepleteNeed(TinyLife.NeedType type, float amount, TinyLife.GameSpeed speed);

Parameters

type NeedType
The type of need to deplete

amount System.Single
The amount to deplete the need by

speed GameSpeed
The speed that the need depletion should be influenced by

Person.Die(DeathReason, bool) Method

Causes this person to die, removing it from the world and optionally spawning a TinyLife.Objects.FurnitureType.Gravestone.
Note thta this method's content is executed at the end of the current Update(GameTime, TimeSpan, GameSpeed) frame, and not right away.

public void Die(TinyLife.Objects.Person.DeathReason reason, bool createGravestone=true);

Parameters

reason DeathReason
The reason for this person's death

createGravestone System.Boolean
Whether or not to create a gravestone

Person.DisplayEmote(EmoteCategory, float, float) Method

Causes this person to display a Emote over its head for 1 to 3 seconds

public void DisplayEmote(TinyLife.Actions.EmoteCategory possibleCategories, float minimumSeconds=1f, float maximumSeconds=3f);

Parameters

possibleCategories EmoteCategory
A combined flag that represents the categories to pick emotes from

minimumSeconds System.Single
The minimum amount of real-time seconds that the emote should be displayed for, or 1 by default

maximumSeconds System.Single
The maximum amount of real-time seconds that the emote should be displayed for, or 3 by default

Person.DisplayEmoteAndSpeak(EmoteCategory, SpeakStyle, float, float) Method

This is a combined helper method that invokes DisplayEmote(EmoteCategory, float, float) and Speak(SpeakStyle, float, float) together.
Since both methods choose a random amount of time for their actions independently, the emote display might end at a different time than the speaking sound.

public void DisplayEmoteAndSpeak(TinyLife.Actions.EmoteCategory emoteCategories, TinyLife.Objects.SpeakStyle speakStyles, float minimumSeconds=1f, float maximumSeconds=3f);

Parameters

emoteCategories EmoteCategory
The emote categories to choose from, can be a combined flag

speakStyles SpeakStyle
The speak styles to choose from, can be a combined flag

minimumSeconds System.Single
The minimum amount of time, in seconds, to speak and display the emote for

maximumSeconds System.Single
The maximum amount of time, in seconds, to speak and display the emote for

Person.Draw(GameTime, SpriteBatch, Vector2, Nullable<Color>) Method

Draws this object on the current Map, at the current Position.

public override void Draw(Microsoft.Xna.Framework.GameTime time, Microsoft.Xna.Framework.Graphics.SpriteBatch batch, Microsoft.Xna.Framework.Vector2 _, System.Nullable<Microsoft.Xna.Framework.Color> overrideColor);

Parameters

time Microsoft.Xna.Framework.GameTime
The current time

batch Microsoft.Xna.Framework.Graphics.SpriteBatch
The sprite batch to use for drawing

_ Microsoft.Xna.Framework.Vector2

overrideColor System.Nullable<Microsoft.Xna.Framework.Color>
The color that should be used instead of this object's actual color. If null, the object's regular color should be used.

Person.DrawUi(SpriteBatch, Vector2, float, Direction2) Method

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

public void DrawUi(Microsoft.Xna.Framework.Graphics.SpriteBatch batch, Microsoft.Xna.Framework.Vector2 pos, float scale, MLEM.Misc.Direction2 rotation=MLEM.Misc.Direction2.Right);

Parameters

batch Microsoft.Xna.Framework.Graphics.SpriteBatch
The sprite batch to use for drawing

pos Microsoft.Xna.Framework.Vector2
The position, in screen space, to draw at

scale System.Single
The scale to draw with

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

Person.EnqueueAction(ActionType, ActionInfo, bool, Nullable<ActionVariety>, bool, bool) Method

Enqueues the given action into ActionQueue to be executed later.

public TinyLife.Actions.Action EnqueueAction(TinyLife.Actions.ActionType type, TinyLife.Actions.ActionInfo info, bool automatic, System.Nullable<TinyLife.Actions.ActionVariety> variety=null, bool priority=false, bool force=false);

Parameters

type ActionType
The type of action to enqueue

info ActionInfo
The action information

automatic System.Boolean
Whether this action is considered to have started automatically (or invoked by a player)

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

priority System.Boolean
Whether to add this action to the start of the action queue rather than the end

force System.Boolean
Whether to start the action even if CanExecute returns false

Returns

Action
The created action, or null if the action cannot be executed

Person.FindPathAsync(Point, Point, GetCost, Nullable<bool>) Method

Finds a path asynchronously using the A* pathfinding algorithm.
Note that the found path is not automatically embarked on.
Usually, this method should not be used, but GoHereAction should be used instead.

public System.Threading.Tasks.Task<System.Collections.Generic.Stack<Microsoft.Xna.Framework.Point>> FindPathAsync(Microsoft.Xna.Framework.Point start, Microsoft.Xna.Framework.Point goal, MLEM.Pathfinding.AStar<Microsoft.Xna.Framework.Point>.GetCost costFunction=null, System.Nullable<bool> allowDiagonals=null);

Parameters

start Microsoft.Xna.Framework.Point
The start tile position

goal Microsoft.Xna.Framework.Point
The goal tile position

costFunction MLEM.Pathfinding.AStar.GetCost<Microsoft.Xna.Framework.Point>
The function to use for determining the cost of tiles

allowDiagonals System.Nullable<System.Boolean>
Whether diagonal movement should be allowed

Returns

System.Threading.Tasks.Task<System.Collections.Generic.Stack<Microsoft.Xna.Framework.Point>>
A task that, when completed, returns the path found or an empty stack if there is none

Person.FocusCameraOnEvent() Method

A helper method that causes the game camera to focus on this person if it is relevant.
This person is considered relevant if its Household is current or if the CurrentLot is visible to the CurrentHousehold.

public void FocusCameraOnEvent();

Person.GainSkill(SkillType, float, GameSpeed) Method

Causes this person to gain the skill with the given SkillType and raises it by the given amount.
Note that PersonalityTypes influence the skinn gain automatically.

public void GainSkill(TinyLife.Skills.SkillType type, float amount, TinyLife.GameSpeed speed=TinyLife.GameSpeed.Regular);

Parameters

type SkillType
The type of skill to gain

amount System.Single
The amount of skill points to gain

speed GameSpeed
The speed with which the skill gain should be influenced

Person.GetCategories(Person) Method

Returns a set of ObjectCategory flags that this object has, based on the given Person.

public override TinyLife.Objects.ObjectCategory GetCategories(TinyLife.Objects.Person person);

Parameters

person Person
The person to query categories for

Returns

ObjectCategory
A set of categories that this object has

Person.GetEfficiencyModifier(SkillType, float) Method

Returns a multiplier (which will be close to 1) of how "efficiently" this person currently works and moves.
This value is influenced by the level of the passed skill as well as this person's Emotion and PersonalityTypes.

public float GetEfficiencyModifier(TinyLife.Skills.SkillType skill=null, float levelModifier=0.1f);

Parameters

skill SkillType
A skill that optionally influences the efficiency

levelModifier System.Single
The amount that each skill level should influence the efficiency by. Defaults to 0.1.

Returns

System.Single
The person's efficiency, which is a value close to or equal to 1

Person.GetFreeActionSpotInfo(Person, ObjectCategory) Method

Returns the first free action spot, packed into an ActionInfo.

public override TinyLife.Actions.ActionInfo GetFreeActionSpotInfo(TinyLife.Objects.Person person, TinyLife.Objects.ObjectCategory context=null);

Parameters

person Person
The person to query free action spots for

context ObjectCategory
The object category that this action spot needs to have

Returns

ActionInfo
The first free action spot as an ActionInfo

Person.GetFreeTalkingSpots(Person) Method

Returns a set of locations, in world space, that this person can be talked to from while standing in its current location

public System.Collections.Generic.IEnumerable<Microsoft.Xna.Framework.Vector2> GetFreeTalkingSpots(TinyLife.Objects.Person person);

Parameters

person Person

Returns

System.Collections.Generic.IEnumerable<Microsoft.Xna.Framework.Vector2>
A set of free talking spots

Person.GetHeldActionInfo() Method

Returns a ActionInfo for the GetHeldObject<T>(), or null if there is none.

public TinyLife.Actions.ActionInfo GetHeldActionInfo();

Returns

ActionInfo
The held action info

Person.GetHeldObject<T>() Method

Returns the Furniture that this person is currently holding in their hands.
Note that, if the held object is not of the required type T, null is returned.

public T GetHeldObject<T>()
    where T : TinyLife.Objects.Furniture;

Type parameters

T
The type that the held furniture is expected to have

Returns

T
The held furniture

Person.GetHomeLocation() Method

Shorthand method for GetHomeLocation(Person) that returns the home location of this person's Household's lot

public Microsoft.Xna.Framework.Vector2 GetHomeLocation();

Returns

Microsoft.Xna.Framework.Vector2
This person's home location

Person.GetHoverInfo() Method

Returns a MLEM.Ui.Elements.Tooltip object that is displayed whenever the mouse is hovered over this object in the world.
By default, this method returns null, which will cause no tooltip to be displayed.

public override MLEM.Ui.Elements.Tooltip GetHoverInfo();

Returns

MLEM.Ui.Elements.Tooltip
The tooltip to display

Person.GetMatchingOutfit(ClothesIntention, float) Method

Returns the index of the Outfits collection that best matches the given ClothesIntention.
This method internally uses GetIntentionMatchingOutfit(IEnumerable<IEnumerable<Clothes>>, ClothesIntention, float).

public int GetMatchingOutfit(TinyLife.Objects.ClothesIntention intention, float requiredMatchPercentage=0f);

Parameters

intention ClothesIntention
The intention to match the best outfit to

requiredMatchPercentage System.Single
An optional minimum percentage that the returned outfit needs to have. If this is greater than 0, this method can return -1, meaning no outfit is sufficiently matching.

Returns

System.Int32
The index in the Outfits collection that best matches the intention, or -1 if requiredMatchPercentage is set and there is no sufficient match

Person.GetNeed(NeedType) Method

Returns the NeedValue of the given type for this person

public float GetNeed(TinyLife.NeedType type);

Parameters

type NeedType
The type of need that should be returned

Returns

System.Single
This person's need value

Person.GetNeedPercentage(NeedType) Method

Returns the NeedPercentage of the given type for this person

public float GetNeedPercentage(TinyLife.NeedType type);

Parameters

type NeedType
The type of need that should be returned

Returns

System.Single
This person's need percentage

Person.GetPassiveActionPriority(ActionType) Method

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

public float GetPassiveActionPriority(TinyLife.Actions.ActionType type);

Parameters

type ActionType
The type of action to get the passive priority for

Returns

System.Single
The action's passive priority

Person.GetProject(string, string) Method

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

public TinyLife.Goals.Project GetProject(string type, string name);

Parameters

type System.String
The Type of the project to return

name System.String
The Name of the project to return

Returns

Project
The matching project, or null if there is none

Person.GetProjects(string) Method

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 System.Collections.Generic.IEnumerable<TinyLife.Goals.Project> GetProjects(string type);

Parameters

type System.String
The Type of project to return

Returns

System.Collections.Generic.IEnumerable<Project>
A set of projects that match the given type

Person.GetRandomSpeakSound(SpeakStyle, List<SoundEffect>, Nullable<TimeSpan>) Method

Returns a random sound effect which is a speak sound that matches any of the given SpeakStyle flag values

public static Microsoft.Xna.Framework.Audio.SoundEffect GetRandomSpeakSound(TinyLife.Objects.SpeakStyle style, System.Collections.Generic.List<Microsoft.Xna.Framework.Audio.SoundEffect> avoid=null, System.Nullable<System.TimeSpan> maxLength=null);

Parameters

style SpeakStyle
The styles to chooose sounds from, can be a combined flag

avoid System.Collections.Generic.List<Microsoft.Xna.Framework.Audio.SoundEffect>
A list of sounds that will not be chosen from, even if they match the passed styles

maxLength System.Nullable<System.TimeSpan>
The maximum length for the returned sound effect to have, or null to return sounds of any length

Returns

Microsoft.Xna.Framework.Audio.SoundEffect
A random sound effect that matches the given properties

Person.GetRelationship(Person, bool) Method

Returns the current relationship level for the given Person.
Note that this returns this person's Relationships entry, which might have different values from the passed Person's.

public TinyLife.Relationship GetRelationship(TinyLife.Objects.Person person, bool initialize);

Parameters

person Person
The person to get relationship values for

initialize System.Boolean
Whether a new relationship should be added to the relationships menu if no relationship exists yet

Returns

Relationship
The relationship, or null if there is none and initialize is false

Person.GetRelationshipType(Person) Method

Returns the RelationshipType that this person has to the given Person.
This is a helper method that returns the relationship type of GetRelationship(Person, bool), or Acquaintances if there is no relationship.

public TinyLife.RelationshipType GetRelationshipType(TinyLife.Objects.Person person);

Parameters

person Person

Returns

RelationshipType

Person.GetSkillLevel(SkillType) Method

Returns the level of the Skill of the given type that this person has.
If this person does not have the given skill, 0 is returned.

public int GetSkillLevel(TinyLife.Skills.SkillType type);

Parameters

type SkillType
The type of skill to query

Returns

System.Int32
The person's skill level

Person.GetSkillPercentage(SkillType) Method

Returns the total skill level percentage of the given skill for this person.
This is a shorthand for LevelPercentage.

public float GetSkillPercentage(TinyLife.Skills.SkillType type);

Parameters

type SkillType
The type of skill to query

Returns

System.Single
The person's skill level percentage

Person.GetWalkSpeed() Method

Returns this person's current walk speed, per update frame.
The walk speed is influenced by their PersonalityTypes and Emotion.

public float GetWalkSpeed();

Returns

System.Single
The walk speed

Person.HasEmotionModifier(EmotionModifier) Method

Returns whether this person has the given EmotionModifier in their EmotionModifiers list

public bool HasEmotionModifier(TinyLife.Emotions.EmotionModifier type);

Parameters

type EmotionModifier
The type of emotion modifier to query

Returns

System.Boolean
Whether the emotion modifier is active

Person.HasHouseholdMember(Guid) Method

Returns whether the given person Id is a part of this household

public bool HasHouseholdMember(System.Guid person);

Parameters

person System.Guid
The unique id of the person to query

Returns

System.Boolean
true if the person is part of this household, false otherwise

Person.HasHouseholdMember(Person) Method

Returns whether the given person Id is a part of this household

public bool HasHouseholdMember(TinyLife.Objects.Person person);

Parameters

person Person
The unique id of the person to query

Returns

System.Boolean
true if the person is part of this household, false otherwise

Person.HasPersonality(PersonalityType) Method

Returns whether this person has the given PersonalityType

public bool HasPersonality(TinyLife.PersonalityType type);

Parameters

type PersonalityType
The personality type to query

Returns

System.Boolean
true if this person has this personality type, false otherwise

Person.HasSkillLevel(SkillType, int) Method

Returns whether this person has a Skill of the given type and whether its value is high enough.

public bool HasSkillLevel(TinyLife.Skills.SkillType type, int level);

Parameters

type SkillType
The type of skill to query

level System.Int32
The level that the skill has to be

Returns

System.Boolean
true if the person has this skill level, false otherwise

Person.Intersects(RectangleF) Method

Returns whether this map object intersects with the given rectangle.
This is used for GetObjects<T>(RectangleF)

public override bool Intersects(MLEM.Misc.RectangleF rectangle);

Parameters

rectangle MLEM.Misc.RectangleF
The area that should be checked for

Returns

System.Boolean
true if this object intersects with the given rectangle

Person.IsCloseForTalking(Vector2) Method

Returns true if pos is considered close enough for talking.
For a person to be close enough for talking, they have to be at least 0.25 and at most 2.5 tiles away and in the same Room.

public bool IsCloseForTalking(Microsoft.Xna.Framework.Vector2 pos);

Parameters

pos Microsoft.Xna.Framework.Vector2
The position of the person to query closeness for

Returns

System.Boolean
Whether the person is close enough to talk to

Person.IsLotVisible(Lot) Method

Returns whether the given lot is considered visible to this household
Note that passing this household's Lot will always cause this method to return true.

public bool IsLotVisible(TinyLife.World.Lot lot);

Parameters

lot Lot
The lot to query

Returns

System.Boolean
Whether the lot is visible

Person.LowerEmotion(EmotionType, float, GameSpeed) Method

Lowers any EmotionModifiers of the given EmotionType by the given percentage.
Each modifier's Time will be lowered by the percentage of their TotalTime.

public bool LowerEmotion(TinyLife.Emotions.EmotionType type, float percentage, TinyLife.GameSpeed speed=TinyLife.GameSpeed.Regular);

Parameters

type EmotionType
The type of emotion to lower

percentage System.Single
The percentage to lower the emotion by

speed GameSpeed
The game's current speed, or Regular by default

Returns

System.Boolean
Whether the emotion could be lowered, or this person had no emotion modifiers of the given type

Person.LowerEmotionModifier(EmotionModifier, float, GameSpeed) Method

Lowers the specified emotion modifier by the specified percentage.
This differs from LowerEmotion(EmotionType, float, GameSpeed) in that only the specific modifier is lowered.

public bool LowerEmotionModifier(TinyLife.Emotions.EmotionModifier modifier, float percentage, TinyLife.GameSpeed speed=TinyLife.GameSpeed.Regular);

Parameters

modifier EmotionModifier
The emotion modifier to lower

percentage System.Single
The percentage to lower the emotion by

speed GameSpeed
The game's current speed, or Regular by default

Returns

System.Boolean
Whether the emotion could be lowered, or this person had no emotion modifiers of the given type

Person.OccupyActionSpot(Furniture, ActionSpot, bool, Nullable<Direction2>) Method

Causes the given action spot of the given furniture to be marked as occupied.
Optionally, the VisualPosition can also be changed, causing this person to look as if they were sitting, standing or laying on the furniture.
Note that the values set in this method are reset every Update(GameTime, TimeSpan, GameSpeed) call.

public void OccupyActionSpot(TinyLife.Objects.Furniture furniture, TinyLife.Objects.ActionSpot spot, bool enterSpot, System.Nullable<MLEM.Misc.Direction2> rotation=null);

Parameters

furniture Furniture
The furniture to occupy

spot ActionSpot
The action spot to occupy on the furniture

enterSpot System.Boolean
Whether or not the visual position should be updated to enter the spot

rotation System.Nullable<MLEM.Misc.Direction2>
The rotation that this person should get, or null to use the spot's default rotation

Person.OccupyFreeActionSpot(Furniture, ObjectCategory, bool, Nullable<Direction2>) Method

This is a shorthand method for GetFreeActionSpot(Person, ObjectCategory) and OccupyActionSpot(Furniture, ActionSpot, bool, Nullable<Direction2>).
Note that this method needs to be called every update frame for the person to keep occupying the action spot.

public bool OccupyFreeActionSpot(TinyLife.Objects.Furniture furniture, TinyLife.Objects.ObjectCategory context=null, bool enter=false, System.Nullable<MLEM.Misc.Direction2> rotation=null);

Parameters

furniture Furniture
The furniture whose object spot to occupy

context ObjectCategory
The category that the action spot should have

enter System.Boolean
Whether or not the action spot should be entered

rotation System.Nullable<MLEM.Misc.Direction2>
The rotation that the person should have, or the action spot's rotation by default

Returns

System.Boolean
Whether or not we were able to occupy a free action spot

Person.OnCameraRotationChanged(Direction2, Direction2) Method

This method is invoked when the game's camera rotation changes.
Additionally, the old and new rotations are passed.

public override void OnCameraRotationChanged(MLEM.Misc.Direction2 oldRotation, MLEM.Misc.Direction2 newRotation);

Parameters

oldRotation MLEM.Misc.Direction2
The old camera rotation

newRotation MLEM.Misc.Direction2
The new camera rotation

Person.RemoveEmotion(EmotionModifier) Method

Removes the given EmotionModifier from this person's EmotionModifiers

public bool RemoveEmotion(TinyLife.Emotions.EmotionModifier type);

Parameters

type EmotionModifier
The type of emotion to remove

Returns

System.Boolean
Whether the emotion could be removed (or wasn't contained in the first place)

Person.ResetToStatic(bool) Method

Resets this person to a static version of itself.
This action clears AllActions, clears the LastVisitedLot, resets all Relationships and restores all Needs to their default value.
This method is used by map and household ex- and imports.

public void ResetToStatic(bool resetRelationships);

Parameters

resetRelationships System.Boolean
Whether or not relationships should be reset or not

Person.RestoreNeed(NeedType, float, GameSpeed) Method

Restores this person's Need of the given type by the given amount

public void RestoreNeed(TinyLife.NeedType type, float amount, TinyLife.GameSpeed speed=TinyLife.GameSpeed.Regular);

Parameters

type NeedType
The type of need to restore

amount System.Single
The amount to restore this need by

speed GameSpeed
The speed that the need gain should be influenced by

Person.SetCurrentOutfit(int) Method

Sets this person's CurrentOutfitIndex to the given index.
Additionally, this method updates this person's animation and portrait to the new outfit.

public void SetCurrentOutfit(int index);

Parameters

index System.Int32
The index to set

Person.SetCurrentOutfit(ClothesIntention, float) Method

Sets the current outfit to an outfit that matches the given ClothesIntention.
This method returns whether GetMatchingOutfit(ClothesIntention, float) returned a valid outfit index or if no matching outfit could be found.

public bool SetCurrentOutfit(TinyLife.Objects.ClothesIntention intention, float requiredMatchPercentage=0f);

Parameters

intention ClothesIntention
The intention to match the best outfit to

requiredMatchPercentage System.Single
An optional minimum percentage that the returned outfit needs to have. If this is greater than 0, this method can return false, meaning no outfit is sufficiently matching.

Returns

System.Boolean
True if an outfit could be found, or false if requiredMatchPercentage is greater than 0 and no sufficiently matching outfit could be found

Person.SetHeldObject(Furniture) Method

Sets this person's held object to the given instance.
Note that this resets the Furniture's position to -1, -1.

public void SetHeldObject(TinyLife.Objects.Furniture furniture);

Parameters

furniture Furniture
The furniture to hold

Person.SetHeldObject<T>(FurnitureType, int[], Nullable<Guid>) Method

Sets the person's held object to the given furniture type, with the given data, and returns the created instance.

public T SetHeldObject<T>(TinyLife.Objects.FurnitureType type, int[] colors=null, System.Nullable<System.Guid> id=null)
    where T : TinyLife.Objects.Furniture;

Type parameters

T
The type that the created furniture is expected to have

Parameters

type FurnitureType
The type of furniture to construct

colors System.Int32[]
The colors that the constructed furniture should have, or null to use the defaults

id System.Nullable<System.Guid>
The id that this furniture should have, or null to choose a random one

Returns

T
The created furniture instance

Person.SetJob(JobType) Method

Sets this person's current Job.
If null is passed, the person's job gets removed.

public void SetJob(TinyLife.Goals.JobType type);

Parameters

type JobType
The job to start

Person.Speak(SpeakStyle, float, float) Method

Causes this person to play speaking sounds with their VoicePitch applied for the given amount of time

public void Speak(TinyLife.Objects.SpeakStyle possibleStyles, float minimumSeconds=1f, float maximumSeconds=3f);

Parameters

possibleStyles SpeakStyle
The speak styles to choose sounds from, can be a combined flag

minimumSeconds System.Single
The minimum amount of time, in seconds, to speak for

maximumSeconds System.Single
The maximum amount of time, in seconds, to speak for

Person.StartProject(Project) Method

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

public TinyLife.Goals.Project StartProject(TinyLife.Goals.Project project);

Parameters

project Project
The project to start

Returns

Project
The project that was passed, for chaining

Person.StopEmoting() Method

Causes this person to stop displaying the current emote immediately

public void StopEmoting();

Person.StopSpeaking() Method

Causes this person to stop speaking, resetting their CurrentSpeakStyle and interrupting any currently playing speak sounds

public void StopSpeaking();

Person.ToCreatedByString() Method

Returns a string representation of this person using the localized "Created by:" prefix

public string ToCreatedByString();

Returns

System.String
A "created by" string

Person.Update(GameTime, TimeSpan, GameSpeed) Method

The update method, which is called every update frame by the underlying Map

public void Update(Microsoft.Xna.Framework.GameTime time, System.TimeSpan passedInGame, TinyLife.GameSpeed speed);

Parameters

time Microsoft.Xna.Framework.GameTime
The game's time

passedInGame System.TimeSpan
The amount of time that has passed since the last call

speed GameSpeed
The game's speed

Implements Update(GameTime, TimeSpan, GameSpeed)

Person.Validate() Method

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

System.Boolean
false if the object is not valid, true otherwise

Person.VisitLot(Lot) Method

Marks the given lot as visited, setting LotVisitCooldown to 4 hours if the lot is the person's home lot, and 2 otherwise
The passed lot is additionally marked as visible using MarkLotVisible(Lot),

public void VisitLot(TinyLife.World.Lot lot);

Parameters

lot Lot
The lot to mark as visited

Events

Person.OnActionsChanged Event

An event that is invoked when the CurrentActions or ActionQueue of this person changed
This event can be subscribed to using OnEventsAttachable.

public event OnActionsChanged;

Event Type

System.Action<Person>

Person.OnActionsCompleted Event

An event that is invoked when an Action is completed, no matter the resulting CompletionType.
This event can be subscribed to using OnEventsAttachable.

public event OnActionsCompleted;

Event Type

System.Action<Action,CompletionType>

Person.OnActionUpdated Event

An event that is invoked when an Action is updated in Update(GameTime, TimeSpan, GameSpeed).
This event can be subscribed to using OnEventsAttachable.

public event OnActionUpdated;

Event Type

ActionUpdateDelegate(Action, GameTime, TimeSpan, GameSpeed, EventPhase)

Person.OnEmotionChanged Event

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

public event OnEmotionChanged;

Event Type

System.Action<Person>

Person.OnEmotionModifiersChanged Event

An event that is invoked when the EmotionModifiers change.
This event can be subscribed to using OnEventsAttachable.

public event OnEmotionModifiersChanged;

Event Type

System.Action<Person>

Person.OnGetEfficiencyModifier Event

An event that is invoked at the end of GetEfficiencyModifier(SkillType, float), after the default efficiency modifier is evaulated.
This event can be used to change this person's efficiency based on additional mod factors.
This event can be subscribed to using OnEventsAttachable.

public event OnGetEfficiencyModifier;

Event Type

EfficiencyModifierDelegate(SkillType, float, float)

Person.OnGetPassiveActionPriority Event

An event that is invoked at the end of GetPassiveActionPriority(ActionType), after the default action priority is evaulated.
This event can be used to change the action priority based on additional mod factors.
This event can be subscribed to using OnEventsAttachable.

public event OnGetPassiveActionPriority;

Event Type

PassiveActionPriorityDelegate(ActionType, float)

Person.OnGetWalkSpeed Event

An event that is invoked at the end of GetWalkSpeed(), after the default walk speed is evaluated.
This event can be used to change this person's walk speed based on additional mod factors.
This event can be subscribed to using OnEventsAttachable.

public event OnGetWalkSpeed;

Event Type

WalkSpeedDelegate(float)

Person.OnJobChanged Event

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

public event OnJobChanged;

Event Type

System.Action<Person>

Person.OnNewSkillLearned Event

An event that is invoked when the Skills list gains a new entry, meaning the person learned a new skill
This event can be subscribed to using OnEventsAttachable.

public event OnNewSkillLearned;

Event Type

System.Action<Person>

Person.OnOutfitChanged Event

An event that is invoked when this person's CurrentOutfitIndex changes.
This event can be subscribed to using OnEventsAttachable.

public event OnOutfitChanged;

Event Type

System.Action<Person>