public static bool CanRefuel(Pawn pawn, Thing t, bool forced = false) { CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>(); if (compRefuelable == null || compRefuelable.IsFull) { return(false); } bool flag = !forced; if (flag && !compRefuelable.ShouldAutoRefuelNow) { return(false); } if (!t.IsForbidden(pawn)) { LocalTargetInfo target = t; if (pawn.CanReserve(target, 1, -1, null, forced)) { if (t.Faction != pawn.Faction) { return(false); } ThingFilter fuelFilter = new ThingFilter(); CompSelectFuel comp = t.TryGetComp <CompSelectFuel>(); comp.PurgeFuelSettings(); fuelFilter = comp.FuelSettings.filter; if (FindBestFuel(pawn, t) == null) { JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter.Summary), null); return(false); } if (t.TryGetComp <CompRefuelable>().Props.atomicFueling&& FindAllFuel(pawn, t) == null) { JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter.Summary), null); return(false); } return(true); } } return(false); }
public override void SettingsChanged() { base.SettingsChanged(); if (Current.ProgramState == ProgramState.Playing) { Find.Maps.ForEach(delegate(Map map) { List <Thing> affected = map.listerThings.ThingsMatching(ThingRequest.ForGroup(ThingRequestGroup.Refuelable)); foreach (Thing t in affected) { Building b = t as Building; if (b != null) { CompSelectFuel comp = b.GetComp <CompSelectFuel>(); if (comp != null) { comp.ValidateFuelSettings(); } } } }); } }