コード例 #1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.EndOnDespawnedOrNull(TargetIndex.A, JobCondition.Incompletable);
            bool hasBed = base.TargetC.HasThing && base.TargetC.Thing is Building_Bed;
            Toil watch;

            if (hasBed)
            {
                this.KeepLyingDown(TargetIndex.C);
                yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.C, TargetIndex.None));

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

                watch = Toils_LayDown.LayDown(TargetIndex.C, true, false, true, true);
                watch.AddFailCondition(() => !watch.actor.Awake());
            }
            else
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell));

                watch = new Toil();
            }
            watch.AddPreTickAction(delegate
            {
                this.$this.WatchTickAction();
            });
            watch.AddFinishAction(delegate
            {
                JoyUtility.TryGainRecRoomThought(this.$this.pawn);
            });
            watch.defaultCompleteMode = ToilCompleteMode.Delay;
            watch.defaultDuration     = this.job.def.joyDuration;
            watch.handlingFacing      = true;
            yield return(watch);
        }
コード例 #2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(BedInd);
            this.FailOnDespawnedOrNull(PartnerInd);
            this.FailOn(() => !Partner.health.capacities.CanBeAwake);
            this.KeepLyingDown(BedInd);
            yield return(Toils_Bed.ClaimBedIfNonMedical(BedInd));

            yield return(Toils_Bed.GotoBed(BedInd));

            Toil toil = new Toil();

            toil.initAction = delegate
            {
                if (Partner.CurJob == null || Partner.CurJob.def != JobDefOf.Lovin)
                {
                    Job newJob = JobMaker.MakeJob(JobDefOf.Lovin, pawn, Bed);
                    Partner.jobs.StartJob(newJob, JobCondition.InterruptForced);
                    ticksLeft = (int)(2500f * Mathf.Clamp(Rand.Range(0.1f, 1.1f), 0.1f, 2f));
                }
                else
                {
                    ticksLeft = 9999999;
                }
            };
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(toil);

            Toil toil2 = Toils_LayDown.LayDown(BedInd, hasBed: true, lookForOtherJobs: false, canSleep: false, gainRestAndHealth: false);

            toil2.FailOn(() => Partner.CurJob == null || Partner.CurJob.def != JobDefOf.Lovin);
            toil2.AddPreTickAction(delegate
            {
                ticksLeft--;
                if (ticksLeft <= 0)
                {
                    ReadyForNextToil();
                }
                else if (pawn.IsHashIntervalTick(100))
                {
                    MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
                }
            });
            toil2.AddFinishAction(delegate
            {
                Thought_Memory thought_Memory = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.GotSomeLovin);
                if ((pawn.health != null && pawn.health.hediffSet != null && pawn.health.hediffSet.hediffs.Any((Hediff h) => h.def == HediffDefOf.LoveEnhancer)) || (Partner.health != null && Partner.health.hediffSet != null && Partner.health.hediffSet.hediffs.Any((Hediff h) => h.def == HediffDefOf.LoveEnhancer)))
                {
                    thought_Memory.moodPowerFactor = 1.5f;
                }
                if (pawn.needs.mood != null)
                {
                    pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory, Partner);
                }
                pawn.mindState.canLovinTick = Find.TickManager.TicksGame + GenerateRandomMinTicksToNextLovin(pawn);
            });
            toil2.socialMode = RandomSocialMode.Off;
            yield return(toil2);
        }
コード例 #3
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(this.BedInd);
            this.FailOnDespawnedOrNull(this.PartnerInd);
            this.FailOn(() => !((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0061: stateMachine*/)._0024this.Partner.health.capacities.CanBeAwake);
            this.KeepLyingDown(this.BedInd);
            yield return(Toils_Bed.ClaimBedIfNonMedical(this.BedInd, TargetIndex.None));

            /*Error: Unable to find new state assignment for yield return*/;
        }
コード例 #4
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(this.BedInd);
            this.FailOnDespawnedOrNull(this.PartnerInd);
            this.FailOn(() => !this.Partner.health.capacities.CanBeAwake);
            this.KeepLyingDown(this.BedInd);
            yield return(Toils_Bed.ClaimBedIfNonMedical(this.BedInd, TargetIndex.None));

            yield return(Toils_Bed.GotoBed(this.BedInd));

            yield return(new Toil
            {
                initAction = delegate()
                {
                    if (this.Partner.CurJob == null || this.Partner.CurJob.def != JobDefOf.Lovin)
                    {
                        Job newJob = new Job(JobDefOf.Lovin, this.pawn, this.Bed);
                        this.Partner.jobs.StartJob(newJob, JobCondition.InterruptForced, null, false, true, null, null, false);
                        this.ticksLeft = (int)(2500f * Mathf.Clamp(Rand.Range(0.1f, 1.1f), 0.1f, 2f));
                    }
                    else
                    {
                        this.ticksLeft = 9999999;
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

            Toil doLovin = Toils_LayDown.LayDown(this.BedInd, true, false, false, false);

            doLovin.FailOn(() => this.Partner.CurJob == null || this.Partner.CurJob.def != JobDefOf.Lovin);
            doLovin.AddPreTickAction(delegate
            {
                this.ticksLeft--;
                if (this.ticksLeft <= 0)
                {
                    base.ReadyForNextToil();
                }
                else if (this.pawn.IsHashIntervalTick(100))
                {
                    MoteMaker.ThrowMetaIcon(this.pawn.Position, this.pawn.Map, ThingDefOf.Mote_Heart);
                }
            });
            doLovin.AddFinishAction(delegate
            {
                Thought_Memory newThought = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.GotSomeLovin);
                this.pawn.needs.mood.thoughts.memories.TryGainMemory(newThought, this.Partner);
                this.pawn.mindState.canLovinTick = Find.TickManager.TicksGame + this.GenerateRandomMinTicksToNextLovin(this.pawn);
            });
            doLovin.socialMode = RandomSocialMode.Off;
            yield return(doLovin);

            yield break;
        }
コード例 #5
0
ファイル: JobDriver_LayDown.cs プロジェクト: potsh/RimWorld
        protected override IEnumerable <Toil> MakeNewToils()
        {
            if (!job.GetTarget(TargetIndex.A).HasThing)
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell));

                /*Error: Unable to find new state assignment for yield return*/;
            }
            yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.A));

            /*Error: Unable to find new state assignment for yield return*/;
        }
コード例 #6
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            if (!FromBed)
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell));

                /*Error: Unable to find new state assignment for yield return*/;
            }
            this.KeepLyingDown(TargetIndex.A);
            yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.A));

            /*Error: Unable to find new state assignment for yield return*/;
        }
コード例 #7
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            bool hasBed = this.job.GetTarget(TargetIndex.A).HasThing;

            if (hasBed)
            {
                yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.A, TargetIndex.None));

                yield return(Toils_Bed.GotoBed(TargetIndex.A));
            }
            else
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell));
            }
            yield return(Toils_LayDown.LayDown(TargetIndex.A, hasBed, true, true, true));
        }
コード例 #8
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            _003CMakeNewToils_003Ec__Iterator0 _003CMakeNewToils_003Ec__Iterator = (_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_003e: stateMachine*/;

            this.EndOnDespawnedOrNull(TargetIndex.A);
            if (!base.TargetC.HasThing || !(base.TargetC.Thing is Building_Bed))
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell));

                /*Error: Unable to find new state assignment for yield return*/;
            }
            this.KeepLyingDown(TargetIndex.C);
            yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.C));

            /*Error: Unable to find new state assignment for yield return*/;
        }
コード例 #9
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.EndOnDespawnedOrNull(TargetIndex.A);
            Toil watch;

            if (base.TargetC.HasThing && base.TargetC.Thing is Building_Bed)
            {
                this.KeepLyingDown(TargetIndex.C);
                yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.C));

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

                watch = Toils_LayDown.LayDown(TargetIndex.C, hasBed: true, lookForOtherJobs: false);
                watch.AddFailCondition(() => !watch.actor.Awake());
            }
            else
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell));

                watch = new Toil();
            }
            watch.AddPreTickAction(delegate
            {
                WatchTickAction();
            });
            watch.AddFinishAction(delegate
            {
                JoyUtility.TryGainRecRoomThought(pawn);
            });
            watch.defaultCompleteMode = ToilCompleteMode.Delay;
            watch.defaultDuration     = job.def.joyDuration;
            watch.handlingFacing      = true;
            if (base.TargetA.Thing.def.building != null && base.TargetA.Thing.def.building.effectWatching != null)
            {
                watch.WithEffect(() => base.TargetA.Thing.def.building.effectWatching, EffectTargetGetter);
            }
            yield return(watch);

            LocalTargetInfo EffectTargetGetter()
            {
                return(base.TargetA.Thing.OccupiedRect().RandomCell + IntVec3.North.RotatedBy(base.TargetA.Thing.Rotation));
            }
        }
コード例 #10
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil relax;

            if (this.FromBed)
            {
                this.KeepLyingDown(TargetIndex.A);
                yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.A, TargetIndex.None));

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

                relax = Toils_LayDown.LayDown(TargetIndex.A, true, false, true, true);
                relax.AddFailCondition(() => !this.pawn.Awake());
            }
            else
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell));

                relax            = new Toil();
                relax.initAction = delegate()
                {
                    this.faceDir = ((!this.job.def.faceDir.IsValid) ? Rot4.Random : this.job.def.faceDir);
                };
                relax.handlingFacing = true;
            }
            relax.defaultCompleteMode = ToilCompleteMode.Delay;
            relax.defaultDuration     = this.job.def.joyDuration;
            relax.AddPreTickAction(delegate
            {
                if (this.faceDir.IsValid)
                {
                    this.pawn.rotationTracker.FaceCell(this.pawn.Position + this.faceDir.FacingCell);
                }
                this.pawn.GainComfortFromCellIfPossible();
                JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 1f, null);
            });
            yield return(relax);

            yield break;
        }
コード例 #11
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil toil;

            if (FromBed)
            {
                this.KeepLyingDown(TargetIndex.A);
                yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.A));

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

                toil = Toils_LayDown.LayDown(TargetIndex.A, hasBed: true, lookForOtherJobs: false, CanSleep);
                toil.AddFailCondition(() => !pawn.Awake());
            }
            else
            {
                yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell));

                toil            = new Toil();
                toil.initAction = delegate
                {
                    faceDir = (job.def.faceDir.IsValid ? job.def.faceDir : Rot4.Random);
                };
                toil.handlingFacing = true;
            }
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = job.def.joyDuration;
            toil.AddPreTickAction(delegate
            {
                if (faceDir.IsValid)
                {
                    pawn.rotationTracker.FaceCell(pawn.Position + faceDir.FacingCell);
                }
                pawn.GainComfortFromCellIfPossible();
                JoyUtility.JoyTickCheckEnd(pawn);
            });
            yield return(toil);
        }
コード例 #12
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedOrNull(TargetIndex.B);
            this.FailOnAggroMentalStateAndHostile(TargetIndex.A);
            this.FailOn(delegate
            {
                if (((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_006a: stateMachine*/)._0024this.job.def.makeTargetPrisoner)
                {
                    if (!((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_006a: stateMachine*/)._0024this.DropBed.ForPrisoners)
                    {
                        return(true);
                    }
                }
                else if (((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_006a: stateMachine*/)._0024this.DropBed.ForPrisoners != ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_006a: stateMachine*/)._0024this.Takee.IsPrisoner)
                {
                    return(true);
                }
                return(false);
            });
            yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.B, TargetIndex.A));

            /*Error: Unable to find new state assignment for yield return*/;
        }
コード例 #13
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 (job.def == JobDefOf.Arrest && !pawn.CheckAcceptArrest(base.pawn))
                    {
                        base.pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                    }
                    if (!pawn.IsPrisoner)
                    {
                        QuestUtility.SendQuestTargetSignals(pawn.questTags, "Arrested", pawn.Named("SUBJECT"));
                    }
                }
            };
            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 Thing _);
                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);
        }
コード例 #14
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedOrNull(TargetIndex.B);
            this.FailOnAggroMentalStateAndHostile(TargetIndex.A);
            this.FailOn(delegate()
            {
                if (this.job.def.makeTargetPrisoner)
                {
                    if (!this.DropBed.ForPrisoners)
                    {
                        return(true);
                    }
                }
                else if (this.DropBed.ForPrisoners != this.Takee.IsPrisoner)
                {
                    return(true);
                }
                return(false);
            });
            yield return(Toils_Bed.ClaimBedIfNonMedical(TargetIndex.B, TargetIndex.A));

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

            yield return(new Toil
            {
                initAction = delegate()
                {
                    if (this.job.def.makeTargetPrisoner)
                    {
                        Pawn pawn = (Pawn)this.job.targetA.Thing;
                        Lord lord = pawn.GetLord();
                        if (lord != null)
                        {
                            lord.Notify_PawnAttemptArrested(pawn);
                        }
                        GenClamor.DoClamor(pawn, 10f, ClamorDefOf.Harm);
                        if (this.job.def == JobDefOf.Arrest && !pawn.CheckAcceptArrest(this.pawn))
                        {
                            this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                        }
                    }
                }
            });

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

            startCarrying.AddPreInitAction(new Action(this.CheckMakeTakeeGuest));
            yield return(startCarrying);

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

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

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

            yield return(new Toil
            {
                initAction = delegate()
                {
                    IntVec3 position = this.DropBed.Position;
                    Thing thing;
                    this.pawn.carryTracker.TryDropCarriedThing(position, ThingPlaceMode.Direct, out thing, null);
                    if (!this.DropBed.Destroyed && (this.DropBed.owners.Contains(this.Takee) || (this.DropBed.Medical && this.DropBed.AnyUnoccupiedSleepingSlot) || this.Takee.ownership == null))
                    {
                        this.Takee.jobs.Notify_TuckedIntoBed(this.DropBed);
                        if (this.Takee.RaceProps.Humanlike && this.job.def != JobDefOf.Arrest && !this.Takee.IsPrisonerOfColony)
                        {
                            this.Takee.relations.Notify_RescuedBy(this.pawn);
                        }
                        this.Takee.mindState.Notify_TuckedIntoBed();
                    }
                    if (this.Takee.IsPrisonerOfColony)
                    {
                        LessonAutoActivator.TeachOpportunity(ConceptDefOf.PrisonerTab, this.Takee, OpportunityType.GoodToKnow);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

            yield break;
        }
コード例 #15
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.FailOnDestroyedOrNull(TargetIndex.A);
                    this.FailOnDestroyedOrNull(TargetIndex.B);
                    this.FailOnAggroMentalStateAndHostile(TargetIndex.A);
                    this.FailOn(delegate()
                    {
                        if (this.job.def.makeTargetPrisoner)
                        {
                            if (!base.DropBed.ForPrisoners)
                            {
                                return(true);
                            }
                        }
                        else if (base.DropBed.ForPrisoners != base.Takee.IsPrisoner)
                        {
                            return(true);
                        }
                        return(false);
                    });
                    this.$current = Toils_Bed.ClaimBedIfNonMedical(TargetIndex.B, TargetIndex.A);
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    base.AddFinishAction(delegate
                    {
                        if (this.job.def.makeTargetPrisoner && base.Takee.ownership.OwnedBed == base.DropBed && base.Takee.Position != RestUtility.GetBedSleepingSlotPosFor(base.Takee, base.DropBed))
                        {
                            base.Takee.ownership.UnclaimBed();
                        }
                    });
                    this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.A).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOn(() => this.job.def == JobDefOf.Arrest && !base.Takee.CanBeArrestedBy(this.pawn)).FailOn(() => !this.pawn.CanReach(base.DropBed, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)).FailOn(() => this.job.def == JobDefOf.Rescue && !base.Takee.Downed).FailOnSomeonePhysicallyInteracting(TargetIndex.A);
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                {
                    Toil checkArrestResistance = new Toil();
                    checkArrestResistance.initAction = delegate()
                    {
                        if (this.job.def.makeTargetPrisoner)
                        {
                            Pawn pawn = (Pawn)this.job.targetA.Thing;
                            Lord lord = pawn.GetLord();
                            if (lord != null)
                            {
                                lord.Notify_PawnAttemptArrested(pawn);
                            }
                            GenClamor.DoClamor(pawn, 10f, ClamorDefOf.Harm);
                            if (this.job.def == JobDefOf.Arrest && !pawn.CheckAcceptArrest(this.pawn))
                            {
                                this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                            }
                        }
                    };
                    this.$current = checkArrestResistance;
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);
                }

                case 3u:
                    startCarrying = Toils_Haul.StartCarryThing(TargetIndex.A, false, false, false).FailOnNonMedicalBedNotOwned(TargetIndex.B, TargetIndex.A);
                    startCarrying.AddPreInitAction(new Action(base.CheckMakeTakeeGuest));
                    this.$current = startCarrying;
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

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

                case 5u:
                {
                    Toil makePrisonerAndInit = new Toil();
                    makePrisonerAndInit.initAction = delegate()
                    {
                        base.CheckMakeTakeePrisoner();
                        if (base.Takee.playerSettings == null)
                        {
                            base.Takee.playerSettings = new Pawn_PlayerSettings(base.Takee);
                        }
                    };
                    this.$current = makePrisonerAndInit;
                    if (!this.$disposing)
                    {
                        this.$PC = 6;
                    }
                    return(true);
                }

                case 6u:
                    this.$current = Toils_Reserve.Release(TargetIndex.B);
                    if (!this.$disposing)
                    {
                        this.$PC = 7;
                    }
                    return(true);

                case 7u:
                {
                    Toil tuckIntoBed = new Toil();
                    tuckIntoBed.initAction = delegate()
                    {
                        IntVec3 position = base.DropBed.Position;
                        Thing   thing;
                        this.pawn.carryTracker.TryDropCarriedThing(position, ThingPlaceMode.Direct, out thing, null);
                        if (!base.DropBed.Destroyed && (base.DropBed.owners.Contains(base.Takee) || (base.DropBed.Medical && base.DropBed.AnyUnoccupiedSleepingSlot) || base.Takee.ownership == null))
                        {
                            base.Takee.jobs.Notify_TuckedIntoBed(base.DropBed);
                            if (base.Takee.RaceProps.Humanlike && this.job.def != JobDefOf.Arrest && !base.Takee.IsPrisonerOfColony)
                            {
                                base.Takee.relations.Notify_RescuedBy(this.pawn);
                            }
                            base.Takee.mindState.Notify_TuckedIntoBed();
                        }
                        if (base.Takee.IsPrisonerOfColony)
                        {
                            LessonAutoActivator.TeachOpportunity(ConceptDefOf.PrisonerTab, base.Takee, OpportunityType.GoodToKnow);
                        }
                    };
                    tuckIntoBed.defaultCompleteMode = ToilCompleteMode.Instant;
                    this.$current = tuckIntoBed;
                    if (!this.$disposing)
                    {
                        this.$PC = 8;
                    }
                    return(true);
                }

                case 8u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
コード例 #16
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.FailOnDespawnedOrNull(this.BedInd);
                    this.FailOnDespawnedOrNull(this.PartnerInd);
                    this.FailOn(() => !base.Partner.health.capacities.CanBeAwake);
                    this.KeepLyingDown(this.BedInd);
                    this.$current = Toils_Bed.ClaimBedIfNonMedical(this.BedInd, TargetIndex.None);
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    this.$current = Toils_Bed.GotoBed(this.BedInd);
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                {
                    Toil preparePartner = new Toil();
                    preparePartner.initAction = delegate()
                    {
                        if (base.Partner.CurJob == null || base.Partner.CurJob.def != JobDefOf.Lovin)
                        {
                            Job newJob = new Job(JobDefOf.Lovin, this.pawn, base.Bed);
                            base.Partner.jobs.StartJob(newJob, JobCondition.InterruptForced, null, false, true, null, null, false);
                            this.ticksLeft = (int)(2500f * Mathf.Clamp(Rand.Range(0.1f, 1.1f), 0.1f, 2f));
                        }
                        else
                        {
                            this.ticksLeft = 9999999;
                        }
                    };
                    preparePartner.defaultCompleteMode = ToilCompleteMode.Instant;
                    this.$current = preparePartner;
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);
                }

                case 3u:
                    doLovin = Toils_LayDown.LayDown(this.BedInd, true, false, false, false);
                    doLovin.FailOn(() => base.Partner.CurJob == null || base.Partner.CurJob.def != JobDefOf.Lovin);
                    doLovin.AddPreTickAction(delegate
                    {
                        this.ticksLeft--;
                        if (this.ticksLeft <= 0)
                        {
                            base.ReadyForNextToil();
                        }
                        else if (this.pawn.IsHashIntervalTick(100))
                        {
                            MoteMaker.ThrowMetaIcon(this.pawn.Position, this.pawn.Map, ThingDefOf.Mote_Heart);
                        }
                    });
                    doLovin.AddFinishAction(delegate
                    {
                        Thought_Memory newThought = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.GotSomeLovin);
                        this.pawn.needs.mood.thoughts.memories.TryGainMemory(newThought, base.Partner);
                        this.pawn.mindState.canLovinTick = Find.TickManager.TicksGame + base.GenerateRandomMinTicksToNextLovin(this.pawn);
                    });
                    doLovin.socialMode = RandomSocialMode.Off;
                    this.$current      = doLovin;
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

                case 4u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
コード例 #17
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    if (base.FromBed)
                    {
                        this.KeepLyingDown(TargetIndex.A);
                        this.$current = Toils_Bed.ClaimBedIfNonMedical(TargetIndex.A, TargetIndex.None);
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        return(true);
                    }
                    this.$current = Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell);
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);

                case 1u:
                    this.$current = Toils_Bed.GotoBed(TargetIndex.A);
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                    relax = Toils_LayDown.LayDown(TargetIndex.A, true, false, true, true);
                    relax.AddFailCondition(() => !this.pawn.Awake());
                    break;

                case 3u:
                    relax            = new Toil();
                    relax.initAction = delegate()
                    {
                        this.faceDir = ((!this.job.def.faceDir.IsValid) ? Rot4.Random : this.job.def.faceDir);
                    };
                    relax.handlingFacing = true;
                    break;

                case 4u:
                    this.$PC = -1;
                    return(false);

                default:
                    return(false);
                }
                relax.defaultCompleteMode = ToilCompleteMode.Delay;
                relax.defaultDuration     = this.job.def.joyDuration;
                relax.AddPreTickAction(delegate
                {
                    if (this.faceDir.IsValid)
                    {
                        this.pawn.rotationTracker.FaceCell(this.pawn.Position + this.faceDir.FacingCell);
                    }
                    this.pawn.GainComfortFromCellIfPossible();
                    JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 1f, null);
                });
                this.$current = relax;
                if (!this.$disposing)
                {
                    this.$PC = 4;
                }
                return(true);
            }