Exemple #1
0
        public override Job TryGiveJob(Pawn pawn)
        {
            if (!Common.PawnMayEnjoyPlayingOutside(pawn))
            {
                return(null);
            }

            var pettingAnimal = Common.GetAnimal(pawn);

            if (pettingAnimal is null)
            {
                PetThemAll.Debug($"no valid animal found");
                return(null);
            }

            if (!Common.TryFindOutsideWalkPath(pawn, pettingAnimal, out var firstCell, out var queue))
            {
                PetThemAll.Debug($"no path");
                return(null);
            }

            var job = JobMaker.MakeJob(this.def.jobDef, firstCell.Value, pettingAnimal);

            job.targetQueueA      = queue;
            job.locomotionUrgency = LocomotionUrgency.Jog;
            PetThemAll.Debug($"found animal {pettingAnimal.ToStringSafe()}, made job {job.ToStringSafe()}");
            return(job);
        }
Exemple #2
0
 public static bool PawnOrAnimalIsGone(Pawn p)
 {
     if (p.DestroyedOrNull())
     {
         PetThemAll.Debug($"destroyed or null: {p.ToStringSafe()}");
         return(true);
     }
     else if (p.Dead)
     {
         PetThemAll.Debug($"dead: {p.ToStringSafe()}");
         return(true);
     }
     else if (!p.Spawned)
     {
         PetThemAll.Debug($"not spawned: {p.ToStringSafe()}");
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
        public static bool PawnOrAnimalIsIncapable(Pawn pawn)
        {
            var caps = pawn?.health?.capacities;

            if (caps is null)
            {
                PetThemAll.Debug($"no health capatibilities: {pawn.ToStringSafe()}");
                return(true);  // impossible?
            }
            else if (caps.GetLevel(PawnCapacityDefOf.Consciousness) < MinConsciousness)
            {
                PetThemAll.Debug($"not enough Consciousness: {pawn.ToStringSafe()}");
                return(true);  // too stupid
            }
            else if (caps.GetLevel(PawnCapacityDefOf.Moving) < MinMoving)
            {
                PetThemAll.Debug($"not enough Moving: {pawn.ToStringSafe()}");
                return(true);  // walking is difficult
            }
            else
            {
                return(false);
            }
        }
Exemple #4
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);
        }