Exemple #1
0
    protected override IEnumerable <Toil> MakeNewToils()
    {
        yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell));

        var gaze = new Toil
        {
            initAction          = delegate { pawn.jobs.posture = PawnPosture.LayingOnGroundFaceUp; },
            tickAction          = delegate { BrrrGlobals.JoyTickOohCheckEnd(pawn); },
            defaultCompleteMode = ToilCompleteMode.Delay,
            defaultDuration     = job.def.joyDuration
        };

        gaze.FailOn(() => pawn.Position.Roofed(pawn.Map));
        gaze.AddFailCondition(delegate
        {
            var actor = gaze.actor;
            var needs = actor.needs;
            if (needs?.food == null)
            {
                return(false);
            }

            var needs2 = actor.needs;
            var num    = needs2 != null ? new float?(needs2.food.CurLevelPercentage) : null;
            var percentageThreshHungry = actor.needs.food.PercentageThreshHungry;
            if ((num.GetValueOrDefault() < percentageThreshHungry) & (num != null))
            {
                return(true);
            }

            return(false);
        });
        yield return(gaze);
    }
 protected override bool Satisfied(Pawn pawn)
 {
     return(Settings.UseGasp && Settings.ApplyAnimals && pawn.AnimalOrWildMan() && !pawn.IsWildMan() &&
            pawn.Faction != null && pawn.Faction == Faction.OfPlayer && !pawn.Downed && !pawn.IsBurning() &&
            pawn.Awake() && !pawn.InMentalState && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Moving) &&
            !HealthAIUtility.ShouldSeekMedicalRest(pawn) && !BrrrGlobals.BrrrAnimalIsFollowing(pawn));
 }
    protected override IEnumerable <Toil> MakeNewToils()
    {
        var goToil = Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell);

        goToil.tickAction = delegate
        {
            if (Find.TickManager.TicksGame > startTick + job.def.joyDuration)
            {
                EndJobWith(JobCondition.Succeeded);
                return;
            }

            BrrrGlobals.JoyTickOohCheckEnd(pawn);
        };
        goToil.AddFailCondition(delegate
        {
            var actor = goToil.actor;
            var needs = actor.needs;
            return(needs?.food != null &&
                   actor.needs.food.CurLevelPercentage < actor.needs.food.PercentageThreshHungry);
        });
        yield return(goToil);

        yield return(new Toil
        {
            initAction = delegate
            {
                if (job.targetQueueA.Count <= 0)
                {
                    return;
                }

                var targetA = job.targetQueueA[0];
                job.targetQueueA.RemoveAt(0);
                job.targetA = targetA;
                JumpToToil(goToil);
            }
        });
    }
Exemple #4
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);
    }
Exemple #5
0
    protected override Job TryGiveJob(Pawn pawn)
    {
        if (!Settings.UseBrrr || !pawn.IsColonistPlayerControlled)
        {
            return(null);
        }

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

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

        var needs = pawn.needs;

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

        var needs2 = pawn.needs;

        if (needs2?.joy != null && pawn.needs.joy.CurLevelPercentage < Settings.JoySev / 100f && Settings.AllowJoy)
        {
            return(null);
        }

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

        if (pawn.CurJobDef == BrrrJobDef.Brrr_BrrrRecovery || pawn.CurJobDef == BrrrJobDef.Brrr_GaspRecovery ||
            pawn.CurJobDef == BrrrJobDef.Brrr_Skygaze || pawn.CurJobDef == BrrrJobDef.Brrr_GoForWalk ||
            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;
        Thing FindBed = Settings.AllowUnsafeAreas
            ? RestUtility.FindBedFor(pawn)
            : 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);
    }
Exemple #6
0
    protected override Job TryGiveJob(Pawn pawn)
    {
        if (!Settings.UseYuk || !pawn.IsColonistPlayerControlled)
        {
            return(null);
        }

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

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

        var needs = pawn.needs;

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

        var needs2 = pawn.needs;

        if (needs2?.joy != null && pawn.needs.joy.CurLevelPercentage < Settings.JoySev / 100f && Settings.AllowJoy)
        {
            return(null);
        }

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

        if (pawn.CurJobDef == BrrrJobDef.Brrr_BrrrRecovery || pawn.CurJobDef == BrrrJobDef.Brrr_GaspRecovery ||
            pawn.CurJobDef == BrrrJobDef.Brrr_Skygaze || pawn.CurJobDef == BrrrJobDef.Brrr_GoForWalk ||
            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 YukBed  = null;
        Thing FindBed = Settings.AllowUnsafeAreas
            ? RestUtility.FindBedFor(pawn)
            : RestUtility.FindBedFor(pawn, pawn, false, true);

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

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

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

        return(new Job(BrrrJobDef.Brrr_YukRecovery, SafeCell));
    }
    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));
    }
Exemple #8
0
    protected override Job TryGiveJob(Pawn pawn)
    {
        if (!Settings.UseOoh || !pawn.IsColonistPlayerControlled)
        {
            return(null);
        }

        var needs = pawn.needs;

        if (needs?.outdoors == null)
        {
            return(null);
        }

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

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

        var needs2 = pawn.needs;

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

        var needs3 = pawn.needs;

        if (needs3?.joy != null && pawn.needs.joy.CurLevelPercentage < Settings.JoySev / 100f && Settings.AllowJoy)
        {
            return(null);
        }

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

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

        if (pawn.needs.outdoors.CurLevelPercentage > Settings.OohSev / 100f)
        {
            return(null);
        }

        if (Settings.UseBrrr)
        {
            var health  = pawn.health;
            var HedHypo = health?.hediffSet.GetFirstHediffOfDef(HediffDefOf.Hypothermia);
            if (HedHypo != null && HedHypo.Severity >= Settings.UnsafeBrrrSev / 100f)
            {
                return(null);
            }
        }

        if (Settings.UsePhew)
        {
            var health2 = pawn.health;
            var HedHeat = health2?.hediffSet.GetFirstHediffOfDef(HediffDefOf.Heatstroke);
            if (HedHeat != null && HedHeat.Severity >= Settings.UnsafePhewSev / 100f)
            {
                return(null);
            }
        }

        if (Settings.UseYuk)
        {
            var health3 = pawn.health;
            var HedYuk  = health3?.hediffSet.GetFirstHediffOfDef(HediffDefOf.ToxicBuildup);
            if (HedYuk != null && HedYuk.Severity >= Settings.UnsafeYukSev / 100f)
            {
                return(null);
            }
        }

        if (!TryFindOohCell(pawn.Position, pawn, out var OohStarGazeDest))
        {
            return(null);
        }

        if (!TryFindOohWalkPath(pawn, OohStarGazeDest, out var OohWalkDests))
        {
            return(null);
        }

        Job OohJob;

        if (BrrrGlobals.GenRnd100() <= 45)
        {
            OohJob = new Job(BrrrJobDef.Brrr_GoForWalk, OohWalkDests[0])
            {
                targetQueueA = new List <LocalTargetInfo>()
            };
            for (var i = 1; i < OohWalkDests.Count; i++)
            {
                OohJob.targetQueueA.Add(OohWalkDests[i]);
            }

            OohJob.locomotionUrgency = LocomotionUrgency.Walk;
        }
        else
        {
            OohJob = new Job(BrrrJobDef.Brrr_Skygaze, OohStarGazeDest);
        }

        return(OohJob);
    }