Ejemplo n.º 1
0
        /// <summary>
        /// What happens while the game is being played. Make it return true if the player wins.
        /// </summary>
        /// <returns></returns>
        protected virtual bool WatchTickAction()
        {
            var extraJoyGainFactor = TargetThingA.GetStatValue(StatDefOf.EntertainmentStrengthFactor);

            JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.None, extraJoyGainFactor);

            return(false);
        }
        protected override Toil GetPlayToil(Pawn musician, Thing instrument, Thing venue)
        {
            // custom toil.
            var play = new Toil();

            var props = instrument.TryGetComp <CompMusicalInstrument>().Props;

            play.initAction = delegate
            {
                pawn.Map.GetComponent <PerformanceManager>().StartPlaying(musician, instrument, venue, false);
            };


            play.tickAction = delegate
            {
                if (props.isBuilding)
                {
                    pawn.rotationTracker.FaceTarget(TargetC);
                    pawn.GainComfortFromCellIfPossible();
                }
                else
                {
                    pawn.rotationTracker.FaceCell(ClosestMusicSpotParentCell);
                }

                if (ticksLeftThisToil % 100 == 99)
                {
                    ThrowMusicNotes(musician.DrawPos, Map);
                }

                JoyUtility.JoyTickCheckEnd(musician, JoyTickFullJoyAction.GoToNextToil);
            };

            play.handlingFacing      = true;
            play.defaultCompleteMode = ToilCompleteMode.Delay;
            play.defaultDuration     = job.def.joyDuration;

            play.AddFinishAction(delegate
            {
                pawn.Map.GetComponent <PerformanceManager>().StopPlaying(musician, venue);

                if (pawn.carryTracker.CarriedThing == null)
                {
                    return;
                }

                if (!pawn.carryTracker.innerContainer.TryTransferToContainer(pawn.carryTracker.CarriedThing,
                                                                             pawn.inventory.innerContainer))
                {
                    _ = pawn.carryTracker.TryDropCarriedThing(pawn.Position,
                                                              pawn.carryTracker.CarriedThing.stackCount, ThingPlaceMode.Near, out _);
                }
            });

            play.socialMode = RandomSocialMode.Quiet;

            return(play);
        }
Ejemplo n.º 3
0
        // Token: 0x06000059 RID: 89 RVA: 0x000042F0 File Offset: 0x000024F0
        protected override void WaitTickAction()
        {
            float num = AQUtility.GetJoyGainFactor(FishyThing.GetStatValue(StatDefOf.Beauty, true) / FishyThing.def.GetStatValueAbstract(StatDefOf.Beauty, null), FishyThing);
            float extraJoyGainFactor = (num > 0f) ? num : 0f;

            pawn.GainComfortFromCellIfPossible(false);
            JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor, (Building)FishyThing);
            AQUtility.ApplyMoodBoostAndInspire(pawn, FishyThing);
        }
        protected override Job TryGivePlayJob(Pawn pawn, Thing t)
        {
            if ((t as ThingWithComps).TryGetComp <CompMountable>().IsMounted&& !ToolsForHaulUtility.IsDriverOfThisVehicle(pawn, t))
            {
                return(null);
            }

            if (!(t as ThingWithComps).TryGetComp <CompRefuelable>().HasFuel)
            {
                return(null);
            }

            if (t.IsForbidden(Faction.OfPlayer))
            {
                return(null);
            }

            if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                return(null);
            }
            if (PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }
            Region reg;

            if (!CellFinder.TryFindClosestRegionWith(pawn.Position.GetRegion(), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), (Region r) => r.Room.PsychologicallyOutdoors && !r.IsForbiddenEntirely(pawn), 100, out reg))
            {
                return(null);
            }
            IntVec3 root;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, null, out root))
            {
                return(null);
            }
            List <IntVec3> list;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root, out list))
            {
                return(null);
            }
            Job job = new Job(this.def.jobDef, list[0])
            {
                targetQueueA = new List <TargetInfo>(),
                targetB      = t,
            };

            for (int i = 1; i < list.Count; i++)
            {
                job.targetQueueA.Add(list[i]);
            }

            job.locomotionUrgency = LocomotionUrgency.Jog;
            return(job);
        }
        protected void ReadTickAction()
        {
            pawn.rotationTracker.FaceCell(TargetB.Cell);
            pawn.GainComfortFromCellIfPossible();
            var statValue = TargetThingA.GetStatValue(StatDefOf.JoyGainFactor);
            var pawn1     = pawn;

            JoyUtility.JoyTickCheckEnd(pawn1, JoyTickFullJoyAction.EndJob, statValue);
        }
        //RCellFinder
        public static void TryFindGatheringSpot_PostFix(Pawn organizer, ref IntVec3 result, ref bool __result)
        {
            var enjoyableOutside = JoyUtility.EnjoyableOutsideNow(organizer);
            var map = organizer.Map;

            if (!map.listerThings.ThingsOfDef(ThingDef.Named("LotRH_PlantPartyTree"))
                .Any(x => x is Plant {
                LifeStage: PlantLifeStage.Mature
            }))
        internal static IEnumerable <Toil> _MakeNewToils(this JobDriver_SocialRelax obj)
        {
            obj.EndOnDespawnedOrNull(GatherSpotParentInd, JobCondition.Incompletable);

            if (obj.HasChair())
            {
                obj.EndOnDespawnedOrNull(ChairOrSpotInd, JobCondition.Incompletable);
            }
            yield return(Toils_Reserve.Reserve(ChairOrSpotInd, 1));

            if (obj.HasDrinkOrDispenser())
            {
                obj.FailOnDestroyedNullOrForbidden(OptionalDrinkInd);
                yield return(Toils_Reserve.Reserve(OptionalDrinkInd, 1));

                if (obj.IsDispenser())
                {
                    yield return(Toils_Goto.GotoThing(OptionalDrinkInd, PathEndMode.InteractionCell));

                    yield return(Toils_FoodSynthesizer.TakeAlcoholFromSynthesizer(OptionalDrinkInd, obj.pawn));
                }
                else
                {
                    yield return(Toils_Goto.GotoThing(OptionalDrinkInd, PathEndMode.OnCell));

                    yield return(Toils_Haul.StartCarryThing(OptionalDrinkInd));
                }
            }

            yield return(Toils_Goto.GotoCell(ChairOrSpotInd, PathEndMode.OnCell));

            var relax = new Toil()
            {
                defaultCompleteMode = ToilCompleteMode.Delay,
                defaultDuration     = obj.pawn.CurJob.def.joyDuration,
                tickAction          = () =>
                {
                    var pawnDrawer     = obj.pawn.GetPawnDrawTracker();
                    var pawnFaceTarget = obj.ClosestGatherSpotParentCell();
                    pawnDrawer.rotator.FaceCell(pawnFaceTarget);
                    obj.pawn.GainComfortFromCellIfPossible();
                    JoyUtility.JoyTickCheckEnd(obj.pawn, JoyTickFullJoyAction.GoToNextToil, 1f);
                }
            };

            relax.AddFinishAction(() =>
                                  JoyUtility.TryGainRecRoomThought(obj.pawn)
                                  );
            relax.socialMode = RandomSocialMode.SuperActive;
            yield return(relax);

            if (obj.IsDrink())
            {
                yield return(Toils_Ingest.FinalizeIngest(obj.pawn, OptionalDrinkInd));
            }
        }
Ejemplo n.º 8
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.EndOnDespawnedOrNull(TargetIndex.A, JobCondition.Incompletable);
            yield return(Toils_Reserve.Reserve(TargetIndex.A, base.job.def.joyMaxParticipants));

            if (this.TargetB != null)
            {
                yield return(Toils_Reserve.Reserve(TargetIndex.B, 1));
            }
            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.OnCell));

            Toil toil = new Toil();

            toil.PlaySustainerOrSound(TargetThingA?.def?.defName == "RimWriter_TableTypewriter"
                ? DefDatabase <SoundDef> .GetNamed("RimWriter_SoundManualTypewriter") : DefDatabase <SoundDef> .GetNamed(
                                          "RimWriter_SoundManualPencil"));
            toil.tickAction = delegate
            {
                this.pawn.rotationTracker.FaceCell(this.TargetA.Cell);
                this.pawn.GainComfortFromCellIfPossible();
                float statValue          = this.TargetThingA.GetStatValue(StatDefOf.JoyGainFactor, true);
                float extraJoyGainFactor = statValue;
                JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.GoToNextToil, extraJoyGainFactor);
            };
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = base.job.def.joyDuration;
            toil.AddFinishAction(delegate
            {
                RimWriterUtility.TryGainLibraryThought(pawn);
            });
            yield return(toil);

            Toil finishedToil = new Toil();

            finishedToil.initAction = delegate
            {
                if (RimWriterUtility.IsCosmicHorrorsLoaded() || RimWriterUtility.IsCultsLoaded())
                {
                    try
                    {
                        if (RimWriterUtility.HasSanityLoss(this.pawn))
                        {
                            RimWriterUtility.ApplySanityLoss(this.pawn, -sanityRestoreRate, 1);
                            Messages.Message(this.pawn.ToString() + " has restored some sanity using the " + this.TargetA.Thing.def.label + ".", new TargetInfo(this.pawn.Position, this.pawn.Map), MessageTypeDefOf.NeutralEvent);// .Standard);
                        }
                    }
                    catch
                    {
                        Log.Message("Error loading Sanity Hediff.");
                    }
                }
            };
            yield return(finishedToil);

            yield break;
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //Fail Checks

            this.EndOnDespawnedOrNull(TargetIndex.A); //If we don't exist, exit.

            if (job.targetA.Thing is Building_Radio)
            {
                report = "Listening to the radio.";
            }


            //yield return Toils_Reserve.Reserve(TargetIndex.A, base.CurJob.def.joyMaxParticipants); //Can we reserve?

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

            Toil toil;

            if (TargetC.HasThing && TargetC.Thing is Building_Bed) //If we have a bed, do something else.
            {
                this.KeepLyingDown(TargetIndex.C);
                yield return(Toils_Reserve.Reserve(TargetIndex.C, ((Building_Bed)TargetC.Thing).SleepingSlotsCount));

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

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

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

                yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell));

                toil = new Toil();
            }

            toil.AddPreTickAction(delegate
            {
                if (job.targetA.Thing is Building_Radio)
                {
                    report = "Listening to the radio.";
                }

                ListenTickAction();
            });
            toil.AddFinishAction(delegate { JoyUtility.TryGainRecRoomThought(pawn); });
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = job.def.joyDuration * 2;
            yield return(toil);
        }
Ejemplo n.º 10
0
 protected Action WaitTickAction()
 {
     return(delegate
     {
         this.pawn.rotationTracker.FaceCell(base.TargetB.Cell);
         this.pawn.GainComfortFromCellIfPossible();
         float extraJoyGainFactor = base.TargetThingA.GetStatValue(StatDefOf.JoyGainFactor, true);
         JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor);
     });
 }
        protected void ReadTickAction()
        {
            this.pawn.rotationTracker.FaceCell(base.TargetB.Cell);
            this.pawn.GainComfortFromCellIfPossible();
            float statValue          = base.TargetThingA.GetStatValue(StatDefOf.JoyGainFactor, true);
            Pawn  pawn               = this.pawn;
            float extraJoyGainFactor = statValue;

            JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor);
        }
Ejemplo n.º 12
0
 private Action WaitTickAction()
 {
     return(delegate
     {
         pawn.rotationTracker.FaceCell(TargetB.Cell);
         pawn.GainComfortFromCellIfPossible();
         var extraJoyGainFactor = TargetThingA.GetStatValue(StatDefOf.JoyGainFactor);
         JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor);
     });
 }
        private void GotToToil()
        {
            if (Find.TickManager.TicksGame > startTick + job.def.joyDuration)
            {
                EndJobWith(JobCondition.Succeeded);
                return;
            }

            JoyUtility.JoyTickCheckEnd(pawn);
        }
Ejemplo n.º 14
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.EndOnDespawnedOrNull(TargetIndex.A);
            Toil chooseCell = Toils_Wrestling.FindRandomInsideReachableCell(TargetIndex.A, TargetIndex.B);

            yield return(chooseCell);

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

            yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell));

            Toil toil = new Toil();

            toil.initAction = delegate
            {
                job.locomotionUrgency = LocomotionUrgency.Jog;
            };
            toil.tickAction = delegate
            {
                pawn.rotationTracker.FaceCell(base.TargetA.Thing.OccupiedRect().CenterCell);
                if (ticksLeftThisToil == 150)
                {
                    Random random = new System.Random();
                    if (random.NextDouble() > 0.7)
                    {
                        SoundDefOf.Corpse_Drop.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
                    }
                    else
                    {
                        SoundDefOf.Pawn_Melee_Punch_HitPawn.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
                    }
                }
                if (Find.TickManager.TicksGame > startTick + job.def.joyDuration)
                {
                    EndJobWith(JobCondition.Succeeded);
                }
                else
                {
                    JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, 1f, (Building)base.TargetThingA);
                }
            };
            toil.handlingFacing      = true;
            toil.socialMode          = RandomSocialMode.SuperActive;
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = MoveDuration;
            toil.AddFinishAction(delegate
            {
                JoyUtility.TryGainRecRoomThought(pawn);
            });
            yield return(toil);

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

            yield return(Toils_Jump.Jump(chooseCell));
        }
Ejemplo n.º 15
0
        public Toil GetToil_ShootAtTarget(Pawn shooter, LocalTargetInfo targetInfo)
        {
            Toil toil = new Toil();

            toil.tickAction          = () => WatchTickAction();
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = this.job.def.joyDuration;
            toil.AddFinishAction(() => JoyUtility.TryGainRecRoomThought(shooter));
            toil.socialMode = RandomSocialMode.SuperActive;
            return(toil);
        }
        // Token: 0x06000568 RID: 1384 RVA: 0x00035040 File Offset: 0x00033440
        public override Job TryGiveJob(Pawn pawn)
        {
            float HowMuchSnowIsThere = 0;

            if (pawn.Map.weatherManager.curWeather.snowRate > 0.0f)
            {
                HowMuchSnowIsThere = pawn.Map.weatherManager.curWeather.snowRate;
            }
            if (HowMuchSnowIsThere < 0.1f)
            {
                return(null);
            }
            if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                return(null);
            }
            if (PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }
            Predicate <IntVec3> cellValidator = (IntVec3 x) => !PawnUtility.KnownDangerAt(x, pawn.Map, pawn) && !x.GetTerrain(pawn.Map).avoidWander&& x.Standable(pawn.Map) && !x.Roofed(pawn.Map);
            Predicate <Region>  validator     = delegate(Region x)
            {
                IntVec3 intVec;
                return(x.Room.PsychologicallyOutdoors && !x.IsForbiddenEntirely(pawn) && x.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out intVec));
            };
            Region reg;

            if (!CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), validator, 100, out reg, RegionType.Set_Passable))
            {
                return(null);
            }
            IntVec3 root;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out root))
            {
                return(null);
            }
            List <IntVec3> list;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root, out list))
            {
                return(null);
            }
            Job job = new Job(this.def.jobDef, list[0]);

            job.targetQueueA = new List <LocalTargetInfo>();
            for (int i = 1; i < list.Count; i++)
            {
                job.targetQueueA.Add(list[i]);
            }
            job.locomotionUrgency = LocomotionUrgency.Walk;
            return(job);
        }
 public static void Postfix(JobDriver_ViewArt __instance)
 {
     if (__instance.pawn.HasTrait(VTEDefOf.VTE_Snob))
     {
         var   ArtThing           = __instance.pawn.CurJob.targetA.Thing;
         float num                = (ArtThing.GetStatValue(StatDefOf.Beauty) / ArtThing.def.GetStatValueAbstract(StatDefOf.Beauty)) * 2f;
         float extraJoyGainFactor = (num > 0f) ? num : 0f;
         __instance.pawn.GainComfortFromCellIfPossible();
         JoyUtility.JoyTickCheckEnd(__instance.pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor, (Building)ArtThing);
     }
 }
        public void TickAction()
        {
            float extraJoyGainFactor = 1 - pawn.Map.weatherManager.RainRate;

            JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor);

            pawn.rotationTracker.FaceCell(TargetA.Cell);
            pawn.GainComfortFromCellIfPossible();

            //Tools.Warn( MyName + " WatchTickAction - Entering WatchTickAction", myDebug);
            TryThrowProjectile();
        }
Ejemplo n.º 19
0
 protected Action MakeEndWhenDone(Func <Toil> endToil)
 {
     return(delegate {
         if (Find.TickManager.TicksGame > this.startTick + this.job.def.joyDuration)
         {
             this.JumpToToil(endToil());
         }
         else
         {
             JoyUtility.JoyTickCheckEnd(this.pawn);
         }
     });
 }
Ejemplo n.º 20
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Goto.GotoCell(Building_Warzone.GetFirstSpot(), PathEndMode.OnCell));

            Toil doPlay = new Toil();

            doPlay.tickAction = delegate
            {
                pawn.skills.Learn(SkillDefOf.Intellectual, 0.02f);
                pawn.GainComfortFromCellIfPossible();
                JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.None);

                var table = Building_Warzone;
                if (!table.InUse && TargetB.Pawn.Position == table.GetSecondSpot())
                {
                    table.StartPlay(this.pawn);
                }
                else if (table.InUse)
                {
                    if (table.LastTurn)
                    {
                        if (Rand.Bool)
                        {
                            table.SelectWinner(pawn, this.TargetB.Pawn);
                        }
                        else
                        {
                            table.SelectWinner(this.TargetB.Pawn, pawn);
                        }
                    }
                    else if (table.IsGameFinished)
                    {
                        if (this.TargetB.Pawn.jobs.curDriver is JobDriver_PlayWarzoneSecondPlayer driver)
                        {
                            driver.endGame = true;
                        }
                        table.StopPlay();
                        ReadyForNextToil();
                    }
                }
            };
            doPlay.defaultCompleteMode = ToilCompleteMode.Never;
            doPlay.activeSkill         = (() => SkillDefOf.Intellectual);
            doPlay.socialMode          = RandomSocialMode.Normal;
            doPlay.AddFinishAction(() => Building_Warzone.StopPlay());
            doPlay.AddFinishAction(delegate
            {
                JoyUtility.TryGainRecRoomThought(pawn);
            });
            yield return(doPlay);
        }
Ejemplo n.º 21
0
        public override Job TryGiveJob(Pawn pawn)
        {
            if (!JoyUtility.EnjoyableOutsideNow(pawn.Map))
            {
                return(null);
            }

            IntVec3 position = IntVec3.Invalid;

            RCellFinder.TryFindRandomSpotJustOutsideColony(pawn.Position, pawn.Map, pawn, out position, (IntVec3 x) =>
            {
                if (!x.InBounds(pawn.Map) || !x.Walkable(pawn.Map))
                {
                    return(false);
                }

                if (x.IsForbidden(pawn))
                {
                    return(false);
                }

                TerrainDef terrainDef = x.GetTerrain(pawn.Map);
                if (terrainDef.fertility <= 0)
                {
                    return(false);
                }

                int distSq = x.DistanceToSquared(pawn.Position);
                if (distSq < 9 && distSq > 225)
                {
                    return(false);
                }

                if (!pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.None))
                {
                    return(false);
                }

                return(true);
            });

            if (position.IsValid)
            {
                return(new Job(IdleJobDefOf.IdleJob_Graffiti, position)
                {
                    locomotionUrgency = modSettings.wanderMovePolicy
                });
            }

            return(null);
        }
Ejemplo n.º 22
0
        protected virtual void ListenTickAction()
        {
            if (!Gramophone.IsOn())
            {
                base.EndJobWith(JobCondition.Incompletable);
                return;
            }
            this.pawn.rotationTracker.FaceCell(base.TargetA.Cell);
            this.pawn.GainComfortFromCellIfPossible();
            float statValue          = base.TargetThingA.GetStatValue(StatDefOf.JoyGainFactor, true);
            float extraJoyGainFactor = statValue;

            JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor);
        }
Ejemplo n.º 23
0
        protected void ReadTickAction()
        {
            this.pawn.rotationTracker.FaceCell(TargetB.Cell);
            this.pawn.GainComfortFromCellIfPossible();
            var  statValue          = TargetThingA.GetStatValue(StatDefOf.JoyGainFactor, true);
            Pawn pawn               = this.pawn;
            var  extraJoyGainFactor = statValue;

            if (TargetThingA is GuideBook gBook)
            {
                gBook.Teach(pawn);
            }
            JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.GoToNextToil, extraJoyGainFactor);
        }
Ejemplo n.º 24
0
        protected virtual void ListenTickAction()
        {
            if (!Gramophone.IsOn())
            {
                EndJobWith(JobCondition.Incompletable);
                return;
            }

            pawn.rotationTracker.FaceCell(TargetA.Cell);
            pawn.GainComfortFromCellIfPossible();
            var statValue = TargetThingA.GetStatValue(StatDefOf.JoyGainFactor);

            JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, statValue);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.EndOnDespawnedOrNull(TargetIndex.A);
            yield return(Toils_Reserve.Reserve(TargetIndex.A, job.def.joyMaxParticipants));

            if (TargetB != null)
            {
                yield return(Toils_Reserve.Reserve(TargetIndex.B));
            }

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

            var toil     = new Toil();
            var soundDef = Find.World.GetComponent <WorldComponent_Tunes>().TuneDefCache
                           .FindAll(x => x.instrumentDefs.Contains(TargetThingA.def)).RandomElement();

            toil.PlaySustainerOrSound(soundDef);
            toil.tickAction = delegate
            {
                pawn.rotationTracker.FaceCell(TargetA.Cell);
                pawn.GainComfortFromCellIfPossible();
                var statValue = TargetThingA.GetStatValue(StatDefOf.JoyGainFactor);
                JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, statValue);
            };
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = job.def.joyDuration;
            toil.AddFinishAction(delegate
            {
                if (Utility.IsCosmicHorrorsLoaded())
                {
                    try
                    {
                        if (Utility.HasSanityLoss(pawn))
                        {
                            Utility.ApplySanityLoss(pawn, -sanityRestoreRate);
                            Messages.Message(
                                pawn + " has restored some sanity using the " + TargetA.Thing.def.label + ".",
                                new TargetInfo(pawn.Position, pawn.Map), MessageTypeDefOf.NeutralEvent); // .Standard);
                        }
                    }
                    catch
                    {
                        Log.Message("Error loading Sanity Hediff.");
                    }
                }

                JoyUtility.TryGainRecRoomThought(pawn);
            });
            yield return(toil);
        }
Ejemplo n.º 26
0
        // RimWorld.JobDriver_ViewArt
        protected override Action GetWaitTickAction()
        {
            return(delegate
            {
                // float num = this.ArtThing.GetStatValue(StatDefOf.EntertainmentStrengthFactor, true);
                // float num2 = this.ArtThing.GetStatValue(StatDefOf.Beauty, true) / this.ArtThing.def.GetStatValueAbstract(StatDefOf.Beauty, null);
                // num *= ((num2 <= 0f) ? 0f : num2);
                this.pawn.rotationTracker.FaceCell(base.TargetA.Cell);
                this.pawn.GainComfortFromCellIfPossible();

                // float extraJoyGainFactor = num;
                float extraJoyGainFactor = 0.5f;
                JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.GoToNextToil, extraJoyGainFactor);
            });
        }
Ejemplo n.º 27
0
        public override Job TryGiveJob(Pawn pawn)
        {
            if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                return(null);
            }

            IntVec3 c = JoyGiver_FindTreasure.TryFindTreasureCell(pawn);

            if (!c.IsValid)
            {
                return(null);
            }
            return(new Job(this.def.jobDef, c));
        }
Ejemplo n.º 28
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOn(() => !JoyUtility.EnjoyableOutsideNow(pawn.Map, null));
            this.FailOn(() => pawn.Map.mapTemperature.OutdoorTemp < ModSettings_WaterIsCold.swimTemp - 5f);
            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell));

            Action swimTick = delegate()
            {
                JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.GoToNextToil, 1f, null);
            };
            Toil treadWaterToil = Toils_General.Wait(job.def.joyDuration / 3, TargetIndex.C);

            treadWaterToil.tickAction = swimTick;

            //Swim to first spot
            Toil firstSwimToil = Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell);

            firstSwimToil.tickAction = swimTick;
            firstSwimToil.FailOn(() => this.pawn.Position.GetTerrain(this.pawn.Map) == TerrainDef.Named("Marsh"));
            yield return(firstSwimToil);

            yield return(treadWaterToil);

            //Swim to second spot
            Toil secondSwimToil = Toils_Goto.GotoCell(TargetIndex.C, PathEndMode.OnCell);

            secondSwimToil.tickAction = swimTick;
            secondSwimToil.FailOn(() => this.pawn.Position.GetTerrain(this.pawn.Map) == TerrainDef.Named("Marsh"));
            yield return(secondSwimToil);

            yield return(treadWaterToil);

            //Swim back to first spot
            yield return(firstSwimToil);

            yield return(treadWaterToil);

            //Return to shore
            Toil shoreReturnToil = Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell);

            shoreReturnToil.tickAction = delegate()
            {
                JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.None, 1f, null);
            };
            yield return(shoreReturnToil);

            yield break;
        }
Ejemplo n.º 29
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOn(() => !Baby.InBed() || !Baby.Awake());
            if (Chair != null)
            {
                this.FailOnDespawnedNullOrForbidden(TargetIndex.B);
            }
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            if (Chair != null)
            {
                yield return(Toils_Reserve.Reserve(TargetIndex.B));

                yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.OnCell));
            }
            else
            {
                yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));
            }
            yield return(Toils_Interpersonal.WaitToBeAbleToInteract(pawn));

            yield return(new Toil
            {
                tickAction = delegate
                {
                    Baby.needs.joy.GainJoy(job.def.joyGainRate * 0.000144f, job.def.joyKind);
                    if (pawn.IsHashIntervalTick(320))
                    {
                        InteractionDef intDef = (Rand.Value >= 0.8f) ? InteractionDefOf.DeepTalk : InteractionDefOf.Chitchat;
                        pawn.interactions.TryInteractWith(Baby, intDef);
                    }
                    pawn.rotationTracker.FaceCell(Baby.Position);

                    pawn.GainComfortFromCellIfPossible();
                    JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.None);
                    if (pawn.needs.joy.CurLevelPercentage > 0.9999f && Baby.needs.joy.CurLevelPercentage > 0.9999f)
                    {
                        pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                    }
                },
                socialMode = RandomSocialMode.Off,
                defaultCompleteMode = ToilCompleteMode.Delay,
                defaultDuration = job.def.joyDuration
            });
        }
Ejemplo n.º 30
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.EndOnDespawnedOrNull(TargetIndex.A, JobCondition.Incompletable);
            if (HasChair)
            {
                this.EndOnDespawnedOrNull(TargetIndex.B, JobCondition.Incompletable);
            }
            if (HasDrink)
            {
                this.FailOnDestroyedNullOrForbidden(TargetIndex.C);
                yield return(Toils_Goto.GotoThing(TargetIndex.C, PathEndMode.OnCell).FailOnSomeonePhysicallyInteracting(TargetIndex.C));

                yield return(Toils_Haul.StartCarryThing(TargetIndex.C, false, false, false));
            }
            yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell));

            Toil chew = new Toil();

            chew.tickAction = delegate
            {
                pawn.rotationTracker.FaceCell(ClosestGatherSpotParentCell);
                pawn.GainComfortFromCellIfPossible();
                JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.GoToNextToil, 1f);

                if (pawn.IsHashIntervalTick(100))
                {
                    MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Note);
                }
            };
            chew.handlingFacing      = true;
            chew.defaultCompleteMode = ToilCompleteMode.Delay;
            chew.defaultDuration     = job.def.joyDuration;
            chew.AddFinishAction(delegate
            {
                JoyUtility.TryGainRecRoomThought(pawn);
            });
            chew.socialMode = RandomSocialMode.SuperActive;
            Toils_Ingest.AddIngestionEffects(chew, pawn, TargetIndex.C, TargetIndex.None);
            yield return(chew);

            if (HasDrink)
            {
                yield return(Toils_Ingest.FinalizeIngest(pawn, TargetIndex.C));
            }
            yield break;
        }