public static void UpdateFlickDesignation(Thing t) { bool flag = false; ThingWithComps thingWithComps = t as ThingWithComps; if (thingWithComps != null) { for (int i = 0; i < thingWithComps.AllComps.Count; i++) { CompFlickable compFlickable = thingWithComps.AllComps[i] as CompFlickable; if (compFlickable != null && compFlickable.WantsFlick()) { flag = true; break; } } } Designation designation = t.Map.designationManager.DesignationOn(t, DesignationDefOf.Flick); if (flag && designation == null) { t.Map.designationManager.AddDesignation(new Designation(t, DesignationDefOf.Flick)); } else if (!flag && designation != null) { designation.Delete(); } TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.SwitchFlickingDesignation); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); this.FailOn(() => (base.Map.designationManager.DesignationOn(base.TargetThingA, DesignationDefOf.Flick) == null) ? true : false); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); yield return(Toils_General.Wait(15).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch)); 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++) { CompFlickable compFlickable = thingWithComps.AllComps[i] as CompFlickable; if (compFlickable != null && compFlickable.WantsFlick()) { compFlickable.DoFlick(); } } actor.records.Increment(RecordDefOf.SwitchesFlicked); base.Map.designationManager.DesignationOn(thingWithComps, DesignationDefOf.Flick)?.Delete(); }; finalize.defaultCompleteMode = ToilCompleteMode.Instant; yield return(finalize); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: this.FailOnDespawnedOrNull(TargetIndex.A); this.FailOn(delegate() { Designation designation = this.Map.designationManager.DesignationOn(this.TargetThingA, DesignationDefOf.Flick); return(designation == null); }); this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch); if (!this.$disposing) { this.$PC = 1; } return(true); case 1u: this.$current = Toils_General.Wait(15, TargetIndex.None).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); if (!this.$disposing) { this.$PC = 2; } return(true); case 2u: < MakeNewToils > c__AnonStorey.finalize = new Toil(); < MakeNewToils > c__AnonStorey.finalize.initAction = delegate() { Pawn actor = < MakeNewToils > c__AnonStorey.finalize.actor; ThingWithComps thingWithComps = (ThingWithComps)actor.CurJob.targetA.Thing; for (int i = 0; i < thingWithComps.AllComps.Count; i++) { CompFlickable compFlickable = thingWithComps.AllComps[i] as CompFlickable; if (compFlickable != null && compFlickable.WantsFlick()) { compFlickable.DoFlick(); } } actor.records.Increment(RecordDefOf.SwitchesFlicked); Designation designation = < MakeNewToils > c__AnonStorey.< > f__ref$0.$this.Map.designationManager.DesignationOn(thingWithComps, DesignationDefOf.Flick); if (designation != null) { designation.Delete(); } };