public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Building_Composter composter = t as Building_Composter; if (t == null) { return(false); } if (t.IsForbidden(pawn)) { return(false); } if (t.IsBurning()) { return(false); } if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null) { return(false); } if (!composter.ProcessComplete) { JobFailReason.Is(string.Format("twComposter_Incomplete".Translate(), t.Label, composter.Progress.ToStringPercent("0"))); return(false); } return(pawn.CanReserveAndReach(t, PathEndMode.Touch, pawn.NormalMaxDanger(), 1)); }
public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { Building_Composter composter = t as Building_Composter; Thing t2 = this.FindRawResources(pawn, composter); return(new Job(JobDefOf.FillComposter, t, t2) { count = composter.Capacity - composter.RawCompostCount }); }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Building_Composter composter = t as Building_Composter; if (t == null) { return(false); } if (t.IsForbidden(pawn)) { return(false); } if (t.IsBurning()) { return(false); } if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null) { return(false); } if (composter.Full) { JobFailReason.Is(t.Label + " is full."); return(false); } if (!pawn.CanReserveAndReach(t, PathEndMode.Touch, pawn.NormalMaxDanger(), 1)) { return(false); } if (this.FindRawResources(pawn, composter) == null) { JobFailReason.Is("No accessable raw resources for " + t.Label); return(false); } return(true); }
private Thing FindRawResources(Pawn pawn, Building_Composter composter) { Predicate <Thing> predicate = (Thing x) => !x.IsForbidden(pawn) && pawn.CanReserve(x, 1); return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(ThingDefOf.twRawCompost), PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, predicate, null, 0, -1, false)); }