Пример #1
0
        private Job TryGiveJobInt(Pawn pawn, Predicate <CompGatherSpot> gatherSpotValidator)
        {
            if (pawn.Map.gatherSpotLister.activeSpots.Count == 0)
            {
                return(null);
            }
            JoyGiver_SocialRelax.workingSpots.Clear();
            for (int i = 0; i < pawn.Map.gatherSpotLister.activeSpots.Count; i++)
            {
                JoyGiver_SocialRelax.workingSpots.Add(pawn.Map.gatherSpotLister.activeSpots[i]);
            }
            CompGatherSpot compGatherSpot;

            while (JoyGiver_SocialRelax.workingSpots.TryRandomElement(out compGatherSpot))
            {
                JoyGiver_SocialRelax.workingSpots.Remove(compGatherSpot);
                if (!compGatherSpot.parent.IsForbidden(pawn))
                {
                    if (pawn.CanReach(compGatherSpot.parent, PathEndMode.Touch, Danger.None, false, TraverseMode.ByPawn))
                    {
                        if (compGatherSpot.parent.IsSociallyProper(pawn))
                        {
                            if (compGatherSpot.parent.IsPoliticallyProper(pawn))
                            {
                                if (gatherSpotValidator == null || gatherSpotValidator(compGatherSpot))
                                {
                                    Job   job;
                                    Thing t2;
                                    if (compGatherSpot.parent.def.surfaceType == SurfaceType.Eat)
                                    {
                                        Thing t;
                                        if (!JoyGiver_SocialRelax.TryFindChairBesideTable(compGatherSpot.parent, pawn, out t))
                                        {
                                            return(null);
                                        }
                                        job = new Job(this.def.jobDef, compGatherSpot.parent, t);
                                    }
                                    else if (JoyGiver_SocialRelax.TryFindChairNear(compGatherSpot.parent.Position, pawn, out t2))
                                    {
                                        job = new Job(this.def.jobDef, compGatherSpot.parent, t2);
                                    }
                                    else
                                    {
                                        IntVec3 c;
                                        if (!JoyGiver_SocialRelax.TryFindSitSpotOnGroundNear(compGatherSpot.parent.Position, pawn, out c))
                                        {
                                            return(null);
                                        }
                                        job = new Job(this.def.jobDef, compGatherSpot.parent, c);
                                    }
                                    Thing thing;
                                    if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) && JoyGiver_SocialRelax.TryFindIngestibleToNurse(compGatherSpot.parent.Position, pawn, out thing))
                                    {
                                        job.targetC = thing;
                                        job.count   = Mathf.Min(thing.stackCount, thing.def.ingestible.maxNumToIngestAtOnce);
                                    }
                                    return(job);
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }
        private Job TryGiveJobInt(Pawn pawn, Predicate <CompGatherSpot> gatherSpotValidator)
        {
            if (pawn.Map.gatherSpotLister.activeSpots.Count == 0)
            {
                return(null);
            }
            JoyGiver_SocialRelax.workingSpots.Clear();
            for (int i = 0; i < pawn.Map.gatherSpotLister.activeSpots.Count; i++)
            {
                JoyGiver_SocialRelax.workingSpots.Add(pawn.Map.gatherSpotLister.activeSpots[i]);
            }
            goto IL_006c;
IL_0108:
            goto IL_006c;
IL_006c:
            CompGatherSpot compGatherSpot = default(CompGatherSpot);

            while (true)
            {
                if (!((IEnumerable <CompGatherSpot>)JoyGiver_SocialRelax.workingSpots).TryRandomElement <CompGatherSpot>(out compGatherSpot))
                {
                    return(null);
                }
                JoyGiver_SocialRelax.workingSpots.Remove(compGatherSpot);
                if (!compGatherSpot.parent.IsForbidden(pawn) && pawn.CanReach(compGatherSpot.parent, PathEndMode.Touch, Danger.None, false, TraverseMode.ByPawn) && compGatherSpot.parent.IsSociallyProper(pawn) && compGatherSpot.parent.IsPoliticallyProper(pawn))
                {
                    if (gatherSpotValidator == null)
                    {
                        break;
                    }
                    if (gatherSpotValidator(compGatherSpot))
                    {
                        break;
                    }
                }
            }
            Job job;

            if (compGatherSpot.parent.def.surfaceType == SurfaceType.Eat)
            {
                Thing t = default(Thing);
                if (JoyGiver_SocialRelax.TryFindChairBesideTable((Thing)compGatherSpot.parent, pawn, out t))
                {
                    job = new Job(base.def.jobDef, compGatherSpot.parent, t);
                    goto IL_01e6;
                }
                return(null);
            }
            Thing t2 = default(Thing);

            if (JoyGiver_SocialRelax.TryFindChairNear(compGatherSpot.parent.Position, pawn, out t2))
            {
                job = new Job(base.def.jobDef, compGatherSpot.parent, t2);
                goto IL_01e6;
            }
            IntVec3 c = default(IntVec3);

            if (JoyGiver_SocialRelax.TryFindSitSpotOnGroundNear(compGatherSpot.parent.Position, pawn, out c))
            {
                job = new Job(base.def.jobDef, compGatherSpot.parent, c);
                goto IL_01e6;
            }
            return(null);

IL_01e6:
            Thing thing = default(Thing);

            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) && JoyGiver_SocialRelax.TryFindIngestibleToNurse(compGatherSpot.parent.Position, pawn, out thing))
            {
                job.targetC = thing;
                job.count   = Mathf.Min(thing.stackCount, thing.def.ingestible.maxNumToIngestAtOnce);
            }
            return(job);
        }