Table of Contents

Class SkillType

Namespace
TinyLife.Skills
Assembly
Tiny Life.dll

A skill is an ability that a PersonLike can have which influences their behavior in some way. The SkillType class contains underlying data for a Skill instance, like its name and maximum level.

[JsonConverter(typeof(StaticJsonConverter<SkillType>), new object[] { typeof(SkillType), "PrivateTypes" })]
public class SkillType
Inheritance
SkillType
Inherited Members
Extension Methods

Constructors

SkillType(string, TextureRegion, int, SkillCategory)

Creates a new skill type with the given settings

public SkillType(string name, TextureRegion texture, int maxLevel, SkillCategory categories)

Parameters

name string

The skill's name

texture TextureRegion

The skill's icon

maxLevel int

The skill's maximum level. Should be 5 or 10 for consistency.

categories SkillCategory

A combined flag of categories that this skill has

Fields

AllCategories

An array containing every defined SkillCategory.

public static readonly SkillCategory[] AllCategories

Field Value

SkillCategory[]

Baking

public static readonly SkillType Baking

Field Value

SkillType

Categories

The SkillCategory combined flag that this skill type has. The skill categories it has are used to determine skill gain from things like the Creative personality type.

public readonly SkillCategory Categories

Field Value

SkillCategory

Charisma

public static readonly SkillType Charisma

Field Value

SkillType

Cleaning

public static readonly SkillType Cleaning

Field Value

SkillType

Communication

public static readonly SkillType Communication

Field Value

SkillType

Cooking

public static readonly SkillType Cooking

Field Value

SkillType

DrinkMixing

public static readonly SkillType DrinkMixing

Field Value

SkillType

Fitness

public static readonly SkillType Fitness

Field Value

SkillType

Gaming

public static readonly SkillType Gaming

Field Value

SkillType

Humor

public static readonly SkillType Humor

Field Value

SkillType

MaxLevel

The maximum level that this skill can reach. Most skills should default to 5 or 10 for consistency.

public readonly int MaxLevel

Field Value

int

Name

The name of this skill type

public readonly string Name

Field Value

string

Painting

public static readonly SkillType Painting

Field Value

SkillType

Potty

public static readonly SkillType Potty

Field Value

SkillType

Programming

public static readonly SkillType Programming

Field Value

SkillType

Reading

public static readonly SkillType Reading

Field Value

SkillType

Reasoning

public static readonly SkillType Reasoning

Field Value

SkillType

Repair

public static readonly SkillType Repair

Field Value

SkillType

Texture

The texture region of this skill type's icon

public readonly TextureRegion Texture

Field Value

TextureRegion

Tinkering

public static readonly SkillType Tinkering

Field Value

SkillType

Types

A registry of all skill types that exist in the game and mods. Use Register(SkillType) to register custom skill types.

public static readonly ReadOnlyDictionary<string, SkillType> Types

Field Value

ReadOnlyDictionary<string, SkillType>

Woodworking

public static readonly SkillType Woodworking

Field Value

SkillType

Writing

public static readonly SkillType Writing

Field Value

SkillType

Properties

AdditionalEarnedActions

A function that can optionally be used to return a set of action information that is displayed when this skill's level is raised to the given levels. This function is used by skills like Cooking and Woodworking to display what additional items can now be cooked or crafted.

public Func<PersonLike, Skill, IEnumerable<(int Level, string DisplayName)>> AdditionalEarnedActions { get; init; }

Property Value

Func<PersonLike, Skill, IEnumerable<(int Level, string DisplayName)>>

MaxLevelMultipliers

A function that can optionally return a factor that determines the maximum skill level, based on the MaxLevel and the AgeGroup of a person.

public Func<AgeGroup, float> MaxLevelMultipliers { get; init; }

Property Value

Func<AgeGroup, float>

RequiredAges

The ages that are required for a PersonLike to be able to have this skill. This value defaults to Child and Adult.

public AgeGroup RequiredAges { get; init; }

Property Value

AgeGroup

RequiredPersonType

The type of PersonLike that is able to have this skill. This value default to the Person type.

public Type RequiredPersonType { get; init; }

Property Value

Type

RewardPersonality

A function that can optionally return a PersonalityType that should be added to a person when they age up if they have reached a certain set of conditions.

public Func<(Skill Skill, AgeGroup LastAge, AgeGroup Age), PersonalityType> RewardPersonality { get; init; }

Property Value

Func<(Skill Skill, AgeGroup LastAge, AgeGroup Age), PersonalityType>

RewardSkills

/// A function that can optionally return a set of Skill types and levels that should be added to a person when they age up if they have reached a certain set of conditions.

public Func<(Skill Skill, AgeGroup LastAge, AgeGroup Age), IEnumerable<(SkillType Type, int Level)>> RewardSkills { get; init; }

Property Value

Func<(Skill Skill, AgeGroup LastAge, AgeGroup Age), IEnumerable<(SkillType Type, int Level)>>

Methods

GetMaxLevel(AgeGroup)

Returns the maximum level for the given AgeGroup, which the MaxLevel multiplied by the corresponding MaxLevelMultipliers.

public int GetMaxLevel(AgeGroup age)

Parameters

age AgeGroup

The age group

Returns

int

The maximum level

GetRandomQuality(PersonLike, Random, ActionInfo, bool, IEmotionSource, bool)

Returns a semi-randomly generated Quality for the given PersonLike based on their level of this skill. The higher the skill level is, the more likely it is for higher qualities to be returned.

public Quality GetRandomQuality(PersonLike person, Random random, ActionInfo info = null, bool modifyEmotions = true, IEmotionSource source = null, bool alwaysAllowAverage = false)

Parameters

person PersonLike

The person that has this skill

random Random

The random that should be used for calculation

info ActionInfo

The action info to use for determining the random quality. If this is set, OnRandomQuality(PersonLike, ActionInfo, bool, SkillType, Random, bool, Dictionary<Quality, float>) will be invoked for all involved objects.

modifyEmotions bool

Whether the given person should receive emotions based on the quality, defaults to true

source IEmotionSource

The emotion source that modified emotions come from

alwaysAllowAverage bool

Whether or not Average should always be part of the random choice, defaults to false

Returns

Quality

A random quality based on the person's skill level

Register(SkillType)

Registers a new SkillType to the Types registry

public static SkillType Register(SkillType type)

Parameters

type SkillType

The type to register

Returns

SkillType

The registered type, for chaining

Events

OnGetRandomQuality

An event that is raised in GetRandomQuality(PersonLike, Random, ActionInfo, bool, IEmotionSource, bool) before a quality is chosen.

public static event Action<(PersonLike Person, ActionInfo Info, SkillType Skill, Random Random, bool AlwaysAllowAverage, Dictionary<Quality, float> Weights)> OnGetRandomQuality

Event Type

Action<(PersonLike Person, ActionInfo Info, SkillType Skill, Random Random, bool AlwaysAllowAverage, Dictionary<Quality, float> Weights)>

OnRandomQuality

An event that is raised in GetRandomQuality(PersonLike, Random, ActionInfo, bool, IEmotionSource, bool) after a quality is chosen.

public static event Action<(PersonLike Person, ActionInfo Info, SkillType Skill, bool ModifyEmotions, IEmotionSource Source, Quality Quality)> OnRandomQuality

Event Type

Action<(PersonLike Person, ActionInfo Info, SkillType Skill, bool ModifyEmotions, IEmotionSource Source, Quality Quality)>