private Thing FindClosestAltar(Pawn pawn, int MaxParticipants)
        {
            var altars = Find.ListerBuildings
                         .AllBuildingsColonistOfClass <BuildingAltar>()
                         .Where(altar => (
                                    (
                                        (!altar.def.socialPropernessMatters) ||
                                        (SocialProperness.IsSociallyProper(altar, pawn))
                                    ) &&
                                    (pawn.CanReserveAndReach(altar, PathEndMode.Touch, pawn.NormalMaxDanger(), MaxParticipants))
                                    )).ToList();

            if (altars.NullOrEmpty())
            {
                return(null);
            }
            altars.Sort((x, y) =>
            {
                var distX = (x.Position - pawn.Position).LengthManhattan;
                var distY = (y.Position - pawn.Position).LengthManhattan;
                return(distX < distY
                        ? -1
                        : 1);
            });
            return(altars[0]);
        }
Exemplo n.º 2
0
        public Job TryGiveJob(Pawn pawn, Thing targetThing, bool NoJoyCheck = false)
        {
            Verb verb = null;

            if (pawn != null)
            {
                verb = pawn.meleeVerbs.TryGetMeleeVerb(targetThing);
            }
            Job result;

            if (pawn.WorkTagIsDisabled(WorkTags.Violent) || verb == null || verb.verbProps == null)
            {
                result = null;
            }
            else
            {
                List <Thing>      list      = pawn.Map.listerThings.ThingsOfDef(this.def.thingDefs[0]);
                Predicate <Thing> predicate = delegate(Thing t)
                {
                    return(!ForbidUtility.IsForbidden(t, pawn) &&
                           ReservationUtility.CanReserve(pawn, t, this.def.jobDef.joyMaxParticipants, -1, null, false) &&
                           SocialProperness.IsSociallyProper(t, pawn));
                };
                Thing thing = null;
                if (targetThing != null && ReachabilityUtility.CanReach(pawn, targetThing.Position, PathEndMode.InteractionCell, Danger.Deadly, false, 0) && predicate(targetThing))
                {
                    thing = targetThing;
                }
                else if (targetThing == null)
                {
                    thing = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, list, PathEndMode.InteractionCell, TraverseParms.For(pawn, Danger.Deadly, 0, false), 9999f, predicate, null);
                }
                if (thing != null)
                {
                    Job job = JobMaker.MakeJob(this.def.jobDef, thing);
                    return(job);
                }
                result = null;
            }
            return(result);
        }
Exemplo n.º 3
0
 // Token: 0x0600004F RID: 79 RVA: 0x00005498 File Offset: 0x00003698
 private static bool DrugValidator(Pawn pawn, Thing drug)
 {
     if (!drug.def.IsDrug)
     {
         return(false);
     }
     if (!pawn.IsPrisoner && drug.Spawned)
     {
         if (ForbidUtility.IsForbidden(drug, pawn))
         {
             return(false);
         }
         if (!ReservationUtility.CanReserve(pawn, drug, 1, -1, null, false))
         {
             return(false);
         }
         if (!SocialProperness.IsSociallyProper(drug, pawn))
         {
             return(false);
         }
     }
     return(true);
 }