public void RegisterActivated(CompGatherSpot spot)
 {
     if (!this.activeSpots.Contains(spot))
     {
         this.activeSpots.Add(spot);
     }
 }
 public void RegisterDeactivated(CompGatherSpot spot)
 {
     if (this.activeSpots.Contains(spot))
     {
         this.activeSpots.Remove(spot);
     }
 }
Example #3
0
 internal bool <> m__0(CompGatherSpot x)
 {
     return(PartyUtility.InPartyArea(x.parent.Position, this.partySpot, this.pawn.Map));
 }
        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);
        }