Example #1
0
        // Token: 0x06000022 RID: 34 RVA: 0x00002891 File Offset: 0x00000A91
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedOrNull(TargetIndex.B);
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null));

            yield return(Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null));

            this.FailOn(delegate()
            {
                IBillGiver billGiver = this.job.GetTarget(TargetIndex.A).Thing as IBillGiver;
                return(this.BellRef.currentState == Building_Bell.State.rest);
            });
            base.AddFinishAction(delegate
            {
                bool flag = this.Takee == this.BellRef.fighter1.p;
                if (flag)
                {
                    bool isInFight = this.BellRef.fighter1.isInFight;
                    if (!isInFight)
                    {
                        this.BellRef.TryCancelBrawl("");
                    }
                }
                else
                {
                    bool flag2 = this.Takee == this.BellRef.fighter2.p;
                    if (flag2)
                    {
                        bool isInFight2 = this.BellRef.fighter2.isInFight;
                        if (!isInFight2)
                        {
                            this.BellRef.TryCancelBrawl("");
                        }
                    }
                }
            });
            yield return(new Toil
            {
                initAction = delegate()
                {
                    bool flag = this.BellRef.currentState == Building_Bell.State.scheduled;
                    if (flag)
                    {
                        this.BellRef.currentState = Building_Bell.State.preparation;
                        this.BellRef.startTheShow();
                    }
                }
            });

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, false, false));

            yield return(Toils_Goto.GotoCell(TargetIndex.C, PathEndMode.Touch));

            yield return(new Toil
            {
                initAction = delegate()
                {
                    IntVec3 position = this.DropPosition;
                    Thing thing;
                    this.pawn.carryTracker.TryDropCarriedThing(position, ThingPlaceMode.Direct, out thing, null);
                    bool flag = !this.BellRef.Destroyed;
                    if (flag)
                    {
                        this.HaulFinished();
                        this.BellRef.PrisonerDelievered(this.Takee);
                        bool flag2 = this.BellRef.currentState != Building_Bell.State.fight;
                        if (flag2)
                        {
                            Job carryPrisonerJob = new Job(JobDefOfArena.HaulingPrisoner, this.BellRef.getPrisonerForHaul(), this.BellRef, this.BellRef.getFighterStandPoint())
                            {
                                count = 1
                            };
                            this.pawn.jobs.TryTakeOrderedJob(carryPrisonerJob, JobTag.Misc);
                        }
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

            yield break;
        }
Example #2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(building);
            Toil reserveTargetA = Toils_Reserve.Reserve(building);

            yield return(reserveTargetA);

            comp            = this.pawn.GetComp <CompAbilityUserMagic>();
            portalBldg      = TargetA.Thing as Building_TMPortal;
            arcaneCapacitor = TargetA.Thing as Building_TMArcaneCapacitor;
            dmp             = TargetA.Thing as Building_TM_DMP;
            bldg            = TargetA.Thing as Building;

            Toil gotoPortal = new Toil()
            {
                initAction = () =>
                {
                    //pawn.pather.StartPath(portalBldg.InteractionCell, PathEndMode.OnCell);
                    if (pawn.pather != null && bldg.InteractionCell != null)
                    {
                        pawn.pather.StartPath(bldg.InteractionCell, PathEndMode.OnCell);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.PatherArrival
            };

            yield return(gotoPortal);

            Toil chargePortal = new Toil()
            {
                initAction = () =>
                {
                    if (age > duration)
                    {
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                    if (comp != null && comp.Mana != null && comp.Mana.CurLevel < .01f)
                    {
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                    else if (bldg.def.defName == "TM_DimensionalManaPocket")
                    {
                        this.duration = 220;
                    }
                },
                tickAction = () =>
                {
                    if (age > (effectsAge + ticksTillEffects))
                    {
                        this.effectsAge = this.age;
                        TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f));
                        Vector3 moteDirection = TM_Calc.GetVector(this.pawn.Position, bldg.Position);
                        TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Shadow, pawn.DrawPos, pawn.Map, Rand.Range(.4f, .6f), Rand.Range(.1f, .2f), .04f, Rand.Range(.1f, .2f), 300, 5f, (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0);
                    }
                    if (age > (chargeAge + ticksTillCharge))
                    {
                        if (bldg.def.defName == "TM_Portal")
                        {
                            comp.Mana.CurLevel         -= .01f;
                            portalBldg.ArcaneEnergyCur += .01f;
                            xpNum += 3;
                        }
                        else if (bldg.def.defName == "TM_ArcaneCapacitor")
                        {
                            comp.Mana.CurLevel -= .01f;
                            arcaneCapacitor.ArcaneEnergyCur += 1f;
                        }
                        else if (bldg.def.defName == "TM_DimensionalManaPocket")
                        {
                            comp.Mana.CurLevel  -= .05f;
                            dmp.ArcaneEnergyCur += 4f;
                            age += 4;
                        }
                        else
                        {
                            age = duration;
                        }
                        chargeAge = age;
                    }
                    age++;
                    if (age > duration)
                    {
                        AttributeXP(comp);
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                    if (comp.Mana.CurLevel < .1f)
                    {
                        AttributeXP(comp);
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                    if (comp.Mana.CurLevel < .05f && bldg.def.defName == "TM_DimensionalManaPocket")
                    {
                        //AttributeXP(comp);
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                    if (portalBldg != null && portalBldg.ArcaneEnergyCur >= 1f)
                    {
                        AttributeXP(comp);
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                    if (arcaneCapacitor != null && arcaneCapacitor.ArcaneEnergyCur >= arcaneCapacitor.TargetArcaneEnergyPct)
                    {
                        //AttributeXP(comp);
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                    if (dmp != null && dmp.ArcaneEnergyCur >= dmp.TargetArcaneEnergyPct)
                    {
                        //AttributeXP(comp);
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Never
            };

            yield return(chargePortal);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            if (tar == null)
            {
                foreach (var toil in base.MakeNewToils())
                {
                    yield return(toil);
                }
            }
            else
            {
                // Find the pawn to use the item on.
                Pawn other;
                {
                    var corpse = tar as Corpse;
                    other = (corpse == null) ? (Pawn)tar : corpse.InnerPawn;
                }

                this.FailOnDespawnedNullOrForbidden(itar);
                if (!other.Dead)
                {
                    this.FailOnAggroMentalState(itar);
                }
                yield return(Toils_Reserve.Reserve(itar));

                if ((pawn.inventory != null) && pawn.inventory.Contains(item))
                {
                    yield return(Toils_Misc.TakeItemFromInventoryToCarrier(pawn, iitem));
                }
                else
                {
                    yield return(Toils_Reserve.Reserve(iitem));

                    yield return(Toils_Goto.GotoThing(iitem, PathEndMode.ClosestTouch).FailOnForbidden(iitem));

                    yield return(pickup_item(pawn, item));
                }

                yield return(Toils_Goto.GotoThing(itar, PathEndMode.Touch));

                yield return(new Toil
                {
                    initAction = delegate
                    {
                        if (!other.Dead)
                        {
                            PawnUtility.ForceWait(other, 60);
                        }
                    },
                    defaultCompleteMode = ToilCompleteMode.Delay,
                    defaultDuration = 60
                });

                yield return(new Toil
                {
                    initAction = delegate
                    {
                        var effective_item = item;

                        // Drop the item if it's some kind of apparel. This is because ApparelTracker.Wear only works properly
                        // if the apparel to wear is spawned. (I'm just assuming that DoEffect for apparel wears it, which is
                        // true for bondage gear)
                        if ((effective_item as Apparel) != null)
                        {
                            Thing dropped_thing;
                            if (pawn.carryTracker.TryDropCarriedThing(pawn.Position, ThingPlaceMode.Near, out dropped_thing))
                            {
                                effective_item = dropped_thing as Apparel;
                            }
                            else
                            {
                                Log.Error("Unable to drop " + effective_item.Label + " for use on " + xxx.get_pawnname(other) + " (apparel must be dropped before use)");
                                effective_item = null;
                            }
                        }

                        if (effective_item != null)
                        {
                            var eff = effective_item.TryGetComp <CompUseEffect>();
                            if (eff != null)
                            {
                                eff.DoEffect(other);
                            }
                            else
                            {
                                Log.Error("Unable to get CompUseEffect for use of " + effective_item.Label + " on " + xxx.get_pawnname(other) + " by " + xxx.get_pawnname(pawn));
                            }
                        }
                    },
                    defaultCompleteMode = ToilCompleteMode.Instant
                });
            }
        }
Example #4
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedOrNull(TargetIndex.B);
            this.FailOnAggroMentalStateAndHostile(TargetIndex.A);
            this.FailOn(delegate
            {
                if (job.def.makeTargetPrisoner)
                {
                    if (!DropBed.ForPrisoners)
                    {
                        return(true);
                    }
                }
                else if (DropBed.ForPrisoners != Takee.IsPrisoner)
                {
                    return(true);
                }
                return(false);
            });
            yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.B, TargetIndex.A));

            AddFinishAction(delegate
            {
                if (job.def.makeTargetPrisoner && Takee.ownership.OwnedBed == DropBed && Takee.Position != RestUtility.GetBedSleepingSlotPosFor(Takee, DropBed))
                {
                    Takee.ownership.UnclaimBed();
                }
            });
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.A).FailOnDespawnedNullOrForbidden(TargetIndex.B)
                         .FailOn(() => job.def == JobDefOf.Arrest && !Takee.CanBeArrestedBy(pawn))
                         .FailOn(() => !pawn.CanReach(DropBed, PathEndMode.OnCell, Danger.Deadly))
                         .FailOn(() => (job.def == JobDefOf.Rescue || job.def == JobDefOf.Capture) && !Takee.Downed)
                         .FailOnSomeonePhysicallyInteracting(TargetIndex.A));

            Toil toil = new Toil();

            toil.initAction = delegate
            {
                if (job.def.makeTargetPrisoner)
                {
                    Pawn pawn = (Pawn)job.targetA.Thing;
                    pawn.GetLord()?.Notify_PawnAttemptArrested(pawn);
                    GenClamor.DoClamor(pawn, 10f, ClamorDefOf.Harm);
                    if (!pawn.IsPrisoner)
                    {
                        QuestUtility.SendQuestTargetSignals(pawn.questTags, "Arrested", pawn.Named("SUBJECT"));
                    }
                    if (job.def == JobDefOf.Arrest && !pawn.CheckAcceptArrest(base.pawn))
                    {
                        base.pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                    }
                }
            };
            yield return(toil);

            Toil toil2 = Toils_Haul.StartCarryThing(TargetIndex.A).FailOnNonMedicalBedNotOwned(TargetIndex.B, TargetIndex.A);

            toil2.AddPreInitAction(CheckMakeTakeeGuest);
            yield return(toil2);

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch));

            Toil toil3 = new Toil();

            toil3.initAction = delegate
            {
                CheckMakeTakeePrisoner();
                if (Takee.playerSettings == null)
                {
                    Takee.playerSettings = new Pawn_PlayerSettings(Takee);
                }
            };
            yield return(toil3);

            yield return(Toils_Reserve.Release(TargetIndex.B));

            Toil toil4 = new Toil();

            toil4.initAction = delegate
            {
                IntVec3 position = DropBed.Position;
                pawn.carryTracker.TryDropCarriedThing(position, ThingPlaceMode.Direct, out var _);
                if (!DropBed.Destroyed && (DropBed.OwnersForReading.Contains(Takee) || (DropBed.Medical && DropBed.AnyUnoccupiedSleepingSlot) || Takee.ownership == null))
                {
                    Takee.jobs.Notify_TuckedIntoBed(DropBed);
                    if (Takee.RaceProps.Humanlike && job.def != JobDefOf.Arrest && !Takee.IsPrisonerOfColony)
                    {
                        Takee.relations.Notify_RescuedBy(pawn);
                    }
                    Takee.mindState.Notify_TuckedIntoBed();
                }
                if (Takee.IsPrisonerOfColony)
                {
                    LessonAutoActivator.TeachOpportunity(ConceptDefOf.PrisonerTab, Takee, OpportunityType.GoodToKnow);
                }
            };
            toil4.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(toil4);
        }
Example #5
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_General.Wait(10, TargetIndex.None));

            yield return(new Toil
            {
                initAction = delegate()
                {
                    Thing MarkedThing = CompUnloadChecker.getFirstMarked(pawn);
                    if (MarkedThing == null)
                    {
                        EndJobWith(JobCondition.Succeeded);
                        return;
                    }
                    //
                    if (pawn.equipment.Contains(MarkedThing))
                    {
                        Equipment = (ThingWithComps)MarkedThing;
                        Apparel = null;
                    }
                    else
                    {
                        Apparel = pawn.apparel.Contains(MarkedThing) ? (Apparel)MarkedThing : null;
                        Equipment = null;
                    }

                    ThingCount firstUnloadableThing = MarkedThing == null ? default(ThingCount) : new ThingCount(MarkedThing, MarkedThing.stackCount);
                    IntVec3 c;
                    if (!StoreUtility.TryFindStoreCellNearColonyDesperate(firstUnloadableThing.Thing, pawn, out c))
                    {
                        Thing thing;
                        pawn.inventory.innerContainer.TryDrop(firstUnloadableThing.Thing, ThingPlaceMode.Near, firstUnloadableThing.Count, out thing, null, null);
                        EndJobWith(JobCondition.Succeeded);
                        return;
                    }

                    job.SetTarget(TargetIndex.A, firstUnloadableThing.Thing);
                    job.SetTarget(TargetIndex.B, c);
                    countToDrop = firstUnloadableThing.Count;
                }
            });

            yield return(Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null));

            yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.Touch).FailOnDestroyedOrNull(TargetIndex.A).FailOn(delegate() { return !stillUnloadable(pawn.CurJob.GetTarget(TargetIndex.A).Thing); }));

            //preintiating unequip-delay
            Toil unequip = new Toil
            {
                initAction = delegate()
                {
                    if (Equipment != null)
                    {
                        pawn.equipment.TryTransferEquipmentToContainer(Equipment, pawn.inventory.innerContainer);
                    }
                    else if (Apparel != null)
                    {
                        ThingOwner <Apparel> a = Traverse.Create(pawn.apparel).Field("wornApparel").GetValue <ThingOwner <Apparel> >();
                        a.TryTransferToContainer(Apparel, pawn.inventory.innerContainer);
                    }
                }
            };
            //if equiped, wait unequipping time
            Toil wait = new Toil();

            wait.initAction = delegate()
            {
                ticker   = 0;
                duration = Apparel != null?Apparel.GetStatValue(StatDefOf.EquipDelay, true) * 60f : Equipment != null ? 30 : 0;

                pawn.pather.StopDead();
            };
            wait.tickAction = delegate()
            {
                if (ticker >= duration)
                {
                    ReadyForNextToil();
                }
                ticker++;
            };
            wait.defaultCompleteMode = ToilCompleteMode.Never;
            wait.WithProgressBar(TargetIndex.A, () => ticker / duration);
            //unequip to inventory
            yield return(wait);

            yield return(unequip);

            //hold in hands
            yield return(new Toil
            {
                initAction = delegate()
                {
                    Thing thing = job.GetTarget(TargetIndex.A).Thing;
                    CompUnloadChecker c = thing.TryGetComp <CompUnloadChecker>();
                    if (c == null || !c.ShouldUnload)
                    {
                        EndJobWith(JobCondition.Incompletable);
                        return;
                    }
                    if (thing == null || !pawn.inventory.innerContainer.Contains(thing))
                    {
                        EndJobWith(JobCondition.Incompletable);
                        return;
                    }
                    if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !thing.def.EverStorable(false))
                    {
                        pawn.inventory.innerContainer.TryDrop(thing, ThingPlaceMode.Near, countToDrop, out thing, null, null);
                        EndJobWith(JobCondition.Succeeded);
                    }
                    else
                    {
                        pawn.inventory.innerContainer.TryTransferToContainer(thing, pawn.carryTracker.innerContainer, countToDrop, out thing, true);
                        job.count = countToDrop;
                        job.SetTarget(TargetIndex.A, thing);
                    }
                    thing.SetForbidden(false, false);
                }
            });

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B).FailOnDestroyedOrNull(TargetIndex.A).FailOn(delegate() { return(!stillUnloadable(pawn.CurJob.GetTarget(TargetIndex.A).Thing)); });

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true));

            yield break;
        }
Example #6
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            rotateToFace = Facing;

            this.AddEndCondition(delegate
            {
                if (TeacherPawn.CurJob.def.defName != "TeachLesson")
                {
                    return(JobCondition.Incompletable);
                }
                return(JobCondition.Ongoing);
            });
            this.EndOnDespawnedOrNull(Spot, JobCondition.Incompletable);
            this.EndOnDespawnedOrNull(Build, JobCondition.Incompletable);


            yield return(Toils_Reserve.Reserve(Spot, this.CurJob.def.joyMaxParticipants, 0, null));

            Toil gotoPreacher;

            if (this.TargetC.HasThing)
            {
                gotoPreacher = Toils_Goto.GotoThing(Spot, PathEndMode.OnCell);
            }
            else
            {
                gotoPreacher = Toils_Goto.GotoCell(Spot, PathEndMode.OnCell);
            }
            yield return(gotoPreacher);


            bool b        = setupSkills(this.Spott.teacher);
            Toil spotToil = new Toil();

            spotToil.defaultCompleteMode = ToilCompleteMode.Delay;
            spotToil.defaultDuration     = 9999;
            spotToil.AddPreTickAction(() =>
            {
                this.pawn.GainComfortFromCellIfPossible();
                this.ticksLeftThisToil = 9999;
                this.pawn.Drawer.rotator.FaceCell(TargetB.Cell);

                //LEARN
                Pawn actor = this.pawn;

                String leaderReport = this.Spott.teacher.jobs.curDriver.GetReport();
                if (leaderReport == "TeachingDesc".Translate() || leaderReport == "FinishLessonDesc".Translate())
                {
                    actor.skills.Learn(this.skillPool.RandomElementByWeight(delegate(SkillDef d)
                    {
                        return(1f + this.Spott.teacher.skills.GetSkill(d).Level);
                    }), TeachingUtility.learningFactor * Spott.GetStatValue(StatDef.Named("LearningSpeedFactor"), true));
                }

                //

                if (TeacherPawn.CurJob.def.defName != "TeachLesson" || !b)
                {
                    this.ticksLeftThisToil = -1;
                }
            });
            yield return(spotToil);

            yield return(Toils_Reserve.Release(Spot));

            this.AddFinishAction(() =>
            {
                if (Spott.currentLessonState == Building_TeachingSpot.LessonState.finishing ||
                    Spott.currentLessonState == Building_TeachingSpot.LessonState.finished)
                {
                    if (Rand.Range(0f, 1f) < 0.8f)
                    {
                        this.pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("LessonPositive"), this.Spott.teacher);
                    }
                    else
                    {
                        this.pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("LessonNegative"), this.Spott.teacher);
                    }
                    //CultUtility.AttendWorshipTickCheckEnd(PreacherPawn, this.pawn);
                    //Cthulhu.Utility.DebugReport("Called end tick check");
                    //what happens to learner
                }
                if (this.TargetC.HasThing)
                {
                    if (Map.reservationManager.IsReserved(this.CurJob.targetC.Thing, Faction.OfPlayer))
                    {
                        Map.reservationManager.Release(this.CurJob.targetC.Thing, pawn);
                    }
                }
                else
                {
                    if (Map.reservationManager.IsReserved(this.CurJob.targetC.Cell, Faction.OfPlayer))
                    {
                        Map.reservationManager.Release(this.CurJob.targetC.Cell, this.pawn);
                    }
                }
            });
            yield break;
        }
        public override IEnumerable <Toil> MakeNewToils()
        {
            AddEndCondition(delegate
            {
                Thing thing = GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing;
                if (thing is Building && !thing.Spawned)
                {
                    return(JobCondition.Incompletable);
                }
                return(JobCondition.Ongoing);
            });
            this.FailOnBurningImmobile(TargetIndex.A);
            this.FailOn(delegate()
            {
                IBillGiver billGiver = job.GetTarget(TargetIndex.A).Thing as IBillGiver;
                if (billGiver != null)
                {
                    if (job.bill.DeletedOrDereferenced)
                    {
                        return(true);
                    }
                    if (!billGiver.CurrentlyUsableForBills())
                    {
                        return(true);
                    }
                    if (project == null)
                    {
                        Log.Error("[HumanResources] Tried to document a null project.");
                        TryMakePreToilReservations(true);
                        return(true);
                    }
                    if (!techComp.homework.Contains(project))
                    {
                        return(true);
                    }
                }
                return(false);
            });
            Toil gotoBillGiver = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell);

            yield return(new Toil
            {
                initAction = delegate()
                {
                    if (job.targetQueueB != null && job.targetQueueB.Count == 1)
                    {
                        UnfinishedThing unfinishedThing = job.targetQueueB[0].Thing as UnfinishedThing;
                        if (unfinishedThing != null)
                        {
                            unfinishedThing.BoundBill = (Bill_ProductionWithUft)job.bill;
                        }
                    }
                }
            });

            yield return(Toils_Jump.JumpIf(gotoBillGiver, () => job.GetTargetQueue(TargetIndex.B).NullOrEmpty <LocalTargetInfo>()));

            Toil extract = Toils_JobTransforms.ExtractNextTargetFromQueue(TargetIndex.B, true);

            yield return(extract);

            Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B);

            yield return(getToHaulTarget);

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B, true, false, true));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOnDestroyedOrNull(TargetIndex.B));

            Toil findPlaceTarget = Toils_JobTransforms.SetTargetToIngredientPlaceCell(TargetIndex.A, TargetIndex.B, TargetIndex.C);

            yield return(findPlaceTarget);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, findPlaceTarget, false, false));

            yield return(Toils_Jump.JumpIfHaveTargetInQueue(TargetIndex.B, extract));

            extract         = null;
            getToHaulTarget = null;
            findPlaceTarget = null;
            yield return(gotoBillGiver);

            yield return(MakeUnfinishedThingIfNeeded());

            yield return(Toils_Recipe.DoRecipeWork().FailOnDespawnedNullOrForbiddenPlacedThings().FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell));

            yield return(FinishRecipeAndStartStoringProduct());

            if (!job.RecipeDef.products.NullOrEmpty <ThingDefCountClass>() || !job.RecipeDef.specialProducts.NullOrEmpty <SpecialProductType>())
            {
                yield return(Toils_Reserve.Reserve(TargetIndex.B));

                yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, true, false));

                findPlaceTarget = Toils_Haul.CarryHauledThingToContainer();
                yield return(findPlaceTarget);

                Toil prepare = Toils_General.Wait(250);
                prepare.WithProgressBarToilDelay(TargetIndex.B, false, -0.5f);
                yield return(prepare);

                yield return(new Toil
                {
                    initAction = delegate
                    {
                        Building_BookStore shelf = (Building_BookStore)job.GetTarget(TargetIndex.B).Thing;
                        CurToil.FailOn(() => shelf == null);
                        Thing book = pawn.carryTracker.CarriedThing;
                        if (pawn.carryTracker.CarriedThing == null)
                        {
                            Log.Error($"[HumanResources] {pawn} tried to place a book on shelf but is not hauling anything.");
                            return;
                        }
                        if (shelf.Accepts(book))
                        {
                            bool flag = false;
                            if (book.holdingOwner != null)
                            {
                                book.holdingOwner.TryTransferToContainer(book, shelf.TryGetInnerInteractableThingOwner(), book.stackCount, true);
                                flag = true;
                            }
                            else
                            {
                                flag = shelf.TryGetInnerInteractableThingOwner().TryAdd(book, true);
                            }
                            pawn.carryTracker.innerContainer.Remove(book);
                        }
                        else
                        {
                            Log.Error($"[HumanResources] {pawn} tried to place a book in {shelf}, but it won't accept it.");
                            return;
                        }
                        pawn.jobs.EndCurrentJob(JobCondition.Succeeded, true, true);
                    }
                });
            }
            yield break;
        }
        public static IEnumerable <Toil> MakeFeedToils(JobDef job, JobDriver thisDriver, Pawn actor, LocalTargetInfo TargetA, ThoughtDef victimThoughtDef, ThoughtDef actorThoughtDef, float workLeft, Action effect, Func <Pawn, Pawn, bool> stopCondition, bool needsGrapple = true, bool cleansWound = true, bool neverGiveUp = false)
        {
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            Toil gotoToil = actor?.Faction == TargetA.Thing?.Faction && (!actor.InAggroMentalState && !((Pawn)TargetA.Thing).InAggroMentalState) ? Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch) : Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);

            yield return(gotoToil);

            Toil grappleToil = new Toil()
            {
                initAction = delegate
                {
                    MoteMaker.MakeColonistActionOverlay(actor, ThingDefOf.Mote_ColonistAttacking);

                    workLeft = BaseFeedTime;
                    Pawn victim = TargetA.Thing as Pawn;
                    if (victim != null)
                    {
//                        if (!AllowFeeding(actor, victim))
//                        {
//                            actor.jobs.EndCurrentJob(JobCondition.Incompletable);
//                        }
                        if (actor.InAggroMentalState || victim.InAggroMentalState || victim.Faction != actor.Faction)
                        {
                            if (needsGrapple)
                            {
                                int grappleBonus = actor is PawnTemporary ? 100 : 0;
                                if (!JecsTools.GrappleUtility.TryGrapple(actor, victim, grappleBonus))
                                {
                                    thisDriver.EndJobWith(JobCondition.Incompletable);
                                    PawnUtility.ForceWait(actor, (int)(BaseFeedTime * 0.15f));
                                    return;
                                }
                            }
                        }
                        if (actor.IsVampire())
                        {
                            VampireBiteUtility.MakeNew(actor, victim);
                        }
                        victim.stances.stunner.StunFor((int)BaseFeedTime, actor);
                    }
                }
            };

            yield return(grappleToil);

            Toil feedToil = new Toil()
            {
                tickAction = delegate
                {
                    //try
                    //{
                    if (TargetA.Thing is Pawn victim && victim.Spawned && !victim.Dead)
                    {
                        workLeft--;
                        VampireWitnessUtility.HandleWitnessesOf(job, actor, victim);
                        if (victim?.needs?.mood?.thoughts?.memories != null)
                        {
                            Thought_Memory victimThought = null;
                            if (victimThoughtDef != null)
                            {
                                victimThought = (Thought_Memory)ThoughtMaker.MakeThought(victimThoughtDef);
                            }
                            if (victimThought != null)
                            {
                                victim.needs.mood.thoughts.memories.TryGainMemory(victimThought);
                            }
                        }
                        if (actor?.needs?.mood?.thoughts?.memories != null)
                        {
                            Thought_Memory actorThought = null;
                            if (actorThoughtDef != null)
                            {
                                actorThought = (Thought_Memory)ThoughtMaker.MakeThought(actorThoughtDef);
                            }
                            if (actorThought != null)
                            {
                                actor.needs.mood.thoughts.memories.TryGainMemory(actorThought);
                            }
                        }


                        if (workLeft <= 0f)
                        {
                            if (actor?.VampComp() is CompVampire v && v.IsVampire && actor.Faction == Faction.OfPlayer)
                            {
                                MoteMaker.ThrowText(actor.DrawPos, actor.Map, "XP +" + 15);
                                v.XP    += 15;
                                workLeft = BaseFeedTime;
                                MoteMaker.MakeColonistActionOverlay(actor, ThingDefOf.Mote_ColonistAttacking);
                            }

                            effect();
                            if (victim != null && !victim.Dead && needsGrapple)
                            {
                                int victimBonus = (victim.VampComp() is CompVampire victimVampComp) ? -victimVampComp.Generation + 14 : 0;
                                int actorBonus  = 0;
                                if (actor?.VampComp() is CompVampire v2 && v2.IsVampire)
                                {
                                    actorBonus = -v2.Generation + 14;
                                }
                                if (!JecsTools.GrappleUtility.TryGrapple(actor, victim, actorBonus, victimBonus))
                                {
                                    thisDriver.EndJobWith(JobCondition.Incompletable);
                                }
                            }

                            if (!stopCondition(actor, victim))
                            {
                                thisDriver.ReadyForNextToil();
                                if (actor.IsVampire() && cleansWound)
                                {
                                    VampireBiteUtility.CleanBite(actor, victim);
                                }
                            }
                            else
                            {
                                if (victim != null && !victim.Dead)
                                {
                                    victim.stances.stunner.StunFor((int)BaseFeedTime, actor);
                                    PawnUtility.ForceWait((Pawn)TargetA.Thing, (int)BaseFeedTime, actor);
                                }
                            }
                        }
                    }
Example #9
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(PartnerInd);
            this.FailOnDespawnedNullOrForbidden(BedInd);
            this.FailOn(() => Actor is null || !Actor.CanReserveAndReach(Partner, PathEndMode.Touch, Danger.Deadly));
            this.FailOn(() => pawn.Drafted);
            yield return(Toils_Reserve.Reserve(PartnerInd, 1, 0));

            //yield return Toils_Reserve.Reserve(BedInd, Bed.SleepingSlotsCount, 0);
            Toil gotoAnimal = Toils_Goto.GotoThing(PartnerInd, PathEndMode.Touch);

            yield return(gotoAnimal);

            bool partnerHasPenis = Genital_Helper.has_penis(Partner) || Genital_Helper.has_penis_infertile(Partner);

            Toil gotoBed = new Toil
            {
                initAction = delegate
                {
                    Actor.pather.StartPath(SleepSpot, PathEndMode.OnCell);
                    Partner.pather.StartPath(SleepSpot, PathEndMode.OnCell);
                },
                defaultCompleteMode = ToilCompleteMode.PatherArrival
            };

            gotoBed.FailOnBedNoLongerUsable(BedInd);
            gotoBed.AddFailCondition(() => Partner.Downed);
            yield return(gotoBed);

            gotoBed.AddFinishAction(delegate
            {
                var gettin_loved = new Job(xxx.gettin_loved, Actor, Bed);
                Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced, null, false, true, null);
            });

            Toil waitInBed = new Toil
            {
                initAction = delegate
                {
                    //Rand.PopState();
                    //Rand.PushState(RJW_Multiplayer.PredictableSeed());
                    ticksLeftThisToil = 5000;
                    ticks_left        = (int)(2000.0f * Rand.Range(0.30f, 1.30f));
                },
                tickAction = delegate
                {
                    Actor.GainComfortFromCellIfPossible();
                    if (IsInOrByBed(Bed, Partner))
                    {
                        ticksLeftThisToil = 0;
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Delay,
            };

            waitInBed.FailOn(() => pawn.GetRoom(RegionType.Set_Passable) == null);
            yield return(waitInBed);

            Toil loveToil = new Toil
            {
                initAction = delegate
                {
                    if (!partnerHasPenis)
                    {
                        Actor.rotationTracker.Face(Partner.DrawPos);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Never,                 //Changed from Delay
            };

            loveToil.AddPreTickAction(delegate
            {
                //Actor.Reserve(Partner, 1, 0);
                --ticks_left;
                xxx.reduce_rest(Actor, 1);
                xxx.reduce_rest(Partner, 2);
                if (ticks_left <= 0)
                {
                    ReadyForNextToil();
                }
                else if (pawn.IsHashIntervalTick(ticks_between_hearts))
                {
                    MoteMaker.ThrowMetaIcon(Actor.Position, Actor.Map, ThingDefOf.Mote_Heart);
                }
                Actor.GainComfortFromCellIfPossible();
                Partner.GainComfortFromCellIfPossible();
            });
            loveToil.AddFailCondition(() => Partner.Dead || !IsInOrByBed(Bed, Partner));
            loveToil.socialMode = RandomSocialMode.Off;
            yield return(loveToil);

            Toil afterSex = new Toil
            {
                initAction = delegate
                {
                    //Log.Message("JobDriver_BestialityForFemale::MakeNewToils() - Calling aftersex");
                    // Trying to add some interactions and social logs
                    SexUtility.ProcessSex(Partner, pawn);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(afterSex);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            setup_ticks();
            parteners.Add(Partner);            // add job starter, so this wont fail, before Initiator starts his job
            float partner_ability = xxx.get_sex_ability(Partner);

            // More/less hearts based on partner ability.
            if (partner_ability < 0.8f)
            {
                ticks_between_thrusts += 120;
            }
            else if (partner_ability > 2.0f)
            {
                ticks_between_thrusts -= 30;
            }

            // More/less hearts based on opinion.
            if (pawn.relations.OpinionOf(Partner) < 0)
            {
                ticks_between_hearts += 50;
            }
            else if (pawn.relations.OpinionOf(Partner) > 60)
            {
                ticks_between_hearts -= 25;
            }

            this.FailOnDespawnedOrNull(iTarget);
            this.FailOn(() => !Partner.health.capacities.CanBeAwake);

            yield return(Toils_Reserve.Reserve(iTarget, 1, 0));

            Toil get_loved = new Toil();

            get_loved.defaultCompleteMode = ToilCompleteMode.Never;
            get_loved.socialMode          = RandomSocialMode.Off;
            get_loved.initAction          = delegate
            {
                pawn.pather.StopDead();
                pawn.jobs.curDriver.asleep = false;
            };
            get_loved.AddPreTickAction(delegate
            {
                if (pawn.IsHashIntervalTick(ticks_between_hearts))
                {
                    ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
                }
            });
            get_loved.AddEndCondition(new Func <JobCondition>(() =>
            {
                if ((ticks_remaining <= 0) || (parteners.Count <= 0))
                {
                    return(JobCondition.Succeeded);
                }
                return(JobCondition.Ongoing);
            }));
            get_loved.AddFinishAction(delegate
            {
                if (xxx.is_human(pawn))
                {
                    pawn.Drawer.renderer.graphics.ResolveApparelGraphics();
                }
            });
            yield return(get_loved);
        }
Example #11
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            yield return(Toils_Reserve.ReserveQueue(TargetIndex.A, 1));

            yield return(Toils_Reserve.Reserve(TargetIndex.B, 10, 1));

            yield return(Toils_Reserve.ReserveQueue(TargetIndex.B, 1));

            Toil toil = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A);

            yield return(toil);

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, true));

            yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(toil, TargetIndex.A));

            Toil toil2 = Toils_Goto.Goto(TargetIndex.B, PathEndMode.ClosestTouch);

            yield return(toil2);

            Toil toil3 = new Toil();

            toil3.defaultCompleteMode = ToilCompleteMode.Delay;
            toil3.defaultDuration     = 500;
            toil3.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            yield return(toil3);

            yield return(new Toil
            {
                initAction = delegate
                {
                    ShipBase ship = (ShipBase)TargetB.Thing;
                    ThingWithComps thing = (ThingWithComps)TargetA.Thing;
                    CompShipWeapon comp = thing.TryGetComp <CompShipWeapon>();

                    Action action = delegate
                    {
                        if (comp != null)
                        {
                            switch (comp.SProps.weaponSystemType)
                            {
                            case WeaponSystemType.LightCaliber:
                                {
                                    if (ship.TryInstallTurret(comp))
                                    {
                                        this.pawn.carryTracker.GetDirectlyHeldThings().Remove(TargetA.Thing);
                                        ship.weaponsToInstall.Remove(comp.slotToInstall);
                                    }
                                    break;
                                }

                            case WeaponSystemType.HeavyCaliber:
                                {
                                    break;
                                }

                            case WeaponSystemType.Bombing:
                                {
                                    WeaponSystemShipBomb bomb = thing as WeaponSystemShipBomb;
                                    if (ship.TryInstallPayload(bomb, comp))
                                    {
                                        this.pawn.carryTracker.GetDirectlyHeldThings().Remove(TargetA.Thing);
                                        ship.weaponsToInstall.Remove(comp.slotToInstall);
                                    }
                                    break;
                                }
                            }
                        }
                    };

                    action();
                },

                defaultCompleteMode = ToilCompleteMode.Instant
            });

            yield break;
        }
        public override IEnumerable <Toil> MakeNewToils()
        {
            var ZTracker = ZUtils.ZTracker;

            if (pawn.Map == this.job.targetA.Thing.Map && pawn.Map == ZTracker.jobTracker[pawn].targetDest.Map)
            {
                ZLogger.Message("pawn map and thing map and dest map are same, yield breaking in JobDriver_HaulThingToDest");
                yield break;
            }
            yield return(new Toil
            {
                initAction = delegate()
                {
                    this.savedThing = this.job.targetA.Thing;
                }
            });

            Toil reserveItem = Toils_Reserve.Reserve(TargetIndex.A);

            ZLogger.Message($"JobDriver HaulThingToDest1 About to call findRouteWithStairs, with pawn {GetActor()}, dest { TargetA.Thing}, instance {this}");
            foreach (var toil in Toils_ZLevels.GoToMap(GetActor(), new TargetInfo(TargetA.Thing).Map, this))
            {
                yield return(toil);
            }
            yield return(new Toil
            {
                initAction = delegate()
                {
                    ZLogger.Message("JobDriver_HaulThingToDest 1: " + pawn + " trying to reserve: " + TargetA, true);
                }
            });

            Toil toilGoto = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch);

            yield return(reserveItem.FailOnDespawnedNullOrForbidden(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A));

            yield return(new Toil
            {
                initAction = delegate()
                {
                    ZLogger.Message("JobDriver_HaulThingToDest 1: " + pawn + " reserved: " + TargetA, true);
                }
            });

            yield return(toilGoto);

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, putRemainderInQueue: false, subtractNumTakenFromJobCount: true).FailOnDestroyedNullOrForbidden(TargetIndex.A));

            if (job.haulOpportunisticDuplicates)
            {
                yield return(new Toil
                {
                    initAction = delegate()
                    {
                        ZLogger.Message("2: " + pawn + " trying to reserve other things: " + TargetA, true);
                    }
                });

                yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveItem, TargetIndex.A, TargetIndex.None, takeFromValidStorage: true));

                yield return(new Toil
                {
                    initAction = delegate()
                    {
                        ZLogger.Message("2: " + pawn + " reserved other things: " + TargetA, true);
                    }
                });
            }
            yield return(new Toil
            {
                initAction = delegate()
                {
                    try
                    {
                        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 != TargetA.Thing)
                            {
                                ZTracker.jobTracker[pawn].mainJob.targetA = new LocalTargetInfo(TargetA.Thing);
                            }
                            else if (ZTracker.jobTracker[pawn].mainJob.targetB.Thing != null &&
                                     ZTracker.jobTracker[pawn].mainJob.targetB.Thing == this.savedThing &&
                                     ZTracker.jobTracker[pawn].mainJob.targetB.Thing != TargetA.Thing)
                            {
                                ZTracker.jobTracker[pawn].mainJob.targetB = new LocalTargetInfo(TargetA.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 != TargetA.Thing)
                                    {
                                        ZTracker.jobTracker[pawn].mainJob.targetQueueA[i] = new LocalTargetInfo(TargetA.Thing);
                                    }
                                }
                            }
                            catch { }
                            try
                            {
                                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 != TargetA.Thing)
                                    {
                                        if (ZTracker.jobTracker[pawn].mainJob.targetQueueB[i].Thing.stackCount == 0)
                                        {
                                            ZTracker.jobTracker[pawn].mainJob.targetQueueB[i] = new LocalTargetInfo(TargetA.Thing);
                                            ZTracker.jobTracker[pawn].mainJob.countQueue[i] = TargetA.Thing.stackCount;
                                            break;
                                        }
                                        else
                                        {
                                            if (ZTracker.jobTracker[pawn].mainJob.targetQueueB
                                                .Where(x => x.Thing == TargetA.Thing).Count() == 0)
                                            {
                                                var newTarget = new LocalTargetInfo(TargetA.Thing);
                                                ZTracker.jobTracker[this.pawn].mainJob.targetQueueB.Add(newTarget);
                                                ZTracker.jobTracker[this.pawn].mainJob.countQueue.Add(newTarget.Thing.stackCount);
                                                int ind = ZTracker.jobTracker[this.pawn].mainJob.targetQueueB.FirstIndexOf(x => x.Thing == this.savedThing);
                                                ZTracker.jobTracker[this.pawn].mainJob.targetQueueB.RemoveAt(ind);
                                                ZTracker.jobTracker[this.pawn].mainJob.countQueue.RemoveAt(ind);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            catch { }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Z-Tracker produced an error in JobDriver_HaulThingToStairs class. Report about it to devs. Error: " + ex);
                    }
                }
            });

            ZLogger.Message($"JobDriver HaulThingToDest 2About to call findRouteWithStairs, with pawn {GetActor()}, dest {ZTracker.jobTracker[pawn].targetDest}, instance {this}");
            foreach (var toil in Toils_ZLevels.GoToMap(GetActor(), ZTracker.jobTracker[pawn].targetDest.Map, this))
            {
                yield return(toil);
            }
        }
Example #13
0
        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);
            yield return(new Toil
            {
                initAction = delegate()
                {
                    var ZTracker = Current.Game.GetComponent <ZLevelsManager>();
                    if (ZTracker.jobTracker[pawn].mainJob.count != -1)
                    {
                        this.pawn.jobs.curJob.count = ZTracker.jobTracker[pawn].mainJob.count;
                    }
                    else 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);
                }
            });

            Toil reserveItem = Toils_Reserve.Reserve(TargetIndex.B);

            yield return(reserveItem);

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B, putRemainderInQueue: false, subtractNumTakenFromJobCount: true).FailOnDestroyedNullOrForbidden(TargetIndex.B));

            yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveItem, TargetIndex.B, TargetIndex.None, takeFromValidStorage: true));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell));

            //Toil reserveTargetA = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null);
            //yield return reserveTargetA;
            //yield return Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch);
            //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 { }
                }
            });
Example #14
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //--Log.Message("JobDriver_NymphJoinInBed::MakeNewToils() called");
            this.FailOnDespawnedOrNull(ipartner);
            this.FailOnDespawnedOrNull(ibed);
            this.FailOn(() => !Partner.health.capacities.CanBeAwake);
            this.FailOn(() => !xxx.is_laying_down_alone(Partner));
            yield return(Toils_Reserve.Reserve(ipartner, comfort_prisoners.max_rapists_per_prisoner, 0));

            yield return(Toils_Goto.GotoThing(ipartner, PathEndMode.OnCell));

            yield return(new Toil
            {
                initAction = delegate
                {
                    //--Log.Message("JobDriver_NymphJoinInBed::MakeNewToils() - setting initAction");
                    ticks_left = (int)(2500.0f * Rand.Range(0.30f, 1.30f));
                    var gettin_loved = new Job(xxx.gettin_loved, pawn, Bed);
                    Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced, null, false, true, null);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

            var do_lovin = new Toil();

            do_lovin.defaultCompleteMode = ToilCompleteMode.Never;
            do_lovin.FailOn(() => (Partner.CurJob == null) || (Partner.CurJob.def != xxx.gettin_loved));
            do_lovin.AddPreTickAction(delegate
            {
                --ticks_left;
                if (ticks_left <= 0)
                {
                    ReadyForNextToil();
                }
                else if (pawn.IsHashIntervalTick(ticks_between_hearts))
                {
                    MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
                }
            });
            do_lovin.socialMode = RandomSocialMode.Off;
            yield return(do_lovin);

            yield return(new Toil
            {
                initAction = delegate
                {
                    //--Log.Message("JobDriver_NymphJoinInBed::MakeNewToils() - setting pawn.got_some_lovin memory in second initAction");
                    var sex_mem = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.GotSomeLovin);
                    var pawn_memories = pawn.needs.mood.thoughts.memories as MemoryThoughtHandler;
                    if (pawn_memories != null)
                    {
                        pawn.needs.mood.thoughts.memories.TryGainMemory(sex_mem, Partner);
                    }

                    //--Log.Message("JobDriver_NymphJoinInBed::MakeNewToils() - setting Partner.got_some_lovin memory in second initAction");
                    var sex_mem2 = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.GotSomeLovin);                     // Is this neccessary?
                    if (Partner.needs != null && Partner.needs.mood != null && Partner.needs.mood.thoughts != null)
                    {
                        Partner.needs.mood.thoughts.memories.TryGainMemory(sex_mem2, pawn);
                    }

                    //--Log.Message("JobDriver_NymphJoinInBed::MakeNewToils() - calling aftersex in second initAction");
                    xxx.aftersex(pawn, Partner);
                    //--Log.Message("JobDriver_NymphJoinInBed::MakeNewToils() - calling aftersex again in second initAction");
                    //xxx.aftersex (Partner, pawn);
                    //--Log.Message("JobDriver_NymphJoinInBed::MakeNewToils() - setting mindstate in second initAction");
                    pawn.mindState.canLovinTick = Find.TickManager.TicksGame + xxx.generate_min_ticks_to_next_lovin(pawn);
                    //--Log.Message("JobDriver_NymphJoinInBed::MakeNewToils() - setting mindstate again in second initAction");
                    Partner.mindState.canLovinTick = Find.TickManager.TicksGame + xxx.generate_min_ticks_to_next_lovin(Partner);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });
        }
Example #15
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            // Error checking/input validation.
            if (turret == null)
            {
                Log.Error(string.Concat(errorBase, "TargetThingA isn't a Building_TurretGunCE"));
                yield return(null);
            }
            if (compReloader == null)
            {
                Log.Error(string.Concat(errorBase, "TargetThingA (Building_TurretGunCE) is missing it's CompAmmoUser."));
                yield return(null);
            }
            if (compReloader.UseAmmo && ammo == null)
            {
                Log.Error(string.Concat(errorBase, "TargetThingB is either null or not an AmmoThing."));
                yield return(null);
            }

            // Set fail condition on turret.
            if (pawn.Faction != Faction.OfPlayer)
            {
                this.FailOnDestroyedOrNull(TargetIndex.A);
            }
            else
            {
                this.FailOnDestroyedNullOrForbidden(TargetIndex.A);
            }

            if (compReloader.UseAmmo)
            {
                // Perform ammo system specific activities, failure condition and hauling
                if (pawn.Faction != Faction.OfPlayer)
                {
                    ammo.SetForbidden(false, false);
                    this.FailOnDestroyedOrNull(TargetIndex.B);
                }
                else
                {
                    this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
                }

                // Haul ammo
                yield return(Toils_Reserve.Reserve(TargetIndex.B, 1));

                yield return(Toils_Goto.GotoCell(ammo.Position, PathEndMode.ClosestTouch));

                yield return(Toils_Haul.StartCarryThing(TargetIndex.B));

                yield return(Toils_Goto.GotoCell(turret.Position, PathEndMode.ClosestTouch));
                //yield return Toils_Haul.PlaceHauledThingInCell(TargetIndex.A, null, false);
            }
            else
            {
                // If ammo system is turned off we just need to go to the turret.
                yield return(Toils_Goto.GotoCell(turret.Position, PathEndMode.ClosestTouch));
            }

            // Wait in place
            Toil waitToil = new Toil()
            {
                actor = pawn
            };

            waitToil.initAction = delegate
            {
                // Initial relaod process activities.
                waitToil.actor.pather.StopDead();
                turret.isReloading = true;
                if (compReloader.ShouldThrowMote)
                {
                    MoteMaker.ThrowText(turret.Position.ToVector3Shifted(), turret.Map, string.Format("CE_ReloadingTurretMote".Translate(), TargetThingA.LabelCapNoCount));
                }
                Thing newAmmo;
                compReloader.TryUnload(out newAmmo);
                if (newAmmo?.CanStackWith(ammo) ?? false)
                {
                    pawn.carryTracker.TryStartCarry(newAmmo, Mathf.Min(newAmmo.stackCount, compReloader.Props.magazineSize - ammo.stackCount));
                }
            };
            waitToil.AddFinishAction(() => turret.isReloading = false);
            waitToil.defaultCompleteMode = ToilCompleteMode.Delay;
            waitToil.defaultDuration     = Mathf.CeilToInt(compReloader.Props.reloadTime.SecondsToTicks() / pawn.GetStatValue(CE_StatDefOf.ReloadSpeed));
            yield return(waitToil.WithProgressBarToilDelay(TargetIndex.A));

            //Actual reloader
            Toil reloadToil = new Toil();

            reloadToil.defaultCompleteMode = ToilCompleteMode.Instant;
            reloadToil.initAction          = delegate
            {
                compReloader.LoadAmmo(ammo);
            };
            //if (compReloader.useAmmo) reloadToil.EndOnDespawnedOrNull(TargetIndex.B);
            yield return(reloadToil);
        }
Example #16
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //Commence fail checks!
            this.FailOnDestroyedOrNull(TargetIndex.A);

            yield return(Toils_Reserve.Reserve(AltarIndex, Building_SacrificialAltar.LyingSlotsCount));

            yield return(new Toil
            {
                initAction = delegate
                {
                    DropAltar.ChangeState(Building_SacrificialAltar.State.worshipping, Building_SacrificialAltar.WorshipState.gathering);
                }
            });

            //Who are we worshipping today?
            var    deitySymbol = ((CosmicEntityDef)DropAltar.currentWorshipDeity.def).Symbol;
            string deityLabel  = DropAltar.currentWorshipDeity.Label;

            Toil goToAltar = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell);

            //Toil 0: Activate any nearby Worship Callers.
            yield return(new Toil
            {
                initAction = delegate
                {
                    Predicate <Thing> validator = (x => x.TryGetComp <CompWorshipCaller>() != null);
                    Thing worshipCaller = GenClosest.ClosestThingReachable(DropAltar.Position, DropAltar.Map,
                                                                           ThingRequest.ForGroup(ThingRequestGroup.BuildingArtificial), PathEndMode.ClosestTouch,
                                                                           TraverseParms.For(this.pawn, Danger.None, TraverseMode.ByPawn), 9999, validator, null, 0, -1, false, RegionType.Set_Passable, false);
                    if (worshipCaller != null)
                    {
                        WorshipCaller = worshipCaller;
                        this.job.SetTarget(TargetIndex.B, worshipCaller);
                    }
                    else
                    {
                        base.JumpToToil(goToAltar);
                    }
                }
            });

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).JumpIfDespawnedOrNullOrForbidden(TargetIndex.B, goToAltar));

            yield return(new Toil
            {
                initAction = delegate
                {
                    WorshipCaller.TryGetComp <CompWorshipCaller>().Use(Forced);
                }
            }.JumpIfDespawnedOrNullOrForbidden(TargetIndex.B, goToAltar));

            //Toil 1: Go to the altar.
            yield return(goToAltar);

            //Toil 2: Wait a bit for stragglers.
            Toil waitingTime = new Toil();

            waitingTime.defaultCompleteMode = ToilCompleteMode.Delay;
            waitingTime.defaultDuration     = CultUtility.ritualDuration;
            waitingTime.initAction          = delegate
            {
                report = "Cults_WaitingToStartSermon".Translate();
                DropAltar.ChangeState(Building_SacrificialAltar.State.worshipping, Building_SacrificialAltar.WorshipState.worshipping);
            };

            yield return(waitingTime);

            //Toil 3: Preach the sermon.
            Toil preachingTime = new Toil();

            preachingTime.defaultCompleteMode = ToilCompleteMode.Delay;
            preachingTime.defaultDuration     = CultUtility.ritualDuration;
            preachingTime.initAction          = delegate
            {
                report = "Cults_PreachingAbout".Translate(
                    deityLabel
                    );
                if (deitySymbol != null)
                {
                    MoteMaker.MakeInteractionBubble(this.pawn, null, ThingDefOf.Mote_Speech, deitySymbol);
                }
            };
            preachingTime.tickAction = delegate
            {
                Pawn actor = this.pawn;
                actor.skills.Learn(SkillDefOf.Social, 0.25f);
                actor.GainComfortFromCellIfPossible();
            };

            yield return(preachingTime);

            //Toil 4: Time to pray
            Toil chantingTime = new Toil();

            chantingTime.defaultCompleteMode = ToilCompleteMode.Delay;
            chantingTime.defaultDuration     = CultUtility.ritualDuration;
            chantingTime.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            chantingTime.PlaySustainerOrSound(CultsDefOf.RitualChanting);
            chantingTime.initAction = delegate
            {
                report = "Cults_PrayingTo".Translate(
                    deityLabel
                    );
                if (deitySymbol != null)
                {
                    MoteMaker.MakeInteractionBubble(this.pawn, null, ThingDefOf.Mote_Speech, deitySymbol);
                }
            };
            chantingTime.tickAction = delegate
            {
                Pawn actor = this.pawn;
                actor.skills.Learn(SkillDefOf.Social, 0.25f);
                actor.GainComfortFromCellIfPossible();
            };

            yield return(chantingTime);

            //Toil 8: Execution of Prisoner
            yield return(new Toil
            {
                initAction = delegate
                {
                    //TaleRecorder.RecordTale(
                    // Of.ExecutedPrisoner, new object[]
                    //{
                    //    this.pawn,
                    //    this.Takee
                    //});
                    CultUtility.WorshipComplete(this.pawn, DropAltar, DropAltar.currentWorshipDeity);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

            yield return(new Toil
            {
                initAction = delegate
                {
                    if (DropAltar != null)
                    {
                        if (DropAltar.currentWorshipState != Building_SacrificialAltar.WorshipState.finished)
                        {
                            DropAltar.ChangeState(Building_SacrificialAltar.State.worshipping, Building_SacrificialAltar.WorshipState.finished);
                            //Map.GetComponent<MapComponent_SacrificeTracker>().ClearVariables();
                        }
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });


            this.AddFinishAction(() =>
            {
                //When the ritual is finished -- then let's give the thoughts
                if (DropAltar.currentWorshipState == Building_SacrificialAltar.WorshipState.finishing ||
                    DropAltar.currentWorshipState == Building_SacrificialAltar.WorshipState.finished)
                {
                    Cthulhu.Utility.DebugReport("Called end tick check");
                    CultUtility.HoldWorshipTickCheckEnd(this.pawn);
                }
            });

            yield break;
        }
        public static IEnumerable <Toil> MakeFeedToils(JobDriver thisDriver, Pawn actor, LocalTargetInfo TargetA, float workLeft, Action effect, Func <Pawn, Pawn, bool> stopCondition)
        {
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null));

            Toil gotoToil = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);

            yield return(gotoToil);

            Toil grappleToil = new Toil()
            {
                initAction = delegate
                {
                    MoteMaker.MakeColonistActionOverlay(actor, ThingDefOf.Mote_ColonistAttacking);

                    workLeft = JobDriver_Feed.BaseFeedTime;
                    Pawn victim = (Pawn)TargetA.Thing;
                    if (victim != null)
                    {
                        if (victim.InAggroMentalState || victim.Faction != actor.Faction)
                        {
                            if (!actor.CanGrapple(victim))
                            {
                                thisDriver.EndJobWith(JobCondition.Incompletable);
                            }
                        }
                        GenClamor.DoClamor(actor, 10f, ClamorType.Harm);
                        if (!AllowFeeding(actor, victim))
                        {
                            actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                        }
                        if (actor?.VampComp()?.Bloodline?.bloodlineHediff?.CompProps <HediffCompProperties_VerbGiver>()?.verbs is List <VerbProperties> verbProps)
                        {
                            if (actor?.VerbTracker?.AllVerbs is List <Verb> verbs)
                            {
                                if (verbs.Find(x => verbProps.Contains(x.verbProps)) is Verb_MeleeAttack v)
                                {
                                    victim.TakeDamage(new DamageInfo(v.verbProps.meleeDamageDef, v.verbProps.meleeDamageBaseAmount, -1, actor));
                                }
                            }
                        }
                        victim.stances.stunner.StunFor((int)BaseFeedTime);
                    }
                }
            };

            yield return(grappleToil);

            Toil feedToil = new Toil()
            {
                tickAction = delegate
                {
                    Pawn victim = (Pawn)TargetA.Thing;
                    if (victim == null || !victim.Spawned || victim.Dead)
                    {
                        thisDriver.ReadyForNextToil();
                    }
                    workLeft--;

                    if (workLeft <= 0f)
                    {
                        if (actor?.VampComp() is CompVampire v && v.IsVampire && actor.Faction == Faction.OfPlayer)
                        {
                            MoteMaker.ThrowText(actor.DrawPos, actor.Map, "XP +" + 15, -1f);
                            v.XP += 15;
                        }
                        workLeft = BaseFeedTime;
                        MoteMaker.MakeColonistActionOverlay(actor, ThingDefOf.Mote_ColonistAttacking);
                        effect();
                        if ((victim.HostileTo(actor.Faction) || victim.IsPrisoner) && !actor.CanGrapple(victim))
                        {
                            thisDriver.EndJobWith(JobCondition.Incompletable);
                        }

                        if (!stopCondition(actor, victim))
                        {
                            thisDriver.ReadyForNextToil();
                        }
                        else
                        {
                            if (victim != null && !victim.Dead)
                            {
                                victim.stances.stunner.StunFor((int)BaseFeedTime);
                                PawnUtility.ForceWait((Pawn)TargetA.Thing, (int)BaseFeedTime, actor);
                            }
                        }
                    }
                },
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            Toil toil = new Toil()
            {
                initAction = delegate
                {
                    this.pawn.pather.StartPath(this.TargetThingA, PathEndMode.ClosestTouch);
                },
                defaultCompleteMode = ToilCompleteMode.PatherArrival
            };

            toil.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            yield return(toil);

            yield return(new Toil
            {
                initAction = delegate
                {
                    Thing itemToGather = this.CurJob.targetA.Thing;
                    //bool flag = false;
                    Thing itemToGatherSplit;
                    if (itemToGather.def.stackLimit > 1 && itemToGather.stackCount > 1)
                    {
                        itemToGatherSplit = itemToGather.SplitOff(1);
                    }
                    else
                    {
                        itemToGatherSplit = itemToGather;
                        //flag = true;
                    }

                    //Find the compslotloadable
                    Pawn_EquipmentTracker pawn_EquipmentTracker = this.pawn.equipment;
                    if (pawn_EquipmentTracker != null)
                    {
                        //Log.Message("2");
                        ThingWithComps thingWithComps = pawn_EquipmentTracker.Primary; //(ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker);

                        if (thingWithComps != null)
                        {
                            //Log.Message("3");
                            CompSlotLoadable CompSlotLoadable = thingWithComps.GetComp <CompSlotLoadable>();
                            if (CompSlotLoadable != null)
                            {
                                CompSlotLoadable.TryLoadSlot(itemToGather);
                                if (thingWithComps.def.soundInteract != null)
                                {
                                    thingWithComps.def.soundInteract.PlayOneShot(new TargetInfo(this.pawn.Position, this.pawn.Map, false));
                                }
                                //if (flag)
                                //{
                                //    thingWithComps.DeSpawn();
                                //}
                            }
                        }
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

            yield break;
        }
Example #19
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            bool itemIsInMap = Item.ParentHolder is Map;
            bool runeIsInMap = false;

            if (RuneThing != null)
            {
                runeIsInMap = RuneThing.ParentHolder is Map;
            }

            if (Workbench.def.hasInteractionCell)
            {
                this.AddFailCondition(() => !Workbench.InteractionCell.Standable(Workbench.Map));
            }

            //Add conditions
            if (itemIsInMap)
            {
                this.FailOnDestroyedNullOrForbidden(TargetItem);
            }
            if (runeIsInMap)
            {
                this.FailOnDestroyedNullOrForbidden(TargetRune);
            }
            if (Workbench != null)
            {
                this.FailOnDestroyedNullOrForbidden(TargetWorkBench);
            }

            //Reserve
            if (itemIsInMap)
            {
                yield return(Toils_Reserve.Reserve(TargetItem));
            }
            if (runeIsInMap)
            {
                yield return(Toils_Reserve.Reserve(TargetRune));
            }
            if (Workbench != null)
            {
                yield return(Toils_Reserve.Reserve(TargetWorkBench));
            }

            //Walk and carry as needed.
            Toil endToil = new Toil();

            if (itemIsInMap)
            {
                yield return(Toils_Goto.GotoThing(TargetItem, PathEndMode.OnCell));

                yield return(Toils_Haul.StartCarryThing(TargetItem));

                if (job.GetTarget(TargetWorkBench).IsValid)
                {
                    if (Workbench.def.hasInteractionCell)
                    {
                        yield return(Toils_Goto.GotoCell(Workbench.InteractionCell, PathEndMode.OnCell));
                    }
                    else
                    {
                        yield return(Toils_Goto.Goto(TargetWorkBench, PathEndMode.ClosestTouch));
                    }
                    yield return(Toils_Haul.PlaceHauledThingInCell(TargetWorkBench, endToil, false));
                }
            }

            if (runeIsInMap)
            {
                yield return(Toils_Goto.GotoThing(TargetRune, PathEndMode.OnCell));

                if (!job.GetTarget(TargetWorkBench).IsValid)
                {
                    if (itemIsInMap)
                    {
                        yield return(Toils_Haul.PlaceHauledThingInCell(TargetRune, endToil, false));
                    }
                }
                else
                {
                    yield return(Toils_Haul.StartCarryThing(TargetRune));

                    if (Workbench.def.hasInteractionCell)
                    {
                        yield return(Toils_Goto.GotoCell(Workbench.InteractionCell, PathEndMode.OnCell));
                    }
                    else
                    {
                        yield return(Toils_Goto.Goto(TargetWorkBench, PathEndMode.ClosestTouch));
                    }
                    yield return(Toils_Haul.PlaceHauledThingInCell(TargetWorkBench, endToil, false));
                }
            }

            //Here do work happen.
            foreach (Toil toil in MakeWorkToils(endToil))
            {
                yield return(toil);
            }

            //Failure toil if hauling did not work as intended.
            yield return(endToil);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            CompUniversalFermenter comp = Fermenter.TryGetComp <CompUniversalFermenter>();

            // Verify fermenter validity
            this.FailOn(() => !comp.Fermented);
            this.FailOnDestroyedNullOrForbidden(FermenterInd);

            // Reserve fermenter
            yield return(Toils_Reserve.Reserve(FermenterInd));

            // Go to the fermenter
            yield return(Toils_Goto.GotoThing(FermenterInd, PathEndMode.ClosestTouch));

            // Add delay for collecting product from fermenter, if it is ready
            yield return(Toils_General.Wait(Duration).FailOnDestroyedNullOrForbidden(FermenterInd).WithProgressBarToilDelay(FermenterInd));

            // Collect product
            Toil collect = new Toil();

            collect.initAction = () =>
            {
                Thing product = comp.TakeOutProduct();
                GenPlace.TryPlaceThing(product, pawn.Position, Map, ThingPlaceMode.Near);
                StoragePriority storagePriority = HaulAIUtility.StoragePriorityAtFor(product.Position, product);
                IntVec3         c;

                // Try to find a suitable storage spot for the product
                if (StoreUtility.TryFindBestBetterStoreCellFor(product, pawn, Map, storagePriority, pawn.Faction, out c))
                {
                    this.job.SetTarget(TargetIndex.B, product);
                    this.job.count = product.stackCount;
                    this.job.SetTarget(TargetIndex.C, c);
                }
                // If there is no spot to store the product, end this job
                else
                {
                    EndJobWith(JobCondition.Incompletable);
                }
            };
            collect.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(collect);

            // Reserve the product
            yield return(Toils_Reserve.Reserve(ProductToHaulInd));

            // Reserve the storage cell
            yield return(Toils_Reserve.Reserve(StorageCellInd));

            // Go to the product
            yield return(Toils_Goto.GotoThing(ProductToHaulInd, PathEndMode.ClosestTouch));

            // Pick up the product
            yield return(Toils_Haul.StartCarryThing(ProductToHaulInd));

            // Carry the product to the storage cell, then place it down
            Toil carry = Toils_Haul.CarryHauledThingToCell(StorageCellInd);

            yield return(carry);

            yield return(Toils_Haul.PlaceHauledThingInCell(StorageCellInd, carry, true));

            // End the current job
            yield break;
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            const float baseFishingDuration = 2000f;

            int   fishingDuration            = (int)baseFishingDuration;
            float catchSomethingThreshold    = 0f;
            Building_FishingPier fishingPier = this.TargetThingA as Building_FishingPier;
            Passion     passion          = Passion.None;
            const float skillGainPerTick = 0.15f;
            float       skillGainFactor  = 0f;

            this.AddEndCondition(() =>
            {
                var targ = this.pawn.jobs.curJob.GetTarget(fishingPierIndex).Thing;
                if (targ is Building && !targ.Spawned)
                {
                    return(JobCondition.Incompletable);
                }
                return(JobCondition.Ongoing);
            });

            this.FailOnBurningImmobile(fishingPierIndex); // Bill giver or product burning in carry phase.

            this.rotateToFace = TargetIndex.B;

            yield return(Toils_Reserve.Reserve(fishingPierIndex));

            float fishingSkillLevel = 0f;

            fishingSkillLevel = this.pawn.skills.AverageOfRelevantSkillsFor(WorkTypeDefOf.Hunting);
            float fishingSkillDurationFactor = fishingSkillLevel / 20f;

            fishingDuration = (int)(baseFishingDuration * (1.5f - fishingSkillDurationFactor));

            yield return(Toils_Goto.GotoThing(fishingPierIndex, fishingPier.riverCell).FailOnDespawnedOrNull(fishingPierIndex));

            Toil fishToil = new Toil()
            {
                initAction = () =>
                {
                    ThingDef moteDef = null;
                    if (fishingPier.Rotation == Rot4.North)
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodNorthDef;
                    }
                    else if (fishingPier.Rotation == Rot4.East)
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodEastDef;
                    }
                    else if (fishingPier.Rotation == Rot4.South)
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodSouthDef;
                    }
                    else
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodWestDef;
                    }
                    this.fishingRodMote = (Mote)ThingMaker.MakeThing(moteDef, null);
                    this.fishingRodMote.exactPosition = fishingPier.fishingSpotCell.ToVector3Shifted();
                    this.fishingRodMote.Scale         = 1f;
                    GenSpawn.Spawn(this.fishingRodMote, fishingPier.fishingSpotCell, this.Map);
                    WorkTypeDef fishingWorkDef = WorkTypeDefOf.Hunting;
                    passion = this.pawn.skills.MaxPassionOfRelevantSkillsFor(fishingWorkDef);
                    if (passion == Passion.None)
                    {
                        skillGainFactor = 0.3f;
                    }
                    else if (passion == Passion.Minor)
                    {
                        skillGainFactor = 1f;
                    }
                    else
                    {
                        skillGainFactor = 1.5f;
                    }
                },
                tickAction = () =>
                {
                    if (passion == Passion.Minor)
                    {
                        this.pawn.needs.joy.GainJoy(NeedTunings.JoyPerXpForPassionMinor, JoyKindDefOf.Work);
                    }
                    else if (passion == Passion.Major)
                    {
                        this.pawn.needs.joy.GainJoy(NeedTunings.JoyPerXpForPassionMajor, JoyKindDefOf.Work);
                    }
                    this.pawn.skills.Learn(SkillDefOf.Shooting, skillGainPerTick * skillGainFactor);

                    if (this.ticksLeftThisToil == 1)
                    {
                        if (this.fishingRodMote != null)
                        {
                            this.fishingRodMote.Destroy();
                        }
                    }
                },
                defaultDuration     = fishingDuration,
                defaultCompleteMode = ToilCompleteMode.Delay
            };

            yield return(fishToil.WithProgressBarToilDelay(fishingPierIndex));

            Toil computeChanceToCatchToil = new Toil()
            {
                initAction = () =>
                {
                    catchSomethingThreshold = fishingSkillLevel / 20f;
                    // Reframe min and max chance (min 5%, max 75 % chance of success).
                    Mathf.Clamp(catchSomethingThreshold, 0.05f, 0.75f);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(computeChanceToCatchToil);

            Toil catchFishToil = new Toil()
            {
                initAction = () =>
                {
                    Job   curJob       = this.pawn.jobs.curJob;
                    Thing fishingCatch = null;

                    // 90% chance to successfully catch something.
                    bool catchIsSuccessful = (Rand.Value >= 0.1f);
                    if (catchIsSuccessful == false)
                    {
                        MoteMaker.ThrowMetaIcon(this.pawn.Position, this.Map, ThingDefOf.Mote_IncapIcon);
                        this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                        return;
                    }

                    float catchSelectorValue = Rand.Value;
                    if (catchSelectorValue > 0.04f)
                    {
                        // Catch a fish.
                        bool fishSpotIsMarshy = (this.Map.terrainGrid.TerrainAt(fishingPier.fishingSpotCell) == TerrainDef.Named("Marsh"));
                        bool isDaytime        = (this.Map.skyManager.CurSkyGlow >= 0.4f);

                        PawnKindDef caugthFishDef = null;
                        if (fishSpotIsMarshy && isDaytime)
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList()
                                             where fishSpecies.livesInMarsh
                                             where fishSpecies.catchableDuringDay
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        else if (fishSpotIsMarshy && !isDaytime)
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList()
                                             where fishSpecies.livesInMarsh
                                             where fishSpecies.catchableDuringNight
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        else if (!fishSpotIsMarshy && isDaytime)
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList()
                                             where fishSpecies.livesInSea
                                             where fishSpecies.catchableDuringDay
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        else
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList()
                                             where fishSpecies.livesInSea
                                             where fishSpecies.catchableDuringNight
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        Pawn caughtFish = PawnGenerator.GeneratePawn(caugthFishDef);
                        GenSpawn.Spawn(caughtFish, this.pawn.Position, this.Map);
                        HealthUtility.GiveInjuriesToKill(caughtFish);
                        foreach (Thing thing in this.pawn.Position.GetThingList(this.Map))
                        {
                            Corpse fishCorpse = thing as Corpse;
                            if (fishCorpse != null)
                            {
                                fishingCatch = fishCorpse;
                            }
                        }
                        if (caughtFish.BodySize >= 0.1f)
                        {
                            fishingPier.fishStock--;
                            fishingPier.UpdateMaxFishStock();
                        }
                    }
                    else if (catchSelectorValue > 0.02)
                    {
                        fishingCatch            = GenSpawn.Spawn(Util_FishIndustry.OysterDef, this.pawn.Position, this.Map);
                        fishingCatch.stackCount = Rand.RangeInclusive(5, 27);
                    }
                    else
                    {
                        float bonusCatchValue = Rand.Value;
                        if (bonusCatchValue < 0.01f)
                        {
                            // Really small chance to find a sunken treasure!!!
                            fishingCatch            = GenSpawn.Spawn(ThingDefOf.Gold, this.pawn.Position, this.Map);
                            fishingCatch.stackCount = Rand.RangeInclusive(58, 289);
                            Thing treasureSilver = GenSpawn.Spawn(ThingDefOf.Silver, fishingPier.middleCell, this.Map);
                            treasureSilver.stackCount = Rand.RangeInclusive(237, 2154);
                            string eventText = this.pawn.Name.ToStringShort.CapitalizeFirst() + " has found a sunken treasure while fishing! What a good catch!\n";
                            Find.LetterStack.ReceiveLetter("Sunken treasure!", eventText, LetterType.Good, this.pawn);
                        }
                        else if (bonusCatchValue < 0.02f)
                        {
                            // Really small chance to find a complete power armor set + sniper or charge rifle.
                            Thing powerArmor = GenSpawn.Spawn(ThingDef.Named("Apparel_PowerArmor"), this.pawn.Position, this.Map);
                            fishingCatch = powerArmor; // Used to carry the power armor.
                            Thing powerArmorHelmet = GenSpawn.Spawn(ThingDef.Named("Apparel_PowerArmorHelmet"), this.pawn.Position, this.Map);
                            Thing rifle            = null;
                            if (Rand.Value < 0.5f)
                            {
                                rifle = GenSpawn.Spawn(ThingDef.Named("Gun_ChargeRifle"), this.pawn.Position, this.Map);
                            }
                            else
                            {
                                rifle = GenSpawn.Spawn(ThingDef.Named("Gun_SniperRifle"), this.pawn.Position, this.Map);
                            }
                            CompQuality qualityComp = powerArmor.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }
                            qualityComp = powerArmorHelmet.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }
                            qualityComp = rifle.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }

                            Faction faction    = Find.FactionManager.FirstFactionOfDef(FactionDefOf.SpacerHostile);
                            Pawn    deadMarine = PawnGenerator.GeneratePawn(PawnKindDefOf.SpaceSoldier, faction);
                            GenSpawn.Spawn(deadMarine, fishingPier.bankCell, this.Map);
                            HealthUtility.GiveInjuriesToKill(deadMarine);
                            List <Thing> thingsList = deadMarine.Position.GetThingList(this.Map);
                            foreach (Thing thing in thingsList)
                            {
                                if (thing.def.defName.Contains("Corpse"))
                                {
                                    CompRottable rotComp = thing.TryGetComp <CompRottable>();
                                    if (rotComp != null)
                                    {
                                        rotComp.RotProgress = 20f * GenDate.TicksPerDay; // 20 days so the corpse is dessicated.
                                    }
                                }
                            }
                            string eventText = this.pawn.Name.ToStringShort.CapitalizeFirst() + " has cought a dead body while fishing!\n\n'This is really disgusting but look at his gear! This guy was probably a MiningCo. security member. I wonder what happend to him...'\n";
                            Find.LetterStack.ReceiveLetter("Dead marine", eventText, LetterType.Good, this.pawn);
                        }
                        else
                        {
                            // Find a small amount of gold.
                            fishingCatch            = GenSpawn.Spawn(ThingDefOf.Gold, this.pawn.Position, this.Map);
                            fishingCatch.stackCount = Rand.RangeInclusive(1, 7);
                        }
                        // TODO: add chance to get hurt by a tailteeth (missing finger or even hand!).
                    }
                    IntVec3 storageCell;
                    if (StoreUtility.TryFindBestBetterStoreCellFor(fishingCatch, this.pawn, this.Map, StoragePriority.Unstored, this.pawn.Faction, out storageCell, true))
                    {
                        this.pawn.carryTracker.TryStartCarry(fishingCatch);
                        curJob.targetB = storageCell;
                        curJob.targetC = fishingCatch;
                        curJob.count   = 99999;
                    }
                    else
                    {
                        this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                    }
                }
            };

            yield return(catchFishToil);

            // Reserve the product and storage cell.
            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            yield return(Toils_Reserve.Reserve(TargetIndex.C));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true));

            yield return(Toils_Reserve.Release(fishingPierIndex));
        }
Example #22
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.FailOnDestroyedOrNull(TargetIndex.A);
                    this.$current = Toils_General.Wait(this.duration, TargetIndex.None).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    this.$current = Toils_General.Do(delegate
                    {
                        if (this.pawn.apparel.WornApparel.Contains(base.Apparel))
                        {
                            Apparel apparel;
                            if (this.pawn.apparel.TryDrop(base.Apparel, out apparel))
                            {
                                this.job.targetA = apparel;
                                if (this.job.haulDroppedApparel)
                                {
                                    apparel.SetForbidden(false, false);
                                    StoragePriority currentPriority = StoreUtility.CurrentStoragePriorityOf(apparel);
                                    IntVec3 c;
                                    if (StoreUtility.TryFindBestBetterStoreCellFor(apparel, this.pawn, base.Map, currentPriority, this.pawn.Faction, out c, true))
                                    {
                                        this.job.count   = apparel.stackCount;
                                        this.job.targetB = c;
                                    }
                                    else
                                    {
                                        base.EndJobWith(JobCondition.Incompletable);
                                    }
                                }
                                else
                                {
                                    base.EndJobWith(JobCondition.Succeeded);
                                }
                            }
                            else
                            {
                                base.EndJobWith(JobCondition.Incompletable);
                            }
                        }
                        else
                        {
                            base.EndJobWith(JobCondition.Incompletable);
                        }
                    });
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                    if (this.job.haulDroppedApparel)
                    {
                        this.$current = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null);
                        if (!this.$disposing)
                        {
                            this.$PC = 3;
                        }
                        return(true);
                    }
                    break;

                case 3u:
                    this.$current = Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null);
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

                case 4u:
                    this.$current = Toils_Haul.StartCarryThing(TargetIndex.A, false, false, false).FailOn(() => !this.pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation));
                    if (!this.$disposing)
                    {
                        this.$PC = 5;
                    }
                    return(true);

                case 5u:
                    carryToCell   = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);
                    this.$current = carryToCell;
                    if (!this.$disposing)
                    {
                        this.$PC = 6;
                    }
                    return(true);

                case 6u:
                    this.$current = Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true);
                    if (!this.$disposing)
                    {
                        this.$PC = 7;
                    }
                    return(true);

                case 7u:
                    break;

                default:
                    return(false);
                }
                this.$PC = -1;
                return(false);
            }
Example #23
0
        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);
                    }
                    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.ArtilleryShellLoaded.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);
        }
Example #24
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Apparel_Toolbelt toolbelt = this.CurJob.GetTarget(SlotterInd).Thing as Apparel_Toolbelt;

            // no free slots
            this.FailOn(() => toolbelt.slotsComp.slots.Count >= toolbelt.MaxItem);


            // reserve resources
            yield return(Toils_Reserve.ReserveQueue(HaulableInd));

            // extract next target thing from targetQueue
            Toil toilExtractNextTarget = Toils_JobTransforms.ExtractNextTargetFromQueue(HaulableInd);

            yield return(toilExtractNextTarget);

            Toil toilGoToThing = Toils_Goto.GotoThing(HaulableInd, PathEndMode.ClosestTouch)
                                 .FailOnDespawnedOrNull(HaulableInd);

            yield return(toilGoToThing);

            Toil pickUpThingIntoSlot = new Toil
            {
                initAction = () =>
                {
                    if (!toolbelt.slotsComp.slots.TryAdd(this.CurJob.targetA.Thing))
                    {
                        this.EndJobWith(JobCondition.Incompletable);
                    }
                    else
                    {
                        float statfloat = 0;
                        Thing thing     = this.TargetThingA;
                        // add stats to pawn inventory
                        foreach (KeyValuePair <StatDef, float> stat in pawn.GetWeightedWorkStats())
                        {
                            statfloat = RightTools.GetMaxStat(thing as ThingWithComps, stat.Key);
                            if (statfloat > 0)
                            {
                                MapComponent_ToolsForHaul.CachedToolEntries.Add(new MapComponent_ToolsForHaul.Entry(pawn, thing, stat.Key, statfloat));
                            }
                            for (int i = toolbelt.slotsComp.slots.Count - 1; i >= 0; i--)
                            {
                                var tool      = toolbelt.slotsComp.slots[i];
                                var checkstat = RightTools.GetMaxStat(tool as ThingWithComps, stat.Key);
                                if (checkstat > 0 && checkstat < statfloat)
                                {
                                    Thing dropTool;
                                    toolbelt.slotsComp.slots.TryDrop(tool, pawn.Position, pawn.Map, ThingPlaceMode.Near, out dropTool, null);
                                    for (int j = MapComponent_ToolsForHaul.CachedToolEntries.Count - 1;
                                         j >= 0;
                                         j--)
                                    {
                                        var entry = MapComponent_ToolsForHaul.CachedToolEntries[j];
                                        if (entry.tool == tool)
                                        {
                                            MapComponent_ToolsForHaul.CachedToolEntries.RemoveAt(j);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            yield return(pickUpThingIntoSlot);

            yield return(Toils_Jump.JumpIfHaveTargetInQueue(HaulableInd, toilExtractNextTarget));
        }
        // Token: 0x06000022 RID: 34 RVA: 0x00002891 File Offset: 0x00000A91
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedOrNull(TargetIndex.B);
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            this.FailOn(delegate
            {
                var billGiver = job.GetTarget(TargetIndex.A).Thing as IBillGiver;
                return(BellRef.currentState == Building_Bell.State.rest);
            });
            AddFinishAction(delegate
            {
                var flag = Takee == BellRef.fighter1.p;
                if (flag)
                {
                    var isInFight = BellRef.fighter1.isInFight;
                    if (!isInFight)
                    {
                        BellRef.TryCancelBrawl();
                    }
                }
                else
                {
                    var flag2 = Takee == BellRef.fighter2.p;
                    if (!flag2)
                    {
                        return;
                    }

                    var isInFight2 = BellRef.fighter2.isInFight;
                    if (!isInFight2)
                    {
                        BellRef.TryCancelBrawl();
                    }
                }
            });
            yield return(new Toil
            {
                initAction = delegate
                {
                    var flag = BellRef.currentState == Building_Bell.State.scheduled;
                    if (!flag)
                    {
                        return;
                    }

                    BellRef.currentState = Building_Bell.State.preparation;
                    BellRef.startTheShow();
                }
            });

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A));

            yield return(Toils_Goto.GotoCell(TargetIndex.C, PathEndMode.Touch));

            yield return(new Toil
            {
                initAction = delegate
                {
                    var position = DropPosition;
                    pawn.carryTracker.TryDropCarriedThing(position, ThingPlaceMode.Direct, out _);
                    var flag = !BellRef.Destroyed;
                    if (!flag)
                    {
                        return;
                    }

                    HaulFinished();
                    BellRef.PrisonerDelievered(Takee);
                    var flag2 = BellRef.currentState != Building_Bell.State.fight;
                    if (!flag2)
                    {
                        return;
                    }

                    var carryPrisonerJob = new Job(JobDefOfArena.HaulingPrisoner, BellRef.getPrisonerForHaul(), BellRef,
                                                   BellRef.getFighterStandPoint())
                    {
                        count = 1
                    };
                    pawn.jobs.TryTakeOrderedJob(carryPrisonerJob);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });
        }
Example #26
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.FailOnDespawnedOrNull(TargetIndex.A);
                    this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    this.$current = Toils_General.Wait(10, TargetIndex.None);
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                {
                    Toil dropOrStartCarrying = new Toil();
                    dropOrStartCarrying.initAction = delegate()
                    {
                        Pawn otherPawn = base.OtherPawn;
                        if (!otherPawn.inventory.UnloadEverything)
                        {
                            base.EndJobWith(JobCondition.Succeeded);
                        }
                        else
                        {
                            ThingCount firstUnloadableThing = otherPawn.inventory.FirstUnloadableThing;
                            IntVec3    c;
                            if (!firstUnloadableThing.Thing.def.EverStorable(false) || !this.pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !StoreUtility.TryFindStoreCellNearColonyDesperate(firstUnloadableThing.Thing, this.pawn, out c))
                            {
                                Thing thing;
                                otherPawn.inventory.innerContainer.TryDrop(firstUnloadableThing.Thing, ThingPlaceMode.Near, firstUnloadableThing.Count, out thing, null, null);
                                base.EndJobWith(JobCondition.Succeeded);
                                if (thing != null)
                                {
                                    thing.SetForbidden(false, false);
                                }
                            }
                            else
                            {
                                Thing thing2;
                                otherPawn.inventory.innerContainer.TryTransferToContainer(firstUnloadableThing.Thing, this.pawn.carryTracker.innerContainer, firstUnloadableThing.Count, out thing2, true);
                                this.job.count = thing2.stackCount;
                                this.job.SetTarget(TargetIndex.B, thing2);
                                this.job.SetTarget(TargetIndex.C, c);
                                firstUnloadableThing.Thing.SetForbidden(false, false);
                            }
                        }
                    };
                    this.$current = dropOrStartCarrying;
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);
                }

                case 3u:
                    this.$current = Toils_Reserve.Reserve(TargetIndex.C, 1, -1, null);
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

                case 4u:
                    carryToCell   = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);
                    this.$current = carryToCell;
                    if (!this.$disposing)
                    {
                        this.$PC = 5;
                    }
                    return(true);

                case 5u:
                    this.$current = Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carryToCell, true);
                    if (!this.$disposing)
                    {
                        this.$PC = 6;
                    }
                    return(true);

                case 6u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
        //What should we do?
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //Check it out. Can we go there?
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);

            //Wait a minute, is this thing already playing?
            if (!Gramophone.IsOn())
            {
                if (job.targetA.Thing is Building_Radio)
                {
                    report = "playing the radio.";
                }

                // Toil 1:
                // Reserve Target (TargetPack A is selected (It has the info where the target cell is))
                yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

                // Toil 2:
                // Go to the thing.
                yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

                // Toil 3:
                // Wind up the gramophone
                var wind = new Toil
                {
                    defaultCompleteMode = ToilCompleteMode.Delay,
                    defaultDuration     = Duration
                };
                wind.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
                if (job.targetA.Thing is Building_Radio)
                {
                    wind.PlaySustainerOrSound(DefDatabase <SoundDef> .GetNamed("Estate_RadioSeeking"));
                }
                else
                {
                    wind.PlaySustainerOrSound(DefDatabase <SoundDef> .GetNamed("Estate_GramophoneWindup"));
                }
                wind.initAction = delegate
                {
                    Gramophone.StopMusic();
                };
                yield return(wind);

                // Toil 4:
                // Play music.

                var toilPlayMusic = new Toil
                {
                    defaultCompleteMode = ToilCompleteMode.Instant,
                    initAction          = delegate
                    {
                        Gramophone.PlayMusic(pawn);
                    }
                };
                yield return(toilPlayMusic);
            }

            Toil toil;

            if (base.TargetC.HasThing && base.TargetC.Thing is Building_Bed bed)   //If we have a bed, lie in bed to listen.
            {
                this.KeepLyingDown(TargetIndex.C);
                yield return(Toils_Reserve.Reserve(TargetIndex.C, bed.SleepingSlotsCount));

                yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.C, TargetIndex.None));

                yield return(Toils_Bed.GotoBed(TargetIndex.C));

                toil = Toils_LayDown.LayDown(TargetIndex.C, true, false, true, true);
                toil.AddFailCondition(() => !pawn.Awake());
            }
            else
            {
                if (base.TargetC.HasThing)
                {
                    yield return(Toils_Reserve.Reserve(TargetIndex.C, 1));
                }
                yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell));

                toil = new Toil();
            }
            toil.AddPreTickAction(delegate
            {
                ListenTickAction();
                if (job.targetA.Thing is Building_Radio)
                {
                    report = "Listening to the radio.";
                }
            });
            toil.AddFinishAction(delegate
            {
                JoyUtility.TryGainRecRoomThought(pawn);
            });
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = base.job.def.joyDuration;
            yield return(toil);

            yield break;
        }
Example #28
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Apparel_Backpack backpack = CurJob.GetTarget(BackpackInd).Thing as Apparel_Backpack;

            ///
            //Set fail conditions
            ///


            //Backpack is full.
            this.FailOn(() => { return((pawn.inventory.container.Count < backpack.MaxItem) ? false : true); });

            ///
            //Define Toil
            ///

            Toil extractB = new Toil();

            extractB.initAction = () =>
            {
                if (!CurJob.targetQueueB.NullOrEmpty())
                {
                    CurJob.targetB = CurJob.targetQueueB.First();
                    CurJob.targetQueueB.RemoveAt(0);
                    this.FailOnDestroyed(HaulableInd);
                }
                else
                {
                    this.EndJobWith(JobCondition.Succeeded);
                }
            };

            Toil toilGoToThing = Toils_Goto.GotoThing(HaulableInd, PathEndMode.ClosestTouch)
                                 .FailOnDespawned(HaulableInd);

            ///
            //Toils Start
            ///

            //Reserve thing to be stored and storage cell
            yield return(Toils_Reserve.Reserve(BackpackInd));

            yield return(Toils_Reserve.Reserve(HaulableInd));

            yield return(Toils_Reserve.ReserveQueue(HaulableInd));


            yield return(Toils_Jump.JumpIf(toilGoToThing, () => { return (CurJob.targetB.HasThing) ? true : false; }));

            //Collect TargetQueue
            {
                //Extract an haulable into TargetA
                yield return(extractB);

                yield return(toilGoToThing);

                //CollectIntoCarrier
                Toil toilPutInInventory = new Toil();
                toilPutInInventory.initAction = () =>
                {
                    if (pawn.inventory.container.Count < backpack.MaxItem &&
                        backpack.wearer.inventory.container.TotalStackCount < backpack.MaxStack)
                    {
                        if (CurJob.targetB.Thing.TryGetComp <CompForbiddable>() != null && CurJob.targetB.Thing.TryGetComp <CompForbiddable>().Forbidden == true)
                        {
                            CurJob.targetB.Thing.TryGetComp <CompForbiddable>().Forbidden = false;
                        }
                        if (pawn.inventory.container.TryAdd(CurJob.targetB.Thing, CurJob.maxNumToCarry))
                        {
                            CurJob.targetB.Thing.holder       = pawn.inventory.GetContainer();
                            CurJob.targetB.Thing.holder.owner = pawn.inventory;
                            backpack.numOfSavedItems++;
                        }
                    }
                    else
                    {
                        this.EndJobWith(JobCondition.Incompletable);
                    }
                };
                yield return(toilPutInInventory);

                yield return(Toils_Jump.JumpIfHaveTargetInQueue(HaulableInd, extractB));
            }
        }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.FailOn(() => !base.Map.lordManager.lords.Contains(this.job.lord));
                    reserve       = Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null).FailOnDespawnedOrNull(TargetIndex.A);
                    this.$current = reserve;
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                    this.$current = base.DetermineNumToHaul();
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);

                case 3u:
                    this.$current = Toils_Haul.StartCarryThing(TargetIndex.A, false, true, false);
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

                case 4u:
                    this.$current = base.AddCarriedThingToTransferables();
                    if (!this.$disposing)
                    {
                        this.$PC = 5;
                    }
                    return(true);

                case 5u:
                    this.$current = Toils_Haul.CheckForGetOpportunityDuplicate(reserve, TargetIndex.A, TargetIndex.None, true, (Thing x) => base.Transferable.things.Contains(x));
                    if (!this.$disposing)
                    {
                        this.$PC = 6;
                    }
                    return(true);

                case 6u:
                    findCarrier   = base.FindCarrier();
                    this.$current = findCarrier;
                    if (!this.$disposing)
                    {
                        this.$PC = 7;
                    }
                    return(true);

                case 7u:
                    this.$current = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch).JumpIf(() => !JobDriver_PrepareCaravan_GatherItems.IsUsableCarrier(base.Carrier, this.pawn, true), findCarrier);
                    if (!this.$disposing)
                    {
                        this.$PC = 8;
                    }
                    return(true);

                case 8u:
                    this.$current = Toils_General.Wait(25, TargetIndex.None).JumpIf(() => !JobDriver_PrepareCaravan_GatherItems.IsUsableCarrier(base.Carrier, this.pawn, true), findCarrier).WithProgressBarToilDelay(TargetIndex.B, false, -0.5f);
                    if (!this.$disposing)
                    {
                        this.$PC = 9;
                    }
                    return(true);

                case 9u:
                    this.$current = base.PlaceTargetInCarrierInventory();
                    if (!this.$disposing)
                    {
                        this.$PC = 10;
                    }
                    return(true);

                case 10u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
Example #30
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Building_OrbitalRelay orbitalRelay = this.TargetThingA as Building_OrbitalRelay;

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.InteractionCell).FailOn(delegate()
            {
                return (orbitalRelay.canUseConsoleNow == false);
            }));

            Toil faceConsoleToil = new Toil()
            {
                initAction = () =>
                {
                    this.GetActor().rotationTracker.FaceCell(orbitalRelay.Position);
                }
            };

            yield return(faceConsoleToil);

            Toil callMiningCoToil = new Toil()
            {
                initAction = () =>
                {
                    DiaNode mainDiaNode = new DiaNode("\"MiningCo. here!\n"
                                                      + "What do you want, partner?\"");

                    // Cargo supply request option.
                    DiaOption cargoSupplyDiaOption = GetCargoSupplyDiaOption(orbitalRelay);
                    mainDiaNode.options.Add(cargoSupplyDiaOption);

                    // Medical supply request option.
                    DiaOption medicalSupplyDiaOption = GetMedicalSupplyDiaOption(orbitalRelay);
                    mainDiaNode.options.Add(medicalSupplyDiaOption);

                    // Air support request option.
                    DiaOption airSupportDiaOption = GetAirSupportDiaOption(orbitalRelay, mainDiaNode);
                    mainDiaNode.options.Add(airSupportDiaOption);

                    // Partnership and goodwill fee payment option.
                    if ((Util_Misc.Partnership.globalGoodwillFeeInSilver > 0) ||
                        (Util_Misc.Partnership.feeInSilver[this.Map] > 0))
                    {
                        foreach (DiaOption option in mainDiaNode.options)
                        {
                            option.Disable("fee unpaid");
                        }
                        DiaOption feePaymentDiaOption = GetFeePaymentDiaOption(orbitalRelay);
                        mainDiaNode.options.Add(feePaymentDiaOption);
                    }

                    // Disconnect option.
                    DiaOption disconnectDiaOption = new DiaOption("Disconnect");
                    disconnectDiaOption.resolveTree = true;
                    mainDiaNode.options.Add(disconnectDiaOption);

                    Find.WindowStack.Add(new Dialog_NodeTree(mainDiaNode, true, true, "-- Comlink with MiningCo. --"));
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(callMiningCoToil);

            yield return(Toils_Reserve.Release(orbitalRelayConsoleIndex));
        }