public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_AC_CompostBin CompostBin = t as Building_AC_CompostBin;

            if (CompostBin == null ||
                CompostBin.Fermented ||
                CompostBin.SpaceLeftForCompost <= 0)
            {
                return(false);
            }
            float temperature = CompostBin.Position.GetTemperature(CompostBin.Map);
            CompProperties_AC_Fermenter compProperties = CompostBin.def.GetCompProperties <CompProperties_AC_Fermenter>();

            if (temperature < compProperties.minSafeTemp || temperature > compProperties.maxSafeTemp)
            {
                JobFailReason.Is(WorkGiver_FillCompostBin.TemperatureTrans);
                return(false);
            }
            if (t.IsForbidden(pawn) ||
                !pawn.CanReserveAndReach(t, PathEndMode.Touch, pawn.NormalMaxDanger(), 1))
            {
                return(false);
            }
            if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null)
            {
                return(false);
            }
            if (this.FindCompost(pawn, CompostBin) == null)
            {
                JobFailReason.Is(WorkGiver_FillCompostBin.NoCompostTrans);
                return(false);
            }
            return(!t.IsBurning());
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_AC_CompostBin CompostBin = t as Building_AC_CompostBin;

            return(CompostBin != null &&
                   CompostBin.Fermented &&
                   !t.IsBurning() &&
                   !t.IsForbidden(pawn) &&
                   pawn.CanReserveAndReach(t, PathEndMode.Touch, pawn.NormalMaxDanger(), 1));
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_AC_CompostBin CompostBin = t as Building_AC_CompostBin;
            Thing t2 = this.FindCompost(pawn, CompostBin);

            return(new Job(JobDefOf.AC_FillCompostBin, t, t2)
            {
                count = CompostBin.SpaceLeftForCompost
            });
        }
        private Thing FindCompost(Pawn pawn, Building_AC_CompostBin bin)
        {
            Predicate <Thing> predicate = (Thing x) => !x.IsForbidden(pawn) && pawn.CanReserve(x, 1);
            Predicate <Thing> validator = predicate;

            return(GenClosest.ClosestThingReachable(
                       pawn.Position,
                       pawn.Map,
                       ThingRequest.ForDef(ThingDefOf.AC_RawCompost),
                       PathEndMode.ClosestTouch,
                       TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false),
                       9999f,
                       validator,
                       null,
                       0,
                       -1,
                       false));
        }