Esempio n. 1
0
 public static bool CheckIfCanRefuel(Pawn pawn, Thing t, CompRefuelableMulti compRefuelable, bool forced = false)
 {
     if (compRefuelable == null || compRefuelable.IsFull || (!forced && !compRefuelable.allowAutoRefuel))
     {
         return(false);
     }
     if (!forced && !compRefuelable.ShouldAutoRefuelNow)
     {
         return(false);
     }
     if (t.IsForbidden(pawn) || !pawn.CanReserve(t, 1, -1, null, forced))
     {
         return(false);
     }
     if (t.Faction != pawn.Faction)
     {
         return(false);
     }
     if (FindBestFuel(pawn, compRefuelable.FuelFilter) == null)
     {
         JobFailReason.Is("NoFuelToRefuel".Translate(compRefuelable.FuelFilter.Summary));
         return(false);
     }
     if (compRefuelable.Props.atomicFueling && FindAllFuel(pawn, t, compRefuelable) == null)
     {
         JobFailReason.Is("NoFuelToRefuel".Translate(compRefuelable.FuelFilter.Summary));
         return(false);
     }
     return(true);
 }
Esempio n. 2
0
        private static List <Thing> FindAllFuel(Pawn pawn, Thing refuelable, CompRefuelableMulti refuelableComp)
        {
            int         fuelCountToFullyRefuel = refuelableComp.GetFuelCountToFullyRefuel();
            ThingFilter filter = refuelableComp.FuelFilter;

            return(FindEnoughReservableThings(pawn, refuelable.Position, new IntRange(fuelCountToFullyRefuel, fuelCountToFullyRefuel), (Thing t) => filter.Allows(t)));
        }
Esempio n. 3
0
        public static Job GiveRefuelJob(Pawn pawn, Thing t, CompRefuelableMulti refuelable, bool forced = false, JobDef customRefuelJob = null, JobDef customAtomicRefuelJob = null)
        {
            if (!refuelable.Props.atomicFueling)
            {
                Thing t2 = FindBestFuel(pawn, refuelable.FuelFilter);
                return(JobMaker.MakeJob(customRefuelJob ?? BETADefOf.BETA_RefuelChargingStation, t, t2));
            }
            List <Thing> source = FindAllFuel(pawn, t, refuelable);
            Job          job    = JobMaker.MakeJob(customAtomicRefuelJob ?? BETADefOf.BETA_RefuelAtomicChargingStation, t);

            job.targetQueueB = source.Select((Thing f) => new LocalTargetInfo(f)).ToList();
            return(job);
        }
Esempio n. 4
0
        public static Toil FinalizeRefueling(TargetIndex refuelableInd, TargetIndex fuelInd, CompRefuelableMulti RefuelableComp)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Job   curJob = toil.actor.CurJob;
                Thing thing  = curJob.GetTarget(refuelableInd).Thing;
                if (toil.actor.CurJob.placedThings.NullOrEmpty())
                {
                    RefuelableComp.Refuel(new List <Thing>
                    {
                        curJob.GetTarget(fuelInd).Thing
                    });
                }
                else
                {
                    RefuelableComp.Refuel(toil.actor.CurJob.placedThings.Select((ThingCountClass p) => p.thing).ToList());
                }
            };
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            return(toil);
        }
Esempio n. 5
0
 public Command_SetAmmoType(CompRefuelableMulti compRefuelableMulti, Map map)
 {
     this.compRefuelableMulti = compRefuelableMulti;
     this.map = map;
 }