protected override IEnumerable <Toil> MakeNewToils() { Utility.Log($"Making new toils for {pawn} to destroy {TargetThingA.LabelCap}..."); this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnThingMissingDesignation(TargetIndex.A, DestroyItemDefOf.Designation_DestroyItem); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil destroyToil = new Toil(); destroyToil.tickAction = () => { if (!TargetThingA.IsHashIntervalTick(GenTicks.TicksPerRealSecond)) { return; } float hpLossAmount = pawn.GetStatValue(StatDefOf.MeleeDPS) * pawn.GetStatValue(StatDefOf.GeneralLaborSpeed) * Settings.destructionSpeed; if (Settings.instantDestruction || hpLossAmount >= TargetThingA.HitPoints) { pawn.records.Increment(DestroyItemDefOf.Record_ItemsDestroyed); if (TargetThingA is Corpse corpse && corpse.InnerPawn.RaceProps.Humanlike) { Utility.Log($"The destroyed item was a humanlike corpse. Adding bad thoughts to {pawn} and other pawns."); if (pawn.needs?.mood?.thoughts != null) { pawn.needs.mood.thoughts.memories.TryGainMemory(DestroyItemDefOf.Thought_DestroyedCorpse); } foreach (Pawn p in pawn.Map.mapPawns.SpawnedPawnsInFaction(pawn.Faction).Where(p => pawn != p && p.needs?.mood?.thoughts != null)) { p.needs.mood.thoughts.memories.TryGainMemory(DestroyItemDefOf.Thought_KnowDestroyedCorpse); } } TargetThingA.HitPoints = 0; TargetThingA.Destroy(); ReadyForNextToil(); } else { TargetThingA.TakeDamage(new DamageInfo(DamageDefOf.Deterioration, hpLossAmount, instigator: pawn)); } }; destroyToil.defaultCompleteMode = ToilCompleteMode.Never; destroyToil.WithProgressBar(TargetIndex.A, () => 1f - (float)job.targetA.Thing.HitPoints / job.targetA.Thing.MaxHitPoints); destroyToil.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(destroyToil); yield break; }
// Token: 0x0600008F RID: 143 RVA: 0x00005929 File Offset: 0x00003B29 protected override IEnumerable <Toil> MakeNewToils() { var actor = GetActor(); this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Reserve.Reserve(TargetIndex.A)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch) .FailOnDespawnedNullOrForbidden(TargetIndex.A)); var refuel = Toils_General.Wait(180); refuel.FailOnDespawnedNullOrForbidden(TargetIndex.A); refuel.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); refuel.WithProgressBarToilDelay(TargetIndex.A); yield return(refuel); yield return(new Toil { initAction = delegate { if (actor == null || actor.apparel.WornApparelCount <= 0) { EndJobWith(JobCondition.Incompletable); return; } Apparel GhostGear = null; var list = actor.apparel.WornApparel; foreach (var ghostGear in list) { if (ghostGear is not GhostGearApparel) { continue; } GhostGear = ghostGear; break; } if (GhostGear == null) { EndJobWith(JobCondition.Incompletable); return; } var CaltropsHave = (GhostGear as GhostGearApparel).CaltropsUses; var CaltropsMax = (GhostGear as GhostGearApparel).CaltropsMax; if (CaltropsMax - CaltropsHave <= 0) { EndJobWith(JobCondition.Incompletable); return; } var actorlabel = actor.LabelShort.CapitalizeFirst() != null ? actor.LabelShort.CapitalizeFirst() : "Someone"; var gglabel = GhostGear.Label.CapitalizeFirst() != null ? GhostGear.Label.CapitalizeFirst() : "Ghost Gear"; var def = TargetThingA.def; var thinglabel = def?.label.CapitalizeFirst() != null ? TargetThingA.def.label.CapitalizeFirst() : "Caltrops Pod"; if (TargetThingA.stackCount > CaltropsMax - CaltropsHave) { (GhostGear as GhostGearApparel).CaltropsUses = CaltropsMax; TargetThingA.stackCount -= CaltropsMax - CaltropsHave; if (Controller.Settings.ShowAutoRearmMsg) { Messages.Message("GhostGear.FullyRearmed".Translate(actorlabel, gglabel, thinglabel), actor, MessageTypeDefOf.NeutralEvent, false); } EndJobWith(JobCondition.Succeeded); return; } (GhostGear as GhostGearApparel).CaltropsUses = CaltropsHave + TargetThingA.stackCount; if (Controller.Settings.ShowAutoRearmMsg) { Messages.Message( "GhostGear.CaltropsRearmed".Translate(actorlabel, gglabel, TargetThingA.stackCount.ToString(), TargetThingA.stackCount > 1 ? "s" : "", thinglabel), actor, MessageTypeDefOf.NeutralEvent, false); } TargetThingA.Destroy(); EndJobWith(JobCondition.Succeeded); } });
// Token: 0x0600003C RID: 60 RVA: 0x000038A6 File Offset: 0x00001AA6 protected override IEnumerable <Toil> MakeNewToils() { var actor = GetActor(); this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Reserve.Reserve(TargetIndex.A)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch) .FailOnDespawnedNullOrForbidden(TargetIndex.A)); var refuel = Toils_General.Wait(180); refuel.FailOnDespawnedNullOrForbidden(TargetIndex.A); refuel.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); refuel.WithProgressBarToilDelay(TargetIndex.A); yield return(refuel); yield return(new Toil { initAction = delegate { var obj = actor; if (obj != null && obj.apparel.WornApparelCount == 0) { //Log.Message("True: obj != null && obj.apparel.WornApparelCount == 0"); EndJobWith(JobCondition.Incompletable); return; } Apparel JetPack = null; var list = actor.apparel.WornApparel; foreach (var jetPack in list) { if (jetPack is not JetPackApparel) { continue; } JetPack = jetPack; break; } if (JetPack == null) { EndJobWith(JobCondition.Incompletable); return; } //Log.Message("True: JetPack is JetPackApparel"); var JPFuel = (JetPack as JetPackApparel).JPFuelAmount; var JPMax = (JetPack as JetPackApparel).JPFuelMax; if (JPMax - JPFuel <= 0) { //Log.Message("True: JPMax - JPFuel <= 0"); EndJobWith(JobCondition.Incompletable); return; } if (TargetThingA.stackCount > JPMax - JPFuel) { //Log.Message("True: this.TargetThingA.stackCount > JPMax - JPFuel"); (JetPack as JetPackApparel).JPFuelAmount = JPMax; TargetThingA.stackCount -= JPMax - JPFuel; Messages.Message("JetPack.FullyRefueled".Translate(actor.LabelShort), actor, MessageTypeDefOf.NeutralEvent, false); EndJobWith(JobCondition.Succeeded); return; } //Log.Message("False"); (JetPack as JetPackApparel).JPFuelAmount = JPFuel + TargetThingA.stackCount; Messages.Message( "JetPack.Refueled".Translate(actor.LabelShort.CapitalizeFirst(), TargetThingA.stackCount.ToString(), TargetThingA.stackCount > 1 ? "s" : ""), actor, MessageTypeDefOf.NeutralEvent, false); TargetThingA.Destroy(); EndJobWith(JobCondition.Succeeded); } });
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null)); yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch).FailOn(() => GenPlant.AdjacentSowBlocker(job.plantDefToSow, TargetA.Cell, Map) != null).FailOn(() => !job.plantDefToSow.CanEverPlantAt(TargetLocA, Map))); Toil sowToil = new Toil() { initAction = delegate { TargetThingA = GenSpawn.Spawn(job.plantDefToSow, TargetLocA, Map); pawn.Reserve(TargetThingA, job); PlantWithSecondary plant = (PlantWithSecondary)TargetThingA; plant.Growth = 0f; plant.sown = true; }, tickAction = delegate { Pawn actor = GetActor(); if (actor.skills != null) { actor.skills.Learn(SkillDefOf.Growing, 0.11f, false); } float statValue = actor.GetStatValue(StatDefOf.PlantWorkSpeed, true); float num = statValue; PlantWithSecondary plant = Plant; if (plant.LifeStage != PlantLifeStage.Sowing) { Log.Error(this + " getting sowing work while not in Sowing life stage."); } sowWorkDone += num; if (sowWorkDone >= plant.def.plant.sowWork) { plant.Growth = 0.05f; plant.Sec_Growth = 0.05f; Map.mapDrawer.MapMeshDirty(plant.Position, MapMeshFlag.Things); actor.records.Increment(RecordDefOf.PlantsSown); ReadyForNextToil(); return; } }, defaultCompleteMode = ToilCompleteMode.Never }; sowToil.FailOnDespawnedNullOrForbidden(TargetIndex.A); sowToil.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); sowToil.WithEffect(EffecterDefOf.Sow, TargetIndex.A); sowToil.WithProgressBar(TargetIndex.A, () => sowWorkDone / Plant.def.plant.sowWork, true, -0.5f); sowToil.PlaySustainerOrSound(() => SoundDefOf.Interact_Sow); sowToil.AddFinishAction(delegate { if (TargetThingA != null) { PlantWithSecondary plant = (PlantWithSecondary)GetActor().CurJob.GetTarget(TargetIndex.A).Thing; if (sowWorkDone < plant.def.plant.sowWork && !TargetThingA.Destroyed) { TargetThingA.Destroy(DestroyMode.Vanish); } } }); yield return(sowToil); if (pawn.story.traits.HasTrait(TraitDefOf.GreenThumb)) { yield return(new Toil { initAction = delegate { pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.GreenThumbHappy, null); } }); } }