Ejemplo n.º 1
0
        public override Job GetJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty)
        {
            Job job = null;

            WorkGiver_Scanner scanner = savedJob.WorkGiverScanner;

            if (scanner != null && jobTarget != null && jobTarget.HasThing && !jobTarget.ThingDestroyed && jobTarget.Thing is Pawn)
            {
                Pawn targetPawn = jobTarget.Thing as Pawn;

                if (targetPawn.Faction == meeseeks.Faction || targetPawn.Dead)
                {
                    Logger.MessageFormat(this, "{0} already tamed or dead.", targetPawn);
                    jobAvailabilty = JobAvailability.Complete;
                }
                else if (targetPawn.RaceProps.EatsFood && !HasFoodToInteractAnimal(meeseeks, targetPawn))
                {
                    job = TakeFoodForAnimalInteractJob(meeseeks, targetPawn);
                }
                else if (TameUtility.TriedToTameTooRecently(targetPawn))
                {
                    jobAvailabilty = JobAvailability.Delayed;
                }
                else if (targetPawn.MapHeld != meeseeks.MapHeld)
                {
                    Logger.MessageFormat(this, "{0} not on map with {1}.", targetPawn);
                    job = ExitMapJob(meeseeks);
                }
                else if (targetPawn.Spawned)
                {
                    job = this.GetJobOnTarget(meeseeks, jobTarget, scanner);

                    if (job == null)
                    {
                        jobAvailabilty = JobAvailability.Delayed;
                    }
                }
                else
                {
                    Logger.WarningFormat(this, "Could not get handling job for {0}.", targetPawn);
                    jobAvailabilty = JobAvailability.Delayed;
                }
            }
            else
            {
                Logger.WarningFormat(this, "Unable to get scanner or target for job.");
            }

            if (job != null)
            {
                jobAvailabilty = JobAvailability.Available;
            }

            return(job);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// returns the job for the given pawn on the given thing
        /// </summary>
        /// <param name="pawn">The pawn.</param>
        /// <param name="t">The t.</param>
        /// <param name="forced">if set to <c>true</c> [forced].</param>
        /// <returns></returns>
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (pawn2 == null || !(pawn2.Faction == null || !pawn2.Faction.def.humanlikeFaction))
            {
                return(null);
            }
            if (pawn.Map.designationManager.DesignationOn(t, PMDesignationDefOf.RecruitSapientFormerHuman) == null)
            {
                return(null);
            }
            if (TameUtility.TriedToTameTooRecently(pawn2))
            {
                JobFailReason.Is(WorkGiver_InteractAnimal.AnimalInteractedTooRecentlyTrans);
                return(null);
            }
            if (!CanInteractWithAnimal(pawn, pawn2, forced))
            {
                return(null);
            }

            return(JobMaker.MakeJob(PMJobDefOf.RecruitSapientFormerHuman, t));
        }