public Priority(Pawn pawn, WorkTypeDef workTypeDef, YouDoYou_Settings settings, bool freePawn) { this.pawn = pawn; this.workTypeDef = workTypeDef; this.adjustmentStrings = new List <string> { }; this.mapComp = pawn.Map.GetComponent <YouDoYou_MapComponent>(); this.worldComp = Find.World.GetComponent <YouDoYou_WorldComponent>(); if (freePawn) { this.set(0.2f, "YouDoYouPriorityGlobalDefault".Translate()).compute(); } else { int p = pawn.workSettings.GetPriority(workTypeDef); if (p == 0) { this.set(0.0f, "YouDoYouPriorityNoFreeWill".Translate()); } else { this.set((100f - onePriorityWidth * (p - 1)) / 100f, "YouDoYouPriorityNoFreeWill".Translate()); } } }
private Priority considerInterest(Pawn pawn, SkillDef skillDef, int skillCount, WorkTypeDef workTypeDef) { if (!YouDoYou_WorldComponent.HasInterestsFramework()) { return(this); } SkillRecord skillRecord = pawn.skills.GetSkill(skillDef); float x; string interest; try { interest = YouDoYou_WorldComponent.InterestsStrings[(int)skillRecord.passion]; } catch (System.Exception) { Logger.Message("could not find interest for index " + ((int)skillRecord.passion).ToString()); return(this); } switch (interest) { case "DMinorAversion": x = (1.0f - pawn.needs.mood.CurLevel) * -0.25f / skillCount; return(add(x, "YouDoYouPriorityMinorAversionTo".Translate() + " " + skillDef.skillLabel)); case "DMajorAversion": x = (1.0f - pawn.needs.mood.CurLevel) * -0.5f / skillCount; return(add(x, "YouDoYouPriorityMajorAversionTo".Translate() + " " + skillDef.skillLabel)); case "DCompulsion": List <Thought> allThoughts = new List <Thought>(); pawn.needs.mood.thoughts.GetAllMoodThoughts(allThoughts); foreach (var thought in allThoughts) { if (thought.def.defName == "CompulsionUnmet") { switch (thought.CurStage.label) { case "compulsive itch": x = 0.2f / skillCount; return(add(x, "YouDoYouPriorityCompulsiveItch".Translate() + " " + skillDef.skillLabel)); case "compulsive need": x = 0.4f / skillCount; return(add(x, "YouDoYouPriorityCompulsiveNeed".Translate() + " " + skillDef.skillLabel)); case "compulsive obsession": x = 0.6f / skillCount; return(add(x, "YouDoYouPriorityCompulsiveObsession".Translate() + " " + skillDef.skillLabel)); default: Logger.Debug("could not read compulsion label"); return(this); } } if (thought.def.defName == "NeuroticCompulsionUnmet") { switch (thought.CurStage.label) { case "compulsive itch": x = 0.3f / skillCount; return(add(x, "YouDoYouPriorityCompulsiveItch".Translate() + " " + skillDef.skillLabel)); case "compulsive demand": x = 0.6f / skillCount; return(add(x, "YouDoYouPriorityCompulsiveDemand".Translate() + " " + skillDef.skillLabel)); case "compulsive withdrawal": x = 0.9f / skillCount; return(add(x, "YouDoYouPriorityCompulsiveWithdrawl".Translate() + " " + skillDef.skillLabel)); default: Logger.Debug("could not read compulsion label"); return(this); } } if (thought.def.defName == "VeryNeuroticCompulsionUnmet") { switch (thought.CurStage.label) { case "compulsive yearning": x = 0.4f / skillCount; return(add(x, "YouDoYouPriorityCompulsiveYearning".Translate() + " " + skillDef.skillLabel)); case "compulsive tantrum": x = 0.8f / skillCount; return(add(x, "YouDoYouPriorityCompulsiveTantrum".Translate() + " " + skillDef.skillLabel)); case "compulsive hysteria": x = 1.2f / skillCount; return(add(x, "YouDoYouPriorityCompulsiveHysteria".Translate() + " " + skillDef.skillLabel)); default: Logger.Debug("could not read compulsion label"); return(this); } } } return(this); case "DInvigorating": x = 0.1f / skillCount; return(add(x, "YouDoYouPriorityInvigorating".Translate() + " " + skillDef.skillLabel)); case "DInspiring": return(this); case "DStagnant": return(this); case "DForgetful": return(this); case "DVocalHatred": return(this); case "DNaturalGenius": return(this); case "DBored": if (pawn.mindState.IsIdle) { return(this); } return(neverDo("YouDoYouPriorityBoredBy".Translate() + " " + skillDef.skillLabel)); case "DAllergic": foreach (var hediff in pawn.health.hediffSet.GetHediffs <Hediff>()) { if (hediff.def.defName == "DAllergicReaction") { switch (hediff.CurStage.label) { case "initial": x = -0.2f / skillCount; return(add(x, "YouDoYouPriorityReactionInitial".Translate() + " " + skillDef.skillLabel)); case "itching": x = -0.5f / skillCount; return(add(x, "YouDoYouPriorityReactionItching".Translate() + " " + skillDef.skillLabel)); case "sneezing": x = -0.8f / skillCount; return(add(x, "YouDoYouPriorityReactionSneezing".Translate() + " " + skillDef.skillLabel)); case "swelling": x = -1.1f / skillCount; return(add(x, "YouDoYouPriorityReactionSwelling".Translate() + " " + skillDef.skillLabel)); case "anaphylaxis": return(neverDo("YouDoYouPriorityReactionAnaphylaxis".Translate() + " " + skillDef.skillLabel)); default: break; } } x = 0.1f / skillCount; return(add(x, "YouDoYouPriorityNoReaction".Translate() + " " + skillDef.skillLabel)); } return(this); default: Logger.Debug("did not recognize interest: " + skillRecord.passion.ToString()); return(this); } }