예제 #1
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 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);
        }
예제 #3
0
        public JobData TryGetTaggedJob(DivineJobsComp comp)
        {
            JobData result;

            comp.TryGetJob(job => job.def.tags.Contains(tag), out result);
            return(result);
        }
        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);
        }
 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()));
     }
 }
예제 #6
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()));
     }
 }
예제 #7
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));
     }
 }
예제 #8
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));
            }
        }
예제 #9
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);
            }
        }
        public override bool CanTarget(Pawn targeter, DivineJobsComp jobsComp, LocalTargetInfo target)
        {
            if (targetAnywhere)
            {
                return(true);
            }

            if (targetPawn)
            {
                if (target.Thing is Pawn pawn)
                {
                    if (targetSelf && pawn == targeter)
                    {
                        return(true);
                    }

                    if (pawn.HostileTo(targeter))
                    {
                        return(targetEnemy);
                    }
                    else
                    {
                        return(targetFriendly);
                    }
                }
            }

            if (targetBuilding)
            {
                if (target.Thing is Building building)
                {
                    if (building.HostileTo(targeter))
                    {
                        return(targetEnemy);
                    }
                    else
                    {
                        return(targetFriendly);
                    }
                }
            }

            return(false);
        }
예제 #11
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());
        }
예제 #12
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));
            }
        }
예제 #13
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.records.GetValue(record) >= minimumRequiredAmount);
 }
예제 #14
0
 public abstract bool CanTarget(Pawn targeter, DivineJobsComp jobsComp, LocalTargetInfo target);
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(first.IsRequirementMet(def, comp, pawn) || second.IsRequirementMet(def, comp, pawn));
 }
 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 LocalTargetInfo FindTargetForAI(Pawn targeter, DivineJobsComp jobsComp)
 {
     //Find the closest target. Priorotise targets it can see.
     return(LocalTargetInfo.Invalid);
 }
예제 #18
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(CountAddedParts(pawn) >= minAmount);
 }
예제 #19
0
        public static JobResource MakeResourceInstance(DivineJobResourceDef def, Pawn owner = null, DivineJobsComp comp = null)
        {
            JobResource instance = (JobResource)Activator.CreateInstance(def.resourceClass);

            instance.def      = def;
            instance.owner    = owner;
            instance.jobsComp = comp;
            instance.PostMake();
            return(instance);
        }
예제 #20
0
        public static AbilityData MakeAbilityInstance(DivineAbilityDef def, Pawn owner = null, DivineJobsComp comp = null)
        {
            AbilityData instance = (AbilityData)Activator.CreateInstance(def.abilityClass);

            instance.def      = def;
            instance.owner    = owner;
            instance.jobsComp = comp;
            instance.PostMake();
            return(instance);
        }
 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);
 }
예제 #22
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.skills.GetSkill(skill).Level >= minimumSkillRequired);
 }
예제 #23
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(comp.TryGetJob(jobDef, out JobData data) && data.IsFullyLeveled);
 }
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.health.hediffSet.HasHediff(hediffDef));
 }
예제 #25
0
 public abstract LocalTargetInfo FindTargetForAI(Pawn targeter, DivineJobsComp jobsComp);
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.def == raceDef);
 }
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(research.IsFinished);
 }