public static bool CanRefuel(Pawn pawn, Thing t, bool forced = false) { CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>(); bool result; if (compRefuelable == null || compRefuelable.IsFull) { result = false; } else { bool flag = !forced; if (flag && !compRefuelable.ShouldAutoRefuelNow) { result = false; } else { if (!t.IsForbidden(pawn)) { LocalTargetInfo target = t; if (pawn.CanReserve(target, 1, -1, null, forced)) { if (t.Faction != pawn.Faction) { return(false); } if (RefuelWorkGiverUtility.FindBestFuel(pawn, t) == null) { ThingFilter fuelFilter = t.TryGetComp <CompRefuelable>().Props.fuelFilter; JobFailReason.Is("NoFuelToRefuel".Translate(new object[] { fuelFilter.Summary }), null); return(false); } if (t.TryGetComp <CompRefuelable>().Props.atomicFueling) { if (RefuelWorkGiverUtility.FindAllFuel(pawn, t) == null) { ThingFilter fuelFilter2 = t.TryGetComp <CompRefuelable>().Props.fuelFilter; JobFailReason.Is("NoFuelToRefuel".Translate(new object[] { fuelFilter2.Summary }), null); return(false); } } return(true); } } result = false; } } return(result); }
public static Job RefuelJob(Pawn pawn, Thing t, bool forced = false, JobDef customRefuelJob = null, JobDef customAtomicRefuelJob = null) { if (!t.TryGetComp <CompRefuelable>().Props.atomicFueling) { Thing t2 = RefuelWorkGiverUtility.FindBestFuel(pawn, t); return(new Job(customRefuelJob ?? JobDefOf.Refuel, t, t2)); } List <Thing> source = RefuelWorkGiverUtility.FindAllFuel(pawn, t); Job job = new Job(customAtomicRefuelJob ?? JobDefOf.RefuelAtomic, t); job.targetQueueB = (from f in source select new LocalTargetInfo(f)).ToList <LocalTargetInfo>(); return(job); }