Table of Contents

Class Relationship

Namespace
TinyLife
Assembly
Tiny Life.dll

A relationship is a connection between two Person objects. It should be noted that a relationship is not always the same between a person and the linked OtherPerson. What this means is that A can have a good relationship to B, but B can have a less good relationship to A.

[DataContract]
public class Relationship : JsonTypeSafeGenericDataHolder, IGenericDataHolder
Inheritance
JsonTypeSafeGenericDataHolder
Relationship
Implements
IGenericDataHolder
Inherited Members
JsonTypeSafeGenericDataHolder.GetDataKeys()
Extension Methods

Fields

Dating

This value is set to true if this relationship is a romantic relationship

[DataMember]
public bool Dating

Field Value

bool

HadFirstKiss

This value is set to true if this relationship's partners have invoked the Kiss action at least once.

[DataMember]
[Obsolete("Use the HadFirstKiss memory instead")]
public bool HadFirstKiss

Field Value

bool

KnownJobType

Stores the Types registry name of the job type that this relationship's person currently knows about the relationship's Partner. If this is null, no job type is known. If this value is set to None, the Partner has no job.

[DataMember]
public string KnownJobType

Field Value

string

KnownPersonalityTypes

A set of PersonalityType objects that are known about this relationship's OtherPerson. This collection is populated by AskAboutPersonality.

[DataMember]
public readonly HashSet<PersonalityType> KnownPersonalityTypes

Field Value

HashSet<PersonalityType>

Max

The maximum value that a relationship level can have

public const float Max = 100000

Field Value

float

PassiveFriendReduction

The amount of points (out of Max) that are removed from each relationship's FriendLevel each update frame

public const float PassiveFriendReduction = 0.01

Field Value

float

PassiveRomanceReduction

The amount of points (out of Max) that are removed from each relationship's RomanceLevel each update frame

public const float PassiveRomanceReduction = 0.015

Field Value

float

TryingForBaby

Stores whether the people involved in this relationship have agreed to try for a baby. If this is true, fooling around has a chance to lead to a pregnancy.

[DataMember(EmitDefaultValue = false)]
public bool TryingForBaby

Field Value

bool

Properties

FriendDisplayString

An (unlocalized) string that represents a written version of this relationship's Type status.

public string FriendDisplayString { get; }

Property Value

string

FriendLevel

The current amount of friendship points (out of Max) that this relationship has. This value is automatically clamped between -Max and Max. To take skills, personalities and more into account, use ChangeFriendship(Person, float).

public float FriendLevel { get; set; }

Property Value

float

FriendPercentage

The FriendLevel of this relationship, divided by Max, yielding a percentage between -1 and 1 of how good this friendship is

public float FriendPercentage { get; }

Property Value

float

Genealogy

The GenealogyType of this relationship. Note that the genealogy's value works in the following direction: "I am the [Genealogy] of [OtherPerson]". Note that OtherPerson will always have the GenealogyType's GetOpposite(GenealogyType).

[DataMember]
public GenealogyType Genealogy { get; }

Property Value

GenealogyType

OtherPerson

The Guid of the person that this relationship is linked to. To easily retrieve the matching Person instance, see Partner.

[DataMember]
public Guid OtherPerson { get; }

Property Value

Guid

Partner

The actual other person involved in the relationship. This is a computed property that returns the Person on the map with the OtherPerson id.

public Person Partner { get; }

Property Value

Person

RomanceDisplayString

An (unlocalized) string that represents a written version of this relationship's RomanceType status.

public string RomanceDisplayString { get; }

Property Value

string

RomanceLevel

The current amount of romance points (out of Max) that this relationship has. This value is automatically clamped between 0 and Max. To take skills, personalities and more into account, use ChangeRomance(Person, float). Note that, for aromantic people, getting and setting this value always gets and sets FriendLevel instead.

public float RomanceLevel { get; set; }

Property Value

float

RomancePercentage

The RomanceLevel of this relationship, divided by Max, yielding a percentage between 0 and 1 of how good this relationship's romance level is

public float RomancePercentage { get; }

Property Value

float

RomanceType

The RomanceType that this relationship has, based on the current RomanceLevel.

public RomanceType RomanceType { get; set; }

Property Value

RomanceType

Type

The RelationshipType that this relationship has, based on the current FriendLevel.

public RelationshipType Type { get; set; }

Property Value

RelationshipType

Methods

AddMemory<T>(MemoryType, bool, int, TimeSpan?)

Adds a Memory to this relationship's person's and Partner's Memories list of this person.

public T AddMemory<T>(MemoryType type, bool addToBoth, int toKeep = 0, TimeSpan? timeOccured = null) where T : Memory

Parameters

type MemoryType

The type of memory to add.

addToBoth bool

Whether the memory should be added to the Partner as well.

toKeep int

An amount of memories of the given type to keep, also counting the newly added one. Oldest memories will be removed first.

timeOccured TimeSpan?

The time that this memory occured on, or null to use Time.

Returns

T

The added memory.

Type Parameters

T

CreatePanel(Person, Person, Relationship, Vector2)

Creates a MLEM.Ui.Elements.Group with a MLEM.Ui.Elements.Panel in it that contains information about the given relationship. This method also calls OnRelationshipPanel.

public static Group CreatePanel(Person person, Person otherPerson, Relationship relationship, Vector2 size)

Parameters

person Person

The person who has the relationship.

otherPerson Person

The partner of the relationship.

relationship Relationship

The relationship. May be null.

size Vector2

The MLEM.Ui.Elements.Element.Size that the MLEM.Ui.Elements.Panel should have.

Returns

Group

A MLEM.Ui.Elements.Group that contains the MLEM.Ui.Elements.Panel created.

GetMemories<T>(MemoryType, bool)

Returns all Memory instances that this relationship's person and Partner currently track that match the given MemoryType.

public IEnumerable<T> GetMemories<T>(MemoryType type, bool returnBoth) where T : Memory

Parameters

type MemoryType

The memory type to match.

returnBoth bool

Whether the Partner's memories should also be returned.

Returns

IEnumerable<T>

The memories of the given type.

Type Parameters

T

GetSocialEffectiveness(ActionType)

Returns the effectiveness percentage that the given ActionType has right now, based on the amount of times that it has been used previously. In TalkAction, this effectiveness is used to reduce the friendship and romance gain based on the "boringness" of an action. Note that, if this relationship's main person is younger than a Child, the social effectiveness will always be 1.

public float GetSocialEffectiveness(ActionType action)

Parameters

action ActionType

The action whose effectiveness to query

Returns

float

The social effectiveness, which is a percentage between 0 and 1

GetTimeSinceMemory<T>(MemoryType, bool, Func<T, bool>)

Returns the time since a memory of the given MemoryType has occured in this relationship's main person or Partner. 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 TimeSpan? GetTimeSinceMemory<T>(MemoryType type, bool includeBoth, Func<T, bool> condition = null) where T : Memory

Parameters

type MemoryType

The memory type to query.

includeBoth bool

Whether the Partner's memories should be included in the search.

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

PopulateTooltip(Person, Person, Relationship, Tooltip)

Populates the given tooltip with information about the given relationship. This method also takes the OnRelationshipTooltip event into account.

public static void PopulateTooltip(Person person, Person otherPerson, Relationship relationship, Tooltip tooltip)

Parameters

person Person

The person who has the relationship.

otherPerson Person

The partner of the relationship.

relationship Relationship

The relationship. May be null.

tooltip Tooltip

The tooltip to populate.

RemoveMemory<T>(MemoryType, bool, int, Func<T, bool>)

Removes all Memory instances of the given type T and MemoryType from this relationship's person's and Partner's Memories collections, and returns the amount of memories removed.

public int RemoveMemory<T>(MemoryType type, bool removeFromBoth, int toKeep = 0, Func<T, bool> condition = null) where T : Memory

Parameters

type MemoryType

The memory type to match.

removeFromBoth bool

Wether the Partner's memories should also be removed.

toKeep int

An 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 relationship to a more basic, static version. This method is used when a map or household is exported, and by the ExportHousehold cheat.

public void ResetToStatic(bool thorough, bool sameHousehold)

Parameters

thorough bool

Whether the relationship should be reset thoroughly, causing the friendship level and romance level to be averaged out

sameHousehold bool

Whether the two people that are part of this relationship are in the same household

SetGenealogy(GenealogyType, bool)

Sets this relationship's Genealogy and this Partner's relationship's Genealogy, additionally updating all transitive relationships' genealogies using GetTransitive(GenealogyType, GenealogyType).

public void SetGenealogy(GenealogyType genealogy, bool overwriteExistingTransitive)

Parameters

genealogy GenealogyType

The genealogy to use for this relationship.

overwriteExistingTransitive bool

Whether the genealogies of existing transitive relationships should be updated, even if they are already set to a non-Unrelated relationship.

Validate(Person)

Validates this relationship, setting its internal person reference to the given Person. This method is automatically called for all of their relationships in Validate().

public void Validate(Person person)

Parameters

person Person

The person that this relationship belongs to

Events

OnRelationshipPanel

An event that is raised when a relationship panel is created in CreatePanel(Person, Person, Relationship, Vector2). Use this event to add custom information to a relationship panel.

public static event Action<(Person Person, Person Other, Relationship Relationship, Group Group)> OnRelationshipPanel

Event Type

Action<(Person Person, Person Other, Relationship Relationship, Group Group)>

OnRelationshipTooltip

An event that is raised when a relationship tooltip is populated in PopulateTooltip(Person, Person, Relationship, Tooltip). Use this event to add custom information to a relationship tooltip.

public static event Action<(Person Person, Person Other, Relationship Relationship, Tooltip Tooltip)> OnRelationshipTooltip

Event Type

Action<(Person Person, Person Other, Relationship Relationship, Tooltip Tooltip)>