Class PersonLike
A class that serves as a base class for Person and similar person-like objects. This class can be extended by mods to add new person-like objects that also execute actions, have relationships, can be members of households, and so on.
public abstract class PersonLike : MapObject, IGenericDataHolder, IUpdatingObject
- Inheritance
-
JsonTypeSafeGenericDataHolderPersonLike
- Implements
-
IGenericDataHolder
- Derived
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
PersonLike(Map, Vector2, float)
Creates a new person with the given settings. To create a new person externally, use Create(Map, Random, AgeGroup, bool, bool, bool, bool, PersonLike[]).
protected PersonLike(Map map, Vector2 position, float floor)
Parameters
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, bool, bool, params ActionArgument[]) and CancelAction(Action, Action, bool) to modify this list.
[DataMember]
public readonly List<(Action, bool)> ActionQueue
Field Value
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
Animations
This person's current animations, usually gathered from GenerateAnimationGroup(ClothesLayer, int, IReadOnlyDictionary<Point, TextureRegion>, Point).
protected readonly Dictionary<ClothesLayer, SpriteAnimationGroup> Animations
Field Value
- Dictionary<ClothesLayer, SpriteAnimationGroup>
CurrentActions
The actions that are currently being executed by this person. Use EnqueueAction<T>(ActionType, ActionInfo, bool, bool, bool, params ActionArgument[]) 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
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?
IsDead
Stores whether this person is currently dead. For a person to die, use Die(DeathReason) or Enqueue(PersonLike, DeathReason).
[DataMember]
public bool IsDead
Field Value
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
LastName
This person's last name
[DataMember]
public string LastName
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, int, TimeSpan?)/>, GetMemories<T>(MemoryType) and GetTimeSinceMemory<T>(MemoryType, Func<T, bool>) can be used.
[DataMember]
[JsonConverter(typeof(PersonLike.MemoriesConverter))]
public readonly Dictionary<string, HashSet<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(PersonLike.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
Relationships
This person's Relationship data. To access this collection efficiently, use GetRelationship(PersonLike, bool) and ChangeFriendship(PersonLike, float, bool).
[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 PersonLike 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
SupportedAges
The ages that a given PersonLike child class supports. For mods that implement custom PersonLike types, new entries can be added to this dictionary to specify which ages they support.
public static readonly Dictionary<Type, AgeGroup[]> SupportedAges
Field Value
- Dictionary<Type, AgeGroup[]>
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 VisitingLot.
[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(EmoteChoices, bool, float, float) to modify this property.
public Emote CurrentEmote { get; protected set; }
Property Value
CurrentMode
A property that returns the current IUpdatingObject.UpdateMode for this updating object. This property defaults to returning MajorIfActive. When moving updating objects between update modes (ie changing the return value), objects are moved automatically after the respective update is invoked. This means that update mode changes don't occur immediately. See the documentation for each IUpdatingObject.UpdateMode for more information.
public IUpdatingObject.UpdateMode CurrentMode { get; }
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
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
Difficulty
This person's current DifficultyModifier, based on the game's Difficulty. If this person is not part of the current household, Normal is returned.
public DifficultyModifier Difficulty { get; }
Property Value
DrawSize
The size, in draw space pixels, that a person's texture takes up.
public abstract 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 for Person types.
public virtual 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 virtual 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
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 virtual bool IsRegularVisitor { get; }
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 VisitingLot is set using VisitLot(Lot), this value will be set to a time span between 2 and 24 hours, and then tick down with the passed in-game time in Update(GameTime, TimeSpan, float).
[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, PersonLike[]) method with a nonnull Random.
[DataMember(EmitDefaultValue = false)]
public bool RandomlyGenerated { get; protected set; }
Property Value
RecentActions
A set of Memory instances of the ActionDone types that this person has recently done. The last three or fewer instances of any given ActionType will be returned as part of this collection.
public IEnumerable<(ActionType Type, Memory Memory)> RecentActions { get; }
Property Value
RelationshipInterestingness
Returns the "interestingness" of this person's Relationships, which is the sum of the absolute values of all relationships' FriendLevel and RomanceLevel values. This can be used for sorting by how interesting a person is for keepign around rather than deleting.
public float RelationshipInterestingness { get; }
Property Value
Rotation
The MLEM.Maths.Direction2 that this person is currently facing in
public Direction2 Rotation { get; set; }
Property Value
- Direction2
VisitingLot
The Lot that is currently being visited by this person, or null if they're not visiting a lot right now. A visited lot is a lot that was actively moved to using VisitLotAction, GoHomeAction or a similar action. To modify this value, use VisitLot(Lot).
public Lot VisitingLot { 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
VisualRotation
This person's current visual rotation, based on their Rotation and the CameraRotation.
public Direction2 VisualRotation { get; }
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
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.
AddMemory<T>(MemoryType, ActionInfo, int, TimeSpan?)
public virtual T AddMemory<T>(MemoryType type, ActionInfo info, int toKeep = 0, 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(PersonLike).
toKeep
intAn amount of memories of the given
type
to keep, also counting the newly added one. Oldest memories will be removed first.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.
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
CanTakeOff(ClothesLayer)
Returns whether the given ClothesLayer can be taken off in the character creator.
public virtual bool CanTakeOff(ClothesLayer layer)
Parameters
layer
ClothesLayerThe clothes layer
Returns
- bool
Whether the clothes layer can be taken off
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
ChangeFriendship(PersonLike, float, bool)
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(PersonLike person, float amount, bool particle = true)
Parameters
person
PersonLikeThe person to change friendship with
amount
floatThe amount to change friendship by, can be negative
particle
boolWhether to display a friendship gain or lose particle. Defaults to true.
ChangeRomance(PersonLike, float, bool)
Changes the RomanceLevel Relationship wit the given person by the given amount. Additionally, a romance Particle is displayed.
public virtual void ChangeRomance(PersonLike person, float amount, bool particle = true)
Parameters
person
PersonLikeThe person to change romance with
amount
floatThe amount to change romance by, can be negative
particle
boolWhether to display a romance gain or lose particle. Defaults to true.
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)
Causes this person to die, removing it from the world and optionally spawning a Gravestone.
public virtual bool Die(DeathReason reason)
Parameters
reason
DeathReasonThe reason for this person's death
Returns
DisplayEmote(EmoteChoices, bool, float, float)
Causes this person to display a Emote over its head for 1 to 3 seconds
public virtual void DisplayEmote(EmoteChoices choices, bool thought, float minimumSeconds = 1, float maximumSeconds = 3)
Parameters
choices
EmoteChoicesThe emotes to choose from
thought
boolWhether the emote should be a thought bubble, rather than a speech bubble.
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(EmoteChoices, SpeakStyle?, float, float)
This is a combined helper method that invokes DisplayEmote(EmoteChoices, bool, float, float) and optionally 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(EmoteChoices emoteChoices, SpeakStyle? speakStyles, float minimumSeconds = 1, float maximumSeconds = 3)
Parameters
emoteChoices
EmoteChoicesThe emotes to choose from
speakStyles
SpeakStyle?The speak styles to choose from, can be a combined flag. If this is null, the displayed emote will be a thought.
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, float, 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, float floor, 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.
floor
floatThe floor to draw on.
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.
DrawLooksLayer(SpriteBatch, SpriteAnimation, TextureRegion, WornClothes, int, Vector2, Vector2, float, ParentInfo, Color, float, float)
Draws the given layer of this person's looks in the world. This method is invoked several times in DrawLooks(SpriteBatch, Vector2, Vector2, float, ParentInfo, Color?, float).
protected virtual void DrawLooksLayer(SpriteBatch batch, SpriteAnimation animation, TextureRegion region, WornClothes clothes, int layerIndex, Vector2 drawPos, Vector2 depthPos, float floor, ParentInfo parent, Color color, float scale, float depthOffset)
Parameters
batch
SpriteBatchThe sprite batch to use for drawing.
animation
SpriteAnimationThe animation to draw.
region
TextureRegionThe texture region of the
animation
to draw.clothes
WornClothesThe clothes to draw.
layerIndex
intThe index that this layer is on.
drawPos
Vector2The draw position in screen space.
depthPos
Vector2The position to use for calculating depth.
floor
floatThe floor to draw on.
parent
ParentInfoThis person's parent info.
color
ColorThe color to draw with.
scale
floatThe scale to draw with.
depthOffset
floatThe depth offset to draw with.
DrawUi(SpriteBatch, Vector2, float, Direction2, Outfit, Pose?, AgeGroup?)
Renders this person on a ui level rather than a world level
public abstract void DrawUi(SpriteBatch batch, Vector2 pos, float scale, Direction2 rotation = Direction2.Right, Outfit outfit = null, Pose? pose = null, AgeGroup? age = null)
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.Maths.Direction2.Right.
outfit
OutfitThe outfit to draw with, which defaults to this person's CurrentOutfit.
pose
Pose?The pose to draw with, which defaults to this person's CurrentPose.
age
AgeGroup?The age to draw with, which defaults to this person's Age.
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[]). Note that this needs to be compatible with the EarnMoney's ValidObjects.
EnqueueAction<T>(ActionType, ActionInfo, bool, bool, bool, params ActionArgument[])
Enqueues the given action into ActionQueue to be executed later.
public virtual T EnqueueAction<T>(ActionType type, ActionInfo info, bool automatic, bool priority = false, bool force = false, params ActionArgument[] chosenArguments) 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)
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
chosenArguments
ActionArgument[]The arguments for the action to start, or an empty array or null if this action has no arguments, or if a random set of arguments should be chosen
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
FaceObject(MapObject, ActionSpot)
A utility method that causes this person> to face in the direction of the given obj
(and optionally its specific ActionSpot).
This method returns false if this person is occupying a furniture object, or if they're standing in the same location as the obj
.
public bool FaceObject(MapObject obj, ActionSpot spot = null)
Parameters
obj
MapObjectspot
ActionSpot
Returns
- bool
Whether it was possible to face in the object's direction.
FocusCameraOnEvent(bool, 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, bool switchToMap = true)
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.
switchToMap
boolWhether the camera should be switched to this person's Map.
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 abstract 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.
GenerateShadowAnimation()
protected abstract SpriteAnimationGroup GenerateShadowAnimation()
Returns
- 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.
GetAiPriorityForObject(MapObject, ObjectCategory)
Returns the AI priority for the given obj
and the given categories
.
This method checks the GetAiPriority(PersonLike, ObjectCategory) method, as well as any LotEmployment-speciifc AI priorities, and invokes the OnGetAiPriorityForObject event.
public virtual float GetAiPriorityForObject(MapObject obj, ObjectCategory categories)
Parameters
obj
MapObjectThe object.
categories
ObjectCategoryThe categories.
Returns
- float
The AI priority for the object.
GetCategories(PersonLike)
Returns a set of ObjectCategory flags that this object has, based on the given PersonLike.
public override ObjectCategory GetCategories(PersonLike person)
Parameters
person
PersonLikeThe person to query categories for
Returns
- ObjectCategory
A set of categories that this object has
GetCausedEmotion(EmotionModifier)
Returns the emotion that is actually caused in the passed EmotionModifier, which is either its Emotion or a context-dependent override. Specifically, this method returns Happy instead of Frisky for a person who is asexual (Asexual), and Embarrassed instead of Frisky for a Child.
public EmotionType GetCausedEmotion(EmotionModifier modifier)
Parameters
modifier
EmotionModifierThe emotion modifier whose emotion should be queried.
Returns
- EmotionType
The caused emotion.
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
GetDebugLines(GameImpl, List<string>)
Returns the debug lines that should be displayed in Debug when hovering over this object. By default, OnGetDebugLines is invoked, and the id and position of this object are appended to the list of lines.
public override void GetDebugLines(GameImpl game, List<string> lines)
Parameters
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
GetEmotionSkillBoost(SkillType)
Returns a modifier that skills with the given SkillType should be boosted by, based on this person's current Emotion. This method is used by GetEfficiencyModifier(float, ActionInfo, SkillType, float), and is also used to display the emotion image in the skills menu.
public virtual float GetEmotionSkillBoost(SkillType skill)
Parameters
skill
SkillType
Returns
GetFreeActionSpotInfos(PersonLike, ObjectCategory)
Returns a set of ActionInfo instances that represent action spots that the person
can currently use or interact with.
By default, an empty collection is returned by MapObject, but relevant spots are returnd by objects like Furniture and PersonLike.
public override IEnumerable<ActionInfo> GetFreeActionSpotInfos(PersonLike person, ObjectCategory context = null)
Parameters
person
PersonLikeThe person who wants to interact with this object.
context
ObjectCategoryThe context for which to return free action spots, or null to return action spots for any contexts.
Returns
- IEnumerable<ActionInfo>
The free action spots.
GetFreeTalkingSpots(PersonLike)
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(PersonLike person)
Parameters
person
PersonLike
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
GetHoverInfo(Tooltip)
Allows adding a set of paragraphs and other ui elements to the given tooltip
, which is then displayed when this object is hovered over using the cursor in the world.
By default, this method raises OnGetHoverInfo for MapObject, and adds additional information for Furniture and PersonLike.
public override void GetHoverInfo(Tooltip tooltip)
Parameters
tooltip
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
GetMemories<TKey, TMem>(IDictionary<TKey, MemoryType>)
Returns all Memory instances that this person currently tracks that match the given set of MemoryType.
public virtual IEnumerable<(TKey Key, TMem Memory)> GetMemories<TKey, TMem>(IDictionary<TKey, MemoryType> types) where TMem : Memory
Parameters
types
IDictionary<TKey, MemoryType>The memory types to match.
Returns
- IEnumerable<(TKey Key, TMem Memory)>
The memories of the given types.
Type Parameters
TKey
TMem
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
GetPassiveNeedReduction(NeedType)
Returns the given need's current passive reduction for this person. The return value is a combination of PassiveReduction and the OnGetPassiveNeedReduction event, as well as PersonalityType modifiers and the like.
public virtual float GetPassiveNeedReduction(NeedType need)
Parameters
need
NeedTypeThe need.
Returns
- float
The passive need reduction.
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.
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(PersonLike, bool)
Returns the current relationship level for the given PersonLike. Note that this returns this person's Relationships entry, which might have different values from the passed PersonLike's.
public Relationship GetRelationship(PersonLike person, bool initialize)
Parameters
person
PersonLikeThe 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(Vector2)
Teleports this person to the nearest exit road using GetClosestFreeExitPoint(Vector2).
public virtual void GoToExitRoad(Vector2 closestPosition)
Parameters
closestPosition
Vector2
GoToRandomHomeLocation()
Causes this person to teleport to a random location close to their HomeLot's home location (GetHomeLocation(PersonLike)). Note that this method expects this person's Map to be the same as the HomeLot's Map.
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(PersonLike)
Returns whether the given person Id is a part of this household
public bool HasHouseholdMember(PersonLike person)
Parameters
person
PersonLikeThe unique id of the person to query
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
HasRecentlyFailed(ActionType, float)
Returns whether an action of the given type
has recently failed for this person.
A failed action is one that has returned the Failed completion type in its IsCompleted() method.
public virtual bool HasRecentlyFailed(ActionType type, float hours = 1)
Parameters
type
ActionTypeThe action type to query.
hours
floatThe amount of hours that have to have passed since the last failure (if there is one) for this method to return false. Defaults to 1.
Returns
- bool
Whether the given action
type
has recently failed.
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, float)
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, float floor)
Parameters
pos
Vector2The position of the person to query closeness for
floor
floatThe floor that the other person is on.
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<PersonLike>, IEnumerable<Furniture>)) matches the Guid passed. To compare whether two people are an ID match, use IsIdMatch(PersonLike).
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(PersonLike)
Returns whether this person and the other person have matching Id values or whether their ID histories (SetNewId(Map, IEnumerable<PersonLike>, 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(PersonLike other)
Parameters
other
PersonLikeThe 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
MoveToMap(Map, Vector2?, float?)
Moves this object to the given map
, changing the current Map in the process.
This method also removes the object from the current map if it IsInWorld and adds it to the new map
, but only if its current Map is not already equal to map
, in which case, no action is performed.
public override bool MoveToMap(Map map, Vector2? position = null, float? floor = null)
Parameters
map
MapThe map to move to.
position
Vector2?The position on the new map to move to, or null to keep it the same.
floor
float?The floor to move to, or null to keep it the same.
Returns
- bool
Whether moving to the map was successful, which is false if this object's Map is already the given
map
. If true is returned, the object is guaranteed to have been added to the newmap
using AddObject(MapObject). If false is returned, no action was performed.
MoveToMapExitRoad(Map, Vector2)
Causes this person to move to the given map
and sets their position to a free exit road closest to the closestPosition
.
public virtual bool MoveToMapExitRoad(Map map, Vector2 closestPosition)
Parameters
map
MapThe map to move to.
closestPosition
Vector2The position that the exit road should be closest to.
Returns
- bool
Whether moving this person was successful. Returns the return value of MoveToMap(Map, Vector2?, float?).
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(PersonLike, 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 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
OnNewDay()
A method invoked in Update(GameTime, TimeSpan, float) when a new day has just started, specifically, in the first update that occurs after midnight of this person's Map's Time.
protected virtual void OnNewDay()
OnRoomCheck()
A method that is invoked in Update(GameTime, TimeSpan, float) when the timer to check information about the CurrentRoom has elapsed in Update(GameTime, TimeSpan, float). By default, various emotion modifiers are applied based on various conditions.
protected virtual void OnRoomCheck()
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.
RemoveMemory<T>(MemoryType, int, 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, int toKeep = 0, Func<T, bool> condition = null) where T : Memory
Parameters
type
MemoryTypeThe memory type to match.
toKeep
intAn amount of memories of the given
type
to keep. Oldest memories will be removed first.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, bool)
Resets this map object to a static state when the Map that is on is exported.
public override bool ResetToStatic(bool thorough, bool custom)
Parameters
thorough
boolWhether a more thorough reset is expected, which usually involves normalizing additional data and cleaning up player data entirely.
custom
boolWhether the static reset is happening in a custom context, that is, a Household being exported normally rather than through cheats, or a custom Map being exported.
Returns
- bool
Whether this object should stay on the map after the static reset. If false is returned, this object is removed.
ResetVisuals()
A method invoked at the very start of Update(GameTime, TimeSpan, float) that resets this person's non-persistent visuals, like their CurrentPose and WornLayers, to their default state.
protected virtual void ResetVisuals()
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 bool SetCurrentOutfit(int index)
Parameters
index
intThe index to set
Returns
- bool
true if the outfit index was changed and the OnOutfitChanged event was subsequently invoked, false if the outfit index was already set to
index
orindex
was out of bounds.
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
SetNewId(Map, IEnumerable<PersonLike>, 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<PersonLike> possibleAdditionalRelationships = null, IEnumerable<Furniture> possibleAdditionalFurniture = null)
Parameters
map
MapThe map that the person will be added to
possibleAdditionalRelationships
IEnumerable<PersonLike>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
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().
UpdateActions(GameTime, TimeSpan, float)
A method invoked in Update(GameTime, TimeSpan, float) that updates this person's current actions, as well as their action queue.
protected virtual void UpdateActions(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
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.
UpdateEmotes(GameTime, float)
A method invoked in Update(GameTime, TimeSpan, float) that updates this person's emotes based on their CurrentEmote.
protected virtual void UpdateEmotes(GameTime time, float speedMultiplier)
Parameters
time
GameTimeThe game time.
speedMultiplier
floatThe game's speed multiplier.
UpdateEmotions(GameTime, TimeSpan)
A method invoked in Update(GameTime, TimeSpan, float) that updates this person's EmotionModifiers and resulting Emotion.
protected virtual void UpdateEmotions(GameTime time, TimeSpan passedInGame)
Parameters
time
GameTimeThe game's time
passedInGame
TimeSpanThe amount of time that has passed since the last call
UpdateMemories(GameTime, TimeSpan, float)
A method invoked in Update(GameTime, TimeSpan, float) to update this person's updating memories.
protected virtual void UpdateMemories(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
UpdateNeeds(TimeSpan, float)
A method invoked in Update(GameTime, TimeSpan, float) that updates this person's needs.
protected virtual void UpdateNeeds(TimeSpan passedInGame, float speedMultiplier)
Parameters
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
UpdatePose()
A method invoked in Update(GameTime, TimeSpan, float) that updates this person's CurrentPose based on their held object or person.
protected virtual void UpdatePose()
UpdatePregnancy(TimeSpan)
A method invoked in Update(GameTime, TimeSpan, float) to update this person's current pregnancy status.
protected virtual void UpdatePregnancy(TimeSpan passedInGame)
Parameters
passedInGame
TimeSpanThe amount of time that has passed since the last call
UpdateRelationships(float)
A method invoked in Update(GameTime, TimeSpan, float) that updates this person's relationships, like applying passive reduction.
protected virtual void UpdateRelationships(float speedMultiplier)
Parameters
speedMultiplier
floatThe game's speed multiplier.
UpdateSpeech(GameTime, float)
A method invoked in Update(GameTime, TimeSpan, float) that updates this person's speech based on their CurrentSpeakStyle.
protected virtual void UpdateSpeech(GameTime time, float speedMultiplier)
Parameters
time
GameTimeThe game time.
speedMultiplier
floatThe game's 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
VisitLot(Lot)
Marks the given lot as the one that this person is currently visiting. To mark this person as not currently visiting any lots, null can be passed.
public virtual void VisitLot(Lot lot)
Parameters
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
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 ObjectUpdateDelegate<Action> OnActionUpdated
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<PersonLike> 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
OnAddEmotion
An event that is invoked in AddEmotion(EmotionModifier, int, TimeSpan, IEmotionSource, bool). This event allows modifying the amount, time, and specific emotion modifier that will be applied. This event can be subscribed to using OnEventsAttachable.
public event PersonLike.AddEmotionDelegate OnAddEmotion
Event Type
OnChangeFriendship
An event that is invoked in ChangeFriendship(PersonLike, float, bool). This event can be used to change the amount of friendship gained. This event can be subscribed to using OnEventsAttachable.
public event PersonLike.RelationshipChangeDelegate OnChangeFriendship
Event Type
OnChangeRomance
An event that is invoked in ChangeRomance(PersonLike, float, bool). This event can be used to change the amount of romance gained. This event can be subscribed to using OnEventsAttachable.
public event PersonLike.RelationshipChangeDelegate OnChangeRomance
Event Type
OnDrawLooks
An event that is raised when this person is drawn in DrawLooks(SpriteBatch, Vector2, Vector2, float, ParentInfo, Color?, float). This event can be subscribed to using OnEventsAttachable.
public event Action<(SpriteBatch Batch, Vector2 DrawPos, Vector2 DepthPos, float Floor, ParentInfo Parent, Color? OverrideColor, float Scale)> OnDrawLooks
Event Type
- Action<(SpriteBatch Batch, Vector2 DrawPos, Vector2 DepthPos, float Floor, ParentInfo Parent, Color? OverrideColor, float Scale)>
OnDrawLooksLayer
An event that is raised when a single layer of this person's looks is drawn in DrawLooksLayer(SpriteBatch, SpriteAnimation, TextureRegion, WornClothes, int, Vector2, Vector2, float, ParentInfo, Color, float, float). This event can be subscribed to using OnEventsAttachable.
public event Action<(SpriteBatch Batch, SpriteAnimation Animation, TextureRegion Region, WornClothes Clothes, int LayerIndex, Vector2 DrawPos, Vector2 DepthPos, float Floor, ParentInfo Parent, Color Color, float Scale, float DepthOffset)> OnDrawLooksLayer
Event Type
- Action<(SpriteBatch Batch, SpriteAnimation Animation, TextureRegion Region, WornClothes Clothes, int LayerIndex, Vector2 DrawPos, Vector2 DepthPos, float Floor, ParentInfo Parent, Color Color, float Scale, float DepthOffset)>
OnEmotionChanged
An event that is invoked when the Emotion changes. This event can be subscribed to using OnEventsAttachable.
public event Action<PersonLike> OnEmotionChanged
Event Type
OnEmotionModifiersChanged
An event that is invoked when the EmotionModifiers change. This event can be subscribed to using OnEventsAttachable.
public event PersonLike.EmotionModifiersChangedDelegate OnEmotionModifiersChanged
Event Type
OnGetAiPriorityForObject
A delegate that can optionally be used to modify the AI priority for a given object in GetAiPriorityForObject(MapObject, ObjectCategory). This event can be subscribed to using OnEventsAttachable.
public event PersonLike.AiPriorityForObjectDelegate OnGetAiPriorityForObject
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 PersonLike.EfficiencyModifierDelegate OnGetEfficiencyModifier
Event Type
OnGetEmotionSkillBoost
An event that is invoked at the end of GetEmotionSkillBoost(SkillType), after the default emotion skill boost is evaluated. This event can be subscribed to using OnEventsAttachable.
public event PersonLike.SkillBoostDelegate OnGetEmotionSkillBoost
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 PersonLike.PassiveActionPriorityDelegate OnGetPassiveActionPriority
Event Type
OnGetPassiveNeedReduction
An event that is raised when GetPassiveNeedReduction(NeedType) is called. This event can be used to modify the passive need reduction of a need. This event can be subscribed to using OnEventsAttachable.
public event PersonLike.PassiveReductionDelegate OnGetPassiveNeedReduction
Event Type
OnGetPersonalitySkillBoost
An event that is invoked at the end of GetPersonalitySkillBoost(SkillType), after the default personality skill boost is evaluated. This event can be subscribed to using OnEventsAttachable.
public event PersonLike.SkillBoostDelegate OnGetPersonalitySkillBoost
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 PersonLike.WalkSpeedDelegate OnGetWalkSpeed
Event Type
OnMemoriesChanged
An event that is invoked when this person's Memories change in AddMemory(Memory) and RemoveMemory<T>(MemoryType, int, Func<T, bool>). This event can be subscribed to using OnEventsAttachable.
public event Action<Memory> OnMemoriesChanged
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<PersonLike> 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 PersonLike.RestoreNeedDelegate OnRestoreNeed