Class SkillType
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(MigratingStaticJsonConverter<SkillType>), new object[] { typeof(SkillType), "PrivateTypes", true })]
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
stringThe skill's name
texture
TextureRegionThe skill's icon
maxLevel
intThe skill's maximum level. Should be 5 or 10 for consistency.
categories
SkillCategoryA combined flag of categories that this skill has
Fields
AllCategories
An array containing every defined SkillCategory.
public static readonly SkillCategory[] AllCategories
Field Value
Baking
public static readonly SkillType Baking
Field Value
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
Charisma
public static readonly SkillType Charisma
Field Value
Cleaning
public static readonly SkillType Cleaning
Field Value
Communication
public static readonly SkillType Communication
Field Value
Cooking
public static readonly SkillType Cooking
Field Value
DrinkMixing
public static readonly SkillType DrinkMixing
Field Value
Fitness
public static readonly SkillType Fitness
Field Value
Gaming
public static readonly SkillType Gaming
Field Value
Humor
public static readonly SkillType Humor
Field Value
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
Name
The name of this skill type
public readonly string Name
Field Value
Painting
public static readonly SkillType Painting
Field Value
Potty
public static readonly SkillType Potty
Field Value
Programming
public static readonly SkillType Programming
Field Value
Reading
public static readonly SkillType Reading
Field Value
Reasoning
public static readonly SkillType Reasoning
Field Value
Repair
public static readonly SkillType Repair
Field Value
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
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
Woodworking
public static readonly SkillType Woodworking
Field Value
Writing
public static readonly SkillType Writing
Field Value
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
RequiredAges
The ages that are required for a PersonLike to be able to have this skill. This value defaults to ChildOrOlder.
public AgeGroup RequiredAges { get; init; }
Property Value
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
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
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
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
AgeGroupThe 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. The returned quality is based on the weights determined by GetRandomQualityWeights(PersonLike, Random, ActionInfo, bool).
public Quality GetRandomQuality(PersonLike person, Random random, ActionInfo info = null, bool modifyEmotions = true, IEmotionSource source = null, bool alwaysAllowAverage = false)
Parameters
person
PersonLikeThe person that has this skill
random
RandomThe random that should be used for calculation
info
ActionInfoThe 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
boolWhether the given person should receive emotions based on the quality, defaults to true
source
IEmotionSourceThe emotion source that modified emotions come from
alwaysAllowAverage
boolWhether 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
GetRandomQualityWeights(PersonLike, Random, ActionInfo, bool)
Returns a set of Quality values and associated weights to be used for determining a random quality for the given PersonLike using GetRandomQuality(PersonLike, Random, ActionInfo, bool, IEmotionSource, bool).
Various factors are taken into account, such as the person
's skill level, PersonalityTypes, Emotion, the return values of OnRandomQuality(PersonLike, ActionInfo, bool, SkillType, Random, bool, Dictionary<Quality, float>) of all of the info
's involved objects, and the OnGetRandomQuality event.
public Dictionary<Quality, float> GetRandomQualityWeights(PersonLike person, Random random, ActionInfo info = null, bool alwaysAllowAverage = false)
Parameters
person
PersonLikeThe person that has this skill
random
RandomThe random that should be used for calculation
info
ActionInfoThe 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.
alwaysAllowAverage
boolWhether or not Average should always be part of the random choice, defaults to false
Returns
- Dictionary<Quality, float>
A set of qualities along with weights that represent their likelihood of being chosen.
Register(SkillType)
public static SkillType Register(SkillType type)
Parameters
type
SkillTypeThe type to register
Returns
- SkillType
The registered type, for chaining
Events
OnGetRandomQuality
An event that is raised in GetRandomQualityWeights(PersonLike, Random, ActionInfo, bool).
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