public static bool PrisonerCaresAboutForbidden(Pawn pawn, bool cellTarget)
 {
     if (!pawn.Spawned || !pawn.IsPrisonerOfColony && pawn.timetable.CurrentAssignment != TimeAssignmentDefOf.Work)
     {
         return(false);
     }
     if (pawn.InMentalState)
     {
         return(false);
     }
     if (cellTarget && ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn))
     {
         return(false);
     }
     return(true);
 }
        public static bool set_Master(Pawn_PlayerSettings __instance, Pawn value)
        {
            if (__instance.master == value)
            {
                return(false);
            }

            if (petsInit == false)
            {
                RebuildPetsDictionary();
            }

            bool flag = ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(__instance.pawn);

            if (__instance.master != null)
            {
                if (pets.TryGetValue(__instance.master, out List <Pawn> pawnList2))
                {
                    pawnList2.Remove(__instance.pawn);
                }
            }
            __instance.master = null;
            if (!__instance.pawn.training.HasLearned(TrainableDefOf.Obedience))
            {
                Log.ErrorOnce("Attempted to set master for non-obedient pawn", 73908573);
                return(false);
            }
            __instance.master = value;
            if (value != null)
            {
                if (!pets.TryGetValue(value, out List <Pawn> pawnList))
                {
                    pawnList = new List <Pawn>();
                    lock (pets)
                    {
                        pets[value] = pawnList;
                    }
                }
                pawnList.Add(__instance.pawn);
            }

            if (__instance.pawn.Spawned && (flag || ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(__instance.pawn)))
            {
                __instance.pawn.jobs.EndCurrentJob(JobCondition.InterruptForced);
            }
            return(false);
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            Job result;

            if (pawn.playerSettings != null && pawn.playerSettings.UsesConfigurableHostilityResponse)
            {
                result = null;
            }
            else if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn))
            {
                result = null;
            }
            else
            {
                if (pawn.Faction == null)
                {
                    List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.AlwaysFlee);
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (pawn.Position.InHorDistOf(list[i].Position, 18f) && SelfDefenseUtility.ShouldFleeFrom(list[i], pawn, false, false))
                        {
                            return(ReturnToStationJob((Pawn_Drone)pawn));
                        }
                    }
                    Job job2 = FleeLargeFireJob(pawn);
                    if (job2 != null)
                    {
                        return(job2);
                    }
                }
                else if (pawn.GetLord() == null)
                {
                    List <IAttackTarget> potentialTargetsFor = pawn.Map.attackTargetsCache.GetPotentialTargetsFor(pawn);
                    for (int j = 0; j < potentialTargetsFor.Count; j++)
                    {
                        Thing thing = potentialTargetsFor[j].Thing;
                        if (pawn.Position.InHorDistOf(thing.Position, 18f) && SelfDefenseUtility.ShouldFleeFrom(thing, pawn, false, true))
                        {
                            return(ReturnToStationJob((Pawn_Drone)pawn));
                        }
                    }
                }
                result = null;
            }
            return(result);
        }
Beispiel #4
0
    protected override Job TryGiveJob(Pawn pawn)
    {
        if (!Settings.doAnimalFlee)
        {
            return(null);
        }

        if (!pawn.AnimalOrWildMan())
        {
            return(null);
        }

        if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn))
        {
            return(null);
        }

        if (pawn.GetLord() != null || pawn.Faction == Faction.OfPlayer && pawn.Map.IsPlayerHome ||
            pawn.CurJob != null)
        {
            return(null);
        }

        var Plantlist = pawn.Map.listerThings.ThingsOfDef(ThingDef.Named("Plant_USStinkroot"));

        foreach (var thing in Plantlist)
        {
            var plantchk = thing as Plant;
            if (plantchk?.def.defName != "Plant_USStinkroot" ||
                !((plantchk.Position - pawn.Position).LengthHorizontal <= 5f))
            {
                continue;
            }

            var fleeplant = FleeJob(pawn, plantchk);
            if (fleeplant != null)
            {
                return(fleeplant);
            }
        }

        return(null);
    }
Beispiel #5
0
    protected override Job TryGiveJob(Pawn pawn)
    {
        if (!Settings.UseBrrr || !Settings.ApplyAnimals)
        {
            return(null);
        }

        if (pawn?.Map == null)
        {
            return(null);
        }

        if (!pawn.AnimalOrWildMan() || pawn.IsWildMan())
        {
            return(null);
        }

        if (pawn.Faction == null)
        {
            return(null);
        }

        if (pawn.Faction != Faction.OfPlayer)
        {
            return(null);
        }

        if (pawn.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted&&
            pawn.training.HasLearned(TrainableDefOf.Obedience) &&
            ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn))
        {
            return(null);
        }

        if (pawn.InMentalState)
        {
            return(null);
        }

        var needs = pawn.needs;

        if (needs?.food != null && pawn.needs.food.CurLevelPercentage < pawn.needs.food.PercentageThreshHungry)
        {
            return(null);
        }

        if (RestUtility.DisturbancePreventsLyingDown(pawn))
        {
            return(null);
        }

        if (pawn.CurJobDef == BrrrJobDef.Brrr_BrrrRecovery || pawn.CurJobDef == BrrrJobDef.Brrr_GaspRecovery ||
            pawn.CurJobDef == BrrrJobDef.Brrr_PhewRecovery || pawn.CurJobDef == BrrrJobDef.Brrr_YukRecovery)
        {
            return(null);
        }

        if (!pawn.health.hediffSet.HasHediff(HediffDefOf.Hypothermia))
        {
            return(null);
        }

        var HedHypo = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Hypothermia);

        if (HedHypo == null || !(HedHypo.Severity >= Settings.UnsafeBrrrSev / 100f))
        {
            return(null);
        }

        Thing BrrrBed = null;
        var   FindBed = RestUtility.FindBedFor(pawn, pawn, false, true);

        if (FindBed != null && !FindBed.GetRoom().PsychologicallyOutdoors&&
            pawn.ComfortableTemperatureRange().Includes(FindBed.GetRoom().Temperature))
        {
            BrrrBed = FindBed;
        }

        if (BrrrBed != null)
        {
            return(new Job(BrrrJobDef.Brrr_BrrrRecovery, BrrrBed));
        }

        var tempRange = pawn.ComfortableTemperatureRange();
        var region    = BrrrGlobals.BrrrClosestRegionWithinTemperatureRange(pawn.Position, pawn.Map, tempRange,
                                                                            TraverseParms.For(pawn));

        if (region != null)
        {
            return(BrrrGlobals.GenNewRRJob(BrrrJobDef.Brrr_BrrrRecovery, region));
        }

        return(null);
    }
 private static bool CanStartFleeingBecauseOfPawnAction(Pawn p)
 {
     return(p.RaceProps.Animal && !p.InMentalState && !p.IsFighting() && !p.Downed && !p.Dead && !ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(p));
 }
Beispiel #7
0
 public static bool Replacement(ref bool __result, Pawn pawn, bool cellTarget)
 {
     __result = !pawn.InMentalState && AddedFactionCheck(pawn) &&
                (!cellTarget || !ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn));
     return(false);
 }
 public static bool Replacement(ref bool __result, Pawn pawn, bool cellTarget)
 {
     // I have split up the original check to make some sense of it. Still doesn't make any sense.
     __result = CrazyRimWorldCheck(pawn) && !pawn.InMentalState && (!cellTarget || !ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn));
     return(false);
 }
Beispiel #9
0
 private static bool CanStartFleeingBecauseOfPawnAction(Pawn p)
 {
     if (p.RaceProps.Animal && !p.InMentalState && !p.IsFighting() && !p.Downed && !p.Dead && !ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(p))
     {
         if (p.jobs.curJob != null && p.jobs.curJob.def == JobDefOf.Flee)
         {
             return(p.jobs.curJob.startTick != Find.TickManager.TicksGame);
         }
         return(true);
     }
     return(false);
 }
    protected override Job TryGiveJob(Pawn pawn)
    {
        if (!Settings.UseYuk || !Settings.ApplyAnimals)
        {
            return(null);
        }

        if (pawn?.Map == null)
        {
            return(null);
        }

        if (!pawn.AnimalOrWildMan() || pawn.IsWildMan())
        {
            return(null);
        }

        if (pawn.Faction == null)
        {
            return(null);
        }

        if (pawn.Faction != Faction.OfPlayer)
        {
            return(null);
        }

        if (pawn.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted&&
            pawn.training.HasLearned(TrainableDefOf.Obedience) &&
            ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn))
        {
            return(null);
        }

        if (pawn.InMentalState)
        {
            return(null);
        }

        var needs = pawn.needs;

        if (needs?.food != null && pawn.needs.food.CurLevelPercentage < pawn.needs.food.PercentageThreshHungry)
        {
            return(null);
        }

        if (RestUtility.DisturbancePreventsLyingDown(pawn))
        {
            return(null);
        }

        if (pawn.CurJobDef == BrrrJobDef.Brrr_BrrrRecovery || pawn.CurJobDef == BrrrJobDef.Brrr_GaspRecovery ||
            pawn.CurJobDef == BrrrJobDef.Brrr_PhewRecovery || pawn.CurJobDef == BrrrJobDef.Brrr_YukRecovery)
        {
            return(null);
        }

        if (!pawn.health.hediffSet.HasHediff(HediffDefOf.ToxicBuildup))
        {
            return(null);
        }

        var HedTox = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.ToxicBuildup);

        if (HedTox == null || HedTox.Severity < Settings.UnsafeYukSev / 100f)
        {
            return(null);
        }

        Thing BrrrBed = null;
        var   FindBed = RestUtility.FindBedFor(pawn, pawn, false, true);

        if (FindBed != null && FindBed.Position.Roofed(pawn.Map) &&
            pawn.ComfortableTemperatureRange().Includes(FindBed.GetRoom().Temperature))
        {
            BrrrBed = FindBed;
        }

        if (BrrrBed != null)
        {
            return(new Job(BrrrJobDef.Brrr_YukRecovery, BrrrBed));
        }

        var tempRange = pawn.ComfortableTemperatureRange();
        var SafeCell  = BrrrGlobals.GetNearestSafeRoofedCell(pawn, pawn.Position, pawn.Map, tempRange);

        return(new Job(BrrrJobDef.Brrr_YukRecovery, SafeCell));
    }