Exemplo n.º 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);
        }
Exemplo n.º 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()));
     }
 }
Exemplo n.º 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()));
     }
 }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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());
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 13
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.records.GetValue(record) >= minimumRequiredAmount);
 }
Exemplo n.º 14
0
 public abstract bool CanTarget(Pawn targeter, DivineJobsComp jobsComp, LocalTargetInfo target);
Exemplo n.º 15
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(first.IsRequirementMet(def, comp, pawn) || second.IsRequirementMet(def, comp, pawn));
 }
Exemplo n.º 16
0
 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);
 }
Exemplo n.º 18
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(CountAddedParts(pawn) >= minAmount);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 22
0
 public override bool IsRequirementMet(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     return(pawn.skills.GetSkill(skill).Level >= minimumSkillRequired);
 }
Exemplo n.º 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));
 }
Exemplo n.º 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);
 }