AH! I forgot all about traits! I think I'll definitely be using that for the initial "Make Incapable" I'm looking for with certain pawns. However, when I go to make them capable again, I've found the method needed to do so after quite a bit of playing in Visual Studio.
I've found that when enabling work-types, it is necessary to re-make the SkillRecord of all associated re-enabled work-types. If that makes sense xD So, what I do, is this:
Code Select
// This will make a pawn incapable of the work type given as the argument, and disable associated skills.
pawn.story.DisabledWorkTypes.Add(WorkTypeDef w);
// This will make pawns capable of the work type given as the argument, but will NOT enable associated skills.
pawn.story.DisabledWorkTypes.Remove(WorkTypeDef w);
// This will make pawns capable of every work type again
pawn.story.DisabledWorkTypes.Clear();
I've found that when enabling work-types, it is necessary to re-make the SkillRecord of all associated re-enabled work-types. If that makes sense xD So, what I do, is this:
Code Select
// Disable the work-type of "Warden"; Effectively disables the "Social" SkillRecord, making it so that the pawn cannot learn the skill at all.
pawn.story.DisabledWorkTypes.Add(WorkTypeDefOf.Warden);
// It's just good practice to implement checks before removing things from lists :P
if(pawn.story.DisabledWorkTypes.Contains(WorkTypeDefOf.Warden)
{
// This will re-enable the work-type of warden. In the game, this just means the pawn can be assigned to the "Warden" task again. However, the "Social" skill is still DISABLED.
pawn.story.DisabledWorkTypes.Remove(WorkTypeDefOf.Warden);
}
// THIS PART IS UNTESTED; It is a stub of some code that I've used and tested, though.
// Declare a new SkillRecord
SkillRecord cleanSocial = new SkillRecord(pawn, SkillDefOf.Social);
// Assign the clean SkillRecord to the pawn
pawn.skills.skills.Add(cleanSocial);
// The pawn now has an enabled SkillRecord for the "Social" skill type, though the level is set to 0, as is the total xp