protected override IEnumerable <Toil> MakeNewToils() { _003CMakeNewToils_003Ec__Iterator0 _003CMakeNewToils_003Ec__Iterator = (_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_004e: stateMachine*/; this.FailOnDespawnedNullOrForbidden(TargetIndex.A); Toil gotoTurret = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); Toil loadIfNeeded = new Toil(); loadIfNeeded.initAction = delegate { Pawn actor = loadIfNeeded.actor; Building building = (Building)actor.CurJob.targetA.Thing; Building_TurretGun building_TurretGun = building as Building_TurretGun; if (!JobDriver_ManTurret.GunNeedsLoading(building)) { _003CMakeNewToils_003Ec__Iterator._0024this.JumpToToil(gotoTurret); } else { Thing thing = JobDriver_ManTurret.FindAmmoForTurret(_003CMakeNewToils_003Ec__Iterator._0024this.pawn, building_TurretGun); if (thing == null) { if (actor.Faction == Faction.OfPlayer) { Messages.Message("MessageOutOfNearbyShellsFor".Translate(actor.LabelShort, building_TurretGun.Label).CapitalizeFirst(), building_TurretGun, MessageTypeDefOf.NegativeEvent); } actor.jobs.EndCurrentJob(JobCondition.Incompletable, true); } actor.CurJob.targetB = thing; actor.CurJob.count = 1; } }; yield return(loadIfNeeded); /*Error: Unable to find new state assignment for yield return*/; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); Toil gotoTurret = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); Toil loadIfNeeded = new Toil(); loadIfNeeded.initAction = delegate { Pawn actor = loadIfNeeded.actor; Building building = (Building)actor.CurJob.targetA.Thing; Building_TurretGun building_TurretGun = building as Building_TurretGun; if (!JobDriver_ManTurret.GunNeedsLoading(building)) { this.$this.JumpToToil(gotoTurret); return; } Thing thing = JobDriver_ManTurret.FindAmmoForTurret(this.$this.pawn, building_TurretGun); if (thing == null) { if (actor.Faction == Faction.OfPlayer) { Messages.Message("MessageOutOfNearbyShellsFor".Translate(new object[] { actor.LabelShort, building_TurretGun.Label }).CapitalizeFirst(), building_TurretGun, MessageTypeDefOf.NegativeEvent, true); } actor.jobs.EndCurrentJob(JobCondition.Incompletable, true); } actor.CurJob.targetB = thing; actor.CurJob.count = 1; }; yield return(loadIfNeeded); yield return(Toils_Reserve.Reserve(TargetIndex.B, 10, 1, null)); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.OnCell).FailOnSomeonePhysicallyInteracting(TargetIndex.B)); yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, false, false)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); yield return(new Toil { initAction = delegate { Pawn actor = loadIfNeeded.actor; Building building = (Building)actor.CurJob.targetA.Thing; Building_TurretGun building_TurretGun = building as Building_TurretGun; SoundDefOf.Artillery_ShellLoaded.PlayOneShot(new TargetInfo(building_TurretGun.Position, building_TurretGun.Map, false)); building_TurretGun.gun.TryGetComp <CompChangeableProjectile>().LoadShell(actor.CurJob.targetB.Thing.def, 1); actor.carryTracker.innerContainer.ClearAndDestroyContents(DestroyMode.Vanish); } }); yield return(gotoTurret); Toil man = new Toil(); man.tickAction = delegate { Pawn actor = man.actor; Building building = (Building)actor.CurJob.targetA.Thing; if (JobDriver_ManTurret.GunNeedsLoading(building)) { this.$this.JumpToToil(loadIfNeeded); return; } building.GetComp <CompMannable>().ManForATick(actor); }; man.defaultCompleteMode = ToilCompleteMode.Never; man.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); yield return(man); }