Class Relationship
- Namespace
- TinyLife
- Assembly
- Tiny Life.dll
A relationship is a connection between two PersonLike 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
-
JsonTypeSafeGenericDataHolderRelationship
- 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
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
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
Max
The maximum value that a relationship level can have
public const float Max = 100000
Field Value
Migrations
public static readonly List<Migration<Relationship>> Migrations
Field Value
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
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
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
Properties
FriendDisplayString
An (unlocalized) string that represents a written version of this relationship's Type status.
public string FriendDisplayString { get; }
Property Value
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(PersonLike, float, bool).
public float FriendLevel { get; set; }
Property Value
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
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
OtherPerson
The Guid of the person that this relationship is linked to. To easily retrieve the matching PersonLike instance, see Partner.
[DataMember]
public Guid OtherPerson { get; }
Property Value
Partner
The actual other person involved in the relationship. This is a computed property that returns the PersonLike on the map with the OtherPerson id.
public PersonLike Partner { get; }
Property Value
Person
public PersonLike Person { get; }
Property Value
RomanceDisplayString
An (unlocalized) string that represents a written version of this relationship's RomanceType status.
public string RomanceDisplayString { get; }
Property Value
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(PersonLike, float, bool). Note that, for aromantic people, getting and setting this value always gets and sets FriendLevel instead.
public float RomanceLevel { get; set; }
Property Value
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
RomanceType
The RomanceType that this relationship has, based on the current RomanceLevel.
public RomanceType RomanceType { get; set; }
Property Value
Type
The RelationshipType that this relationship has, based on the current FriendLevel.
public RelationshipType Type { get; set; }
Property Value
Methods
AddMemory<T>(MemoryType, bool, int, TimeSpan?)
public T AddMemory<T>(MemoryType type, bool addToBoth, int toKeep = 0, TimeSpan? timeOccured = null) where T : Memory
Parameters
type
MemoryTypeThe type of memory to add.
addToBoth
boolWhether the memory should be added to the Partner as well.
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
CreateBars(Anchor, PersonLike, Relationship, Vector2, float, bool)
Creates a MLEM.Ui.Elements.Group with two MLEM.Ui.Elements.ProgressBar elements in it that represent the friendship and romance levels of the given relationship
.
public static Group CreateBars(Anchor anchor, PersonLike person, Relationship relationship, Vector2 size, float barHeight = 10, bool showText = true)
Parameters
anchor
AnchorThe anchor to use.
person
PersonLikeThe person who has the
relationship
.relationship
RelationshipThe relationship. May be null.
size
Vector2The MLEM.Ui.Elements.Element.Size that the MLEM.Ui.Elements.Group should have.
barHeight
floatThe height of the bars.
showText
boolWhether the relationship type should be displayed as text in the bars.
Returns
- Group
The group containing the bars.
CreatePanel(PersonLike, PersonLike, 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(PersonLike person, PersonLike otherPerson, Relationship relationship, Vector2 size)
Parameters
person
PersonLikeThe person who has the
relationship
.otherPerson
PersonLikeThe partner of the
relationship
.relationship
RelationshipThe relationship. May be null.
size
Vector2The 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
MemoryTypeThe memory type to match.
returnBoth
boolWhether 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
ActionTypeThe 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
MemoryTypeThe memory type to query.
includeBoth
boolWhether 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(PersonLike, PersonLike, 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(PersonLike person, PersonLike otherPerson, Relationship relationship, Tooltip tooltip)
Parameters
person
PersonLikeThe person who has the
relationship
.otherPerson
PersonLikeThe partner of the
relationship
.relationship
RelationshipThe relationship. May be null.
tooltip
TooltipThe 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
MemoryTypeThe memory type to match.
removeFromBoth
boolWether the Partner's memories should also be removed.
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 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
boolWhether the relationship should be reset thoroughly, causing the friendship level and romance level to be averaged out
sameHousehold
boolWhether the two people that are part of this relationship are in the same household
SetGenealogy(GenealogyType, bool, Action<PersonLike, Relationship, GenealogyType>, ICollection<PersonLike>)
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, Action<PersonLike, Relationship, GenealogyType> onGenealogyChanged = null, ICollection<PersonLike> possibleAdditionalPeople = null)
Parameters
genealogy
GenealogyTypeThe genealogy to use for this relationship.
overwriteExistingTransitive
boolWhether the genealogies of existing transitive relationships should be updated, even if they are already set to a non-Unrelated relationship.
onGenealogyChanged
Action<PersonLike, Relationship, GenealogyType>An action that is invoked when a genealogy is changed, which is additionally passed to recursive calls of this method.
possibleAdditionalPeople
ICollection<PersonLike>A set of additional people that can optionally be considered as this relationship's or subsequent recursive calls' relationships' partners, in addition to the Partner and subsequent recursive calls' partners, which may not currently be present on the map.
Validate(PersonLike, AppliedMigrations)
Validates this relationship, setting its internal person reference to the given PersonLike. This method is automatically called for all of their relationships in Validate(AppliedMigrations).
public bool Validate(PersonLike person, AppliedMigrations appliedMigrations)
Parameters
person
PersonLikeThe person that this relationship belongs to
appliedMigrations
AppliedMigrations
Returns
Events
OnRelationshipPanel
An event that is raised when a relationship panel is created in CreatePanel(PersonLike, PersonLike, Relationship, Vector2). Use this event to add custom information to a relationship panel.
public static event Action<(PersonLike Person, PersonLike Other, Relationship Relationship, Group Group)> OnRelationshipPanel
Event Type
- Action<(PersonLike Person, PersonLike Other, Relationship Relationship, Group Group)>
OnRelationshipTooltip
An event that is raised when a relationship tooltip is populated in PopulateTooltip(PersonLike, PersonLike, Relationship, Tooltip). Use this event to add custom information to a relationship tooltip.
public static event Action<(PersonLike Person, PersonLike Other, Relationship Relationship, Tooltip Tooltip)> OnRelationshipTooltip
Event Type
- Action<(PersonLike Person, PersonLike Other, Relationship Relationship, Tooltip Tooltip)>