Class Person
A person is a MapObject placed on a Map that represents a person. It stores its actions, clothes, data and movement.
public class Person : MapObject, IGenericDataHolder, IUpdatingObject
- Inheritance
-
JsonTypeSafeGenericDataHolderPerson
- Implements
-
IGenericDataHolder
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
Person(Map, Vector2)
Creates a new person with the given settings. To create a new person externally, use Create(Map, Random, AgeGroup, bool, bool, bool, bool, Person[]).
[JsonConstructor]
protected Person(Map map, Vector2 position)
Parameters
map
MapThe map.
position
Vector2The position.
Fields
ActionQueue
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 should be force-started (true) or whether it should do the necessary checks (false). Use EnqueueAction<T>(ActionType, ActionInfo, bool, ActionVariety, bool, bool) and CancelAction(Action, Action, bool) to modify this list.
[DataMember]
public readonly List<(Action, bool)> ActionQueue
Field Value
AgeGroups
A set of all AgeGroup enum values that are explicitly defined.
public static readonly AgeGroup[] AgeGroups
Field Value
- AgeGroup[]
AnimateHeldObject
Whether or not the GetHeldObject<T>(bool) 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, float) frame.
public bool AnimateHeldObject
Field Value
AnimationSpeed
The speed that this person's animation should run with. Note that this value is not saved to disk, and is reset to 1 every Update(GameTime, TimeSpan, float) frame.
public float AnimationSpeed
Field Value
CurrentActions
The actions that are currently being executed by this person. Use EnqueueAction<T>(ActionType, ActionInfo, bool, ActionVariety, bool, bool) and CancelAction(Action, Action, bool) to modify this list.
[DataMember]
public readonly List<Action> CurrentActions
Field Value
CurrentAgeDays
The amount of in-game days that this person has had their current Age for. See DaysLived for a full amount of days lived.
[DataMember]
public int CurrentAgeDays
Field Value
CurrentPose
This person's current Pose. Note that this value is reset to the GetDefaultPose(AgeGroup) for this person's Age every Update(GameTime, TimeSpan, float) frame.
[DataMember]
public Pose CurrentPose
Field Value
DaysLived
The amount of in-game days that this person has lived for in total. See CurrentAgeDays for the amount of days with their current Age.
[DataMember]
public int DaysLived
Field Value
DefaultWalkSpeed
The default walk speed for a person, which is used in GetWalkSpeed(), and additionally determines a person's animation speed.
public const float DefaultWalkSpeed = 0.05
Field Value
Description
This person's description
[DataMember]
public string Description
Field Value
DiaperDirty
Whether this person's diaper is dirty.
[DataMember(EmitDefaultValue = false)]
public bool DiaperDirty
Field Value
EmotionModifiers
The EmotionModifier.Instance objects that are currently applied to this person. To access this collection efficiently, use AddEmotion(EmotionModifier, int, TimeSpan, IEmotionSource, bool), RemoveEmotion(EmotionModifier) and LowerEmotion(EmotionType, float, float).
[DataMember]
public readonly List<EmotionModifier.Instance> EmotionModifiers
Field Value
FirstName
This person's first name
[DataMember]
public string FirstName
Field Value
HeldObjectRotation
The rotation that the GetHeldObject<T>(bool) 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, float) frame.
public Direction2? HeldObjectRotation
Field Value
- Direction2?
IsInLabor
Whether this person is currently in labor. Note that, when a person is in labor, their PregnancyHoursRemaining have already reached 0.
[DataMember(EmitDefaultValue = false)]
public bool IsInLabor
Field Value
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
LastBedSleptIn
[DataMember(EmitDefaultValue = false)]
public Guid LastBedSleptIn
Field Value
LastName
This person's last name
[DataMember]
public string LastName
Field Value
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
MaxRecentActionsAmount
The maximum amount of recent actions that is stored in RecentActions
public const int MaxRecentActionsAmount = 200
Field Value
Memories
A set of Memory instances that this person currently has or tracks. To edit and query this collection easily, AddMemory<T>(MemoryType, ActionInfo, bool, TimeSpan?)/>, GetMemories<T>(MemoryType) and GetTimeSinceMemory<T>(MemoryType, Func<T, bool>) can be used.
[DataMember]
public readonly List<Memory> Memories
Field Value
Needs
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).
[DataMember]
public readonly Dictionary<string, Need> Needs
Field Value
Outfits
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.
[DataMember]
[JsonConverter(typeof(Person.OutfitsConverter))]
public readonly List<Outfit> Outfits
Field Value
PersonalityTypes
The names of the PersonalityType values that this person has. To access this collection efficiently, use HasPersonality(PersonalityType).
[DataMember]
public readonly HashSet<PersonalityType> PersonalityTypes
Field Value
PregnancyAbility
This person's PregnancyAbility.
[DataMember]
public PregnancyAbility PregnancyAbility
Field Value
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
Pronouns
This person's pronouns.
[DataMember]
public string Pronouns
Field Value
RecentActions
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.
[DataMember]
public readonly List<ActionType> RecentActions
Field Value
Relationships
This person's Relationship data. To access this collection efficiently, use GetRelationship(Person, bool) and ChangeFriendship(Person, float).
[DataMember]
public readonly List<Relationship> Relationships
Field Value
Skills
This person's Skill data. To access this collection efficiently, use GetSkillLevel(SkillType) and GainSkill(SkillType, float, ActionInfo, float).
[DataMember]
public readonly Dictionary<string, Skill> Skills
Field Value
SpeakSounds
All of the Microsoft.Xna.Framework.Audio.SoundEffect instances that a Person can use for speaking, which are returned in GetRandomSpeakSound(VoiceStyle, SpeakStyle, List<SoundEffect>, TimeSpan?). Mods can simply add to this collection to add new speak sounds.
public static readonly Dictionary<(VoiceStyle, SpeakStyle), List<SoundEffect>> SpeakSounds
Field Value
- Dictionary<(VoiceStyle, SpeakStyle), List<SoundEffect>>
SpeakStyles
All defined SpeakStyle enum values.
public static readonly SpeakStyle[] SpeakStyles
Field Value
Tint
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, float) frame.
public Color? Tint
Field Value
- Color?
VoicePitch
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.
[DataMember]
public float VoicePitch
Field Value
VoiceStyle
The style of this person's voice, used for speaking (Speak(SpeakStyle, float, float)). Note that, if this person is a Child or Baby, the Child or Baby styles will be used regardless of this field's value.
[DataMember]
public VoiceStyle VoiceStyle
Field Value
VoiceStyles
All defined VoiceStyle enum values.
public static readonly VoiceStyle[] VoiceStyles
Field Value
WasInvitedIn
Whether this person was already invited in to their LastVisitedLot.
[DataMember(EmitDefaultValue = false)]
public bool WasInvitedIn
Field Value
WornLayers
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, float) frame. Setting this value to 0 (no layer) will also stop the Emote and GetHeldObject<T>(bool) from drawing.
[DataMember]
public ClothesLayer WornLayers
Field Value
Properties
Age
The AgeGroup that this person currently has.
public AgeGroup Age { get; set; }
Property Value
AllActions
A concatenation of CurrentActions and ActionQueue that represents all actions that the current person has knowledge about
public IEnumerable<Action> AllActions { get; }
Property Value
CurrentEmote
The Emote that this person is currently displaying. Use DisplayEmote(EmoteCategory, float, float) to modify this property.
public Emote CurrentEmote { get; protected set; }
Property Value
CurrentOutfit
Returns the outfit that this person is currently wearing, which is the Outfits entry at the CurrentOutfitIndex.
public Outfit CurrentOutfit { get; }
Property Value
CurrentOutfitIndex
The index of the outfit, in the Outfits list, that this person is currently wearing. To change this value, use SetCurrentOutfit(ClothesIntention) or SetCurrentOutfit(int).
[DataMember]
public int CurrentOutfitIndex { get; }
Property Value
CurrentRoomDecorativeRating
The decorative rating of the CurrentRoom, resulting from the DecorativeRating of the contained furniture
public int CurrentRoomDecorativeRating { get; }
Property Value
CurrentSpeakStyle
The current speak styles that speaking sounds are chosen from. Use Speak(SpeakStyle, float, float) to modify this property.
public SpeakStyle? CurrentSpeakStyle { get; protected set; }
Property Value
DrawSize
The size, in draw space pixels, that a person's texture takes up.
public static Point DrawSize { get; }
Property Value
- Point
Emotion
The EmotionType that this person currently has, resulting from their current EmotionModifiers
public EmotionType Emotion { get; }
Property Value
EmotionAmount
The total sum of all emotion modifiers that cause the current Emotion.
public int EmotionAmount { get; }
Property Value
FullName
public string FullName { get; }
Property Value
FullNamePronouns
This person's full name and pronouns, which is a concatenation of their FullName, and their pronouns in parentheses.
public string FullNamePronouns { get; }
Property Value
HomeLot
The Lot that this household lives on. For exported households, this might be null.
public Lot HomeLot { get; }
Property Value
Household
The Household that this person is a part of
public Household Household { get; }
Property Value
IsAllowedToDie
Returns whether this person is allowed to die. A person is allowed to die if they are an Adult or older, and if they're not pregnant.
public bool IsAllowedToDie { get; }
Property Value
IsCurrentHousehold
A property that indicates whether or not this household is the same as CurrentHousehold
public bool IsCurrentHousehold { get; }
Property Value
IsDead
A property that computes whether this person is dead. Note that a person has to be on a Map's TinyLife.World.Map.DeadPeople list for this property to function correctly.
public bool IsDead { get; }
Property Value
IsMinorUpdateNow
A property that returns whether this updating object should currently update minorly, rather than majorly. A minor update means that Update(GameTime, TimeSpan, float) is only called once every 10 in-game minutes (see MinorUpdateMinutes), but all of the parameters to Update(GameTime, TimeSpan, float) are modified accordingly to maintain proper time calculations. Note that this property is only queried every 10 in-game minutes, as switching between major and minor update schedules only happens when a minor update is executed. For example, a Person updates minorly when they're out of town to aid the game's performance.
public bool IsMinorUpdateNow { get; }
Property Value
IsMoving
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; protected set; }
Property Value
IsPregnant
Whether this person is currently considered pregnant. This property returns true if PregnancyHoursRemaining is greater than 0 or if IsInLabor is true.
public bool IsPregnant { get; }
Property Value
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 bool IsRegularVisitor { get; }
Property Value
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
LastVisitedLot
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 Lot LastVisitedLot { get; }
Property Value
LifeGoal
This person's current LifeGoal.Instance
public LifeGoal.Instance LifeGoal { get; set; }
Property Value
LifeSpan
This person's LifeSpan, which is determined by PerSaveOptions and whether this person IsCurrentHousehold.
public LifeSpan LifeSpan { get; }
Property Value
LotVisitCooldown
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.
[DataMember(EmitDefaultValue = false)]
public TimeSpan LotVisitCooldown { get; protected set; }
Property Value
Money
The money that this household has, rounded by two digits after the decimal point
public float Money { get; set; }
Property Value
OccupiedFurniture
The set of Furniture and their occresponding ActionSpot that this person is currently occupying in some capacity.
Note that this value is not saved to disk, and is cleared every Update(GameTime, TimeSpan, float) frame, unless Stay
is set to true.
To edit this value, use OccupyActionSpot(Furniture, ActionSpot, bool, Direction2?, bool).
public IEnumerable<(Furniture Furniture, ActionSpot Spot, bool Stay)> OccupiedFurniture { get; }
Property Value
ParentInfo
Returns a ParentInfo for this object in its current context. By default, this method returns default, and Furniture returns a ParentInfo based on its current attachments.
public override ParentInfo ParentInfo { get; }
Property Value
Portrait
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 RenderTarget2D Portrait { get; }
Property Value
- RenderTarget2D
PregnancyHoursRemaining
The amount of hours that this person will be pregnant for before they have a chance to start IsInLabor. To set this value, use SetPregnancyStatus(int, Guid, bool).
[DataMember(EmitDefaultValue = false)]
public float PregnancyHoursRemaining { get; }
Property Value
PregnancyPartner
The Id of the person that caused this person's current pregnancy, or Empty if this person is not pregnant, or became pregnant through means that don't involve a second party. To set this value, use SetPregnancyStatus(int, Guid, bool).
[DataMember(EmitDefaultValue = false)]
public Guid PregnancyPartner { get; }
Property Value
RandomlyGenerated
A property that stores whether this person has been randomly generated by invoking the Create(Map, Random, AgeGroup, bool, bool, bool, bool, Person[]) method with a nonnull TinyLife.Objects.Person.Random.
[DataMember(EmitDefaultValue = false)]
public bool RandomlyGenerated { get; protected set; }
Property Value
Rotation
The MLEM.Misc.Direction2 that this person is currently facing in
public Direction2 Rotation { get; set; }
Property Value
- Direction2
VisuallyOccupiedSpot
The ActionSpot and corresponding Furniture that this person is visually occupying in the OccupiedFurniture collection.
If this tuple has no value, or any of its entries are null, this person is not visually occupying any of the spots.
Note that this value is not saved to disk, and is reset to -1 every Update(GameTime, TimeSpan, float) frame, unless Stay
is set to true.
To edit this value, use OccupyActionSpot(Furniture, ActionSpot, bool, Direction2?, bool).
public (Furniture Furniture, ActionSpot Spot, bool Stay) VisuallyOccupiedSpot { get; }
Property Value
VisualPosition
The visual position of this person, which is influenced by their Position and a visual override that can additionally be set using OccupyActionSpot(Furniture, ActionSpot, bool, Direction2?, bool). Note that this value is reset to Position every Update(GameTime, TimeSpan, float) frame. Also note that the visual position does not affect collision detection or most interactions.
public Vector2 VisualPosition { get; set; }
Property Value
- Vector2
Methods
AddEmotion(EmotionModifier, int, TimeSpan, IEmotionSource, bool)
Adds the given EmotionModifier with the given intensity and time
public virtual bool AddEmotion(EmotionModifier type, int amount, TimeSpan time, IEmotionSource source, bool increaseExisting = false)
Parameters
type
EmotionModifierThe type of emotion to add
amount
intThe intensity of the emotion to add
time
TimeSpanThe amount of in-game time the emotion should last for
source
IEmotionSourceThe emotion source that caused this emotion. Supported objects include FurnitureType, ActionType, NeedType and more. May be null.
increaseExisting
boolWhether 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
- bool
Whether the emotion could be added or it was already applied. If
increaseExisting
is true, this method always returns true.
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
Returns
- bool
Whether the job could be added. If this is false, then this person already has a job of the given
type
.
AddMemory<T>(MemoryType, ActionInfo, bool, TimeSpan?)
public virtual T AddMemory<T>(MemoryType type, ActionInfo info, bool replace = true, TimeSpan? timeOccured = null) where T : Memory
Parameters
type
MemoryTypeThe type of memory to add.
info
ActionInfoThe action info to attach to this memory, or null to use FromSelf(Person).
replace
boolWhether existing instances of the given
type
should be replaced by this memory.timeOccured
TimeSpan?
Returns
- T
The added memory.
Type Parameters
T
CanApplyPersonality(PersonalityType)
Returns whether the given personality type
can be applied to this person.
The return value is determined by this person's existing PersonalityTypes and the personality type's AllowedAges and IsCompatible(PersonalityType) value.
public virtual bool CanApplyPersonality(PersonalityType type)
Parameters
type
PersonalityType
Returns
- bool
Whether the personality type can apply to this person.
CancelAction(Action, Action, bool)
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 virtual bool CancelAction(Action action, Action cancelSource = null, bool force = false)
Parameters
action
ActionThe action to cancel
cancelSource
ActionThe action that is responsible for this cancelation, or null by default
force
boolWhether to cancel the action even if CanCancel(Action) returns false
Returns
- bool
Whether the action could be canceled successfully
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 virtual CanExecuteResult CanExecuteAction(ActionType type, ActionInfo info, bool automatic)
Parameters
type
ActionTypeThe action to execute.
info
ActionInfoThe action info
automatic
boolWhether the action is automatically executed
Returns
- CanExecuteResult
A CanExecuteResult that represents whether the action can be executed right now
ChangeFriendship(Person, float)
Changes the FriendLevel Relationship 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 virtual void ChangeFriendship(Person person, float amount)
Parameters
person
PersonThe person to change friendship with
amount
floatThe amount to change friendship by, can be negative
ChangeRomance(Person, float)
Changes the RomanceLevel Relationship wit the given person by the given amount. Additionally, a romance Particle is displayed.
public virtual void ChangeRomance(Person person, float amount)
Parameters
person
PersonThe person to change romance with
amount
floatThe amount to change romance by, can be negative
Create(Map, Random, AgeGroup, bool, bool, bool, bool, Person[])
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, Person[] geneticInfluences = null)
Parameters
map
MapThe map to create the person for.
random
RandomThe TinyLife.Objects.Person.Random instance to use for generating the person.
allowedAges
AgeGroupA set of AgeGroup flags that the person is allowed to have.
markRandomlyGenerated
boolWhether to mark the person as RandomlyGenerated.
initializeName
boolWhether to initialize the person's FirstName, LastName and Pronouns.
initializePersonality
boolWhether to initialize the person's PersonalityTypes.
generateMultipleOutfits
boolWhether to generate multiple outfits, rather than just one default one.
geneticInfluences
Person[]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.
DepleteNeed(NeedType, float, float)
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 virtual void DepleteNeed(NeedType type, float amount, float speedMultiplier)
Parameters
type
NeedTypeThe type of need to deplete
amount
floatThe amount to deplete the need by, out of Max.
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
Die(DeathReason, bool)
Causes this person to die, removing it from the world and optionally spawning a Gravestone. Note thta this method's content is executed at the end of the current Update(GameTime, TimeSpan, float) frame, and not right away.
public virtual void Die(DeathReason reason, bool createGravestone = true)
Parameters
reason
DeathReasonThe reason for this person's death
createGravestone
boolWhether or not to create a gravestone
DisplayEmote(EmoteCategory, float, float)
Causes this person to display a Emote over its head for 1 to 3 seconds
public virtual void DisplayEmote(EmoteCategory possibleCategories, float minimumSeconds = 1, float maximumSeconds = 3)
Parameters
possibleCategories
EmoteCategoryA combined flag that represents the categories to pick emotes from
minimumSeconds
floatThe minimum amount of real-time seconds that the emote should be displayed for, or 1 by default
maximumSeconds
floatThe maximum amount of real-time seconds that the emote should be displayed for, or 3 by default
DisplayEmoteAndSpeak(EmoteCategory, SpeakStyle, float, float)
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 virtual void DisplayEmoteAndSpeak(EmoteCategory emoteCategories, SpeakStyle speakStyles, float minimumSeconds = 1, float maximumSeconds = 3)
Parameters
emoteCategories
EmoteCategoryThe emote categories to choose from, can be a combined flag
speakStyles
SpeakStyleThe speak styles to choose from, can be a combined flag
minimumSeconds
floatThe minimum amount of time, in seconds, to speak and display the emote for
maximumSeconds
floatThe maximum amount of time, in seconds, to speak and display the emote for
Draw(GameTime, object, Vector2, Color?, List<Item>)
Draws this object on the current Map, at the current Position. To draw a map object while invoking all the required events, use DoDraw(GameTime, object, Color?, bool, List<Item>).
public override void Draw(GameTime time, object batch, Vector2 _, Color? overrideColor, List<StaticSpriteBatch.Item> items)
Parameters
time
GameTimeThe current time
batch
objectThe sprite batch to use for drawing, which is either a Microsoft.Xna.Framework.Graphics.SpriteBatch or MLEM.Graphics.StaticSpriteBatch.
_
Vector2overrideColor
Color?The color that should be used instead of this object's actual color. If null, the object's regular color should be used.
items
List<StaticSpriteBatch.Item>A list of sprite batch items that items should be added to if the
batch
is a MLEM.Graphics.StaticSpriteBatch.
DrawLooks(SpriteBatch, Vector2, Vector2, ParentInfo, Color?, float)
Draws this person's looks in the world, which includes their clothes and shadow by default.
protected virtual void DrawLooks(SpriteBatch batch, Vector2 drawPos, Vector2 depthPos, ParentInfo parent, Color? overrideColor = null, float scale = 1)
Parameters
batch
SpriteBatchThe sprite batch to use for drawing.
drawPos
Vector2The draw position in screen space.
depthPos
Vector2The position to use for calculating depth.
parent
ParentInfoThis person's parent info.
overrideColor
Color?An override color to use instead of this person's default colors.
scale
floatThe scale to draw with.
DrawUi(SpriteBatch, Vector2, float, Direction2)
Renders this person on a ui level rather than a world level
public virtual void DrawUi(SpriteBatch batch, Vector2 pos, float scale, Direction2 rotation = Direction2.Right)
Parameters
batch
SpriteBatchThe sprite batch to use for drawing
pos
Vector2The position, in screen space, to draw at
scale
floatThe scale to draw with
rotation
Direction2The rotation that this person should be drawn with. Defaults to MLEM.Misc.Direction2.Right.
EarnMoney(float, object)
Causes this person's Money to be increased, but additionally triggers the EarnMoney AmountGoal. This method should only be used if the money is earned in a "manual" way, like when selling a homemade painting or publishing a book.
public virtual void EarnMoney(float money, object triggerObject)
Parameters
money
floatThe money to earn.
triggerObject
objectThe object that caused the money to be earned, which is passed to Trigger(IGoalTriggerable, object, GoalTrigger, params object[]).
EnqueueAction<T>(ActionType, ActionInfo, bool, ActionVariety, bool, bool)
Enqueues the given action into ActionQueue to be executed later.
public virtual T EnqueueAction<T>(ActionType type, ActionInfo info, bool automatic, ActionVariety variety = null, bool priority = false, bool force = false) where T : Action
Parameters
type
ActionTypeThe type of action to enqueue
info
ActionInfoThe action information
automatic
boolWhether this action is considered to have started automatically (or invoked by a player)
variety
ActionVarietyThe variety of the action to start, or null if this action has no varieties or a random variety should be chosen
priority
boolWhether to add this action to the start of the action queue rather than the end
force
boolWhether to start the action even if CanExecute returns false
Returns
- T
The created action, or null if the action cannot be executed or the maximum amount of entries in the ActionQueue is reached.
Type Parameters
T
~Person()
protected ~Person()
FindPathAsync(Point, ICollection<Point>, GetCost)
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 virtual Task<Stack<Point>> FindPathAsync(Point start, ICollection<Point> goals, AStar<Point>.GetCost costFunction = null)
Parameters
start
PointThe start tile position
goals
ICollection<Point>The goal tile positions.
costFunction
AStar<Point>.GetCostThe function to use for determining the cost of tiles
Returns
- Task<Stack<Point>>
A task that, when completed, returns the path found or an empty stack if there is none
FocusCameraOnEvent(bool)
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 virtual bool FocusCameraOnEvent(bool onlyIfImportant)
Parameters
onlyIfImportant
boolWhether only Tinies that are considered important should be focused on. An important Tiny is one that at least one person in the currently active household knows.
Returns
GainSkill(SkillType, float, ActionInfo, float)
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 virtual bool GainSkill(SkillType type, float amount, ActionInfo info, float speedMultiplier)
Parameters
type
SkillTypeThe type of skill to gain
amount
floatThe amount of skill points to gain
info
ActionInfoAn optional action info whose GetInvolvedObjects<T>(ObjectCategory, bool, bool) can influence the efficiency
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
Returns
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 virtual SpriteAnimationGroup GenerateAnimationGroup(ClothesLayer clothesLayer, int layerAmount, IReadOnlyDictionary<Point, TextureRegion> textures, Point textureRegion)
Parameters
clothesLayer
ClothesLayerThe clothes layer.
layerAmount
intThe amount of layers the clothing item has.
textures
IReadOnlyDictionary<Point, TextureRegion>The textures to use.
textureRegion
PointThe initial texture region to use.
Returns
- SpriteAnimationGroup
The generated MLEM.Animations.SpriteAnimationGroup.
GetAction<T>(Guid, bool)
Returns the action in this person's AllActions set whose Id matches the given id
and the given type T
.
public T GetAction<T>(Guid id, bool regardChildren = false) where T : Action
Parameters
id
GuidThe id of the action to query.
regardChildren
boolWhether child actions should be queried. If this is true, GetChild<T>(Guid, bool) is used.
Returns
- T
The action with the given
id
and typeT
, or null if none are found.
Type Parameters
T
The type of action to find and return.
GetCategories(Person)
Returns a set of ObjectCategory flags that this object has, based on the given Person.
public override ObjectCategory GetCategories(Person person)
Parameters
person
PersonThe person to query categories for
Returns
- ObjectCategory
A set of categories that this object has
GetCurrentGoals()
Returns a set of GoalSet objects that this person is currently working on. To add more current goals, use OnGetCurrentGoals.
public virtual List<IGoalTriggerable> GetCurrentGoals()
Returns
- List<IGoalTriggerable>
This person's current goals
GetEfficiencyModifier(float, ActionInfo, SkillType, float)
Returns a multiplier (which will be close to 1) of how "efficiently" this person currently works and moves.
This value is influenced by the speedMultiplier
, the level of the passed skill
as well as this person's Emotion and PersonalityTypes.
public virtual float GetEfficiencyModifier(float speedMultiplier = 1, ActionInfo info = null, SkillType skill = null, float levelModifier = 0.1)
Parameters
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
info
ActionInfoAn optional action info whose GetInvolvedObjects<T>(ObjectCategory, bool, bool) can influence the efficiency
skill
SkillTypeA skill that optionally influences the efficiency
levelModifier
floatThe amount that each
skill
level should influence the efficiency by. Defaults to 0.1.
Returns
- float
The person's efficiency, which is a value close to or equal to 1
GetFreeActionSpotInfo(Person, ObjectCategory)
Returns the first free action spot, packed into an ActionInfo.
public override ActionInfo GetFreeActionSpotInfo(Person person, ObjectCategory context = null)
Parameters
person
PersonThe person to query free action spots for
context
ObjectCategoryThe object category that this action spot needs to have
Returns
- ActionInfo
The first free action spot as an ActionInfo
GetFreeTalkingSpots(Person)
Returns a set of locations, in world space, that this person can be talked to from while standing in its current location
public virtual IEnumerable<Vector2> GetFreeTalkingSpots(Person person)
Parameters
person
Person
Returns
- IEnumerable<Vector2>
A set of free talking spots
GetHeldActionInfo()
Returns a ActionInfo for the GetHeldObject<T>(bool), or null if there is none. Note that, if the held object is marked as being fake, this method also returns null.
public virtual ActionInfo GetHeldActionInfo()
Returns
- ActionInfo
The held action info.
GetHeldItemDepthOffset()
Returns this person's held item's depth offset, which is used by ParentInfo for drawing.
public virtual float GetHeldItemDepthOffset()
Returns
- float
This person's held item's depth offset.
GetHeldItemDrawOffset(bool)
Returns this person's held item's draw offset, which is used by ParentInfo for drawing.
public virtual Vector2 GetHeldItemDrawOffset(bool includeItemOffsets)
Parameters
includeItemOffsets
bool
Returns
- Vector2
This person's held item's draw offset.
GetHeldObject<T>(bool)
Returns the Furniture that this person is currently holding in their hands, which will always be on the same map as this person's Map.
Note that, if the held object is not of the required type T
, null is returned.
public virtual T GetHeldObject<T>(bool alsoReturnFake = true) where T : MapObject
Parameters
alsoReturnFake
bool
Returns
- T
The held furniture
Type Parameters
T
The type that the held furniture is expected to have
GetHomeLocation()
Shorthand method for GetHomeLocation(Person) that returns the home location of this person's Household's lot
public virtual Vector2 GetHomeLocation()
Returns
- Vector2
This person's home location
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 Person.
public override void GetHoverInfo(Tooltip tooltip)
Parameters
tooltip
TooltipThe tooltip that will be displayed.
GetMemories<T>(MemoryType)
Returns all Memory instances that this person currently tracks that match the given MemoryType.
public virtual IEnumerable<T> GetMemories<T>(MemoryType type) where T : Memory
Parameters
type
MemoryTypeThe memory type to match.
Returns
- IEnumerable<T>
The memories of the given type.
Type Parameters
T
GetNeed(NeedType)
public float GetNeed(NeedType type)
Parameters
type
NeedTypeThe type of need that should be returned
Returns
- float
This person's need value
GetNeedPercentage(NeedType)
Returns the Need Percentage of the given type for this person
public float GetNeedPercentage(NeedType type)
Parameters
type
NeedTypeThe type of need that should be returned
Returns
- float
This person's need percentage
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 virtual float GetPassiveActionPriority(ActionType type)
Parameters
type
ActionTypeThe type of action to get the passive priority for
Returns
- float
The action's passive priority
GetPersonalitySkillBoost(SkillType)
Returns a modifier that skills with the given SkillType should be boosted by, based on this person's PersonalityTypes. This method is used by GetEfficiencyModifier(float, ActionInfo, SkillType, float).
public virtual float GetPersonalitySkillBoost(SkillType skill)
Parameters
skill
SkillTypeThe skill category whose personality skill boost to return
Returns
- float
A modifier that skills should be boosted by
GetPivot()
Returns this person's screen-space pivot position, based on the current animation frame.
public virtual Vector2 GetPivot()
Returns
- Vector2
This person's screen-space pivot position.
GetProject(string, string)
public Project GetProject(string type, string name)
Parameters
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
Returns
- IEnumerable<Project>
A set of projects that match the given type
GetRandomOutfit(ClothesIntention)
Returns the index of the Outfits collection that best matches the given ClothesIntention.
public virtual int GetRandomOutfit(ClothesIntention intention)
Parameters
intention
ClothesIntentionThe intention to match the best outfit to.
Returns
GetRandomSpeakSound(VoiceStyle, SpeakStyle, List<SoundEffect>, TimeSpan?)
Returns a random sound effect which is a speak sound that matches any of the given SpeakStyle flag values
public static SoundEffect GetRandomSpeakSound(VoiceStyle voice, SpeakStyle style, List<SoundEffect> avoid = null, TimeSpan? maxLength = null)
Parameters
voice
VoiceStyleThe VoiceStyle to use.
style
SpeakStyleThe styles to chooose sounds from, can be a combined flag
avoid
List<SoundEffect>A list of sounds that will not be chosen from, even if they match the passed styles
maxLength
TimeSpan?The maximum length for the returned sound effect to have, or null to return sounds of any length
Returns
- SoundEffect
A random sound effect that matches the given properties
GetRelationship(Person, bool)
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 Relationship GetRelationship(Person person, bool initialize)
Parameters
person
PersonThe person to get relationship values for
initialize
boolWhether 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
GetSkill(SkillType, bool)
Returns the Skill instance that this person has for the given SkillType.
If this person does not have the skill yet, and initialize
is false or the skill's RequiredAges don't match this person's Age, null is returned.
public virtual Skill GetSkill(SkillType type, bool initialize)
Parameters
type
SkillTypeThe type of skill to query.
initialize
boolWhether the skill should be added if it doesn't exist already.
Returns
- Skill
The skill instance, or null if this person doesn't have the skill yet, and
initialize
is false or the skill's RequiredAges don't match this person's Age.
GetSkillLevel(SkillType)
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(SkillType type)
Parameters
type
SkillTypeThe type of skill to query
Returns
- int
The person's skill level
GetSkillPointPercentage(SkillType)
Returns the percentage that this person has in the given skill's current level. This is a shorthand for PointPercentage.
public float GetSkillPointPercentage(SkillType type)
Parameters
type
SkillTypeThe type of skill to query
Returns
- float
The person's skill point percentage
GetSkillTotalPercentage(SkillType)
Returns the total skill level percentage of the given skill for this person. This is a shorthand for TotalPercentage.
public float GetSkillTotalPercentage(SkillType type)
Parameters
type
SkillTypeThe type of skill to query
Returns
- float
The person's total skill level percentage
GetTimeSinceMemory<T>(MemoryType, Func<T, bool>)
Returns the time since a memory of the given MemoryType has occured. If there are multiple memories of the given type, the minimum time is returned. If there is no memory of the given type, null is returned.
public virtual TimeSpan? GetTimeSinceMemory<T>(MemoryType type, Func<T, bool> condition = null) where T : Memory
Parameters
type
MemoryTypeThe memory type to query.
condition
Func<T, bool>An additional condition to determine whether memories should be included in the search.
Returns
- TimeSpan?
The time since the given memory type.
Type Parameters
T
GetTimeSinceMemory<T>(params MemoryType[])
Returns the time since a memory of one of the given MemoryType values has occured. If there are multiple memories that match the given types, the minimum time is returned. If there is no memory of any of the given types, null is returned.
public virtual TimeSpan? GetTimeSinceMemory<T>(params MemoryType[] types) where T : Memory
Parameters
types
MemoryType[]The memory types to query.
Returns
- TimeSpan?
The time since the given memory type.
Type Parameters
T
GetValidClothes(ClothesLayer)
Returns the clothes from the Types registry that match the given ClothesLayer that this person can wear, based on their Age and other factors.
public virtual IEnumerable<Clothes> GetValidClothes(ClothesLayer layer)
Parameters
layer
ClothesLayerThe layer
Returns
- IEnumerable<Clothes>
The clothes that match
GetWalkSpeed()
Returns this person's current walk speed, per update frame. The walk speed is influenced by their PersonalityTypes and Emotion.
public virtual float GetWalkSpeed()
Returns
- float
The walk speed
GoToExitRoad()
Teleports this person to the nearest exit road using GetClosestFreeExitPoint(Vector2).
public virtual void GoToExitRoad()
GoToRandomHomeLocation()
Causes this person to teleport to a random location close to their home location (GetHomeLocation()).
public virtual void GoToRandomHomeLocation()
HasEmotionModifier(EmotionModifier)
Returns whether this person has the given EmotionModifier in their EmotionModifiers list
public bool HasEmotionModifier(EmotionModifier type)
Parameters
type
EmotionModifierThe type of emotion modifier to query
Returns
- bool
Whether the emotion modifier is active
HasHouseholdMember(Guid)
Returns whether the given person Id is a part of this household
public bool HasHouseholdMember(Guid person)
Parameters
person
GuidThe unique id of the person to query
Returns
- bool
true if the person is part of this household, false otherwise
HasHouseholdMember(Person)
Returns whether the given person Id is a part of this household
public bool HasHouseholdMember(Person person)
Parameters
person
Person
Returns
- bool
true if the person is part of this household, false otherwise
HasPersonality(PersonalityType)
Returns whether this person has the given PersonalityType
public bool HasPersonality(PersonalityType type)
Parameters
type
PersonalityTypeThe personality type to query
Returns
- bool
true if this person has this personality type, false otherwise
HasSkillLevel(SkillType, int)
Returns whether this person has a Skill of the given type and whether its value is high enough.
public bool HasSkillLevel(SkillType type, int level)
Parameters
Returns
- bool
true if the person has this skill level, false otherwise
ImportAtExitRoad(Map)
Imports this person at a nearby exit road, additionally validating them, setting a new Id for them and adding them to the given map
.
public virtual void ImportAtExitRoad(Map map)
Parameters
map
MapThe map to import on.
InitializeAction(Action)
A method that is called by this person's Update(GameTime, TimeSpan, float) method when an action from the ActionQueue is moved to CurrentActions. By default, this method raises the OnActionInitialized event and calls Initialize().
protected virtual void InitializeAction(Action action)
Parameters
action
ActionThe action.
Intersects(RectangleF)
Returns whether this map object intersects with the given rectangle. This is used for GetObjects<T>(RectangleF)
public override bool Intersects(RectangleF rectangle)
Parameters
rectangle
RectangleFThe area that should be checked for
Returns
- bool
true if this object intersects with the given rectangle
IsCloseForTalking(Vector2)
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 virtual bool IsCloseForTalking(Vector2 pos)
Parameters
pos
Vector2The position of the person to query closeness for
Returns
- bool
Whether the person is close enough to talk to
IsIdMatch(Guid)
Returns whether this person's Id or any entry in their ID history (SetNewId(Map, IEnumerable<Person>, IEnumerable<Furniture>)) matches the Guid passed. To compare whether two people are an ID match, use IsIdMatch(Person).
public bool IsIdMatch(Guid id)
Parameters
id
GuidThe id to compare this person's ids to
Returns
- bool
Whether any of this person's id match
IsIdMatch(Person)
Returns whether this person and the other person have matching Id values or whether their ID histories (SetNewId(Map, IEnumerable<Person>, IEnumerable<Furniture>)) overlap. If this method returns two, this person and the other person can be considered the same person to a certain degree, as it means that they are copies of each other, or copies of the same person.
public bool IsIdMatch(Person other)
Parameters
other
PersonThe person to compare this person to
Returns
- bool
Whether this person and the passed person have matching ids
LowerEmotion(EmotionType, float, float)
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 virtual bool LowerEmotion(EmotionType type, float percentage, float speedMultiplier = 1)
Parameters
type
EmotionTypeThe type of emotion to lower
percentage
floatThe percentage to lower the emotion by
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
Returns
- bool
Whether the emotion could be lowered, or this person had no emotion modifiers of the given type
LowerEmotionModifier(EmotionModifier, float, float)
Lowers the specified emotion modifier by the specified percentage. This differs from LowerEmotion(EmotionType, float, float) in that only the specific modifier is lowered.
public virtual bool LowerEmotionModifier(EmotionModifier modifier, float percentage, float speedMultiplier = 1)
Parameters
modifier
EmotionModifierThe emotion modifier to lower
percentage
floatThe percentage to lower the emotion by
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
Returns
- bool
Whether the emotion could be lowered, or this person had no emotion modifiers of the given type
OccupyActionSpot(Furniture, ActionSpot, bool, Direction2?, bool)
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, float) call if stayOccupied
is false.
To exit an action spot that was marked as stayOccupied
, this method can be called with furniture
and/or spot
set to null.
public virtual void OccupyActionSpot(Furniture furniture, ActionSpot spot, bool visual = false, Direction2? rotation = null, bool stayOccupied = false)
Parameters
furniture
FurnitureThe furniture to occupy.
spot
ActionSpotThe action spot to occupy on the furniture.
visual
boolWhether or not the visual position should be updated to enter the spot, causing VisuallyOccupiedSpot to contain the given
furniture
andspot
. Note that, whenfurniture
orspot
is null, this value has no effect.rotation
Direction2?The rotation that this person should get, or null to use the spot's default rotation.
stayOccupied
boolWhether this person should continue to occupy this action spot after the current update frame is over.
OccupyFreeActionSpot(ActionInfo, ObjectCategory, bool, Direction2?, bool)
This is a shorthand method for OccupyFreeActionSpot(Furniture, ObjectCategory, bool, Direction2?, bool) Note that this method needs to be called every update frame for the person to keep occupying the action spot.
public virtual bool OccupyFreeActionSpot(ActionInfo info, ObjectCategory context = null, bool visual = false, Direction2? rotation = null, bool stayOccupied = false)
Parameters
info
ActionInfoThe action info whose action object to occupy.
context
ObjectCategoryThe category that the action spot should have
visual
boolWhether or not the action spot should be entered visually.
rotation
Direction2?The rotation that the person should have, or the action spot's rotation by default
stayOccupied
boolWhether this person should continue to occupy this action spot after the current update frame is over.
Returns
- bool
Whether or not we were able to occupy a free action spot
OccupyFreeActionSpot(Furniture, ObjectCategory, bool, Direction2?, bool)
This is a shorthand method for GetFreeActionSpot(Person, ObjectCategory) and OccupyActionSpot(Furniture, ActionSpot, bool, Direction2?, bool). Note that this method needs to be called every update frame for the person to keep occupying the action spot.
public virtual bool OccupyFreeActionSpot(Furniture furniture, ObjectCategory context = null, bool visual = false, Direction2? rotation = null, bool stayOccupied = false)
Parameters
furniture
FurnitureThe furniture whose object spot to occupy
context
ObjectCategoryThe category that the action spot should have
visual
boolWhether or not the action spot should be entered visually.
rotation
Direction2?The rotation that the person should have, or the action spot's rotation by default
stayOccupied
boolWhether this person should continue to occupy this action spot after the current update frame is over.
Returns
- bool
Whether or not we were able to occupy a free action spot
OnActionCompleted(Action, CompletionType)
A method that is called in this person's Update(GameTime, TimeSpan, float) when an Action completes. By default, this method does multiple things, including raising the OnActionsCompleted event and calling OnCompleted(CompletionType), as well as multiple things related to specific action results, like adding PersonalityType-based emotions.
protected virtual void OnActionCompleted(Action action, CompletionType completion)
Parameters
action
Actioncompletion
CompletionType
OnAgeChanged(AgeGroup)
A method that is called by TinyLife.Objects.Person.Age.set when this person's Age has just changed. Their previous age is stored in lastAge
.
protected virtual void OnAgeChanged(AgeGroup lastAge)
Parameters
lastAge
AgeGroupThis person's previous age.
OnCameraRotationChanged(Direction2, Direction2)
This method is invoked when the game's camera rotation changes. Additionally, the old and new rotations are passed.
public override void OnCameraRotationChanged(Direction2 oldRotation, Direction2 newRotation)
Parameters
oldRotation
Direction2The old camera rotation
newRotation
Direction2The new camera rotation
PrepareForPermanentRemoval()
Prepares this person for permanent removal, which includes removing all references to this person from other people's Relationships. This method should only be called when a person is about to be irrevocably deleted.
public virtual void PrepareForPermanentRemoval()
RemoveEmotion(EmotionModifier)
Removes the given EmotionModifier from this person's EmotionModifiers
public virtual bool RemoveEmotion(EmotionModifier type)
Parameters
type
EmotionModifierThe type of emotion to remove
Returns
- bool
Whether the emotion could be removed (or wasn't contained in the first place)
RemoveHeldObject<T>()
Removes this person's held object from the world and returns it.
public virtual T RemoveHeldObject<T>() where T : MapObject
Returns
- T
The held object that was removed, or null if it did not match, or there was none.
Type Parameters
T
The type of object to remove. If this person's held object does not match, it is not removed.
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
JobTypeThe type to remove.
Returns
- bool
Whether this person has a job of the given type.
RemoveMemory<T>(MemoryType, Func<T, bool>)
Removes all Memory instances of the given type T
and MemoryType from this person's Memories collection, and returns the amount of memories removed.
public virtual int RemoveMemory<T>(MemoryType type, Func<T, bool> condition = null) where T : Memory
Parameters
type
MemoryTypeThe memory type to match.
condition
Func<T, bool>An additional condition to determine whether memories should be included in the search.
Returns
- int
How many memories were removed.
Type Parameters
T
ResetToStatic(bool)
Resets this map object to a static state when the Map that is on is exported.
public override bool ResetToStatic(bool thorough)
Parameters
thorough
boolWhether a more thorough reset is expected, which usually involves normalizing additional data and cleaning up player data entirely.
Returns
- bool
Whether this object should stay on the map after the static reset. If false is returned, this object is removed.
RestoreNeed(NeedType, float, ActionInfo, float)
Restores this person's Need of the given type by the given amount. Also invokes OnRestoreNeed and modifies the restored amount by the person's current Emotion.
public virtual void RestoreNeed(NeedType type, float amount, ActionInfo info, float speedMultiplier)
Parameters
type
NeedTypeThe type of need to restore
amount
floatThe amount to restore this need by, out of Max.
info
ActionInfoThe action info of the action that is causing the need to be restored. Can be null if the need is not being restored by an action.
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
RestoreNeed(NeedType, float, ActionInfo, SkillType, float)
Restores this person's Need of the given type by the given amount, additionally taking into account the person's level at the given SkillType.
The higher the level of the given skill is, the higher the percentage of maxAmount
that the Need will be restored with.
This is useful for rewarding Entertainment based on the level in a skill that is currently being built.
public void RestoreNeed(NeedType type, float maxAmount, ActionInfo info, SkillType requiredSkill, float speedMultiplier)
Parameters
type
NeedTypeThe type of need to restore.
maxAmount
floatThe maximum amount to restore this need by, out of Max.
info
ActionInfoThe action info of the action that is causing the need to be restored. Can be null if the need is not being restored by an action.
requiredSkill
SkillTypeThe skill required to restore the given need.
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
SetAnimationsFromLooks()
A method that is called in various places to update this person's animation data. By default, this method calls GenerateAnimationGroup(ClothesLayer, int, IReadOnlyDictionary<Point, TextureRegion>, Point) for each clothes layer as well as this person's shadow.
public virtual void SetAnimationsFromLooks()
SetCurrentOutfit(int)
Sets this person's CurrentOutfitIndex to the given index. Additionally, this method updates this person's animation and portrait to the new outfit.
public virtual void SetCurrentOutfit(int index)
Parameters
index
intThe index to set
SetCurrentOutfit(ClothesIntention)
Sets the current outfit to an outfit that matches the given ClothesIntention. This method returns whether GetRandomOutfit(ClothesIntention) returned a valid outfit index or if no matching outfit could be found. Note that, if this person is already wearing an outfit that matches the intention, the outfit will not be changed, and this method returns true.
public virtual bool SetCurrentOutfit(ClothesIntention intention)
Parameters
intention
ClothesIntentionThe intention to match the best outfit to.
Returns
- bool
True if an outfit could be found, or false if no matching outfit could be found.
SetHeldObject(MapObject, bool)
Sets this person's held object to the given instance.
Note that the obj
has to be on the same map as this person's Map.
public virtual void SetHeldObject(MapObject obj, bool fake = false)
Parameters
obj
MapObjectThe furniture to hold
fake
boolWhether the object set to be held is considered fake. A fake object will not be taken into account when a IsEmptyHanded(ActionInfo, bool) check occurs. Fake items are expected to be removed at the end of an Action that adds them.
SetHeldObject<T>(FurnitureType, int[], Guid?, bool)
Sets the person's held object to the given furniture type, with the given data, and returns the created instance. Note that the returned object will automatically be added to the same map as this person's Map.
public virtual T SetHeldObject<T>(FurnitureType type, int[] colors = null, Guid? id = null, bool fake = false) where T : Furniture
Parameters
type
FurnitureTypeThe type of furniture to construct
colors
int[]The colors that the constructed furniture should have, or null to use the defaults
id
Guid?The id that this furniture should have, or null to choose a random one
fake
boolWhether the object set to be held is considered fake. A fake object will not be taken into account when a IsEmptyHanded(ActionInfo, bool) check occurs. Fake items are expected to be removed at the end of an Action that adds them.
Returns
- T
The created furniture instance
Type Parameters
T
The type that the created furniture is expected to have
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
SetNewId(Map, IEnumerable<Person>, IEnumerable<Furniture>)
Sets a new Id for this person, and also updates any furniture and relationship references for them. Optionally, a set of additional people and furniture that might not currently be on the map can be passed.
public virtual void SetNewId(Map map, IEnumerable<Person> possibleAdditionalRelationships = null, IEnumerable<Furniture> possibleAdditionalFurniture = null)
Parameters
map
MapThe map that the person will be added to
possibleAdditionalRelationships
IEnumerable<Person>A set of people, in addition to the
map
's people, that this person might have a relationship topossibleAdditionalFurniture
IEnumerable<Furniture>A set of objects, in addition to the
map
's objects, that this person might have created
SetPregnancyStatus(int, Guid, bool)
Sets this person's pregnancy status to the given parameters. This person's PregnancyHoursRemaining, as well as their PregnancyPartner will be set. If memories
is true, the FoundOutPregnancy memory will be removed, and the MayBePregnant memory will be added if hours
is greater than 0.
public virtual void SetPregnancyStatus(int hours, Guid partner, bool memories = true)
Parameters
hours
intThe amount of hours this person should be pregnant for at the minimum.
partner
GuidThe Id of this person's pregnancy partner.
memories
boolWhether the appropriate Memory instances should be added to this person.
ShouldDrawHeldItem()
Returns whether or not to draw this person's held object at the given time, whicih is used by ParentInfo for drawing.
public virtual bool ShouldDrawHeldItem()
Returns
- bool
Whether or not to draw this person's held object.
Speak(SpeakStyle, float, float)
Causes this person to play speaking sounds with their VoicePitch applied for the given amount of time
public virtual void Speak(SpeakStyle possibleStyles, float minimumSeconds = 1, float maximumSeconds = 3)
Parameters
possibleStyles
SpeakStyleThe speak styles to choose sounds from, can be a combined flag
minimumSeconds
floatThe minimum amount of time, in seconds, to speak for
maximumSeconds
floatThe maximum amount of time, in seconds, to speak for
StartProject(Project)
Starts a new project, adding it to the Projects list of this person
public virtual Project StartProject(Project project)
Parameters
project
ProjectThe project to start
Returns
- Project
The project that was passed, for chaining
StopEmoting()
Causes this person to stop displaying the current emote immediately
public virtual void StopEmoting()
StopSpeaking()
Causes this person to stop speaking, resetting their CurrentSpeakStyle and interrupting any currently playing speak sounds
public virtual void StopSpeaking()
ToCreatedByString()
Returns a string representation of this person using the localized "Created by:" prefix
public virtual string ToCreatedByString()
Returns
- string
A "created by" string
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 virtual void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)
Parameters
time
GameTimeThe game's time
passedInGame
TimeSpanThe amount of time that has passed since the last call
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
UpdateAction(Action, GameTime, TimeSpan, float, IEnumerable<IGoalTriggerable>)
A method that is called by this person's Update(GameTime, TimeSpan, float) method when an Action is to be updated. By default, this method does multiple things including raising the OnActionUpdated event and calling Update(GameTime, TimeSpan, float).
protected virtual void UpdateAction(Action action, GameTime time, TimeSpan passedInGame, float speedMultiplier, IEnumerable<IGoalTriggerable> goals)
Parameters
action
ActionThe action to update.
time
GameTimeThe game's time.
passedInGame
TimeSpanThe amount of time that has passed in-game since the last update.
speedMultiplier
floatThe current speed multiplier.
goals
IEnumerable<IGoalTriggerable>This person's goals, which is always equal to GetCurrentGoals().
UpdateAnimations(TimeSpan, float)
A method called in Update(GameTime, TimeSpan, float), as well as when this person's rotation changes in OnCameraRotationChanged(Direction2, Direction2) to update this person's animation data to the proper state for the current update frame.
protected virtual void UpdateAnimations(TimeSpan elapsedGameTime, float speedMultiplier)
Parameters
elapsedGameTime
TimeSpanThe amount of time elapsed since the last animation update.
speedMultiplier
floatThe speed multiplier.
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
ValidateClothes()
Validates this person's current Outfits, removing any invalid ones and adding clothes to layers that require them. This method is called automatically in Validate(), as well as when a Household preview is loaded.
public virtual void ValidateClothes()
VisitLot(Lot)
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 for the player using MarkLotVisible(Lot).
public virtual void VisitLot(Lot lot)
Parameters
lot
LotThe lot to mark as visited
Events
OnActionInitialized
An event that is invoked when an Action is initialized. This event can be subscribed to using OnEventsAttachable.
public event Action<Action, EventPhase> OnActionInitialized
Event Type
OnActionsChanged
An event that is invoked when the CurrentActions or ActionQueue of this person changed This event can be subscribed to using OnEventsAttachable.
public event Action<Person> OnActionsChanged
Event Type
OnActionsCompleted
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 Action<Action, CompletionType, EventPhase> OnActionsCompleted
Event Type
OnActionUpdated
An event that is invoked when an Action is updated in Update(GameTime, TimeSpan, float). This event can be subscribed to using OnEventsAttachable.
public event Person.ActionUpdateDelegate OnActionUpdated
Event Type
OnChangeFriendship
An event that is invoked in ChangeFriendship(Person, float). This event can be used to change the amount of friendship gained. This event can be subscribed to using OnEventsAttachable.
public event Person.RelationshipChangeDelegate OnChangeFriendship
Event Type
OnChangeRomance
An event that is invoked in ChangeRomance(Person, float). This event can be used to change the amount of romance gained. This event can be subscribed to using OnEventsAttachable.
public event Person.RelationshipChangeDelegate OnChangeRomance
Event Type
OnEmotionChanged
An event that is invoked when the Emotion changes. This event can be subscribed to using OnEventsAttachable.
public event Action<Person> OnEmotionChanged
Event Type
OnEmotionModifiersChanged
An event that is invoked when the EmotionModifiers change. This event can be subscribed to using OnEventsAttachable.
public event Person.EmotionModifiersChangedDelegate OnEmotionModifiersChanged
Event Type
OnGetCurrentGoals
An event that is invoked in GetCurrentGoals(). This event allows adding more goals to a person that should be tracked by AutoGoalInfo goals. This event can be subscribed to using OnEventsAttachable.
public event Action<List<IGoalTriggerable>> OnGetCurrentGoals
Event Type
OnGetEfficiencyModifier
An event that is invoked at the end of GetEfficiencyModifier(float, ActionInfo, 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 Person.EfficiencyModifierDelegate OnGetEfficiencyModifier
Event Type
OnGetPassiveActionPriority
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 Person.PassiveActionPriorityDelegate OnGetPassiveActionPriority
Event Type
OnGetWalkSpeed
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 Person.WalkSpeedDelegate OnGetWalkSpeed
Event Type
OnJobChanged
An event that is invoked when the Jobs collection changes. This event can be subscribed to using OnEventsAttachable.
public event Action<Person> OnJobChanged
Event Type
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
OnNewSkillLearned
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 Action<Person> OnNewSkillLearned
Event Type
OnOutfitChanged
An event that is invoked when this person's CurrentOutfitIndex changes. This event can be subscribed to using OnEventsAttachable.
public event Action OnOutfitChanged
Event Type
OnRestoreNeed
An event that is invoked in RestoreNeed(NeedType, float, ActionInfo, float). This event allows modifying the amount that a need is restored by based on custom factors. This event can be subscribed to using OnEventsAttachable.
public event Person.RestoreNeedDelegate OnRestoreNeed