private void SpawnSetupWorkSettings() { if (workTypes == null) { //Log.Warning("Unexpected creation of converted pawn."); workTypes = GetRandomWorkTypes(story); } WorkType = workTypes.Count > 0 ? workTypes[0].ToString() : String.Empty; // Work workSettings = new Pawn_WorkSettings(this); workSettings.EnableAndInitialize(); var skillsDefs = new List <SkillDef>(); foreach (WorkTypeDef current in DefDatabase <WorkTypeDef> .AllDefs) { if (workTypes.Contains(current)) { workSettings.SetPriority(current, 1); skillsDefs.AddRange(current.relevantSkills); } else { workSettings.Disable(current); } } skillsDefs.RemoveDuplicates(); foreach (var skillDef in skillsDefs) { var record = skills.GetSkill(skillDef); var minSkillLevel = KindDef.minSkillPoints; if (record == null || record.XpTotalEarned < minSkillLevel) { skills.Learn(skillDef, Rand.Range(minSkillLevel, KindDef.maxSkillPoints)); } } //foreach (WorkTypeDef current in DefDatabase<WorkTypeDef>.AllDefs) //{ // if (workTypes.Contains(current)) // { // } //} }
private void InitWork() { // Caching stuff if (Obedience == null) { Obedience = DefDatabase <TrainableDef> .GetNamed("Obedience"); } if (Release == null) { Release = DefDatabase <TrainableDef> .GetNamed("Release"); } if (Haul == null) { Haul = DefDatabase <TrainableDef> .GetNamed("Haul"); } if (BasicWorker == null) { BasicWorker = DefDatabase <WorkTypeDef> .GetNamed("BasicWorker"); } if (Cleaning == null) { Cleaning = DefDatabase <WorkTypeDef> .GetNamed("Cleaning"); } if (Hauling == null) { Hauling = DefDatabase <WorkTypeDef> .GetNamed("Hauling"); } if (IsFormerHuman()) { return; } if (skills == null) { skills = new Pawn_SkillTracker(this); foreach (SkillRecord skill in skills.skills) // to make skills neutral for price factor { skill.Level = 6; } } if (story == null) { story = new Pawn_StoryTracker(this) // necessary for job giver to work properly, but adds a bunch of problems since only humanlikes are supposed to have it { bodyType = BodyTypeDefOf.Thin, crownType = CrownType.Average, //childhood = xxx, //adulthood = xxx }; } if (workSettings == null) { workSettings = new Pawn_WorkSettings(this); workSettings.EnableAndInitialize(); workSettings.DisableAll(); } }