Relationship - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife

Relationship Class

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.

public class Relationship

Inheritance System.Object 🡒 Relationship

Constructors

Relationship.Relationship(Person, Guid, float, float) Constructor

Creates a new relationship to the given other person

public Relationship(TinyLife.Objects.Person person, System.Guid otherPerson, float friendLevel=0f, float romanceLevel=0f);

Parameters

person Person
The person that this relationship belongs to

otherPerson System.Guid
The other person

friendLevel System.Single
The initial value for FriendLevel

romanceLevel System.Single
The initial value for RomanceLevel

Fields

Relationship.Dating Field

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

public bool Dating;

Field Value

System.Boolean

Relationship.Genealogy Field

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

public GenealogyType Genealogy;

Field Value

GenealogyType

Relationship.KnownPersonalityTypes Field

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

public readonly HashSet<string> KnownPersonalityTypes;

Field Value

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

Relationship.Max Field

The maximum value that a relationship level can have

public const float Max = 100000;

Field Value

System.Single

Relationship.MaxRecentSocialsAmount Field

The maximum amount of social actions that are "remembered" in this relationship.
This is equivalent to RecentActions, but related to this relationship only.

public const int MaxRecentSocialsAmount = 10;

Field Value

System.Int32

Relationship.PassiveFriendReduction Field

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

System.Single

Relationship.PassiveRomanceReduction Field

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

System.Single

Properties

Relationship.DisplayString Property

An (unlocalized) string that represents a written version of this relationship's status.
If Dating is true, the string "Dating" will be returned. Otherwise, Type is returned as a string.

public string DisplayString { get; }

Property Value

System.String

Relationship.FriendLevel Property

The current amount of friendship points (out of Max) that this relationship has.
This value is automatically clamped between -Max and Max.

public float FriendLevel { get; set; }

Property Value

System.Single

Relationship.FriendPercentage Property

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

System.Single

Relationship.OtherPerson Property

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

public System.Guid OtherPerson { get; set; }

Property Value

System.Guid

Relationship.Partner Property

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 TinyLife.Objects.Person Partner { get; }

Property Value

Person

Relationship.RomanceLevel Property

The current amount of romance points (out of Max) that this relationship has.
This value is automatically clamped between 0 and Max.
Note that, for aromantic people, getting and setting this value always gets and sets FriendLevel instead.

public float RomanceLevel { get; set; }

Property Value

System.Single

Relationship.RomancePercentage Property

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

System.Single

Relationship.Type Property

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

public TinyLife.RelationshipType Type { get; }

Property Value

RelationshipType

Methods

Relationship.AddRecentSocial(ActionType) Method

Adds the given action to the list of recent social actions for this relationship.
If the list's length exceeds MaxRecentSocialsAmount, the least recent socials will be removed.
Note that this method is automatically invoked in Evaluate(SocialAction).

public void AddRecentSocial(TinyLife.Actions.ActionType action);

Parameters

action ActionType
The action to add to the recent socials list

Relationship.GetRecentSocialAmount(ActionType) Method

Returns the amount of times that the given ActionType has been used out of the last MaxRecentSocialsAmount social actions in this relationship

public int GetRecentSocialAmount(TinyLife.Actions.ActionType action);

Parameters

action ActionType

Returns

System.Int32

Relationship.GetSocialEffectiveness(ActionType) Method

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.

public float GetSocialEffectiveness(TinyLife.Actions.ActionType action);

Parameters

action ActionType
The action whose effectiveness to query

Returns

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

Relationship.Validate(Person) Method

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 bool Validate(TinyLife.Objects.Person person);

Parameters

person Person
The person that this relationship belongs to

Returns

System.Boolean
True