Esempio n. 1
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (pawn2 == null || !TameUtility.CanTame(pawn2))
            {
                return(null);
            }
            if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Tame) == null)
            {
                return(null);
            }
            if (Find.TickManager.TicksGame < pawn2.mindState.lastAssignedInteractTime + 30000)
            {
                JobFailReason.Is(WorkGiver_InteractAnimal.AnimalInteractedTooRecentlyTrans, null);
                return(null);
            }
            if (!this.CanInteractWithAnimal(pawn, pawn2, forced))
            {
                return(null);
            }
            if (pawn2.RaceProps.EatsFood && !base.HasFoodToInteractAnimal(pawn, pawn2))
            {
                Job job = base.TakeFoodForAnimalInteractJob(pawn, pawn2);
                if (job == null)
                {
                    JobFailReason.Is(WorkGiver_InteractAnimal.NoUsableFoodTrans, null);
                }
                return(job);
            }
            return(new Job(JobDefOf.Tame, t));
        }
Esempio n. 2
0
        private Job InstallJob(Pawn pawn, Blueprint_Install install)
        {
            Thing miniToInstallOrBuildingToReinstall = install.MiniToInstallOrBuildingToReinstall;

            if (miniToInstallOrBuildingToReinstall.IsForbidden(pawn))
            {
                JobFailReason.Is(ForbiddenLowerTranslated);
                return(null);
            }
            if (!pawn.CanReach(miniToInstallOrBuildingToReinstall, PathEndMode.ClosestTouch, pawn.NormalMaxDanger()))
            {
                JobFailReason.Is(NoPathTranslated);
                return(null);
            }
            if (!pawn.CanReserve(miniToInstallOrBuildingToReinstall))
            {
                Pawn pawn2 = pawn.Map.reservationManager.FirstRespectedReserver(miniToInstallOrBuildingToReinstall, pawn);
                if (pawn2 != null)
                {
                    JobFailReason.Is("ReservedBy".Translate(pawn2.LabelShort, pawn2));
                }
                return(null);
            }
            Job job = JobMaker.MakeJob(JobDefOf.HaulToContainer);

            job.targetA  = miniToInstallOrBuildingToReinstall;
            job.targetB  = install;
            job.count    = 1;
            job.haulMode = HaulMode.ToContainer;
            return(job);
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            var wineFermenter = t.TryGetComp <CompWineFermenter>();

            if (wineFermenter == null || wineFermenter.Fermented || wineFermenter.SpaceLeftForMust <= 0)
            {
                return(false);
            }
            float ambientTemperature = wineFermenter.parent.AmbientTemperature;
            CompProperties_TemperatureRuinable compProperties = wineFermenter.TemperatureRuinableComp.Props;

            if (ambientTemperature < compProperties.minSafeTemperature + 2f || ambientTemperature > compProperties.maxSafeTemperature - 2f)
            {
                JobFailReason.Is("BadTemperature".Translate().ToLower(), null);
                return(false);
            }
            if (!t.IsForbidden(pawn))
            {
                LocalTargetInfo target = t;
                if (pawn.CanReserve(target, 1, -1, null, forced))
                {
                    if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null)
                    {
                        return(false);
                    }
                    if (this.FindMust(pawn, wineFermenter) == null)
                    {
                        JobFailReason.Is("VanillaFactionsExpanded.NoMust".Translate(), null);
                        return(false);
                    }
                    return(!t.IsBurning());
                }
            }
            return(false);
        }
        public override Job JobOnThing(Pawn pawn, Thing thing)
        {
            ISlotGroupParent slotGroupParent = thing as ISlotGroupParent;

            if (slotGroupParent == null)
            {
                return(null);
            }
            if (!pawn.CanReserve(thing.Position, 1))
            {
                return(null);
            }
            int          num  = 0;
            List <Thing> list = Find.ThingGrid.ThingsListAt(thing.Position);

            for (int i = 0; i < list.Count; i++)
            {
                Thing thing2 = list[i];
                if (Building_AquacultureBasin.IsAcceptableFeedstock(thing2.def))
                {
                    num += thing2.stackCount;
                }
            }
            if (num > 25)
            {
                JobFailReason.Is("AlreadyFilledLower".Translate());
                return(null);
            }
            return(WorkGiver_FillAquacultureHopper.HopperFillFoodJob(pawn, slotGroupParent));
        }
Esempio n. 5
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_ItemProcessor building_processor = t as Building_ItemProcessor;

            // Log.Message(building_processor.GetComp<CompItemProcessor>().Props.isCompletelyAutoMachine.ToString());
            if (building_processor == null || building_processor.GetComp <CompItemProcessor>().Props.isCompletelyAutoMachine || building_processor.processorStage != ProcessorStage.ExpectingIngredients || building_processor.firstIngredientComplete || building_processor.firstItem == "")
            {
                return(false);
            }

            if (!t.IsForbidden(pawn))
            {
                LocalTargetInfo target = t;
                if (pawn.CanReserve(target, 1, 1, null, forced))
                {
                    if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null)
                    {
                        return(false);
                    }
                    if (this.FindIngredient(pawn, building_processor.firstItem, building_processor) == null)
                    {
                        JobFailReason.Is(WorkGiver_InsertProcessorFirst.NoIngredientFound, null);
                        return(false);
                    }
                    return(!t.IsBurning());
                }
            }
            return(false);
        }
Esempio n. 6
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            var thing = t as ThingWithComps;

            if (thing == null)
            {
                return(null);
            }
            var comp = t.FirstUpgradeableComp();

            if (comp == null)
            {
                return(null);
            }
            var missingIngredient = comp.TryGetNextMissingIngredient();

            var status =
                !pawn.Dead && !pawn.Downed && !pawn.IsBurning() &&
                !comp.parent.Destroyed && !comp.parent.IsBurning() &&
                pawn.CanReserveAndReach(t, PathEndMode.InteractionCell, Danger.Deadly);

            if (status && missingIngredient.Count > 0 && TryFindHaulableOfDef(pawn, missingIngredient.ThingDef) == null)
            {
                JobFailReason.Is("Upgrade_missingMaterials".Translate(missingIngredient.Count, missingIngredient.ThingDef.LabelCap));
                status = false;
            }
            if (status && !comp.PawnMeetsSkillRequirement(pawn))
            {
                JobFailReason.Is("SkillTooLowForConstruction".Translate(SkillDefOf.Construction.LabelCap));
                status = false;
            }
            return(status ? JobMaker.MakeJob(Resources.Job.rxInstallUpgrade, t) : null);
        }
Esempio n. 7
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (pawn2 == null || !pawn2.RaceProps.Animal)
            {
                return(false);
            }
            if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Slaughter) == null)
            {
                return(false);
            }
            if (pawn.Faction != t.Faction)
            {
                return(false);
            }
            if (pawn2.InAggroMentalState)
            {
                return(false);
            }
            LocalTargetInfo target = t;

            if (!pawn.CanReserve(target, 1, -1, null, forced))
            {
                return(false);
            }
            if (pawn.story != null && pawn.story.WorkTagIsDisabled(WorkTags.Violent))
            {
                JobFailReason.Is("IsIncapableOfViolenceShort".Translate());
                return(false);
            }
            return(true);
        }
Esempio n. 8
0
 public virtual bool PawnAllowedToStartAnew(Pawn p)
 {
     if (this.pawnRestriction != null)
     {
         return(this.pawnRestriction == p);
     }
     if (this.recipe.workSkill != null)
     {
         int level = p.skills.GetSkill(this.recipe.workSkill).Level;
         if (level < this.allowedSkillRange.min)
         {
             JobFailReason.Is("UnderAllowedSkill".Translate(new object[]
             {
                 this.allowedSkillRange.min
             }), this.Label);
             return(false);
         }
         if (level > this.allowedSkillRange.max)
         {
             JobFailReason.Is("AboveAllowedSkill".Translate(new object[]
             {
                 this.allowedSkillRange.max
             }), this.Label);
             return(false);
         }
     }
     return(true);
 }
Esempio n. 9
0
        protected virtual bool CanInteractWithAnimal(Pawn pawn, Pawn animal, bool forced)
        {
            if (!pawn.CanReserve(animal, 1, -1, null, forced))
            {
                return(false);
            }
            if (animal.Downed)
            {
                JobFailReason.Is(CantInteractAnimalDownedTrans);
                return(false);
            }
            if (!animal.Awake())
            {
                JobFailReason.Is(CantInteractAnimalAsleepTrans);
                return(false);
            }
            if (!animal.CanCasuallyInteractNow())
            {
                JobFailReason.Is(CantInteractAnimalBusyTrans);
                return(false);
            }
            int num = TrainableUtility.MinimumHandlingSkill(animal);

            if (num > pawn.skills.GetSkill(SkillDefOf.Animals).Level)
            {
                JobFailReason.Is("AnimalsSkillTooLow".Translate(num));
                return(false);
            }
            return(true);
        }
 // this allow the work giver to be present in both drafted and undrafted float menus
 public static FloatMenuOption InjectThingFloatOptionIfNeeded(Thing target, Pawn selPawn)
 {
     if (Designator_FinishOff.IsValidDesignationTarget(target))
     {
         if (WorkGiverEnabled)
         {
             JobFailReason.Clear();
             var giver = CreateInstance();
             var job   = giver.JobOnThing(selPawn, target, true);
             var opt   = new FloatMenuOption("Finish_off_floatMenu".Translate(target.LabelShort), () => {
                 selPawn.jobs.TryTakeOrderedJobPrioritizedWork(job, giver, target.Position);
             });
             opt = FloatMenuUtility.DecoratePrioritizedTask(opt, selPawn, target);
             if (job == null)
             {
                 opt.Disabled = true;
                 if (JobFailReason.HaveReason)
                 {
                     opt.Label = "CannotGenericWork".Translate(giver.def.verb, target.LabelShort, target) + " (" + JobFailReason.Reason + ")";
                 }
             }
             return(opt);
         }
     }
     return(null);
 }
 public static bool CanConstruct(Thing t, Pawn p, bool checkSkills = true, bool forced = false)
 {
     if (FirstBlockingThing(t, p) != null)
     {
         return(false);
     }
     if (!p.CanReserveAndReach(t, PathEndMode.Touch, forced ? Danger.Deadly : p.NormalMaxDanger(), 1, -1, null, forced))
     {
         return(false);
     }
     if (t.IsBurning())
     {
         return(false);
     }
     if (checkSkills && p.skills.GetSkill(SkillDefOf.Construction).Level < t.def.constructionSkillPrerequisite)
     {
         JobFailReason.Is(SkillTooLowTrans.Formatted(SkillDefOf.Construction.LabelCap));
         return(false);
     }
     if (checkSkills && p.skills.GetSkill(SkillDefOf.Artistic).Level < t.def.artisticSkillPrerequisite)
     {
         JobFailReason.Is(SkillTooLowTrans.Formatted(SkillDefOf.Artistic.LabelCap));
         return(false);
     }
     return(true);
 }
Esempio n. 12
0
        public static Job HandleBlockingThingJob(Thing constructible, Pawn worker, bool forced = false)
        {
            Thing thing = GenConstruct.FirstBlockingThing(constructible, worker);
            Job   result;

            if (thing == null)
            {
                result = null;
            }
            else
            {
                if (thing.def.category == ThingCategory.Plant)
                {
                    LocalTargetInfo target    = thing;
                    PathEndMode     peMode    = PathEndMode.ClosestTouch;
                    Danger          maxDanger = worker.NormalMaxDanger();
                    if (worker.CanReserveAndReach(target, peMode, maxDanger, 1, -1, null, forced))
                    {
                        return(new Job(JobDefOf.CutPlant, thing));
                    }
                }
                else if (thing.def.category == ThingCategory.Item)
                {
                    if (thing.def.EverHaulable)
                    {
                        return(HaulAIUtility.HaulAsideJobFor(worker, thing));
                    }
                    Log.ErrorOnce(string.Concat(new object[]
                    {
                        "Never haulable ",
                        thing,
                        " blocking ",
                        constructible.ToStringSafe <Thing>(),
                        " at ",
                        constructible.Position
                    }), 6429262, false);
                }
                else if (thing.def.category == ThingCategory.Building)
                {
                    if (worker.story != null && worker.story.WorkTypeIsDisabled(WorkTypeDefOf.Construction))
                    {
                        JobFailReason.Is(GenConstruct.IncapableOfDeconstruction, null);
                        return(null);
                    }
                    LocalTargetInfo target    = thing;
                    PathEndMode     peMode    = PathEndMode.Touch;
                    Danger          maxDanger = worker.NormalMaxDanger();
                    if (worker.CanReserveAndReach(target, peMode, maxDanger, 1, -1, null, forced))
                    {
                        return(new Job(JobDefOf.Deconstruct, thing)
                        {
                            ignoreDesignations = true
                        });
                    }
                }
                result = null;
            }
            return(result);
        }
Esempio n. 13
0
        //public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        static bool Prefix(Pawn pawn, Thing t, bool forced, ref bool __result)
        {
            //Log.Message("Hello from Patch_WorkGiver_FightFires_HasJobOnThing Prefix!");
            Fire fire = t as Fire;

            if (fire == null)
            {
                __result = false;
                return(false);
            }
            Pawn pawn2        = fire.parent as Pawn;
            bool isFireInArea = isInFirefightingArea(fire.Map, fire.Position);

            if (pawn2 != null)
            {
                if (pawn2 == pawn)
                {
                    __result = false;
                    return(false);
                }
                if ((pawn2.Faction == pawn.Faction || pawn2.HostFaction == pawn.Faction || pawn2.HostFaction == pawn.HostFaction) && !isFireInArea && IntVec3Utility.ManhattanDistanceFlat(pawn.Position, pawn2.Position) > 15)
                {
                    __result = false;
                    return(false);
                }
                if (!pawn.CanReach(pawn2, PathEndMode.Touch, Danger.Deadly))
                {
                    __result = false;
                    return(false);
                }
            }
            else
            {
                if (pawn.WorkTagIsDisabled(WorkTags.Firefighting))
                {
                    __result = false;
                    return(false);
                }
                if (!isFireInArea)
                {
                    JobFailReason.Is(WorkGiver_FixBrokenDownBuilding.NotInHomeAreaTrans);
                    __result = false;
                    return(false);
                }
            }
            if ((pawn.Position - fire.Position).LengthHorizontalSquared > 225 && !pawn.CanReserve(fire, 1, -1, null, forced))
            {
                __result = false;
                return(false);
            }
            if (FireIsBeingHandled(fire, pawn))
            {
                __result = false;
                return(false);
            }
            //return true;
            __result = true;
            return(false);
        }
Esempio n. 14
0
 public static void Postfix()
 {
     if (Harmony_WorkGiver_InteractAnimal_TakeFoodForAnimalInteractJob.rejectedInventoryMass)
     {
         JobFailReason.Is("CE_InventoryFull_TameFail".TranslateSimple());
         Harmony_WorkGiver_InteractAnimal_TakeFoodForAnimalInteractJob.rejectedInventoryMass = false;
     }
 }
Esempio n. 15
0
 private static void Postfix(Pawn pawn, Thing t, ref Job __result)
 {
     if (__result != null && !RaceAddonTools.CheckAnimal(pawn.def, t.def))
     {
         __result = null;
         JobFailReason.Is("RaceAddonRestriction_FloatMenu".Translate(), null);
     }
 }
Esempio n. 16
0
 static void Postfix(ref bool __result, Pawn __instance)
 {
     if (__instance.InBed() && __instance.CurrentBed() is Building_BedMedPod bedMedPod)
     {
         JobFailReason.Is("MedPod_SurgeryProhibited_PatientUsingMedPod".Translate());
         __result = false;
     }
 }
 private static void Postfix(Pawn p, RecipeDef ___recipe, ref bool __result)
 {
     if (__result && !RaceAddonTools.CheckRecipe(p.def, ___recipe))
     {
         __result = false;
         JobFailReason.Is("RaceAddonRestriction_FloatMenu".Translate(), null);
     }
 }
Esempio n. 18
0
 //public virtual bool UsableNow
 public static void Postfix(ref bool __result, Building_WorkTable __instance)
 {
     if (DisableThing.IsReplacing(__instance))
     {
         __result = false;
         JobFailReason.Is("TD.FailedStuffBeingReplaced".Translate());
     }
 }
Esempio n. 19
0
 private Job StartOrResumeBillJob(Pawn pawn, IBillGiver giver)
 {
     for (int i = 0; i < giver.BillStack.Count; i++)
     {
         Bill bill = giver.BillStack[i];
         if ((bill.recipe.requiredGiverWorkType != null && bill.recipe.requiredGiverWorkType != def.workType) || (Find.TickManager.TicksGame < bill.lastIngredientSearchFailTicks + ReCheckFailedBillTicksRange.RandomInRange && FloatMenuMakerMap.makingFor != pawn))
         {
             continue;
         }
         bill.lastIngredientSearchFailTicks = 0;
         if (!bill.ShouldDoNow() || !bill.PawnAllowedToStartAnew(pawn))
         {
             continue;
         }
         SkillRequirement skillRequirement = bill.recipe.FirstSkillRequirementPawnDoesntSatisfy(pawn);
         if (skillRequirement != null)
         {
             JobFailReason.Is("UnderRequiredSkill".Translate(skillRequirement.minLevel), bill.Label);
             continue;
         }
         Bill_ProductionWithUft bill_ProductionWithUft = bill as Bill_ProductionWithUft;
         if (bill_ProductionWithUft != null)
         {
             if (bill_ProductionWithUft.BoundUft != null)
             {
                 if (bill_ProductionWithUft.BoundWorker == pawn && pawn.CanReserveAndReach(bill_ProductionWithUft.BoundUft, PathEndMode.Touch, Danger.Deadly) && !bill_ProductionWithUft.BoundUft.IsForbidden(pawn))
                 {
                     return(FinishUftJob(pawn, bill_ProductionWithUft.BoundUft, bill_ProductionWithUft));
                 }
                 continue;
             }
             UnfinishedThing unfinishedThing = ClosestUnfinishedThingForBill(pawn, bill_ProductionWithUft);
             if (unfinishedThing != null)
             {
                 return(FinishUftJob(pawn, unfinishedThing, bill_ProductionWithUft));
             }
         }
         if (!TryFindBestBillIngredients(bill, pawn, (Thing)giver, chosenIngThings))
         {
             if (FloatMenuMakerMap.makingFor != pawn)
             {
                 bill.lastIngredientSearchFailTicks = Find.TickManager.TicksGame;
             }
             else
             {
                 JobFailReason.Is(MissingMaterialsTranslated, bill.Label);
             }
             chosenIngThings.Clear();
             continue;
         }
         Job haulOffJob;
         Job result = TryStartNewDoBillJob(pawn, bill, giver, chosenIngThings, out haulOffJob);
         chosenIngThings.Clear();
         return(result);
     }
     chosenIngThings.Clear();
     return(null);
 }
Esempio n. 20
0
 static void Postfix(ref bool __result, Pawn p, Thing t, bool forced)
 {
     if (t.CanGetWater() && !t.IsSociallyProper(p, false, true))
     {
         JobFailReason.Is("ReservedForPrisoners".Translate());
         __result = false;
         return;
     }
 }
Esempio n. 21
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced)
        {
#if DEBUG_WORKGIVER
            Log.Message("Checking " + t.LabelCap + " for job.");
            Log.Message("ManagerStation" + (t as Building_ManagerStation != null));
            Log.Message("Comp" + (t.TryGetComp <Comp_ManagerStation>() != null));
            Log.Message("Incap" + (!pawn.Dead && !pawn.Downed && !pawn.IsBurning() && !t.IsBurning()));
            Log.Message("CanReserve and reach" + pawn.CanReserveAndReach(t, PathEndMode, Danger.Some));
            var powera = t.TryGetComp <CompPowerTrader>();
            Log.Message("Power" + (powera == null || powera.PowerOn));
            Log.Message("Job" + (Manager.For(pawn.Map).JobStack.NextJob != null));
#endif
            if (!(t is Building_ManagerStation))
            {
                return(false);
            }

            if (t.TryGetComp <Comp_ManagerStation>() == null)
            {
                return(false);
            }

            if (pawn.Dead ||
                pawn.Downed ||
                pawn.IsBurning() ||
                t.IsBurning())
            {
                return(false);
            }

            if (!pawn.CanReserveAndReach(t, PathEndMode, Danger.Some, ignoreOtherReservations: forced))
            {
                return(false);
            }

            var power = t.TryGetComp <CompPowerTrader>();
            if (power != null &&
                !power.PowerOn)
            {
                JobFailReason.Is("Fluffy.ColonyManager.CannotManage.NoPower".Translate());
                return(false);
            }

            if (!Manager.For(pawn.Map).JobStack.FullStack().Any())
            {
                JobFailReason.Is("Fluffy.ColonyManager.CannotManage.NoJobs".Translate());
                return(false);
            }

            if (Manager.For(pawn.Map).JobStack.NextJob == null)
            {
                JobFailReason.Is("Fluffy.ColonyManager.CannotManage.NoActiveJobs".Translate());
                return(false);
            }

            return(true);
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building building = t as Building;
            bool     result;

            if (building == null)
            {
                result = false;
            }
            else if (!building.def.building.repairable)
            {
                result = false;
            }
            else if (t.Faction != pawn.Faction)
            {
                result = false;
            }
            else if (t.IsForbidden(pawn))
            {
                result = false;
            }
            else if (!t.IsBrokenDown())
            {
                result = false;
            }
            else if (pawn.Faction == Faction.OfPlayer && !pawn.Map.areaManager.Home[t.Position])
            {
                JobFailReason.Is(WorkGiver_FixBrokenDownBuilding.NotInHomeAreaTrans, null);
                result = false;
            }
            else
            {
                LocalTargetInfo target = building;
                if (!pawn.CanReserve(target, 1, -1, null, forced))
                {
                    result = false;
                }
                else if (pawn.Map.designationManager.DesignationOn(building, DesignationDefOf.Deconstruct) != null)
                {
                    result = false;
                }
                else if (building.IsBurning())
                {
                    result = false;
                }
                else if (this.FindClosestComponent(pawn) == null)
                {
                    JobFailReason.Is(WorkGiver_FixBrokenDownBuilding.NoComponentsToRepairTrans, null);
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
 public override Job NonScanJob(Pawn pawn)
 {
     if (ToolsForHaulUtility.TryGetBackpack(pawn) != null)
     {
         return(ToolsForHaulUtility.HaulWithTools(pawn));
     }
     JobFailReason.Is(NoBackpack);
     return((Job)null);
 }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        public static Job HandleBlockingThingJob(Thing constructible, Pawn worker, bool forced = false)
        {
            Thing thing = FirstBlockingThing(constructible, worker);

            if (thing == null)
            {
                return(null);
            }
            if (thing.def.category == ThingCategory.Plant)
            {
                if (worker.CanReserveAndReach(thing, PathEndMode.ClosestTouch, worker.NormalMaxDanger(), 1, -1, null, forced))
                {
                    return(JobMaker.MakeJob(JobDefOf.CutPlant, thing));
                }
            }
            else if (thing.def.category == ThingCategory.Item)
            {
                if (thing.def.EverHaulable)
                {
                    return(HaulAIUtility.HaulAsideJobFor(worker, thing));
                }
                Log.ErrorOnce("Never haulable " + thing + " blocking " + constructible.ToStringSafe() + " at " + constructible.Position, 6429262);
            }
            else if (thing.def.category == ThingCategory.Building)
            {
                if (((Building)thing).DeconstructibleBy(worker.Faction))
                {
                    if (worker.WorkTypeIsDisabled(WorkTypeDefOf.Construction))
                    {
                        JobFailReason.Is(IncapableOfDeconstruction);
                        return(null);
                    }
                    if (worker.CanReserveAndReach(thing, PathEndMode.Touch, worker.NormalMaxDanger(), 1, -1, null, forced))
                    {
                        Job job = JobMaker.MakeJob(JobDefOf.Deconstruct, thing);
                        job.ignoreDesignations = true;
                        return(job);
                    }
                }
                if (thing.def.mineable)
                {
                    if (worker.WorkTypeIsDisabled(WorkTypeDefOf.Mining))
                    {
                        JobFailReason.Is(IncapableOfMining);
                        return(null);
                    }
                    if (worker.CanReserveAndReach(thing, PathEndMode.Touch, worker.NormalMaxDanger(), 1, -1, null, forced))
                    {
                        Job job2 = JobMaker.MakeJob(JobDefOf.Mine, thing);
                        job2.ignoreDesignations = true;
                        return(job2);
                    }
                }
            }
            return(null);
        }
Esempio n. 26
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            bool flag = pawn == t && pawn.playerSettings != null && base.HasJobOnThing(pawn, t, forced);

            if (flag && !pawn.playerSettings.selfTend)
            {
                JobFailReason.Is("SelfTendDisabled".Translate());
            }
            return(flag && pawn.playerSettings.selfTend);
        }
        private bool ValidateChosenWeapons(Bill bill, Pawn pawn)
        {
            bool result = pawn.equipment.Primary != null && bill.ingredientFilter.AllowedThingDefs.Contains(pawn.equipment.Primary.def);

            if (!JobFailReason.HaveReason && !result)
            {
                JobFailReason.Is("NoWeaponEquipped".Translate(pawn), null);
            }
            return(result);
        }
Esempio n. 28
0
        public static void CanInteractWithAnimal_Postfix(Pawn pawn, ref bool __result)
        {
            int hourInteger = GenDate.HourInteger(Find.TickManager.TicksAbs, Find.WorldGrid.LongLatOf(pawn.MapHeld.Tile).x);

            if (hourInteger >= MeMiMoSettings.animalInteractionHourLimit && __result)
            {
                JobFailReason.Is("M4_CantInteractAnimalWillFallAsleepSoon".Translate());
                __result = false;
            }
        }
        private static void Postfix(ref bool __result, Pawn p, Thing t)
        {
            if (!t.CanGetWater() || t.IsSociallyProper(p, false, true))
            {
                return;
            }

            JobFailReason.Is("ReservedForPrisoners".Translate());
            __result = false;
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompLightableRefuelable compRefuelable = t.TryGetComp <CompLightableRefuelable>();

            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);
                    }
                    //Tools.Warn("I am trying to refuel there", true);

                    /*
                     * ThingWithComps thingWithComps = t as ThingWithComps;
                     * if (thingWithComps != null)
                     * {
                     *  CompExtinguishable comp = thingWithComps.GetComp<CompExtinguishable>();
                     *  if (comp != null && !comp.SwitchIsOn)
                     *  {
                     *      return false;
                     *  }
                     * }
                     */
                    if (FindBestFuel(pawn, t) == null)
                    {
                        ThingFilter fuelFilter = t.TryGetComp <CompLightableRefuelable>().Props.fuelFilter;

                        //Avertissement CS0618  'Translator.Translate(string, params object[])' est obsolète: 'Use TranslatorFormattedStringExtensions'
                        JobFailReason.Is("NoFuelToRefuel".Translate(new object[]
                        {
                            fuelFilter.Summary
                        }));

                        //JobFailReason.Is("NoFuelToRefuel".
                        return(false);
                    }
                    //Tools.Warn("Found best fuel", true);
                    return(true);
                }
            }
            return(false);
        }