Ejemplo n.º 1
0
 public static bool PawnMayEnjoyPlayingOutside(Pawn pawn)
 {
     if (PawnOrAnimalIsGoneOrIncapable(pawn))
     {
         return(false);
     }
     else if (pawn.MapHeld is null)
     {
         PetThemAll.Debug($"MapHeld is null: {pawn.ToStringSafe()}");
         return(false);  // impossible?
         //} else if (!pawn.IsColonist) {
         //   PetThemAll.Debug($"not a colonist: {pawn.ToStringSafe()}");
         //   return false;  // prisoners shouldn't be interacting with our pets
     }
     else if (!JoyUtility.EnjoyableOutsideNow(pawn))
     {
         PetThemAll.Debug($"doesn't want to have fun outside: {pawn.ToStringSafe()}");
         return(false);  // world's on fire?
     }
     else if (PawnUtility.WillSoonHaveBasicNeed(pawn))
     {
         PetThemAll.Debug($"will soon have basic need: {pawn.ToStringSafe()}");
         return(false);  // too sleepy or hungry
     }
     else
     {
         return(true);
     }
 }
        protected override Job TryGivePlayJob(Pawn pawn, Thing t)
        {
            if ((t as ThingWithComps).TryGetComp <CompMountable>().IsMounted&& !ToolsForHaulUtility.IsDriverOfThisVehicle(pawn, t))
            {
                return(null);
            }

            if (!(t as ThingWithComps).TryGetComp <CompRefuelable>().HasFuel)
            {
                return(null);
            }

            if (t.IsForbidden(Faction.OfPlayer))
            {
                return(null);
            }

            if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                return(null);
            }
            if (PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }
            Region reg;

            if (!CellFinder.TryFindClosestRegionWith(pawn.Position.GetRegion(), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), (Region r) => r.Room.PsychologicallyOutdoors && !r.IsForbiddenEntirely(pawn), 100, out reg))
            {
                return(null);
            }
            IntVec3 root;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, null, out root))
            {
                return(null);
            }
            List <IntVec3> list;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root, out list))
            {
                return(null);
            }
            Job job = new Job(this.def.jobDef, list[0])
            {
                targetQueueA = new List <TargetInfo>(),
                targetB      = t,
            };

            for (int i = 1; i < list.Count; i++)
            {
                job.targetQueueA.Add(list[i]);
            }

            job.locomotionUrgency = LocomotionUrgency.Jog;
            return(job);
        }
        // Token: 0x06000568 RID: 1384 RVA: 0x00035040 File Offset: 0x00033440
        public override Job TryGiveJob(Pawn pawn)
        {
            float HowMuchSnowIsThere = 0;

            if (pawn.Map.weatherManager.curWeather.snowRate > 0.0f)
            {
                HowMuchSnowIsThere = pawn.Map.weatherManager.curWeather.snowRate;
            }
            if (HowMuchSnowIsThere < 0.1f)
            {
                return(null);
            }
            if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                return(null);
            }
            if (PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }
            Predicate <IntVec3> cellValidator = (IntVec3 x) => !PawnUtility.KnownDangerAt(x, pawn.Map, pawn) && !x.GetTerrain(pawn.Map).avoidWander&& x.Standable(pawn.Map) && !x.Roofed(pawn.Map);
            Predicate <Region>  validator     = delegate(Region x)
            {
                IntVec3 intVec;
                return(x.Room.PsychologicallyOutdoors && !x.IsForbiddenEntirely(pawn) && x.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out intVec));
            };
            Region reg;

            if (!CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), validator, 100, out reg, RegionType.Set_Passable))
            {
                return(null);
            }
            IntVec3 root;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out root))
            {
                return(null);
            }
            List <IntVec3> list;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root, out list))
            {
                return(null);
            }
            Job job = new Job(this.def.jobDef, list[0]);

            job.targetQueueA = new List <LocalTargetInfo>();
            for (int i = 1; i < list.Count; i++)
            {
                job.targetQueueA.Add(list[i]);
            }
            job.locomotionUrgency = LocomotionUrgency.Walk;
            return(job);
        }
Ejemplo n.º 4
0
        public static bool IsHookupAppealing(Pawn target, Pawn w***e)
        {
            if (PawnUtility.WillSoonHaveBasicNeed(target))
            {
                //Log.Message("IsHookupAppealing - fail: " + xxx.get_pawnname(target) + " has need to do");
                return(false);
            }
            float num = target.relations.SecondaryRomanceChanceFactor(w***e) / 1.5f;

            if (xxx.is_frustrated(target))
            {
                num *= 3.0f;
            }
            else if (xxx.is_hornyorfrustrated(target))
            {
                num *= 2.0f;
            }
            if (xxx.is_zoophile(target) && !xxx.is_animal(w***e))
            {
                num *= 0.5f;
            }
            if (xxx.AlienFrameworkIsActive)
            {
                if (xxx.is_xenophile(target))
                {
                    if (target.def.defName == w***e.def.defName)
                    {
                        num *= 0.5f;                         // Same species, xenophile less interested.
                    }
                    else
                    {
                        num *= 1.5f;                         // Different species, xenophile more interested.
                    }
                }
                else if (xxx.is_xenophobe(target))
                {
                    if (target.def.defName != w***e.def.defName)
                    {
                        num *= 0.25f;                         // Different species, xenophobe less interested.
                    }
                }
            }

            num *= 0.8f + ((float)w***e.skills.GetSkill(SkillDefOf.Social).Level / 40);         // 0.8 to 1.3
            num *= Mathf.InverseLerp(-100f, 0f, target.relations.OpinionOf(w***e));             // 1 to 0 reduce score by negative opinion/relations to w***e
            //Log.Message("IsHookupAppealing - score: " + num);
            //Rand.PopState();
            //Rand.PushState(RJW_Multiplayer.PredictableSeed());
            return(Rand.Range(0.05f, 1f) < num);
        }
Ejemplo n.º 5
0
        public override Job TryGiveJob(Pawn pawn)
        {
            Log.Message("TryingToHostsermon");
            if (PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }
            if (Find.StoryWatcher.watcherDanger.DangerRating != StoryDanger.None)
            {
                return(null);
            }

            Job job = new Job(CorruptionDefOfs.HoldSermon, assignedAltar, assignedAltar.InteractionCell);

            BuildingAltar.GetSermonFlock(assignedAltar);
            return(job);
        }
Ejemplo n.º 6
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            //--Log.Message("[RJW] JobGiver_WhoreInvitingVisitors::TryGiveJob( " + pawn.NameStringShort + " ) called0");
            if (pawn == null || !InteractionUtility.CanInitiateInteraction(pawn))
            {
                return(null);
            }
            if (PawnUtility.WillSoonHaveBasicNeed(pawn) || !xxx.is_healthy(pawn) || !xxx.can_be_fucked(pawn))             //As long as pawns is older than minimum sex age, they can be assigned as w****s.
            {
                return(null);
            }

            if (Find.TickManager.TicksGame >= pawn.mindState.canLovinTick && pawn.CurJob == null)
            {
                int  price;
                Pawn pawn2 = FindAttractivePawn(pawn, out price);
                //--Log.Message("[RJW] JobGiver_WhoreInvitingVisitors::TryGiveJob( " + pawn.NameStringShort + " ) called1 - pawn2 is " + (pawn2 == null ? "NULL" : pawn2.NameStringShort));
                if (pawn2 == null)
                {
                    return(null);
                }
                Building_WhoreBed whorebed = xxx.FindWhoreBed(pawn);
                if ((whorebed == null) || !xxx.CanUse(pawn, whorebed) || (100f * Rand.Value) > percentRate)
                {
                    //--Log.Message("resetting ticks");
                    if (xxx.config.whores_always_findjob)
                    {
                        pawn.mindState.canLovinTick = Find.TickManager.TicksGame + 5;
                    }
                    else
                    {
                        pawn.mindState.canLovinTick = Find.TickManager.TicksGame + Rand.Range(75, 150);
                    }
                    return(null);
                }
                //--Log.Message("[RJW] JobGiver_WhoreInvitingVisitors::TryGiveJob( " + pawn.NameStringShort + " ) called2 - " + pawn2.NameStringShort + " is pawn2.");
                whorebed.priceOfWhore = price;
                return(new Job(xxx.inviting_visitors, pawn2, whorebed));
            }
            return(null);
        }
        public override Job TryGiveJob(Pawn pawn)
        {
            if (PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }
            Predicate <IntVec3> cellValidator = (IntVec3 x) => !PawnUtility.KnownDangerAt(x, pawn.Map, pawn) && !x.GetTerrain(pawn.Map).avoidWander&& x.Standable(pawn.Map) && x.SupportsStructureType(pawn.Map, TerrainAffordanceDefOf.Diggable);
            Predicate <Region>  validator     = delegate(Region x)
            {
                IntVec3 intVec;
                return(!x.IsForbiddenEntirely(pawn) && x.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out intVec));
            };
            Region reg;

            if (!CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), validator, 500, out reg, RegionType.Set_Passable))
            {
                return(null);
            }
            IntVec3 root;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out root))
            {
                return(null);
            }
            List <IntVec3> list;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root, out list))
            {
                return(null);
            }
            Job job = new Job(this.def.jobDef, list[0]);

            job.targetQueueA = new List <LocalTargetInfo>();
            job.targetQueueA.Add(list[0]);
            job.locomotionUrgency = LocomotionUrgency.Walk;
            return(job);
        }
Ejemplo n.º 8
0
        public static bool AnimalIsGood(Pawn animal)
        {
            if (PawnOrAnimalIsGoneOrIncapable(animal))
            {
                return(false);
            }
            else if (!AnimalRaceIsGood(animal))
            {
                return(false);
            }
            else if (PawnUtility.WillSoonHaveBasicNeed(animal))
            {
                PetThemAll.Debug($"will soon have basic need: {animal.ToStringSafe()}");
                return(false);  // too hungry or sleepy
            }
            else if (TimetableUtility.GetTimeAssignment(animal) != TimeAssignmentDefOf.Anything)
            {
                PetThemAll.Debug($"it's time to sleep: {animal.ToStringSafe()}");
                return(false);  // should be sleeping (working is impossible)
            }
            else if (animal.carryTracker?.CarriedThing != null)
            {
                PetThemAll.Debug($"currently hauling something: {animal.ToStringSafe()}");
                return(false);  // animal is carrying something, i.e. working
            }

            var mindState = animal.mindState;

            if (mindState is null || !mindState.IsIdle)
            {
                PetThemAll.Debug($"not idle: {animal.ToStringSafe()}");
                return(false);  // working
            }

            return(true);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Tries to give a job to the given pawn.
        /// </summary>
        /// <param name="pawn">The pawn.</param>
        /// <returns></returns>
        public override Job TryGiveJob(Pawn pawn)
        {
            if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                return(null);
            }
            if (PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }


            if (!def.IsValidFor(pawn))
            {
                return(null);
            }


            var allProductionComps = pawn.health.hediffSet.hediffs.Select(h => h.TryGetComp <Comp_TerrainProduction>()?.Props)
                                     .Where(p => p != null)
                                     .ToList();

            if (allProductionComps.Count == 0)
            {
                return(null);
            }

            bool IsValidCell(IntVec3 cell)
            {
                if (PawnUtility.KnownDangerAt(cell, pawn.Map, pawn))
                {
                    return(false);
                }
                var terrain = cell.GetTerrain(pawn.Map);

                if (terrain == null)
                {
                    return(false);
                }
                if (!allProductionComps.Any(p => p.CanProduceOn(terrain)))
                {
                    return(false);
                }
                return(cell.Standable(pawn.Map));
            }

            bool IsValidRegion(Region region)
            {
                if (region.IsForbiddenEntirely(pawn))
                {
                    return(false);
                }
                return(region.TryFindRandomCellInRegionUnforbidden(pawn, IsValidCell, out IntVec3 _));
            }

            if (!CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable),
                                                     TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn), IsValidRegion,
                                                     100, out Region reg, RegionType.Set_Passable))
            {
                return(null);
            }

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, IsValidCell, out IntVec3 root))
            {
                return(null);
            }

            if (!WalkPathFinder.TryFindWalkPath(pawn, root, out var result))
            {
                return(null);
            }

            Job job = new Job(def.jobDef, result[0])
            {
                targetQueueA = new List <LocalTargetInfo>()
            };

            for (int i = 1; i < result.Count; i++)
            {
                job.targetQueueA.Add(result[i]);
            }

            job.locomotionUrgency = LocomotionUrgency.Walk;
            return(job);
        }
Ejemplo n.º 10
0
 public static void TickRare_PostFix(Pawn __instance)
 {
     if (__instance.Spawned && __instance.IsFreeColonist)
     {
         if (ThingCompUtility.TryGetComp <Ammunition_Comp>(__instance).FetchAmmo&& __instance.jobs.curJob.def.casualInterruptible && !__instance.jobs.curJob.playerForced && !__instance.IsFighting() && !(__instance.jobs.curJob.def == RimWorld.JobDefOf.Hunt) && !PawnUtility.WillSoonHaveBasicNeed(__instance))
         {
             Utility.AmmoCheck(__instance, out List <ThingDef> ammo);
             if (ammo.Count > 0)
             {
                 foreach (ThingDef a in ammo)
                 {
                     Utility.FetchAmmo(__instance, a);
                 }
             }
         }
     }
 }
        // Token: 0x06000568 RID: 1384 RVA: 0x00035040 File Offset: 0x00033440
        public override Job TryGiveJob(Pawn pawn)
        {
            string IsCurrentWeatherClear = "Null";

            if (pawn.Map.weatherManager.curWeather != null)
            {
                IsCurrentWeatherClear = pawn.Map.weatherManager.curWeather.ToString();
            }
            if (IsCurrentWeatherClear != "Clear")
            {
                return(null);
            }
            float CurrentCelestialGlow = GenCelestial.CurCelestialSunGlow(pawn.Map);

            if (CurrentCelestialGlow <= 0.4f)
            {
                return(null);
            }

            /*
             * if (GenLocalDate.DayPercent(pawn.Map) < 0.5f)
             * {
             *  return null;
             * }
             */
            if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                return(null);
            }
            if (PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }
            Predicate <IntVec3> cellValidator = (IntVec3 x) => !PawnUtility.KnownDangerAt(x, pawn.Map, pawn) && !x.GetTerrain(pawn.Map).avoidWander&& x.Standable(pawn.Map) && !x.Roofed(pawn.Map);
            Predicate <Region>  validator     = delegate(Region x)
            {
                IntVec3 intVec;
                return(x.Room.PsychologicallyOutdoors && !x.IsForbiddenEntirely(pawn) && x.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out intVec));
            };
            Region reg;

            if (!CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), validator, 100, out reg, RegionType.Set_Passable))
            {
                return(null);
            }
            IntVec3 root;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out root))
            {
                return(null);
            }
            List <IntVec3> list;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root, out list))
            {
                return(null);
            }
            Job job = new Job(this.def.jobDef, list[0]);

            job.targetQueueA = new List <LocalTargetInfo>();
            for (int i = 1; i < list.Count; i++)
            {
                job.targetQueueA.Add(list[i]);
            }
            job.locomotionUrgency = LocomotionUrgency.Walk;
            return(job);
        }
        public override Job TryGiveJob(Pawn pawn)
        {
            if (PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }
            Predicate <IntVec3> cellValidator = (IntVec3 x) => !PawnUtility.KnownDangerAt(x, pawn.Map, pawn) && !x.GetTerrain(pawn.Map).avoidWander&& x.Standable(pawn.Map) && x.CloseToEdge(pawn.Map, 5);
            Predicate <Region>  validator     = delegate(Region x)
            {
                IntVec3 intVec;
                return(x.Room.PsychologicallyOutdoors && x.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out intVec));
            };
            Region reg;

            if (!CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), validator, 500, out reg, RegionType.Set_Passable))
            {
                return(null);
            }
            IntVec3 root;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out root))
            {
                return(null);
            }
            List <IntVec3> list;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root, out list))
            {
                return(null);
            }
            IntVec3 root2;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out root2))
            {
                return(null);
            }
            List <IntVec3> list2;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root2, out list2))
            {
                return(null);
            }
            IntVec3 root4;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out root4))
            {
                return(null);
            }
            List <IntVec3> list4;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root4, out list4))
            {
                return(null);
            }
            IntVec3 root5;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out root5))
            {
                return(null);
            }
            List <IntVec3> list5;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root4, out list5))
            {
                return(null);
            }
            Job job = new Job(this.def.jobDef, list[0]);

            job.targetQueueA = new List <LocalTargetInfo>();
            //can't figure out how to get hte pawn to wait so this has them sit for an extra tick. sadly not more than that.
            list[1] = list[0];
            list[2] = list2[0];
            list[3] = list2[0];
            list[4] = list4[0];
            list[5] = list4[0];
            list[6] = list5[0];
            list[7] = list5[0];
            job.targetQueueA.Add(list[0]);
            job.targetQueueA.Add(list[1]);
            job.targetQueueA.Add(list[2]);
            job.targetQueueA.Add(list[3]);
            job.targetQueueA.Add(list[4]);
            job.targetQueueA.Add(list[5]);
            job.targetQueueA.Add(list[6]);
            job.targetQueueA.Add(list[7]);

            /* adding this made htem go back to the start again. its intersting. still nots rue how this translates to wandering only in water
             * for (int i = 1; i < list.Count; i++)
             * {
             *  job.targetQueueA.Add(list[i]);
             * }
             */
            job.locomotionUrgency = LocomotionUrgency.Sprint;
            return(job);
        }
Ejemplo n.º 13
0
        public override Job TryGiveJob(Pawn pawn)
        {
            Map mapHeld = pawn.MapHeld;

            if (mapHeld == null || !ModSettings_WaterIsCold.funWater || !JoyUtility.EnjoyableOutsideNow(mapHeld, null) || PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }
            //Log.Message(pawn.Name + "is looking for a swimming hole near " + pawn.Position.x + ", " + pawn.Position.z);
            IntVec3 swimSpot;
            IntVec3 shoreSpot;
            IntVec3 wadeSpot = FindRandomSwimmingHoleNear(pawn.Position, mapHeld, pawn, out swimSpot, out shoreSpot);

            if (shoreSpot == wadeSpot)
            {
                return(null);
            }
            return(JobMaker.MakeJob(this.def.jobDef, shoreSpot, wadeSpot, swimSpot));
        }
Ejemplo n.º 14
0
        public static bool AmmoCheck(Pawn pawn, out ThingDef ammoType)
        {
            bool needAmmo = false;

            ammoType = null;
            if (pawn.CanCasuallyInteractNow() && !pawn.IsFighting() && !pawn.jobs.curJob.playerForced && !PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                ammoType = WeaponCheck(pawn);
                if (ammoType != null)
                {
                    int count = AmmoCount(pawn, ammoType) + SettingsHelper.LatestVersion.LeastAmmoFetch;
                    if (count < SettingsHelper.LatestVersion.DesiredAmmo)
                    {
                        needAmmo = true;
                    }
                }
            }
            return(needAmmo);
        }