protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); this.FailOnThingMissingDesignation(TargetIndex.A, DesignationDefOf.RearmTrap); Toil gotoThing = new Toil(); gotoThing.initAction = delegate() { this.pawn.pather.StartPath(base.TargetThingA, PathEndMode.Touch); }; gotoThing.defaultCompleteMode = ToilCompleteMode.PatherArrival; gotoThing.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(gotoThing); yield return(Toils_General.Wait(800, TargetIndex.None).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f)); yield return(new Toil { initAction = delegate() { Thing thing = this.job.targetA.Thing; Designation designation = base.Map.designationManager.DesignationOn(thing, DesignationDefOf.RearmTrap); if (designation != null) { designation.Delete(); } Building_TrapRearmable building_TrapRearmable = thing as Building_TrapRearmable; building_TrapRearmable.Rearm(); this.pawn.records.Increment(RecordDefOf.TrapsRearmed); }, defaultCompleteMode = ToilCompleteMode.Instant }); yield break; }
public override AcceptanceReport CanDesignateThing(Thing t) { Building_TrapRearmable building_TrapRearmable = t as Building_TrapRearmable; return(building_TrapRearmable != null && !building_TrapRearmable.Armed && base.Map.designationManager.DesignationOn(building_TrapRearmable, DesignationDefOf.RearmTrap) == null); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: this.FailOnDespawnedOrNull(TargetIndex.A); this.FailOnThingMissingDesignation(TargetIndex.A, DesignationDefOf.RearmTrap); gotoThing = new Toil(); gotoThing.initAction = delegate() { this.pawn.pather.StartPath(base.TargetThingA, PathEndMode.Touch); }; gotoThing.defaultCompleteMode = ToilCompleteMode.PatherArrival; gotoThing.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.$current = gotoThing; if (!this.$disposing) { this.$PC = 1; } return(true); case 1u: this.$current = Toils_General.Wait(800, TargetIndex.None).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f); if (!this.$disposing) { this.$PC = 2; } return(true); case 2u: { Toil finalize = new Toil(); finalize.initAction = delegate() { Thing thing = this.job.targetA.Thing; Designation designation = base.Map.designationManager.DesignationOn(thing, DesignationDefOf.RearmTrap); if (designation != null) { designation.Delete(); } Building_TrapRearmable building_TrapRearmable = thing as Building_TrapRearmable; building_TrapRearmable.Rearm(); this.pawn.records.Increment(RecordDefOf.TrapsRearmed); }; finalize.defaultCompleteMode = ToilCompleteMode.Instant; this.$current = finalize; if (!this.$disposing) { this.$PC = 3; } return(true); } case 3u: this.$PC = -1; break; } return(false); }