public static bool CanAdoptJob(this Pawn pawn, DivineJobDef def)
        {
            DivineJobsComp comp = pawn.GetJobsComp();

            if (comp == null)
            {
                return(false);
            }

            if (comp.jobs.Any(job => job.def == def))
            {
                return(false);
            }

            if ((def.jobType == JobType.Normal && comp.activeJob != null && !comp.activeJob.IsFullyLeveled) ||
                (def.jobType == JobType.Race && comp.activeRaceJob != null && !comp.activeRaceJob.IsFullyLeveled))
            {
                return(false);
            }

            foreach (JobRequirementWorker req in def.jobRequirements)
            {
                if (!req.IsRequirementMet(def, comp, pawn))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
 public override string RequirementExplanation(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     if (IsRequirementMet(def, comp, pawn))
     {
         JobData taggedJob = TryGetTaggedJob(comp);
         if (fullyLeveled)
         {
             return("DivineJobs_JobRequirement_JobWithTag_Success".Translate(tag.LabelCap, taggedJob.def.LabelCap));
         }
         else
         {
             return("DivineJobs_JobRequirement_JobWithTag_NotLeveled_Success".Translate(tag.LabelCap, taggedJob.def.LabelCap));
         }
     }
     else
     {
         if (fullyLeveled)
         {
             return("DivineJobs_JobRequirement_JobWithTag_Failed".Translate(tag.LabelCap));
         }
         else
         {
             return("DivineJobs_JobRequirement_JobWithTag_NotLeveled_Failed".Translate(tag.LabelCap));
         }
     }
 }
        public static JobData GetDivineJob(this Pawn target, DivineJobDef def)
        {
            if (target.GetJobsComp() is DivineJobsComp comp)
            {
                return(comp.jobs.FirstOrDefault(job => job.def == def));
            }

            return(null);
        }
        public static JobData MakeJobInstance(DivineJobDef def, Pawn owner = null, DivineJobsComp comp = null)
        {
            JobData instance = (JobData)Activator.CreateInstance(def.jobClass);

            instance.def      = def;
            instance.owner    = owner;
            instance.jobsComp = comp;
            return(instance);
        }
示例#5
0
 public override string RequirementExplanation(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     if (IsRequirementMet(def, comp, pawn))
     {
         return("DivineJobs_JobRequirement_AddedParts_Success".Translate(CountAddedParts(pawn), minAmount, minTechLevel.ToStringHuman().CapitalizeFirst()));
     }
     else
     {
         return("DivineJobs_JobRequirement_AddedParts_Failed".Translate(CountAddedParts(pawn), minAmount, minTechLevel.ToStringHuman().CapitalizeFirst()));
     }
 }
示例#6
0
 public override string RequirementExplanation(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     if (IsRequirementMet(def, comp, pawn))
     {
         return("DivineJobs_JobRequirement_Job_Success".Translate(jobDef.LabelCap));
     }
     else
     {
         return("DivineJobs_JobRequirement_Job_Failed".Translate(jobDef.LabelCap));
     }
 }
示例#7
0
        public bool TryGetJob(DivineJobDef def, out JobData jobData)
        {
            if (jobs.FirstOrDefault(job => job.def == def) is JobData foundData)
            {
                jobData = foundData;
                return(true);
            }

            jobData = null;
            return(false);
        }
 public override string RequirementExplanation(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     if (IsRequirementMet(def, comp, pawn))
     {
         return("DivineJobs_JobRequirement_Trait_Success".Translate(TraitsBetweenDegrees()));
     }
     else
     {
         return("DivineJobs_JobRequirement_Trait_Failed".Translate(TraitsBetweenDegrees()));
     }
 }
示例#9
0
        public override void Initialize(CompProperties props)
        {
            base.Initialize(props);

            //Give default starting Job.
            DivineJobDef defaultJob = DefDatabase <DivineJobDef> .AllDefs.FirstOrDefault(def => def.defaultJob);

            if (defaultJob != null)
            {
                AddJob(DivineJobUtility.MakeJobInstance(defaultJob));
            }
        }
示例#10
0
        public override string RequirementExplanation(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
        {
            int skillLevel = pawn.skills.GetSkill(skill).Level;

            if (IsRequirementMet(def, comp, pawn))
            {
                return("DivineJobs_JobRequirement_Skill_Success".Translate(skill.LabelCap, skillLevel, minimumSkillRequired));
            }
            else
            {
                return("DivineJobs_JobRequirement_Skill_Failed".Translate(skill.LabelCap, skillLevel, minimumSkillRequired));
            }
        }
示例#11
0
        public void AddJob(DivineJobDef jobDef, bool setAsActive = false)
        {
            JobData job = DivineJobUtility.MakeJobInstance(jobDef);

            AddJob(job);
            if (setAsActive)
            {
                if (job.def.jobType == JobType.Normal)
                {
                    activeJob = job;
                }
                else if (job.def.jobType == JobType.Race)
                {
                    activeRaceJob = job;
                }
            }
        }
示例#12
0
        public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
        {
            JobData data = TryGetTaggedJob(comp);

            if (data == null)
            {
                return(false);
            }

            if (fullyLeveled)
            {
                return(data.IsFullyLeveled);
            }
            else
            {
                return(true);
            }
        }
示例#13
0
        public static string GenerateJobRequirementReport(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("DivineJobs_JobRequirementReport".Translate() + ":");
            if (def.jobRequirements.Count > 0)
            {
                foreach (JobRequirementWorker req in def.jobRequirements)
                {
                    bool isMet = req.IsRequirementMet(def, comp, pawn);
                    builder.AppendLine($"    {isMet.BoolIntoSymbol()} {req.RequirementExplanation(def, comp, pawn)}");
                }
            }
            else
            {
                builder.AppendLine($"    {"DivineJobs_JobRequirementReport_None".Translate()}");
            }

            return(builder.ToString());
        }
示例#14
0
        public override string RequirementExplanation(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
        {
            string requiredAmount = "";

            if (record.type == RecordType.Int)
            {
                requiredAmount = pawn.records.GetAsInt(record).ToString();
            }
            else if (record.type == RecordType.Float)
            {
                requiredAmount = pawn.records.GetValue(record).ToString();
            }

            if (IsRequirementMet(def, comp, pawn))
            {
                return("DivineJobs_JobRequirement_Record_Success".Translate(record.LabelCap, minimumRequiredAmount, requiredAmount));
            }
            else
            {
                return("DivineJobs_JobRequirement_Record_Failed".Translate(record.LabelCap, minimumRequiredAmount, requiredAmount));
            }
        }
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.health.hediffSet.HasHediff(hediffDef));
 }
 public override string RequirementExplanation(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return("DivineJobs_JobRequirement_Or".Translate(first.RequirementExplanation(def, comp, pawn), second.RequirementExplanation(def, comp, pawn)));
 }
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(first.IsRequirementMet(def, comp, pawn) || second.IsRequirementMet(def, comp, pawn));
 }
示例#18
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.skills.GetSkill(skill).Level >= minimumSkillRequired);
 }
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.story.traits.HasTrait(trait) && pawn.story.traits.GetTrait(trait) is Trait traitInstance && traitInstance.Degree >= minDegree && traitInstance.Degree <= maxDegree);
 }
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.def == raceDef);
 }
示例#21
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(comp.TryGetJob(jobDef, out JobData data) && data.IsFullyLeveled);
 }
示例#22
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.records.GetValue(record) >= minimumRequiredAmount);
 }
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(research.IsFinished);
 }
示例#24
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(CountAddedParts(pawn) >= minAmount);
 }