protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil repair = new Toil(); repair.initAction = delegate { this.$this.ticksToNextRepair = 80f; }; repair.tickAction = delegate { Pawn actor = repair.actor; actor.skills.Learn(SkillDefOf.Construction, 0.275f, false); float statValue = actor.GetStatValue(StatDefOf.ConstructionSpeed, true); this.$this.ticksToNextRepair -= statValue; if (this.$this.ticksToNextRepair <= 0f) { this.$this.ticksToNextRepair += 20f; this.$this.TargetThingA.HitPoints++; this.$this.TargetThingA.HitPoints = Mathf.Min(this.$this.TargetThingA.HitPoints, this.$this.TargetThingA.MaxHitPoints); this.$this.Map.listerBuildingsRepairable.Notify_BuildingRepaired((Building)this.$this.TargetThingA); if (this.$this.TargetThingA.HitPoints == this.$this.TargetThingA.MaxHitPoints) { actor.records.Increment(RecordDefOf.ThingsRepaired); actor.jobs.EndCurrentJob(JobCondition.Succeeded, true); } } }; repair.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); repair.WithEffect(base.TargetThingA.def.repairEffect, TargetIndex.A); repair.defaultCompleteMode = ToilCompleteMode.Never; yield return(repair); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil prepare = Toils_General.Wait(180, TargetIndex.None); prepare.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f); prepare.FailOnDespawnedNullOrForbidden(TargetIndex.A); prepare.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(prepare); Toil maintain = new Toil(); maintain.initAction = delegate() { Pawn actor = maintain.actor; CompMaintainable compMaintainable = actor.CurJob.targetA.Thing.TryGetComp <CompMaintainable>(); compMaintainable.Maintained(); }; maintain.defaultCompleteMode = ToilCompleteMode.Instant; yield return(maintain); yield break; }
//Base: Toils_General.WaitWith private Toil Toils_WaitWithSoundAndEffect(int duration, string soundDefName, string effecterDefName, TargetIndex targetIndex) { Toil toil = new Toil(); toil.initAction = () => { //toil.actor.pather.StopDead(); //toil.actor.Drawer.rotator.FaceCell(toil.actor.CurJob.GetTarget(targetIndex).Cell); Pawn pawn = toil.actor.CurJob.GetTarget(targetIndex).Thing as Pawn; if (pawn != null) // If target is a pawn force him to watch me { PawnUtility.ForceWait(pawn, duration, null, true); } }; toil.handlingFacing = true; toil.FailOnDespawnedOrNull(targetIndex); toil.FailOnCannotTouch(targetIndex, PathEndMode.Touch); toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = duration; toil.WithProgressBarToilDelay(targetIndex, false, -0.5f); toil.PlaySustainerOrSound(() => SoundDef.Named(soundDefName)); // Throws errors? //toil.WithEffect(() => EffecterDef.Named(effecterDefName), targetIndex); return(toil); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.B); yield return(Toils_Goto.Goto(TargetIndex.B, this.PathEndMode)); Toil doWork = new Toil(); doWork.initAction = delegate() { this.workLeft = 65f; }; doWork.tickAction = delegate() { float statValue = doWork.actor.GetStatValue(StatDefOf.ConstructionSpeed, true); this.workLeft -= statValue; if (this.workLeft <= 0f) { this.DoEffect(); this.ReadyForNextToil(); } }; doWork.FailOnCannotTouch(TargetIndex.B, this.PathEndMode); doWork.PlaySoundAtStart(SoundDefOf.Roof_Start); doWork.PlaySoundAtEnd(SoundDefOf.Roof_Finish); doWork.WithEffect(EffecterDefOf.RoofWork, TargetIndex.A); doWork.FailOn(new Func <bool>(this.DoWorkFailOn)); doWork.WithProgressBar(TargetIndex.A, () => 1f - this.workLeft / 65f, false, -0.5f); doWork.defaultCompleteMode = ToilCompleteMode.Never; yield return(doWork); yield break; }
// Token: 0x0600004C RID: 76 RVA: 0x00004148 File Offset: 0x00002348 protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.A); this.FailOn(delegate() { CompDeepDrill compDeepDrill = this.job.targetA.Thing.TryGetComp <CompDeepDrill>(); return(!compDeepDrill.CanDrillNow()); }); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil work = new Toil(); work.tickAction = delegate() { Pawn actor = work.actor; Building building = (Building)actor.CurJob.targetA.Thing; CompDeepDrill comp = building.GetComp <CompDeepDrill>(); comp.DrillWorkDone(actor); }; work.defaultCompleteMode = ToilCompleteMode.Never; work.WithEffect(EffecterDefOf.Drill, TargetIndex.A); work.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); yield return(work); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch)); Toil doWork = new Toil(); doWork.initAction = delegate { workLeft = 2300f; }; doWork.tickAction = delegate { workLeft -= doWork.actor.GetStatValue(StatDefOf.ConstructionSpeed) * 1.7f; if (workLeft <= 0f) { Thing thing = ThingMaker.MakeThing(ThingDefOf.Snowman); thing.SetFaction(pawn.Faction); GenSpawn.Spawn(thing, base.TargetLocA, base.Map); ReadyForNextToil(); } else { JoyUtility.JoyTickCheckEnd(pawn); } }; doWork.defaultCompleteMode = ToilCompleteMode.Never; doWork.FailOn(() => !JoyUtility.EnjoyableOutsideNow(pawn)); doWork.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(doWork); }
// Token: 0x06000393 RID: 915 RVA: 0x000245C8 File Offset: 0x000229C8 protected override IEnumerable <Toil> MakeNewToils() { this.FailOnIncapable(PawnCapacityDefOf.Manipulation); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil prepare = Toils_General.Wait(this.useDuration, TargetIndex.None); prepare.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f); prepare.FailOnDespawnedNullOrForbidden(TargetIndex.A); prepare.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(prepare); Toil use = new Toil(); use.initAction = delegate() { Pawn actor = use.actor; CompUsable_HealthShard compUsable = actor.CurJob.targetA.Thing.TryGetComp <CompUsable_HealthShard>(); compUsable.UsedBy(actor); }; use.defaultCompleteMode = ToilCompleteMode.Instant; yield return(use); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil mending = new Toil(); mending.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); mending.defaultCompleteMode = ToilCompleteMode.Never; mending.socialMode = RandomSocialMode.SuperActive; mending.WithProgressBar(TargetIndex.A, () => workDone / mendingWorks); mending.PlaySustainerOrSound(this.job.targetA.Thing.def.recipeMaker.soundWorking); mending.tickAction = () => { workDone++; if (workDone >= mendingWorks) { var thing = this.job.targetA.Thing; float repairRateMin = 1f / SkillRecord.MaxLevel * 0.1f; float repairRateMax = Math.Max(1, pawn.skills.GetSkill(SkillDefOf.Crafting).Level) / (float)SkillRecord.MaxLevel * 0.1f; float repairRate = Rand.Range(repairRateMin, repairRateMax); thing.HitPoints = Math.Min(thing.MaxHitPoints, thing.HitPoints + (int)(thing.MaxHitPoints * repairRate)); this.ReadyForNextToil(); } }; yield return(mending); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch).FailOn(() => PlantUtility.AdjacentSowBlocker(this.job.plantDefToSow, this.TargetA.Cell, this.Map) != null).FailOn(() => !this.job.plantDefToSow.CanEverPlantAt(this.TargetLocA, this.Map))); Toil sowToil = new Toil(); sowToil.initAction = delegate() { this.TargetThingA = GenSpawn.Spawn(this.job.plantDefToSow, this.TargetLocA, this.Map, WipeMode.Vanish); this.pawn.Reserve(this.TargetThingA, sowToil.actor.CurJob, 1, -1, null, true); Plant plant = (Plant)this.TargetThingA; plant.Growth = 0f; plant.sown = true; }; sowToil.tickAction = delegate() { Pawn actor = sowToil.actor; if (actor.skills != null) { actor.skills.Learn(SkillDefOf.Plants, 0.085f, false); } float statValue = actor.GetStatValue(StatDefOf.PlantWorkSpeed, true); float num = statValue; Plant plant = this.Plant; if (plant.LifeStage != PlantLifeStage.Sowing) { Log.Error(this.$this + " getting sowing work while not in Sowing life stage.", false); } this.sowWorkDone += num; if (this.sowWorkDone >= plant.def.plant.sowWork) { plant.Growth = 0.05f; this.Map.mapDrawer.MapMeshDirty(plant.Position, MapMeshFlag.Things); actor.records.Increment(RecordDefOf.PlantsSown); this.ReadyForNextToil(); return; } }; sowToil.defaultCompleteMode = ToilCompleteMode.Never; sowToil.FailOnDespawnedNullOrForbidden(TargetIndex.A); sowToil.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); sowToil.WithEffect(EffecterDefOf.Sow, TargetIndex.A); sowToil.WithProgressBar(TargetIndex.A, () => this.sowWorkDone / this.Plant.def.plant.sowWork, true, -0.5f); sowToil.PlaySustainerOrSound(() => SoundDefOf.Interact_Sow); sowToil.AddFinishAction(delegate { if (this.TargetThingA != null) { Plant plant = (Plant)sowToil.actor.CurJob.GetTarget(TargetIndex.A).Thing; if (this.sowWorkDone < plant.def.plant.sowWork && !this.TargetThingA.Destroyed) { this.TargetThingA.Destroy(DestroyMode.Vanish); } } }); sowToil.activeSkill = (() => SkillDefOf.Plants); yield return(sowToil); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil repair = new Toil(); repair.initAction = delegate { var ventable = (IVentable)((ThingWithComps)TargetThingA).AllComps.FirstOrDefault(x => x is IVentable y && y.ShouldVentNow); if (ventable != null) { ventable.ShouldVentNow = false; ventable.Vent(); } else { Log.Error("Vent failed. Null Iventable."); } }; repair.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(repair); yield break; }
// Token: 0x06000393 RID: 915 RVA: 0x000245C8 File Offset: 0x000229C8 protected override IEnumerable <Toil> MakeNewToils() { this.FailOnIncapable(PawnCapacityDefOf.Manipulation); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil prepare = Toils_General.Wait(this.useDuration, TargetIndex.A); prepare.NPCWithProgressBarToilDelay(TargetIndex.A, false, -0.5f); prepare.FailOnDespawnedNullOrForbidden(TargetIndex.A); prepare.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(prepare); Toil use = new Toil(); use.initAction = delegate() { Pawn actor = use.actor; Victim.health.AddHediff(heDiffDeff, Victim.RaceProps.body.corePart); Hediff hediff = Victim.health.hediffSet.GetFirstHediffOfDef(heDiffDeff); HediffComp_XenoSpawner _XenoSpawner = hediff.TryGetComp <HediffComp_XenoSpawner>(); _XenoSpawner.countToSpawn = Rand.RangeInclusive(1, 4); _XenoSpawner.predalienImpregnation = true; }; use.defaultCompleteMode = ToilCompleteMode.Instant; yield return(use); yield break; }
/// <summary> /// Makes the new toils. /// </summary> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.B); this.FailOn(() => ((Pawn)(Thing)GetActor().CurJob.GetTarget(TargetIndex.A)).guest.interactionMode != PMPrisonerInteractionModeDefOf.PM_Transform); this.FailOnDowned(TargetIndex.A); this.FailOnAggroMentalState(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOn(() => !Prisoner.IsPrisonerOfColony || !Prisoner.guest.PrisonerIsSecure).FailOnSomeonePhysicallyInteracting(TargetIndex.A)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A)); Toil carryToCell = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.InteractionCell); yield return(carryToCell); Toil toil = Toils_General.Wait(500, TargetIndex.B); toil.FailOnCannotTouch(TargetIndex.B, PathEndMode.InteractionCell); toil.WithProgressBarToilDelay(TargetIndex.B); yield return(toil); Toil toil2 = new Toil { initAction = delegate { Prisoner?.Strip(); Chamber.TryAcceptThing(Prisoner); }, defaultCompleteMode = ToilCompleteMode.Instant }; yield return(toil2); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(TargetIndex.A); this.FailOnDestroyedOrNull(TargetIndex.B); this.FailOnAggroMentalState(TargetIndex.A); this.FailOn(() => !DropPod.Accepts(Takee)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnDespawnedNullOrForbidden(TargetIndex.B) .FailOn(() => DropPod.GetDirectlyHeldThings().Count > 0) .FailOn(() => !Takee.Downed) .FailOn(() => !pawn.CanReach(Takee, PathEndMode.OnCell, Danger.Deadly)) .FailOnSomeonePhysicallyInteracting(TargetIndex.A)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A)); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.InteractionCell)); Toil toil = Toils_General.Wait(500, TargetIndex.B); toil.FailOnCannotTouch(TargetIndex.B, PathEndMode.InteractionCell); toil.WithProgressBarToilDelay(TargetIndex.B); yield return(toil); Toil toil2 = new Toil(); toil2.initAction = delegate { DropPod.TryAcceptThing(Takee); }; toil2.defaultCompleteMode = ToilCompleteMode.Instant; yield return(toil2); }
protected override IEnumerable <Toil> MakeNewToils() { CompScanner scannerComp = job.targetA.Thing.TryGetComp <CompScanner>(); this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.A); this.FailOn(() => !scannerComp.CanUseNow); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil work = new Toil(); work.tickAction = delegate { Pawn actor = work.actor; _ = (Building)actor.CurJob.targetA.Thing; scannerComp.Used(actor); actor.skills.Learn(SkillDefOf.Intellectual, 0.035f); actor.GainComfortFromCellIfPossible(chairsOnly: true); }; work.PlaySustainerOrSound(scannerComp.Props.soundWorking); work.AddFailCondition(() => !scannerComp.CanUseNow); work.defaultCompleteMode = ToilCompleteMode.Never; work.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); work.activeSkill = () => SkillDefOf.Intellectual; yield return(work); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); this.FailOn(delegate() { var comp = this.job.targetA.Thing.TryGetComp <CompDetection_ManualDevice>(); return(!comp.CanUseNow); }); Toil work = new Toil(); lastRotateTick = Find.TickManager.TicksGame; work.tickAction = delegate() { Pawn actor = work.actor; actor.skills.Learn(SkillDefOf.Shooting, 0.035f, false); if (Find.TickManager.TicksGame - lastRotateTick >= 300) { rotateToFace = TargetIndex.B; actor.Rotation = Rot4.Random; lastRotateTick = Find.TickManager.TicksGame; } var comp = this.job.targetA.Thing.TryGetComp <CompDetection_ManualDevice>(); comp.Use(actor); }; work.defaultCompleteMode = ToilCompleteMode.Never; work.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); //work.activeSkill = (() => SkillDefOf.Shooting); yield return(work); }
protected override IEnumerable<Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.A); this.FailOn(delegate() { CompLongRangeMineralScanner compLongRangeMineralScanner = this.job.targetA.Thing.TryGetComp<CompLongRangeMineralScanner>(); return !compLongRangeMineralScanner.CanUseNow; }); yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); Toil work = new Toil(); work.tickAction = delegate() { Pawn actor = work.actor; Building building = (Building)actor.CurJob.targetA.Thing; CompLongRangeMineralScanner comp = building.GetComp<CompLongRangeMineralScanner>(); comp.Used(actor); actor.skills.Learn(SkillDefOf.Intellectual, 0.035f, false); actor.GainComfortFromCellIfPossible(); }; work.defaultCompleteMode = ToilCompleteMode.Never; work.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); work.activeSkill = (() => SkillDefOf.Intellectual); yield return work; yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B)); yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, false, false)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.A)); Toil repair = Toils_General.Wait(75, TargetIndex.None); repair.FailOnDespawnedOrNull(TargetIndex.A); repair.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); repair.WithEffect(Gun.def.repairEffect, TargetIndex.A); repair.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f); yield return(repair); yield return(new Toil { initAction = delegate() { BeamColorThing.BeamColor = pawn.CurJob.maxNumMeleeAttacks; var targetInfo = new TargetInfo(Gun.Position, Map, false); Effecter effecter = EffecterDefOf.Deflect_Metal.Spawn(); effecter.Trigger(targetInfo, targetInfo); effecter.Cleanup(); this.Prism.Destroy(DestroyMode.Vanish); } }); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B)); yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, false, false)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.A)); Toil repair = Toils_General.Wait(1000, TargetIndex.None); repair.FailOnDespawnedOrNull(TargetIndex.A); repair.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); repair.WithEffect(this.Building.def.repairEffect, TargetIndex.A); repair.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f); yield return(repair); yield return(new Toil { initAction = delegate { this.$this.Components.Destroy(DestroyMode.Vanish); if (Rand.Value > this.$this.pawn.GetStatValue(StatDefOf.FixBrokenDownBuildingSuccessChance, true)) { Vector3 loc = (this.$this.pawn.DrawPos + this.$this.Building.DrawPos) / 2f; MoteMaker.ThrowText(loc, this.$this.Map, "TextMote_FixBrokenDownBuildingFail".Translate(), 3.65f); } else { this.$this.Building.GetComp <CompBreakdownable>().Notify_Repaired(); } } }); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); //this.FailOn(() => (base.Map.designationManager.DesignationOn(base.TargetThingA, MeeseeksDefOf.CM_Meeseeks_Box_Designation_PressButton) == null) ? true : false); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil toil = Toils_General.Wait(useDuration); toil.WithProgressBarToilDelay(TargetIndex.A); toil.FailOnDespawnedNullOrForbidden(TargetIndex.A); toil.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(toil); Toil finalize = new Toil(); finalize.initAction = delegate { Pawn actor = finalize.actor; ThingWithComps thingWithComps = (ThingWithComps)actor.CurJob.targetA.Thing; for (int i = 0; i < thingWithComps.AllComps.Count; i++) { CompHasButton compHasButton = thingWithComps.AllComps[i] as CompHasButton; if (compHasButton != null)// && compHasButton.WantsPress) { compHasButton.DoPress(finalize.actor); } } // Don't want to add a bunch of these, one day they will exist in a core mod //actor.records.Increment(PocketDimensionDefOf.CM_PocketDimension_Record_ButtonsPressed); }; finalize.defaultCompleteMode = ToilCompleteMode.Instant; yield return(finalize); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnCellMissingDesignation(TargetIndex.A, DesignationDefOf.Mine); yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); var mine = new Toil(); mine.tickAction = delegate { var actor = mine.actor; var mineTarget = MineTarget; if (ticksToPickHit < -100) { ResetTicksToPickHit(); } if (actor.skills != null) { actor.skills.Learn(SkillDefOf.Mining, 0.11f, false); } ticksToPickHit--; if (ticksToPickHit <= 0) { var position = mineTarget.Position; if (effecter == null) { effecter = EffecterDefOf.Mine.Spawn(); } effecter.Trigger(actor, mineTarget); var num = 80; var mineable = mineTarget as Mineable; if (mineable == null || mineTarget.HitPoints > num) { var actor2 = mine.actor; var dinfo = new DamageInfo(DamageDefOf.Mining, num, -1f, actor2, null, null, DamageInfo.SourceCategory.ThingOrUnknown); mineTarget.TakeDamage(dinfo); } else { mineable.DestroyMined(actor); } if (mineTarget.Destroyed) { actor.Map.mineStrikeManager.CheckStruckOre(position, mineTarget.def, actor); actor.records.Increment(RecordDefOf.CellsMined); ReadyForNextToil(); return; } ResetTicksToPickHit(); } }; mine.defaultCompleteMode = ToilCompleteMode.Never; mine.WithProgressBar(TargetIndex.A, () => 1f - (float)MineTarget.HitPoints / (float)MineTarget.MaxHitPoints, false, -0.5f); mine.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(mine); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch)); Toil doWork = new Toil(); doWork.initAction = delegate() { this.workLeft = 2300f; }; doWork.tickAction = delegate() { this.workLeft -= doWork.actor.GetStatValue(StatDefOf.ConstructionSpeed, true); if (this.workLeft <= 0f) { Thing thing = ThingMaker.MakeThing(ThingDefOf.Snowman, null); thing.SetFaction(this.pawn.Faction, null); GenSpawn.Spawn(thing, this.TargetLocA, this.Map, WipeMode.Vanish); this.ReadyForNextToil(); return; } JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 1f, null); }; doWork.defaultCompleteMode = ToilCompleteMode.Never; doWork.FailOn(() => !JoyUtility.EnjoyableOutsideNow(this.pawn, null)); doWork.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(doWork); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.B); yield return(Toils_Goto.Goto(TargetIndex.B, PathEndMode)); Toil doWork = new Toil(); doWork.initAction = delegate { workLeft = 65f; }; doWork.tickAction = delegate { float num = doWork.actor.GetStatValue(StatDefOf.ConstructionSpeed) * 1.7f; workLeft -= num; if (workLeft <= 0f) { DoEffect(); ReadyForNextToil(); } }; doWork.FailOnCannotTouch(TargetIndex.B, PathEndMode); doWork.PlaySoundAtStart(SoundDefOf.Roof_Start); doWork.PlaySoundAtEnd(SoundDefOf.Roof_Finish); doWork.WithEffect(EffecterDefOf.RoofWork, TargetIndex.A); doWork.FailOn(DoWorkFailOn); doWork.WithProgressBar(TargetIndex.A, () => 1f - workLeft / 65f); doWork.defaultCompleteMode = ToilCompleteMode.Never; doWork.activeSkill = () => SkillDefOf.Construction; yield return(doWork); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOn(() => (!job.ignoreDesignations && base.Map.designationManager.DesignationAt(base.TargetLocA, DesDef) == null) ? true : false); this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch)); Toil doWork = new Toil(); doWork.initAction = delegate { workLeft = BaseWorkAmount; }; doWork.tickAction = delegate { float num = doWork.actor.GetStatValue(StatDefOf.SmoothingSpeed) * 1.7f; workLeft -= num; if (doWork.actor.skills != null) { doWork.actor.skills.Learn(SkillDefOf.Construction, 0.1f); } if (workLeft <= 0f) { DoEffect(); base.Map.designationManager.DesignationAt(base.TargetLocA, DesDef)?.Delete(); ReadyForNextToil(); } }; doWork.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); doWork.WithProgressBar(TargetIndex.A, () => 1f - workLeft / (float)BaseWorkAmount); doWork.defaultCompleteMode = ToilCompleteMode.Never; doWork.activeSkill = () => SkillDefOf.Construction; yield return(doWork); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B)); yield return(Toils_Haul.StartCarryThing(TargetIndex.B)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.A)); Toil toil = Toils_General.Wait(1000); toil.FailOnDespawnedOrNull(TargetIndex.A); toil.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); toil.WithEffect(Building.def.repairEffect, TargetIndex.A); toil.WithProgressBarToilDelay(TargetIndex.A); toil.activeSkill = () => SkillDefOf.Construction; yield return(toil); Toil toil2 = new Toil(); toil2.initAction = delegate { Components.Destroy(); if (Rand.Value > pawn.GetStatValue(StatDefOf.FixBrokenDownBuildingSuccessChance)) { MoteMaker.ThrowText((pawn.DrawPos + Building.DrawPos) / 2f, base.Map, "TextMote_FixBrokenDownBuildingFail".Translate(), 3.65f); } else { Building.GetComp <CompBreakdownable>().Notify_Repaired(); } }; yield return(toil2); }
public static Toil TakeMealFromDispenser(TargetIndex ind, Pawn eater) { Toil toil = new Toil(); toil.initAction = delegate() { Pawn actor = toil.actor; Job curJob = actor.jobs.curJob; Building_NutrientPasteDispenser building_NutrientPasteDispenser = (Building_NutrientPasteDispenser)curJob.GetTarget(ind).Thing; Thing thing = building_NutrientPasteDispenser.TryDispenseFood(); if (thing == null) { actor.jobs.curDriver.EndJobWith(JobCondition.Incompletable); } else { actor.carryTracker.TryStartCarry(thing); actor.CurJob.SetTarget(ind, actor.carryTracker.CarriedThing); } }; toil.FailOnCannotTouch(ind, PathEndMode.Touch); toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = Building_NutrientPasteDispenser.CollectDuration; return(toil); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedNullOrForbidden(TargetIndex.A)); startingDurability = Durability; var maintenance = new Toil(); maintenance.tickAction = delegate { Pawn pawn = maintenance.actor; Durability += pawn.GetStatValue(StatDefOf.ConstructionSpeed) / fullRepairTicks; pawn.skills.Learn(SkillDefOf.Construction, 0.125f); if (Durability > .99f) { pawn.records.Increment(RecordDefOf.ThingsRepaired); pawn.jobs.EndCurrentJob(JobCondition.Succeeded); } }; maintenance.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); maintenance.WithEffect(TargetThingA.def.repairEffect, TargetIndex.A); maintenance.WithProgressBar(TargetIndex.A, progress, true); maintenance.defaultCompleteMode = ToilCompleteMode.Never; yield return(maintenance); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch)); Toil clearToil = new Toil(); clearToil.tickAction = delegate { Pawn actor = clearToil.actor; float statValue = actor.GetStatValue(StatDefOf.UnskilledLaborSpeed, true); float num = statValue; this.$this.workDone += num; if (this.$this.workDone >= this.$this.TotalNeededWork) { this.$this.Map.snowGrid.SetDepth(this.$this.TargetLocA, 0f); this.$this.ReadyForNextToil(); return; } }; clearToil.defaultCompleteMode = ToilCompleteMode.Never; clearToil.WithEffect(EffecterDefOf.ClearSnow, TargetIndex.A); clearToil.PlaySustainerOrSound(() => SoundDefOf.Interact_CleanFilth); clearToil.WithProgressBar(TargetIndex.A, () => this.$this.workDone / this.$this.TotalNeededWork, true, -0.5f); clearToil.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(clearToil); }
protected override IEnumerable <Toil> MakeNewToils() { job.count = 1; this.FailOnIncapable(PawnCapacityDefOf.Manipulation); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.A)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, false, false)); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.B)); Toil toil = Toils_General.Wait(100); toil.WithProgressBarToilDelay(TargetIndex.B); toil.FailOnDespawnedNullOrForbidden(TargetIndex.B); toil.FailOnCannotTouch(TargetIndex.B, PathEndMode.Touch); if (job.targetB.IsValid) { toil.FailOnDespawnedOrNull(TargetIndex.B); } yield return(toil); Toil use = new Toil(); use.initAction = delegate { Pawn pawn = job.targetA.Pawn; this.Map.GetComponent <ArchotechExtractableAnimals_MapComponent>().RemoveAnimalToCarry(pawn); float ParagonOrHybridFactor = 0.5f; if (pawn.kindDef.GetModExtension <DefExtension_Hybrid>()?.dominantGenome == pawn.kindDef.GetModExtension <DefExtension_Hybrid>()?.secondaryGenome) { ParagonOrHybridFactor = 1f; } float DNAExtractionFactor = pawn.TryGetComp <CompHybrid>()?.GetDNAExtractionFactor() ?? 0f; Building_DNAStorageBank building = (Building_DNAStorageBank)job.targetB.Thing; float totalProgress = building.progress + (DNAExtractionFactor * ParagonOrHybridFactor); if (totalProgress >= 1) { building.progress = 1; } else { building.progress += DNAExtractionFactor * ParagonOrHybridFactor; } pawn.Destroy(); }; use.defaultCompleteMode = ToilCompleteMode.Instant; yield return(use); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(TargetIndex.A); this.FailOnDestroyedOrNull(TargetIndex.B); this.FailOnAggroMentalState(TargetIndex.A); this.FailOn(() => !this.DropPod.Accepts(this.Takee)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOn(() => this.DropPod.GetDirectlyHeldThings().Count > 0).FailOn(() => !this.Takee.Downed).FailOn(() => !this.pawn.CanReach(this.Takee, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)).FailOnSomeonePhysicallyInteracting(TargetIndex.A)); yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, false, false)); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.InteractionCell)); Toil prepare = Toils_General.Wait(500, TargetIndex.None); prepare.FailOnCannotTouch(TargetIndex.B, PathEndMode.InteractionCell); prepare.WithProgressBarToilDelay(TargetIndex.B, false, -0.5f); yield return(prepare); yield return(new Toil { initAction = delegate() { this.DropPod.TryAcceptThing(this.Takee, true); }, defaultCompleteMode = ToilCompleteMode.Instant }); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil research = new Toil(); research.tickAction = delegate { Pawn actor = research.actor; float statValue = actor.GetStatValue(StatDefOf.ResearchSpeed); statValue *= base.TargetThingA.GetStatValue(StatDefOf.ResearchSpeedFactor); Find.ResearchManager.ResearchPerformed(statValue, actor); actor.skills.Learn(SkillDefOf.Intellectual, 0.1f); actor.GainComfortFromCellIfPossible(chairsOnly: true); }; research.FailOn(() => Project == null); research.FailOn(() => !Project.CanBeResearchedAt(ResearchBench, ignoreResearchBenchPowerStatus: false)); research.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); research.WithEffect(EffecterDefOf.Research, TargetIndex.A); research.WithProgressBar(TargetIndex.A, () => Project?.ProgressPercent ?? 0f); research.defaultCompleteMode = ToilCompleteMode.Delay; research.defaultDuration = 4000; research.activeSkill = () => SkillDefOf.Intellectual; yield return(research); yield return(Toils_General.Wait(2)); }