示例#1
0
        public static bool CanRefuel(Pawn pawn, Thing t, bool forced = false)
        {
            CompFilteredRefuelable compRefuelable = t.TryGetComp <CompFilteredRefuelable>();
            bool flag2 = compRefuelable == null || compRefuelable.IsFull;
            bool result;

            if (flag2)
            {
                result = false;
            }
            else
            {
                bool flag  = !forced;
                bool flag3 = flag && !compRefuelable.ShouldAutoRefuelNow;
                if (flag3)
                {
                    result = false;
                }
                else
                {
                    bool flag4 = !t.IsForbidden(pawn);
                    if (flag4)
                    {
                        LocalTargetInfo target = t;
                        bool            flag5  = pawn.CanReserve(target, 1, -1, null, forced);
                        if (flag5)
                        {
                            bool flag6 = t.Faction != pawn.Faction;
                            if (flag6)
                            {
                                return(false);
                            }
                            bool flag7 = FilteredRefuelWorkGiverUtility.FindBestFuel(pawn, t) == null;
                            if (flag7)
                            {
                                ThingFilter fuelFilter = t.TryGetComp <CompFilteredRefuelable>().FuelFilter;
                                JobFailReason.Is("PD_NoFood".Translate(fuelFilter.Summary), null);
                                return(false);
                            }
                            bool flag8 = t.TryGetComp <CompFilteredRefuelable>().Props.atomicFueling&& FilteredRefuelWorkGiverUtility.FindAllFuel(pawn, t) == null;
                            if (flag8)
                            {
                                ThingFilter fuelFilter2 = t.TryGetComp <CompFilteredRefuelable>().FuelFilter;
                                JobFailReason.Is("PD_NoFood".Translate(fuelFilter2.Summary), null);
                                return(false);
                            }
                            return(true);
                        }
                    }
                    result = false;
                }
            }
            return(result);
        }
示例#2
0
        public static Job RefuelJob(Pawn pawn, Thing t, bool forced = false, JobDef customRefuelJob = null, JobDef customAtomicRefuelJob = null)
        {
            bool flag = !t.TryGetComp <CompFilteredRefuelable>().Props.atomicFueling;
            Job  result;

            if (flag)
            {
                Thing t2 = FilteredRefuelWorkGiverUtility.FindBestFuel(pawn, t);
                result = new Job(customRefuelJob ?? JobDefOf.Refuel, t, t2);
            }
            else
            {
                List <Thing> source = FilteredRefuelWorkGiverUtility.FindAllFuel(pawn, t);
                Job          job    = new Job(customAtomicRefuelJob ?? JobDefOf.RefuelAtomic, t);
                job.targetQueueB = (from f in source
                                    select new LocalTargetInfo(f)).ToList <LocalTargetInfo>();
                result = job;
            }
            return(result);
        }