Class Skill
A skill is an ability that a PersonLike can have which influences their behavior in some way. Skill instances are created from their corresponding SkillType.
[DataContract]
public class Skill
- Inheritance
-
Skill
- Inherited Members
- Extension Methods
Constructors
Skill(SkillType, PersonLike)
Creates a new skill instance from the given SkillType.
public Skill(SkillType type, PersonLike person)
Parameters
typeSkillTypeThe type of skill to construct
personPersonLikeThe person that has this skill.
Fields
Type
The underlying SkillType that this skill instance originates from
[DataMember]
public readonly SkillType Type
Field Value
Properties
Level
The current level of this skill. Note that this value never goes beyond GetMaxLevel(AgeGroup). To modify this value efficiently, use GainSkill(SkillType, float, ActionInfo, float).
[DataMember]
public int Level { get; set; }
Property Value
Person
The person that has this skill.
public PersonLike Person { get; }
Property Value
PointPercentage
The percentage of PointsToNextLevel out of the RequiredPointsToNextLevel. This value is always between 0 and 1.
public float PointPercentage { get; }
Property Value
PointsToNextLevel
The amount of skill points that are required until the next Level is reached. To modify this value, use GainSkill(SkillType, float, ActionInfo, float).
[DataMember]
public float PointsToNextLevel { get; }
Property Value
RequiredPointsToNextLevel
Returns the amount of skill points that is required to reach the next level. This value is depenedent on the current Level, meaning higher skill levels are harder to reach.
public int RequiredPointsToNextLevel { get; }
Property Value
- int
The points required for the next level
TotalPercentage
The percentage of the Level, plus the PointPercentage, out of the total MaxLevel. Essentially, this value represents the total progress that this skill has, between 0 and 1.
public float TotalPercentage { get; }
Property Value
Methods
Gain(float)
Causes this skill to gain the given amount of points. If the points exceed the required points for the next level, the skill level is increased. Generally, it is preferred to use GainSkill(SkillType, float, ActionInfo, float) over this method.
public bool Gain(float amount)
Parameters
amountfloatThe amount of skill points to gain.
Returns
- bool
Whether the skill points could be gained. If this is false, this skill is already at the max level.
Validate(PersonLike)
Validates this skill, setting its Person when loaded from disk in Validate(AppliedMigrations).
public void Validate(PersonLike person)
Parameters
personPersonLikeThe person that has this skill.
Events
OnAdditionalEarnedActions
An event that is invoked when a notification for a skill level up is displayed for the given Skill. The list can have additional display strings added to based on a reached level to display additional actions or abilities that a person gains when reaching that level. This is an event version of AdditionalEarnedActions.
public static event Action<PersonLike, Skill, List<(int Level, string DisplayName)>> OnAdditionalEarnedActions
Event Type
- Action<PersonLike, Skill, List<(int Level, string DisplayName)>>