コード例 #1
0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            Lord lord = pawn.GetLord();

            if (lord == null)
            {
                if (!pawn.Awake())
                {
                    return(wanderJobGiver.TryIssueJobPackage(pawn, new JobIssueParams()));
                }

                if (pawn.needs?.food?.Starving ?? false)
                {
                    return(wanderJobGiver.TryIssueJobPackage(pawn, new JobIssueParams()));
                }

                if (pawn.story == null)
                {
                    return(wanderJobGiver.TryIssueJobPackage(pawn, new JobIssueParams()));
                }

                IdleJobGiverBase jobGiver = null;
                this.JobGivers.TryRandomElementByWeight((IdleJobGiverBase x) => x.GetWeight(pawn, pawn.story.traits.GetTrait(TraitDefOf.Industriousness)), out jobGiver);
                if (jobGiver != null)
                {
                    Job job = jobGiver.TryGiveJob(pawn);
                    if (job != null)
                    {
#if DEBUG
                        Log.Message(string.Format("idle job {0} to {1}", jobGiver.GetType().Name, pawn.Name));
#endif
                        return(new ThinkResult(job, this, null, false));
                    }
#if DEBUG
                    else
                    {
                        Log.Message(string.Format("idle job {0} to {1} but job is null", jobGiver.GetType().Name, pawn.Name));
                    }
#endif
                }
            }

            return(wanderJobGiver.TryIssueJobPackage(pawn, new JobIssueParams()));
        }
コード例 #2
0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            Lord lord = pawn.GetLord();

            if (lord == null)
            {
                IdleJobGiverBase jobGiver = null;
                this.JobGivers.TryRandomElementByWeight((IdleJobGiverBase x) => x.GetWeight(pawn, pawn.story.traits.GetTrait(TraitDefOf.Industriousness)), out jobGiver);
                if (jobGiver != null)
                {
                    Job job = jobGiver.TryGiveJob(pawn);
                    if (job != null)
                    {
                        return(new ThinkResult(job, this, null, false));
                    }
                }
            }

            return(wanderJobGiver.TryIssueJobPackage(pawn, new JobIssueParams()));
        }