public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { Building_GrapheneVat vat = (Building_GrapheneVat)t; Thing t2 = FindGrapheneCartridge(pawn, vat); return(new Job(JobDefOf.FillGrapheneVat, t, t2)); }
private Thing FindGrapheneCartridge(Pawn pawn, Building_GrapheneVat barrel) { Predicate <Thing> predicate = delegate(Thing x) { if (x.IsForbidden(pawn) || !pawn.CanReserve(x)) { return(false); } return(true); }; IntVec3 position = pawn.Position; Map map = pawn.Map; ThingRequest thingReq = ThingRequest.ForDef(ThingDefOf.GrapheneCartridge); PathEndMode peMode = PathEndMode.ClosestTouch; TraverseParms traverseParams = TraverseParms.For(pawn); Predicate <Thing> validator = predicate; return(GenClosest.ClosestThingReachable(position, map, thingReq, peMode, traverseParams, 9999f, validator)); }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Building_GrapheneVat building_GrapheneVat = t as Building_GrapheneVat; if (building_GrapheneVat == null || building_GrapheneVat.Reacted || building_GrapheneVat.SpaceLeftForGrapheneCartridge <= 0) { return(false); } float ambientTemperature = building_GrapheneVat.AmbientTemperature; CompProperties_TemperatureRuinable compProperties = building_GrapheneVat.def.GetCompProperties <CompProperties_TemperatureRuinable>(); if (ambientTemperature < compProperties.minSafeTemperature + 2f || ambientTemperature > compProperties.maxSafeTemperature - 2f) { JobFailReason.Is(TemperatureTrans); return(false); } if (!t.IsForbidden(pawn)) { LocalTargetInfo target = t; bool ignoreOtherReservations = forced; if (pawn.CanReserve(target, 1, -1, null, ignoreOtherReservations)) { if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null) { return(false); } Thing thing = FindGrapheneCartridge(pawn, building_GrapheneVat); if (thing == null) { JobFailReason.Is(NoGrapheneCartridgeTrans); return(false); } if (t.IsBurning()) { return(false); } return(true); } } return(false); }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Building_GrapheneVat building_GrapheneVat = t as Building_GrapheneVat; if (building_GrapheneVat == null || !building_GrapheneVat.Reacted) { return(false); } if (t.IsBurning()) { return(false); } if (!t.IsForbidden(pawn)) { LocalTargetInfo target = t; bool ignoreOtherReservations = forced; if (pawn.CanReserve(target, 1, -1, null, ignoreOtherReservations)) { return(true); } } return(false); }