// Token: 0x06000002 RID: 2 RVA: 0x00002072 File Offset: 0x00000272 protected override IEnumerable <Toil> MakeNewToils() { ToilFailConditions.FailOnDespawnedOrNull <JobDriver_RearmTrap>(this, TargetIndex.A); ToilFailConditions.FailOnThingMissingDesignation <JobDriver_RearmTrap>(this, TargetIndex.A, YautjaDefOf.RRY_RearmTrap); Toil toil = new Toil(); toil.initAction = delegate() { this.pawn.pather.StartPath(base.TargetThingA, PathEndMode.Touch); }; toil.defaultCompleteMode = ToilCompleteMode.PatherArrival; ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(toil, TargetIndex.A); yield return(toil); yield return(ToilEffects.WithProgressBarToilDelay(Toils_General.Wait(1125, 0), TargetIndex.A, false, -0.5f)); yield return(new Toil { initAction = delegate() { Thing thing = this.job.targetA.Thing; Designation designation = base.Map.designationManager.DesignationOn(thing, YautjaDefOf.RRY_RearmTrap); if (designation != null) { designation.Delete(); } (thing as Building_TrapRearmable).Rearm(); this.pawn.records.Increment(YautjaDefOf.RRY_TrapsRearmed); }, defaultCompleteMode = ToilCompleteMode.Instant }); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { //FAIL CONDITIONS ToilFailConditions.FailOnDestroyedOrNull <JobDriver_Training>(this, TargetIndex.A); ToilFailConditions.FailOnDespawnedNullOrForbidden <JobDriver_Training>(this, TargetIndex.A); this.FailOn(() => { Pawn p = this.pawn; if (this.IsContinuation(this.job) && this.CurToilIndex > 1) { if ((double)p.needs.food.CurLevel < 0.25) { Messages.Message(p.LabelCap + " has stopped training due hunger.", (GlobalTargetInfo)p, MessageTypeDefOf.NeutralEvent); } else if ((double)p.needs.rest.CurLevel < 0.25) { Messages.Message(p.LabelCap + " has stopped training due lack of sleep.", (GlobalTargetInfo)p, MessageTypeDefOf.NeutralEvent); } } return((double)p.needs.food.CurLevel < 0.25 || (double)p.needs.rest.CurLevel < 0.25 || p.Drafted || p.jobs.jobQueue.Any()); }); //SEQUENZA AZIONI PAWN yield return(Toils_Reserve.Reserve(TargetIndex.A, 1)); yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell)); Toil Train = Toils_Training(TargetIndex.B); yield return(Train); yield return(Toils_General.Wait(100)); yield return(Toils_Jump.Jump(Train)); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil exitPocket = Toils_General.Wait(60, 0); ToilEffects.WithProgressBarToilDelay(exitPocket, TargetIndex.A, false, -0.5f); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(exitPocket, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(exitPocket, TargetIndex.A, PathEndMode.InteractionCell); yield return(exitPocket); yield return(new Toil { initAction = delegate() { Pawn pawn = GetActor(); if (TargetA.Thing is Building_PocketDimensionExit pocketDimensionExit) { //PocketDimensionBox box = pocketDimensionExit.GetBox(); //if (box != null) //{ // pawn.DeSpawn(DestroyMode.Vanish); // GenSpawn.Spawn(pawn, box.Position, box.Map, WipeMode.Vanish); //} } } });
/* * //maybe change? * protected abstract int GatherResourcesIntervalDays * { * get; * } * * //add breastsize modifier? * protected abstract int ResourceAmount * { * get; * } * //add more milks? * protected abstract ThingDef ResourceDef * { * get; * } */ protected override IEnumerable <Toil> MakeNewToils() { ToilFailConditions.FailOnDespawnedNullOrForbidden <JobDriver_GatherHumanBodyResources>(this, TargetIndex.A); ToilFailConditions.FailOnNotCasualInterruptible <JobDriver_GatherHumanBodyResources>(this, TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil wait = new Toil(); wait.initAction = delegate { Pawn milker = base.pawn; LocalTargetInfo target = base.job.GetTarget(TargetIndex.A); Pawn target2 = (Pawn)target.Thing; milker.pather.StopDead(); PawnUtility.ForceWait(target2, 15000, null, true); }; wait.tickAction = delegate { Pawn milker = base.pawn; milker.skills.Learn(SkillDefOf.Animals, 0.13f, false); gatherProgress += StatExtension.GetStatValue(milker, StatDefOf.AnimalGatherSpeed, true); if (gatherProgress >= WorkTotal) { GetComp((Pawn)base.job.GetTarget(TargetIndex.A)).Gathered(base.pawn); milker.jobs.EndCurrentJob(JobCondition.Succeeded, true); } }; wait.AddFinishAction((Action) delegate { Pawn milker = base.pawn; LocalTargetInfo target = base.job.GetTarget(TargetIndex.A); Pawn target2 = (Pawn)target.Thing; if (target2 != null && target2.CurJobDef == JobDefOf.Wait_MaintainPosture) { milker.jobs.EndCurrentJob(JobCondition.InterruptForced, true); } }); ToilFailConditions.FailOnDespawnedOrNull <Toil>(wait, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(wait, TargetIndex.A, PathEndMode.Touch); wait.AddEndCondition((Func <JobCondition>) delegate { if (GetComp((Pawn)base.job.GetTarget(TargetIndex.A)).ActiveAndFull) { return(JobCondition.Ongoing); } return(JobCondition.Incompletable); }); wait.defaultCompleteMode = ToilCompleteMode.Never; ToilEffects.WithProgressBar(wait, TargetIndex.A, (Func <float>)(() => gatherProgress / WorkTotal), false, -0.5f); wait.activeSkill = (() => SkillDefOf.Animals); yield return(wait); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell)); Toil extractStack = Toils_General.Wait(120, 0); ToilEffects.WithProgressBarToilDelay(extractStack, TargetIndex.A, false, -0.5f); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(extractStack, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(extractStack, TargetIndex.A, PathEndMode.OnCell); yield return(extractStack); yield return(new Toil { initAction = delegate() { Corpse corpse = (Corpse)TargetThingA; Hediff_CorticalStack hediff = corpse.InnerPawn.health.hediffSet.hediffs.FirstOrDefault((Hediff x) => x.def.defName == "AC_CorticalStack") as Hediff_CorticalStack; if (hediff != null) { if (hediff.def.spawnThingOnRemoved != null) { var corticalStack = ThingMaker.MakeThing(hediff.def.spawnThingOnRemoved) as CorticalStack; if (hediff.hasPawn) { corticalStack.SavePawnFromHediff(hediff); } else { corticalStack.SavePawnToCorticalStack(corpse.InnerPawn); } GenPlace.TryPlaceThing(corticalStack, TargetThingA.Position, GetActor().Map, ThingPlaceMode.Near); ACUtils.ACTracker.RegisterStack(corticalStack); ACUtils.ACTracker.RegisterSleeve(corpse.InnerPawn, corticalStack.stackGroupID); } var head = corpse.InnerPawn.health.hediffSet.GetNotMissingParts().FirstOrDefault((BodyPartRecord x) => x.def == BodyPartDefOf.Head); if (head != null) { Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, corpse.InnerPawn, head); hediff_MissingPart.lastInjury = HediffDefOf.SurgicalCut; hediff_MissingPart.IsFresh = true; corpse.InnerPawn.health.AddHediff(hediff_MissingPart); } corpse.InnerPawn.health.RemoveHediff(hediff); if (pawn.Map.designationManager.DesignationOn(corpse).def == AlteredCarbonDefOf.AC_ExtractStackDesignation) { pawn.Map.designationManager.TryRemoveDesignationOn(corpse, AlteredCarbonDefOf.AC_ExtractStackDesignation); } } } }); }
protected override IEnumerable <Toil> MakeNewToils() { ToilFailConditions.FailOnDespawnedNullOrForbidden(this, TargetIndex.A); ToilFailConditions.FailOnNotCasualInterruptible(this, TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil wait = new Toil(); wait.initAction = delegate() { Pawn actor = wait.actor; Pawn pawn = (Pawn)job.GetTarget(TargetIndex.A).Thing; actor.pather.StopDead(); PawnUtility.ForceWait(pawn, 15000, null, true); }; wait.tickAction = delegate() { Pawn actor = wait.actor; actor.skills.Learn(SkillDefOf.Animals, 0.13f, false); gatherProgress += StatExtension.GetStatValue(actor, StatDefOf.AnimalGatherSpeed, true); if (gatherProgress >= WorkTotal) { GetComp((Pawn)((Thing)job.GetTarget(TargetIndex.A))).Gathered(this.pawn); actor.jobs.EndCurrentJob(JobCondition.Succeeded, true); } }; wait.AddFinishAction(delegate() { Pawn pawn = (Pawn)job.GetTarget(TargetIndex.A).Thing; if (pawn != null && pawn.CurJobDef == JobDefOf.Wait_MaintainPosture) { pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, true); } }); ToilFailConditions.FailOnDespawnedOrNull <Toil>(wait, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(wait, TargetIndex.A, PathEndMode.Touch); wait.AddEndCondition(delegate() { if (!GetComp((Pawn)((Thing)this.job.GetTarget(TargetIndex.A))).ActiveAndFull) { return(JobCondition.Incompletable); } return(JobCondition.Ongoing); }); wait.defaultCompleteMode = ToilCompleteMode.Never; ToilEffects.WithProgressBar(wait, TargetIndex.A, () => this.gatherProgress / this.WorkTotal, false, -0.5f); wait.activeSkill = (() => SkillDefOf.Animals); yield return(wait); yield break; }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil enterPocket = Toils_General.Wait(60, 0); ToilEffects.WithProgressBarToilDelay(enterPocket, TargetIndex.A, false, -0.5f); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(enterPocket, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(enterPocket, TargetIndex.A, PathEndMode.InteractionCell); yield return(enterPocket); yield return(new Toil { initAction = delegate() { Pawn pawn = GetActor(); if (TargetA.Thing is Building_PocketDimensionEntranceBase pocketDimensionEntrance) { Building_PocketDimensionEntranceBase otherSide = PocketDimensionUtility.GetOtherSide(pocketDimensionEntrance); if (otherSide != null && otherSide.Map != null) { IntVec3 position = otherSide.Position; Map map = otherSide.Map; // If otherSide is uninstalled... if (otherSide.Map == null && otherSide.holdingOwner != null && otherSide.holdingOwner.Owner != null && (otherSide.holdingOwner.Owner as MinifiedThing) != null) { MinifiedThing miniThing = (otherSide.holdingOwner.Owner as MinifiedThing); position = miniThing.Position; map = miniThing.Map; } if (position != null && map != null) { pawn.ClearAllReservations(); pawn.DeSpawn(DestroyMode.Vanish); GenSpawn.Spawn(pawn, position, map, WipeMode.Vanish); } } } } });
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell)); Toil extractStack = Toils_General.Wait(120, 0); ToilEffects.WithProgressBarToilDelay(extractStack, TargetIndex.A, false, -0.5f); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(extractStack, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(extractStack, TargetIndex.A, PathEndMode.OnCell); yield return(extractStack); yield return(new Toil { initAction = delegate() { Corpse corpse = (Corpse)TargetThingA; Hediff_CorticalStack hediff = corpse.InnerPawn.health.hediffSet.hediffs.FirstOrDefault((Hediff x) => x.def.defName == "AC_CorticalStack") as Hediff_CorticalStack; if (hediff != null) { if (hediff.def.spawnThingOnRemoved != null) { var corticalStack = ThingMaker.MakeThing(hediff.def.spawnThingOnRemoved) as CorticalStack; if (hediff.hasPawn) { corticalStack.SavePawnFromHediff(hediff); } else { corticalStack.SavePawnToCorticalStack(corpse.InnerPawn); } GenPlace.TryPlaceThing(corticalStack, TargetThingA.Position, GetActor().Map, ThingPlaceMode.Near); ACUtils.ACTracker.RegisterStack(corticalStack); ACUtils.ACTracker.RegisterSleeve(corpse.InnerPawn); } corpse.InnerPawn.health.RemoveHediff(hediff); } } }); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(new Toil { initAction = delegate() { var ZTracker = Current.Game.GetComponent <ZLevelsManager>(); if (ZTracker.jobTracker.ContainsKey(pawn)) { this.savedThing = this.TargetB.Thing; } } }); this.FailOnDestroyedOrNull(TargetIndex.B); this.FailOnBurningImmobile(TargetIndex.B); this.FailOnForbidden(TargetIndex.B); Toil reserveTargetA = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null); yield return(reserveTargetA); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch)); yield return(new Toil { initAction = delegate() { if (this.pawn.jobs.curJob.count == -1) { this.pawn.jobs.curJob.count = Mathf.Min(TargetB.Thing.stackCount, (int)(pawn.GetStatValue(StatDefOf.CarryingCapacity, true) / TargetB.Thing.def.VolumePerUnit)); if (this.pawn.jobs.curJob.count < 0) { this.pawn.jobs.curJob.count = TargetB.Thing.stackCount; } } ZLogger.Message(this.pawn + " haul count: " + this.pawn.jobs.curJob.count); } }); yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, true, false)); yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveTargetA, TargetIndex.B, TargetIndex.A, false, null)); Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.A); yield return(carryToCell); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell)); Toil useStairs = Toils_General.Wait(60, 0); ToilEffects.WithProgressBarToilDelay(useStairs, TargetIndex.A, false, -0.5f); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(useStairs, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(useStairs, TargetIndex.A, PathEndMode.OnCell); //yield return new Toil //{ // initAction = delegate () { // ZLogger.Message("this.pawn.CanReachImmediate(TargetA.Thing, PathEndMode.OnCell): " // + this.pawn.CanReachImmediate(TargetA.Thing, PathEndMode.OnCell), true); // } //}; yield return(useStairs); yield return(new Toil { initAction = delegate() { try { var ZTracker = Current.Game.GetComponent <ZLevelsManager>(); if (ZTracker.jobTracker.ContainsKey(pawn)) { if (ZTracker.jobTracker[pawn].mainJob.targetA.Thing != null && ZTracker.jobTracker[pawn].mainJob.targetA.Thing == this.savedThing && ZTracker.jobTracker[pawn].mainJob.targetA.Thing != TargetB.Thing) { ZLogger.Message("1 Pawns carried thing not the same: " + ZTracker.jobTracker[pawn].mainJob.targetA.Thing); ZTracker.jobTracker[pawn].mainJob.targetA = new LocalTargetInfo(TargetB.Thing); } else if (ZTracker.jobTracker[pawn].mainJob.targetB.Thing != null && ZTracker.jobTracker[pawn].mainJob.targetB.Thing == this.savedThing && ZTracker.jobTracker[pawn].mainJob.targetB.Thing != TargetB.Thing) { ZLogger.Message("2 Pawns carried thing not the same: " + ZTracker.jobTracker[pawn].mainJob.targetB.Thing); ZTracker.jobTracker[pawn].mainJob.targetB = new LocalTargetInfo(TargetB.Thing); } try { for (int i = ZTracker.jobTracker[pawn].mainJob.targetQueueA.Count - 1; i >= 0; i--) { var target = ZTracker.jobTracker[pawn].mainJob.targetQueueA[i]; if (target.Thing != null && target.Thing == this.savedThing && target.Thing != TargetB.Thing) { ZLogger.Message("3 Pawns carried thing not the same: " + target.Thing); ZTracker.jobTracker[pawn].mainJob.targetQueueA[i] = new LocalTargetInfo(TargetB.Thing); } } } catch { } try { try { ZLogger.Message("--------------------------"); for (int i = ZTracker.jobTracker[pawn].mainJob.targetQueueB.Count - 1; i >= 0; i--) { var target = ZTracker.jobTracker[pawn].mainJob.targetQueueB[i]; ZLogger.Message("JobDriver_HaulThingToStairs BEFORE job.targetQueueB: " + target.Thing); ZLogger.Message("JobDriver_HaulThingToStairs BEFORE job.targetQueueB.Map: " + target.Thing.Map); ZLogger.Message("JobDriver_HaulThingToStairs BEFORE job.targetQueueB.stackCount: " + target.Thing.stackCount); ZLogger.Message("JobDriver_HaulThingToStairs BEFORE job.targetQueueB.countQueue: " + ZTracker.jobTracker[pawn].mainJob.countQueue[i]); } } catch { } for (int i = ZTracker.jobTracker[pawn].mainJob.targetQueueB.Count - 1; i >= 0; i--) { var target = ZTracker.jobTracker[pawn].mainJob.targetQueueB[i]; if (target.Thing != null && target.Thing == this.savedThing && target.Thing != TargetB.Thing) { ZLogger.Message("4 Pawns carried thing not the same"); ZLogger.Message("4 Pawns target.Thing: " + target.Thing); ZLogger.Message("4 Pawns target.Thing.Map: " + target.Thing.Map); ZLogger.Message("4 Pawns this.savedThing: " + this.savedThing); ZLogger.Message("4 Pawns this.savedThing.Map: " + this.savedThing.Map); ZLogger.Message("4 Pawns TargetB.Thing: " + TargetB.Thing); ZLogger.Message("4 Pawns TargetB.Thing.Map: " + TargetB.Thing.Map); //ZLogger.Message("Replacing " + ZTracker.jobTracker[this.pawn].mainJob.targetQueueB[i] + " by " + TargetB); // //ZTracker.jobTracker[pawn].mainJob.targetQueueB[i] = new LocalTargetInfo(TargetB.Thing); //ZTracker.jobTracker[pawn].mainJob.countQueue[i] = TargetB.Thing.stackCount; // if (ZTracker.jobTracker[pawn].mainJob.targetQueueB[i].Thing.stackCount == 0) { ZTracker.jobTracker[pawn].mainJob.targetQueueB[i] = new LocalTargetInfo(TargetB.Thing); ZTracker.jobTracker[pawn].mainJob.countQueue[i] = TargetB.Thing.stackCount; ZLogger.Message("Altering " + ZTracker.jobTracker[this.pawn].mainJob); break; } else { if (ZTracker.jobTracker[pawn].mainJob.targetQueueB .Where(x => x.Thing == TargetB.Thing).Count() == 0) { var newTarget = new LocalTargetInfo(TargetB.Thing); ZTracker.jobTracker[this.pawn].mainJob.targetQueueB.Add(newTarget); ZTracker.jobTracker[this.pawn].mainJob.countQueue.Add(newTarget.Thing.stackCount); ZLogger.Message("2 Adding " + newTarget + " to " + ZTracker.jobTracker[this.pawn].mainJob); int ind = ZTracker.jobTracker[this.pawn].mainJob.targetQueueB.FirstIndexOf(x => x.Thing == this.savedThing); ZLogger.Message("2 Removing " + ZTracker.jobTracker[this.pawn].mainJob.targetQueueB[ind] + " from " + ZTracker.jobTracker[this.pawn].mainJob); ZTracker.jobTracker[this.pawn].mainJob.targetQueueB.RemoveAt(ind); ZTracker.jobTracker[this.pawn].mainJob.countQueue.RemoveAt(ind); break; } else { ZLogger.Message("Cant add " + TargetB.Thing + " to " + ZTracker.jobTracker[this.pawn].mainJob); } } } } try { ZLogger.Message("--------------------------"); for (int i = ZTracker.jobTracker[pawn].mainJob.targetQueueB.Count - 1; i >= 0; i--) { var target = ZTracker.jobTracker[pawn].mainJob.targetQueueB[i]; ZLogger.Message("JobDriver_HaulThingToStairs AFTER job.targetQueueB: " + target.Thing); ZLogger.Message("JobDriver_HaulThingToStairs AFTER job.targetQueueB.Map: " + target.Thing.Map); ZLogger.Message("JobDriver_HaulThingToStairs AFTER job.targetQueueB.stackCount: " + target.Thing.stackCount); ZLogger.Message("JobDriver_HaulThingToStairs AFTER job.targetQueueB.countQueue: " + ZTracker.jobTracker[pawn].mainJob.countQueue[i]); } } catch { } } catch { } } } catch (Exception ex) { Log.Error("Z-Tracker produced an error in JobDriver_HaulThingToStairs class. Report about it to devs. Error: " + ex); } } }); yield return(new Toil() { initAction = () => { var ZTracker = Current.Game.GetComponent <ZLevelsManager>(); Pawn pawn = GetActor(); if (TargetA.Thing is Building_StairsUp stairsUp) { Map map = ZTracker.GetUpperLevel(this.pawn.Map.Tile, this.pawn.Map); if (map == null) { map = ZTracker.CreateUpperLevel(this.pawn.Map, stairsUp.Position); if (stairsUp.pathToPreset != null && stairsUp.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsUp.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, true, false, stairsUp.shouldSpawnStairsUpper); stairsUp.shouldSpawnStairsUpper = false; } else { if (stairsUp.pathToPreset != null && stairsUp.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsUp.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, false, false, stairsUp.shouldSpawnStairsUpper); stairsUp.shouldSpawnStairsUpper = false; } } if (TargetA.Thing is Building_StairsDown stairsDown) { Map map = ZTracker.GetLowerLevel(this.pawn.Map.Tile, this.pawn.Map); if (map == null) { map = ZTracker.CreateLowerLevel(this.pawn.Map, stairsDown.Position); if (stairsDown.pathToPreset != null && stairsDown.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsDown.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map); } else { if (stairsDown.pathToPreset != null && stairsDown.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsDown.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map); } } try { for (int i = ZTracker.jobTracker[pawn].mainJob.targetQueueB.Count - 1; i >= 0; i--) { var target = ZTracker.jobTracker[pawn].mainJob.targetQueueB[i]; ZLogger.Message("JobDriver_HaulThingToStairs job.targetQueueB: " + target.Thing); ZLogger.Message("JobDriver_HaulThingToStairs job.targetQueueB.Map: " + target.Thing.Map); ZLogger.Message("JobDriver_HaulThingToStairs job.targetQueueB.stackCount: " + target.Thing.stackCount); ZLogger.Message("JobDriver_HaulThingToStairs job.targetQueueB.countQueue: " + ZTracker.jobTracker[pawn].mainJob.countQueue[i]); } } catch { } } });
public override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell)); Toil useStairs = Toils_General.Wait(60, 0); ToilEffects.WithProgressBarToilDelay(useStairs, TargetIndex.A, false, -0.5f); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(useStairs, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(useStairs, TargetIndex.A, PathEndMode.OnCell); yield return(useStairs); yield return(new Toil { initAction = delegate() { var ZTracker = ZUtils.ZTracker; Pawn pawn = GetActor(); if (TargetA.Thing is Building_StairsUp stairsUp) { Map map = ZTracker.GetUpperLevel(this.pawn.Map.Tile, this.pawn.Map); if (map == null) { map = ZTracker.CreateUpperLevel(this.pawn.Map, stairsUp.Position); if (!string.IsNullOrEmpty(stairsUp.pathToPreset)) { var comp = ZUtils.GetMapComponentZLevel(map); comp.DoGeneration = true; comp.path = stairsUp.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, true, false, true); } else { if (!string.IsNullOrEmpty(stairsUp.pathToPreset)) { var comp = ZUtils.GetMapComponentZLevel(map); comp.DoGeneration = true; comp.path = stairsUp.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, false, false, stairsUp.shouldSpawnStairsUpper); stairsUp.shouldSpawnStairsUpper = false; } } else if (TargetA.Thing is Building_StairsDown stairsDown) { Map map = ZTracker.GetLowerLevel(this.pawn.Map.Tile, this.pawn.Map); if (map == null) { //ZLogger.Message("CREATING LOWER LEVEL AGAIG", true); map = ZTracker.CreateLowerLevel(this.pawn.Map, stairsDown.Position); if (!string.IsNullOrEmpty(stairsDown.pathToPreset)) { var comp = ZUtils.GetMapComponentZLevel(map); comp.DoGeneration = true; comp.path = stairsDown.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, true, true); } else { if (!string.IsNullOrEmpty(stairsDown.pathToPreset)) { var comp = ZUtils.GetMapComponentZLevel(map); comp.DoGeneration = true; comp.path = stairsDown.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, false, stairsDown.shouldSpawnStairsBelow); stairsDown.shouldSpawnStairsBelow = false; } } } });
public static IEnumerable <Toil> Toils_GoToThingMap(Pawn pawn, Thing selectedStairs, Thing thing, JobDriver instance) { Toil setStairs = new Toil { initAction = delegate() { var ZTracker = Current.Game.GetComponent <ZLevelsManager>(); ZLogger.Message("Pawn: " + pawn); ZLogger.Message("Pawn.map: " + pawn.Map); ZLogger.Message("thing: " + thing); ZLogger.Message("thing.Map: " + thing.Map); ZLogger.Message("pawn.CurJob: " + pawn.jobs.curJob); if (ZTracker.GetZIndexFor(pawn.Map) > ZTracker.GetZIndexFor(thing.Map)) { var stairs = ZTracker.stairsDown[pawn.Map]; if (stairs?.Count() > 0) { selectedStairs = stairs.MinBy(x => IntVec3Utility.DistanceTo(thing.Position, x.Position)); } } else if (ZTracker.GetZIndexFor(pawn.Map) < ZTracker.GetZIndexFor(thing.Map)) { var stairs = ZTracker.stairsUp[pawn.Map]; if (stairs?.Count() > 0) { selectedStairs = stairs.MinBy(x => IntVec3Utility.DistanceTo(thing.Position, x.Position)); } } pawn.jobs.curJob.targetC = new LocalTargetInfo(selectedStairs); } }; yield return(setStairs); yield return(Toils_Goto.GotoThing(TargetIndex.C, PathEndMode.OnCell)); Toil useStairs = Toils_General.Wait(60, 0); ToilEffects.WithProgressBarToilDelay(useStairs, TargetIndex.C, false, -0.5f); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(useStairs, TargetIndex.C); //ToilFailConditions.FailOnCannotTouch<Toil>(useStairs, TargetIndex.C, PathEndMode.OnCell); yield return(useStairs); yield return(new Toil { initAction = delegate() { var ZTracker = Current.Game.GetComponent <ZLevelsManager>(); if (selectedStairs is Building_StairsUp stairsUp) { Map map = ZTracker.GetUpperLevel(pawn.Map.Tile, pawn.Map); if (map == null) { map = ZTracker.CreateUpperLevel(pawn.Map, stairsUp.Position); if (stairsUp.pathToPreset != null && stairsUp.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsUp.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, true, false, true); } else { if (stairsUp.pathToPreset != null && stairsUp.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsUp.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, false, false, stairsUp.shouldSpawnStairsUpper); stairsUp.shouldSpawnStairsUpper = false; } } else if (selectedStairs is Building_StairsDown stairsDown) { Map map = ZTracker.GetLowerLevel(pawn.Map.Tile, pawn.Map); if (map == null) { map = ZTracker.CreateLowerLevel(pawn.Map, stairsDown.Position); if (stairsDown.pathToPreset != null && stairsDown.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsDown.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, true, true); } else { if (stairsDown.pathToPreset != null && stairsDown.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsDown.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, false, stairsDown.shouldSpawnStairsBelow); stairsDown.shouldSpawnStairsBelow = false; } } if (pawn.Map != thing.Map) { instance.JumpToToil(setStairs); } } });
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell)); Toil useStairs = Toils_General.Wait(60, 0); ToilEffects.WithProgressBarToilDelay(useStairs, TargetIndex.A, false, -0.5f); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(useStairs, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(useStairs, TargetIndex.A, PathEndMode.OnCell); yield return(useStairs); yield return(new Toil { initAction = delegate() { var ZTracker = Current.Game.GetComponent <ZLevelsManager>(); Pawn pawn = GetActor(); if (TargetA.Thing is Building_StairsUp stairsUp) { Map map = ZTracker.GetUpperLevel(this.pawn.Map.Tile, this.pawn.Map); if (map == null) { map = ZTracker.CreateUpperLevel(this.pawn.Map, stairsUp.Position); if (stairsUp.pathToPreset != null && stairsUp.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsUp.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, true, false, true); } else { if (stairsUp.pathToPreset != null && stairsUp.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsUp.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, false, false, stairsUp.shouldSpawnStairsUpper); stairsUp.shouldSpawnStairsUpper = false; } } else if (TargetA.Thing is Building_StairsDown stairsDown) { Map map = ZTracker.GetLowerLevel(this.pawn.Map.Tile, this.pawn.Map); if (map == null) { map = ZTracker.CreateLowerLevel(this.pawn.Map, stairsDown.Position); if (stairsDown.pathToPreset != null && stairsDown.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsDown.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, true, true); } else { if (stairsDown.pathToPreset != null && stairsDown.pathToPreset.Length > 0) { var comp = map.GetComponent <MapComponentZLevel>(); comp.DoGeneration = true; comp.path = stairsDown.pathToPreset; } ZTracker.TeleportPawn(pawn, pawn.Position, map, false, stairsDown.shouldSpawnStairsBelow); stairsDown.shouldSpawnStairsBelow = false; } } try { ZLogger.Message("5 lastTick"); ZTracker.jobTracker[pawn].lastTickFood = Find.TickManager.TicksGame + 201; ZTracker.jobTracker[pawn].lastTickJoy = Find.TickManager.TicksGame + 201; } catch { }; } });
// Token: 0x0600003C RID: 60 RVA: 0x000038A6 File Offset: 0x00001AA6 protected override IEnumerable <Toil> MakeNewToils() { Pawn actor = base.GetActor(); ToilFailConditions.FailOnDespawnedNullOrForbidden <JobDriver_JPRefuel>(this, TargetIndex.A); yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null)); yield return(ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch), TargetIndex.A)); Toil refuel = Toils_General.Wait(180, 0); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(refuel, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(refuel, TargetIndex.A, PathEndMode.Touch); ToilEffects.WithProgressBarToilDelay(refuel, TargetIndex.A, false, -0.5f); yield return(refuel); yield return(new Toil { initAction = delegate() { int JPFuel = 0; int JPMax = 0; Pawn obj = actor; if (obj != null && obj.apparel.WornApparelCount == 0) { //Log.Message("True: obj != null && obj.apparel.WornApparelCount == 0"); this.EndJobWith(JobCondition.Incompletable); return; } Apparel JetPack = null; List <Apparel> list = actor.apparel.WornApparel; for (int i = 0; i < list.Count; i++) { if (list[i] is JetPackApparel) { JetPack = list[i]; break; } } if (JetPack == null) { this.EndJobWith(JobCondition.Incompletable); return; } if (JetPack is JetPackApparel) { //Log.Message("True: JetPack is JetPackApparel"); JPFuel = (JetPack as JetPackApparel).JPFuelAmount; JPMax = (JetPack as JetPackApparel).JPFuelMax; } if (JPMax - JPFuel <= 0) { //Log.Message("True: JPMax - JPFuel <= 0"); this.EndJobWith(JobCondition.Incompletable); return; } if (this.TargetThingA.stackCount > JPMax - JPFuel) { //Log.Message("True: this.TargetThingA.stackCount > JPMax - JPFuel"); (JetPack as JetPackApparel).JPFuelAmount = JPMax; this.TargetThingA.stackCount -= JPMax - JPFuel; Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.FullyRefueled", actor.LabelShort), actor, MessageTypeDefOf.NeutralEvent, false); this.EndJobWith(JobCondition.Succeeded); return; } //Log.Message("False"); (JetPack as JetPackApparel).JPFuelAmount = JPFuel + this.TargetThingA.stackCount; Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.Refueled", GenText.CapitalizeFirst(actor.LabelShort), this.TargetThingA.stackCount.ToString(), (this.TargetThingA.stackCount > 1) ? "s" : ""), actor, MessageTypeDefOf.NeutralEvent, false); this.TargetThingA.Destroy(0); this.EndJobWith(JobCondition.Succeeded); } }); yield break; }