コード例 #1
0
        // Token: 0x06000046 RID: 70 RVA: 0x00003AD4 File Offset: 0x00001CD4
        private static bool FWHasFE(Pawn p)
        {
            if (p.equipment.Primary != null)
            {
                if (p.equipment.Primary.def.defName == FEDefName && FWFoamUtility.HasFEFoam(p.equipment.Primary))
                {
                    return(true);
                }
            }
            else if (!p.inventory.innerContainer.NullOrEmpty())
            {
                using var enumerator = p.inventory.innerContainer.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current != null && enumerator.Current.def.defName == FEDefName &&
                        FWFoamUtility.HasFEFoam(p.equipment.Primary))
                    {
                        return(true);
                    }
                }

                return(false);
            }

            return(false);
        }
コード例 #2
0
        // Token: 0x06000068 RID: 104 RVA: 0x00004814 File Offset: 0x00002A14
        private static bool FWGotFE(Pawn p)
        {
            if (p.equipment.Primary != null && p.equipment.Primary.def.defName == FEDefName &&
                FWFoamUtility.HasFEFoam(p.equipment.Primary))
            {
                return(true);
            }

            if (p.inventory.innerContainer.NullOrEmpty())
            {
                return(false);
            }

            foreach (var invFECheck in p.inventory.innerContainer)
            {
                if (invFECheck.def.defName != FEDefName)
                {
                    continue;
                }

                if ((invFECheck as FireWardenData)?.FWSwapType != "N")
                {
                    FWResetVars((ThingWithComps)invFECheck);
                }

                return(true);
            }

            return(false);
        }
コード例 #3
0
        // Token: 0x06000018 RID: 24 RVA: 0x00002970 File Offset: 0x00000B70
        private void FindBestReplace(Pawn FW, ThingDef FEItem, out Thing targ)
        {
            targ = null;
            if (FW?.Map == null)
            {
                return;
            }

            var listFE = FW.Map.listerThings.ThingsOfDef(FEItem);
            var needed = 1;

            if (listFE.Count <= 0)
            {
                return;
            }

            Thing besttarg   = null;
            var   bestpoints = 0f;

            foreach (var targchk in listFE)
            {
                if (targchk.IsForbidden(FW) || targchk?.Faction != null && !targchk.Faction.IsPlayer ||
                    !FW.CanReserveAndReach(targchk, PathEndMode.ClosestTouch, Danger.None) ||
                    !FWFoamUtility.IsFEFoamThing(targchk) || FWFoamUtility.ReplaceFEFoam(targchk))
                {
                    continue;
                }

                float targpoints = 0;
                if (targchk != null && targchk.stackCount > needed)
                {
                    targpoints = targchk.stackCount / FW.Position.DistanceTo(targchk.Position);
                }
                else
                {
                    if (targchk != null)
                    {
                        targpoints = targchk.stackCount / (FW.Position.DistanceTo(targchk.Position) * 2f);
                    }
                }

                if (!(targpoints > bestpoints))
                {
                    continue;
                }

                besttarg   = targchk;
                bestpoints = targpoints;
            }

            if (besttarg != null)
            {
                targ = besttarg;
            }
        }
コード例 #4
0
        // Token: 0x06000014 RID: 20 RVA: 0x0000285C File Offset: 0x00000A5C
        private void FEReplaceThing(Pawn replacePawn, Thing togo, Thing tofill, bool Deltogo)
        {
            if (Deltogo)
            {
                togo.Destroy();
            }

            FWFoamUtility.FEFillUp(tofill);
            if (Controller.Settings.SendReplaceMsgs)
            {
                Messages.Message("FWrd.FEReplaced".Translate(replacePawn?.LabelShort, tofill?.Label.CapitalizeFirst()),
                                 replacePawn, MessageTypeDefOf.NeutralEvent, false);
            }
        }
コード例 #5
0
        // Token: 0x06000032 RID: 50 RVA: 0x00003148 File Offset: 0x00001348
        private bool HasFE(Pawn FW)
        {
            if (FW.equipment.Primary == null)
            {
                foreach (var invThing in FW.inventory.innerContainer)
                {
                    if (invThing.def.defName == FEDefName && FWFoamUtility.HasFEFoam(invThing))
                    {
                        return(true);
                    }
                }

                return(false);
            }

            if (FW.equipment.Primary.def.defName != FEDefName)
            {
                var HasFEcheck = false;
                using var enumerator = FW.inventory.innerContainer.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current?.def.defName != FEDefName)
                    {
                        continue;
                    }

                    HasFEcheck = true;
                    break;
                }

                return(HasFEcheck);
            }

            if (FWFoamUtility.HasFEFoam(FW.equipment.Primary))
            {
                return(true);
            }

            foreach (var invThing2 in FW.inventory.innerContainer)
            {
                if (invThing2.def.defName == FEDefName && FWFoamUtility.HasFEFoam(invThing2))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #6
0
        // Token: 0x06000017 RID: 23 RVA: 0x000028E8 File Offset: 0x00000AE8
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!pawn.IsColonistPlayerControlled)
            {
                return(null);
            }

            if (pawn.InMentalState)
            {
                return(null);
            }

            if (pawn.Map == null)
            {
                return(null);
            }

            var jobdef = DefDatabase <JobDef> .GetNamed("FEReplace");

            if (pawn.CurJobDef == jobdef)
            {
                return(null);
            }

            var FE = FWFoamUtility.GetFE(pawn);

            if (FE == null || !FWFoamUtility.ReplaceFEFoam(FE))
            {
                return(null);
            }

            FindBestReplace(pawn, FE.def, out var targ);
            if (targ != null)
            {
                return(new Job(jobdef, targ, FE));
            }

            return(null);
        }
コード例 #7
0
        // Token: 0x06000024 RID: 36 RVA: 0x00002E70 File Offset: 0x00001070
        private static bool FWHasFE(Pawn FW)
        {
            if (FW.equipment.Primary != null)
            {
                return(FW.equipment.Primary.def.defName == "Gun_Fire_Ext" &&
                       FWFoamUtility.HasFEFoam(FW.equipment.Primary));
            }

            if (FW.inventory.innerContainer.NullOrEmpty())
            {
                return(false);
            }

            foreach (var invFECheck in FW.inventory.innerContainer)
            {
                if (invFECheck.def.defName == "Gun_Fire_Ext" && FWFoamUtility.HasFEFoam(invFECheck))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #8
0
        // Token: 0x06000061 RID: 97 RVA: 0x0000419C File Offset: 0x0000239C
        private static bool FWHasFE(Pawn p)
        {
            if (p.equipment.Primary != null)
            {
                if (p.equipment.Primary.def.defName == FEDefName && FWFoamUtility.HasFEFoam(p.equipment.Primary))
                {
                    return(true);
                }
            }
            else if (!p.inventory.innerContainer.NullOrEmpty())
            {
                foreach (var invFECheck in p.inventory.innerContainer)
                {
                    if (invFECheck.def.defName == FEDefName && FWFoamUtility.HasFEFoam(invFECheck))
                    {
                        return(true);
                    }
                }

                return(false);
            }

            return(false);
        }
コード例 #9
0
        // Token: 0x06000067 RID: 103 RVA: 0x000043C0 File Offset: 0x000025C0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParm)
        {
            ThinkResult result;

            if (!Controller.Settings.EquippingDone)
            {
                result = ThinkResult.NoJob;
            }
            else
            {
                var IsFW = pawn.IsColonistPlayerControlled &&
                           pawn.workSettings.WorkIsActive(FWWorkTypeDef.PelFireWarden) &&
                           !pawn.story.traits.HasTrait(TraitDefOf.Pyromaniac);
                if (!IsFW)
                {
                    result = ThinkResult.NoJob;
                }
                else
                {
                    var FWHasGear     = false;
                    var TargetGearDef = "N";
                    if (FWResearch.FireExt.IsFinished)
                    {
                        if (!FWGotFE(pawn))
                        {
                            if (pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                            {
                                if (!Controller.Settings.BrawlerNotOK)
                                {
                                    TargetGearDef = FEDefName;
                                }
                                else if (!FWGotFB(pawn))
                                {
                                    TargetGearDef = FBDefName;
                                }
                                else
                                {
                                    FWHasGear = true;
                                }
                            }
                            else
                            {
                                TargetGearDef = FEDefName;
                            }
                        }
                        else
                        {
                            FWHasGear = true;
                        }
                    }
                    else if (FWResearch.FireBeater.IsFinished)
                    {
                        if (!FWGotFB(pawn))
                        {
                            TargetGearDef = FBDefName;
                        }
                        else
                        {
                            FWHasGear = true;
                        }
                    }

                    if (FWHasGear)
                    {
                        result = ThinkResult.NoJob;
                    }
                    else
                    {
                        var IsFightingFires = pawn.CurJob != null && pawn.CurJob.targetA != null &&
                                              pawn.CurJob.targetA.HasThing &&
                                              pawn.CurJob.targetA.Thing.def == ThingDefOf.Fire;
                        var IsAlreadyEquipping = pawn.CurJob != null && pawn.CurJobDef == FWEquipJobs.FWEquipping;
                        if (IsFightingFires || IsAlreadyEquipping)
                        {
                            result = ThinkResult.NoJob;
                        }
                        else
                        {
                            var IsHomeFire = false;
                            var list       = pawn.Map.listerThings.ThingsOfDef(ThingDefOf.Fire);
                            foreach (var thing in list)
                            {
                                if (!pawn.Map.areaManager.Home[thing.Position] || thing.Position.Fogged(thing.Map))
                                {
                                    continue;
                                }

                                IsHomeFire = true;
                                break;
                            }

                            if (IsHomeFire)
                            {
                                result = ThinkResult.NoJob;
                            }
                            else if (pawn.Drafted || HealthAIUtility.ShouldSeekMedicalRest(pawn) || pawn.IsBurning())
                            {
                                result = ThinkResult.NoJob;
                            }
                            else
                            {
                                var FWSearchRange = (float)Controller.Settings.SearchRange;
                                if (FWSearchRange < 25f)
                                {
                                    FWSearchRange = 25f;
                                }

                                if (FWSearchRange > 75f)
                                {
                                    FWSearchRange = 75f;
                                }

                                var FElist =
                                    pawn.Map.listerThings.ThingsOfDef(DefDatabase <ThingDef> .GetNamed(FEDefName));
                                var FBlist =
                                    pawn.Map.listerThings.ThingsOfDef(DefDatabase <ThingDef> .GetNamed(FBDefName));
                                var traverseParams = TraverseParms.For(pawn);

                                bool ValidatorFe(Thing t)
                                {
                                    return(!t.IsForbidden(pawn) && pawn.CanReserve(t) &&
                                           !FWFoamUtility.ReplaceFEFoam(t) && FWFoamUtility.HasFEFoam(t));
                                }

                                bool ValidatorFb(Thing t)
                                {
                                    return(!t.IsForbidden(pawn) && pawn.CanReserve(t));
                                }

                                Thing ThingToGrab = null;
                                if (TargetGearDef != "N")
                                {
                                    if (TargetGearDef == FEDefName)
                                    {
                                        if (!FWGotFE(pawn))
                                        {
                                            ThingToGrab = GenClosest.ClosestThing_Global_Reachable(pawn.Position,
                                                                                                   pawn.Map, FElist, PathEndMode.OnCell, traverseParams, FWSearchRange,
                                                                                                   ValidatorFe);
                                        }

                                        if (ThingToGrab == null && !FWGotFB(pawn))
                                        {
                                            ThingToGrab = GenClosest.ClosestThing_Global_Reachable(pawn.Position,
                                                                                                   pawn.Map, FBlist, PathEndMode.OnCell, traverseParams, FWSearchRange,
                                                                                                   ValidatorFb);
                                        }
                                    }
                                    else if (!FWGotFB(pawn))
                                    {
                                        ThingToGrab = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map,
                                                                                               FBlist, PathEndMode.OnCell, traverseParams, FWSearchRange, ValidatorFb);
                                    }
                                }

                                if (ThingToGrab != null &&
                                    pawn.inventory.innerContainer.CanAcceptAnyOf(ThingToGrab, false))
                                {
                                    return(new ThinkResult(new Job(FWEquipJobs.FWEquipping, ThingToGrab), this));
                                }

                                result = ThinkResult.NoJob;
                            }
                        }
                    }
                }
            }

            return(result);
        }
コード例 #10
0
        // Token: 0x06000063 RID: 99 RVA: 0x00004318 File Offset: 0x00002518
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            var toilInv       = new Toil();
            var toilEquipGoto = new Toil();
            var toilEquip     = new Toil();
            var toilGoto      = new Toil();
            var toilCast      = new Toil();
            var toilTouch     = new Toil();
            var toilBeat      = new Toil();
            var toilBash      = new Toil();
            var HasPrimFE     = false;
            var HasPrimFB     = false;

            if (pawn.equipment.Primary != null)
            {
                if (pawn.equipment.Primary.def.defName == FEDefName && FWFoamUtility.HasFEFoam(pawn.equipment.Primary))
                {
                    HasPrimFE = true;
                }
                else if (pawn.equipment.Primary.def.defName == FBDefName)
                {
                    HasPrimFB = true;
                }
            }

            if (!HasPrimFE)
            {
                var fb = HasPrimFB;
                toilInv.initAction = delegate
                {
                    var            Swap            = false;
                    ThingWithComps invGearToEquip2 = null;
                    ThingWithComps primToSwap2     = null;
                    Thing          RemoveThing     = null;
                    Thing          BackupThing2    = null;
                    if (pawn.equipment.Primary != null)
                    {
                        primToSwap2 = pawn.equipment.Primary;
                    }

                    foreach (var invThing2 in pawn.inventory.innerContainer)
                    {
                        if (invThing2.def.defName != FEDefName || !FWFoamUtility.HasFEFoam(invThing2))
                        {
                            if (invThing2.def.defName == FBDefName)
                            {
                                BackupThing2 = invThing2;
                            }
                        }
                        else
                        {
                            RemoveThing     = invThing2;
                            invGearToEquip2 = (ThingWithComps)invThing2;
                            if (primToSwap2 != null)
                            {
                                Swap = true;
                            }

                            break;
                        }
                    }

                    if (invGearToEquip2 == null && !fb && BackupThing2 != null)
                    {
                        RemoveThing     = BackupThing2;
                        invGearToEquip2 = (ThingWithComps)BackupThing2;
                        if (primToSwap2 != null)
                        {
                            Swap = true;
                        }
                    }

                    if (invGearToEquip2 == null)
                    {
                        return;
                    }

                    var primDef = "";
                    if (Swap)
                    {
                        primDef = pawn.equipment.Primary.def.defName;
                        pawn.equipment.Remove(pawn.equipment.Primary);
                    }

                    pawn.inventory.innerContainer.Remove(RemoveThing);
                    pawn.equipment.MakeRoomFor(invGearToEquip2);
                    pawn.equipment.AddEquipment(invGearToEquip2);
                    if (Swap)
                    {
                        pawn.inventory.innerContainer.TryAdd(primToSwap2);
                    }

                    if (!Swap)
                    {
                        return;
                    }

                    var returnType = "SI";
                    if (pawn.equipment.Primary.def.defName != FEDefName &&
                        pawn.equipment.Primary.def.defName != FBDefName)
                    {
                        return;
                    }

                    var primary = pawn.equipment.Primary;
                    ((FireWardenData)primary).FWSwapType = returnType;
                    ((FireWardenData)primary).FWPawnID   = pawn.thingIDNumber;
                    ((FireWardenData)primary).FWPrimDef  = primDef;
                    if (!DebugFWData)
                    {
                        return;
                    }

                    var Test      = pawn.equipment.Primary;
                    var debugTest = pawn.Label + " : ";
                    debugTest = debugTest + Test.Label + " : ";
                    debugTest = debugTest + pawn.equipment.Primary.GetType() + " : ";
                    if (((FireWardenData)Test).FWSwapType != null)
                    {
                        debugTest = debugTest + ((FireWardenData)Test).FWSwapType + " : ";
                    }
                    else
                    {
                        debugTest += "null : ";
                    }

                    debugTest = debugTest + ((FireWardenData)Test).FWPawnID + " : ";
                    if (((FireWardenData)Test).FWPrimDef != null)
                    {
                        debugTest += ((FireWardenData)Test).FWPrimDef;
                    }
                    else
                    {
                        debugTest += "null";
                    }

                    Messages.Message(debugTest, pawn, MessageTypeDefOf.NeutralEvent, false);
                };
                toilInv.defaultCompleteMode = ToilCompleteMode.FinishedBusy;
                yield return(toilInv);
            }

            var FWEquipping   = Controller.Settings.EquippingDone;
            var FWSearchRange = (float)Controller.Settings.SearchRange;

            if (FWSearchRange < 25f)
            {
                FWSearchRange = 25f;
            }

            if (FWSearchRange > 75f)
            {
                FWSearchRange = 75f;
            }

            HasPrimFE = false;
            HasPrimFB = false;
            if (pawn.equipment.Primary != null)
            {
                if (pawn.equipment.Primary.def.defName == FEDefName && FWFoamUtility.HasFEFoam(pawn.equipment.Primary))
                {
                    HasPrimFE = true;
                }
                else if (pawn.equipment.Primary.def.defName == FBDefName)
                {
                    HasPrimFB = true;
                }
            }

            if (!HasPrimFE && !HasPrimFB && FWEquipping)
            {
                ThingWithComps invGearToEquip = null;
                ThingWithComps primToSwap     = null;
                Thing          BackupThing    = null;
                if (pawn.equipment.Primary != null)
                {
                    primToSwap = pawn.equipment.Primary;
                }

                foreach (var invThing in pawn.inventory.innerContainer)
                {
                    if (invThing.def.defName == FEDefName && FWFoamUtility.HasFEFoam(invThing))
                    {
                        invGearToEquip = (ThingWithComps)invThing;
                        if (primToSwap != null)
                        {
                        }

                        break;
                    }

                    if (invThing.def.defName == FBDefName)
                    {
                        BackupThing = invThing;
                    }
                }

                if (invGearToEquip == null && BackupThing != null)
                {
                    invGearToEquip = (ThingWithComps)BackupThing;
                }

                if (invGearToEquip == null)
                {
                    Thing ThingToGrab    = null;
                    var   skip           = Controller.Settings.BrawlerNotOK && pawn.story.traits.HasTrait(TraitDefOf.Brawler);
                    var   traverseParams = TraverseParms.For(pawn);

                    bool validatorFE(Thing t)
                    {
                        return(!t.IsForbidden(pawn) && pawn.CanReserve(t) && FWFoamUtility.HasFEFoam(t) &&
                               !FWFoamUtility.ReplaceFEFoam(t));
                    }

                    bool validatorFB(Thing t)
                    {
                        return(!t.IsForbidden(pawn) && pawn.CanReserve(t));
                    }

                    if (!skip)
                    {
                        var FElist = pawn.Map.listerThings.ThingsOfDef(DefDatabase <ThingDef> .GetNamed(FEDefName));
                        var FEGrab = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, FElist,
                                                                              PathEndMode.OnCell, traverseParams, FWSearchRange, validatorFE);
                        if (FEGrab != null)
                        {
                            ThingToGrab = FEGrab;
                        }
                        else
                        {
                            var FBlist = pawn.Map.listerThings.ThingsOfDef(DefDatabase <ThingDef> .GetNamed(FBDefName));
                            var FBGrab = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, FBlist,
                                                                                  PathEndMode.OnCell, traverseParams, FWSearchRange, validatorFB);
                            if (FBGrab != null)
                            {
                                ThingToGrab = FBGrab;
                            }
                        }
                    }
                    else
                    {
                        var FBlist2 = pawn.Map.listerThings.ThingsOfDef(DefDatabase <ThingDef> .GetNamed(FBDefName));
                        var FBGrab2 = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, FBlist2,
                                                                               PathEndMode.OnCell, traverseParams, FWSearchRange, validatorFB);
                        if (FBGrab2 != null)
                        {
                            ThingToGrab = FBGrab2;
                        }
                    }

                    if (ThingToGrab != null)
                    {
                        toilEquipGoto.initAction = delegate
                        {
                            if (Map.reservationManager.CanReserve(pawn, ThingToGrab))
                            {
                                pawn.Reserve(ThingToGrab, job);
                            }

                            pawn.pather.StartPath(ThingToGrab, PathEndMode.OnCell);
                        };
                        toilEquipGoto.FailOn(ThingToGrab.DestroyedOrNull);
                        toilEquipGoto.AddFailCondition(() => FWHasFE(pawn) && ThingToGrab.def.defName == FEDefName);
                        toilEquipGoto.AddFailCondition(() => FWHasFB(pawn) && ThingToGrab.def.defName == FBDefName);
                        toilEquipGoto.defaultCompleteMode = ToilCompleteMode.PatherArrival;
                        yield return(toilEquipGoto);

                        toilEquip.initAction = delegate
                        {
                            var primDeEquip = pawn.equipment.Primary;
                            var primDef     = "N";
                            if (primDeEquip != null)
                            {
                                primDef = pawn.equipment.Primary.def.defName;
                                pawn.equipment.Remove(pawn.equipment.Primary);
                                pawn.inventory.innerContainer.TryAdd(primDeEquip);
                            }

                            var            FWGrabWithComps = (ThingWithComps)ThingToGrab;
                            ThingWithComps FWGrabbed;
                            if (FWGrabWithComps.def.stackLimit > 1 && FWGrabWithComps.stackCount > 1)
                            {
                                FWGrabbed = (ThingWithComps)FWGrabWithComps.SplitOff(1);
                            }
                            else
                            {
                                FWGrabbed = FWGrabWithComps;
                                FWGrabbed.DeSpawn();
                            }

                            pawn.equipment.MakeRoomFor(FWGrabbed);
                            pawn.equipment.AddEquipment(FWGrabbed);
                            var returnType = "EN";
                            if (pawn.equipment.Primary.def.defName != FEDefName &&
                                pawn.equipment.Primary.def.defName != FBDefName)
                            {
                                return;
                            }

                            var primary = pawn.equipment.Primary;
                            ((FireWardenData)primary).FWSwapType = returnType;
                            ((FireWardenData)primary).FWPawnID   = pawn.thingIDNumber;
                            ((FireWardenData)primary).FWPrimDef  = primDef;
                            if (!DebugFWData)
                            {
                                return;
                            }

                            var Test      = pawn.equipment.Primary;
                            var debugTest = pawn.Label + " : ";
                            debugTest = debugTest + Test.Label + " : ";
                            debugTest = debugTest + pawn.equipment.Primary.GetType() + " : ";
                            if ((Test as FireWardenData)?.FWSwapType != null)
                            {
                                debugTest = debugTest + ((FireWardenData)Test).FWSwapType + " : ";
                            }
                            else
                            {
                                debugTest += "null : ";
                            }

                            debugTest = debugTest + ((FireWardenData)Test).FWPawnID + " : ";
                            if (((FireWardenData)Test).FWPrimDef != null)
                            {
                                debugTest += ((FireWardenData)Test).FWPrimDef;
                            }
                            else
                            {
                                debugTest += "null";
                            }

                            Messages.Message(debugTest, pawn, MessageTypeDefOf.NeutralEvent, false);
                        };
                        toilEquip.AddFailCondition(() => FWHasFE(pawn) && ThingToGrab.def.defName == FEDefName);
                        toilEquip.AddFailCondition(() => FWHasFB(pawn) && ThingToGrab.def.defName == FBDefName);
                        toilEquip.defaultCompleteMode = ToilCompleteMode.FinishedBusy;
                        yield return(toilEquip);
                    }
                }
            }

            var HasPrimFEEq = pawn.equipment.Primary != null && pawn.equipment.Primary.def.defName == FEDefName &&
                              FWFoamUtility.HasFEFoam(pawn.equipment.Primary);

            if (HasPrimFEEq)
            {
                var FEVerbToUse  = pawn.TryGetAttackVerb(TargetFire);
                var RangeFireExt = 10f;
                if (FEVerbToUse != null)
                {
                    pawn.jobs.curJob.verbToUse = FEVerbToUse;
                    RangeFireExt  = pawn.jobs.curJob.verbToUse.verbProps.range;
                    RangeFireExt *= (float)(Controller.Settings.HowClose / 100.0);
                    if (RangeFireExt < 3f)
                    {
                        RangeFireExt = 3f;
                    }

                    if (RangeFireExt > pawn.jobs.curJob.verbToUse.verbProps.range)
                    {
                        RangeFireExt = pawn.jobs.curJob.verbToUse.verbProps.range;
                    }
                }

                toilGoto.initAction = delegate
                {
                    if (Map.reservationManager.CanReserve(pawn, TargetFire))
                    {
                        pawn.Reserve(TargetFire, job);
                    }

                    if (!CastPositionFinder.TryFindCastPosition(new CastPositionRequest
                    {
                        caster = pawn,
                        target = TargetFire,
                        verb = pawn.jobs.curJob.verbToUse,
                        maxRangeFromTarget = RangeFireExt,
                        wantCoverFromTarget = false
                    }, out var dest))
                    {
                        toilGoto.actor.jobs.EndCurrentJob(JobCondition.Incompletable);
                        return;
                    }

                    toilGoto.actor.pather.StartPath(dest, PathEndMode.OnCell);
                    pawn.Map.pawnDestinationReservationManager.Reserve(pawn, pawn.jobs.curJob, dest);
                };
                toilGoto.tickAction = delegate
                {
                    if (Controller.Settings.TooBrave)
                    {
                        return;
                    }

                    if (pawn.pather.Moving && pawn.pather.nextCell != TargetFire.Position)
                    {
                        StartTacklingFireIfAnyAt(pawn.pather.nextCell, toilCast);
                    }

                    if (pawn.Position != TargetFire.Position)
                    {
                        StartTacklingFireIfAnyAt(pawn.Position, toilCast);
                    }
                };
                toilGoto.FailOnDespawnedOrNull(TargetIndex.A);
                toilGoto.defaultCompleteMode = ToilCompleteMode.PatherArrival;
                toilGoto.atomicWithPrevious  = true;
                yield return(toilGoto);

                toilCast.initAction = delegate
                {
                    pawn.jobs.curJob.verbToUse.TryStartCastOn(TargetFire);
                    if (!TargetFire.Destroyed)
                    {
                        return;
                    }

                    pawn.records.Increment(RecordDefOf.FiresExtinguished);
                    pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                };
                toilCast.FailOnDespawnedOrNull(TargetIndex.A);
                toilCast.defaultCompleteMode = ToilCompleteMode.FinishedBusy;
                yield return(toilCast);
            }
            else
            {
                toilTouch.initAction = delegate
                {
                    if (Map.reservationManager.CanReserve(pawn, TargetFire))
                    {
                        pawn.Reserve(TargetFire, job);
                    }

                    pawn.pather.StartPath(TargetFire, PathEndMode.Touch);
                };
                toilTouch.tickAction = delegate
                {
                    if (Controller.Settings.TooBrave)
                    {
                        return;
                    }

                    if (pawn.pather.Moving && pawn.pather.nextCell != TargetFire.Position)
                    {
                        StartTacklingFireIfAnyAt(pawn.pather.nextCell, toilBeat);
                    }

                    if (pawn.Position != TargetFire.Position)
                    {
                        StartTacklingFireIfAnyAt(pawn.Position, toilBeat);
                    }
                };
                toilTouch.FailOnDespawnedOrNull(TargetIndex.A);
                toilTouch.defaultCompleteMode = ToilCompleteMode.PatherArrival;
                toilTouch.atomicWithPrevious  = true;
                yield return(toilTouch);

                toilBeat.tickAction = delegate
                {
                    if (!pawn.CanReachImmediate(TargetFire, PathEndMode.Touch))
                    {
                        JumpToToil(toilTouch);
                        return;
                    }

                    if (pawn.Position != TargetFire.Position && StartTacklingFireIfAnyAt(pawn.Position, toilBeat))
                    {
                        return;
                    }

                    if (pawn.equipment.Primary != null)
                    {
                        if (pawn.equipment.Primary.def.defName == FBDefName)
                        {
                            JumpToToil(toilBash);
                        }
                        else
                        {
                            pawn.natives.TryBeatFire(TargetFire);
                        }
                    }
                    else
                    {
                        pawn.natives.TryBeatFire(TargetFire);
                    }

                    if (!TargetFire.Destroyed)
                    {
                        return;
                    }

                    pawn.records.Increment(RecordDefOf.FiresExtinguished);
                    pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                };
                toilBeat.FailOnDespawnedOrNull(TargetIndex.A);
                toilBeat.defaultCompleteMode = ToilCompleteMode.Never;
                yield return(toilBeat);

                if (pawn.equipment.Primary == null || pawn.equipment.Primary.def.defName != FBDefName)
                {
                    yield break;
                }

                toilBash.initAction = delegate
                {
                    if (TargetFire != null && Map.reservationManager.CanReserve(pawn, TargetFire))
                    {
                        pawn.Reserve(TargetFire, job);
                    }

                    pawn.pather.StopDead();
                };
                toilBash.handlingFacing = true;
                toilBash.tickAction     = delegate
                {
                    pawn.rotationTracker.FaceTarget(pawn.CurJob.GetTarget(TargetIndex.A));
                    if (TargetFire != null)
                    {
                        pawn.Drawer.Notify_MeleeAttackOn(TargetFire);
                    }
                };
                toilBash.PlaySoundAtStart(SoundDefOf.Interact_BeatFire);
                toilBash.WithProgressBarToilDelay(TargetIndex.A);
                toilBash.AddFinishAction(delegate
                {
                    if (TargetFire != null && !TargetFire.Destroyed)
                    {
                        TargetFire.Destroy();
                    }
                });
                toilBash.FailOnDespawnedOrNull(TargetIndex.A);
                toilBash.defaultCompleteMode = ToilCompleteMode.Delay;
                var ticks     = 50;
                var WorkSpeed = pawn.GetStatValue(StatDefOf.WorkSpeedGlobal);
                if (WorkSpeed <= 0f)
                {
                    WorkSpeed = 1f;
                }

                ticks = (int)(ticks * (1f / WorkSpeed));
                if (ticks < 25)
                {
                    ticks = 25;
                }

                if (ticks > 200)
                {
                    ticks = 200;
                }

                toilBash.defaultDuration = ticks;
                yield return(toilBash);
            }
        }