public static void GiveThoughtsForPawnExecuted(Pawn victim, PawnExecutionKind kind)
        {
            if (victim.RaceProps.Humanlike)
            {
                int forcedStage = 1;
                if (victim.guilt.IsGuilty)
                {
                    forcedStage = 0;
                }
                else
                {
                    switch (kind)
                    {
                    case PawnExecutionKind.GenericHumane:
                        forcedStage = 1;
                        break;

                    case PawnExecutionKind.GenericBrutal:
                        forcedStage = 2;
                        break;

                    case PawnExecutionKind.OrganHarvesting:
                        forcedStage = 3;
                        break;
                    }
                }
                ThoughtDef def = (!victim.IsColonist) ? ThoughtDefOf.KnowGuestExecuted : ThoughtDefOf.KnowColonistExecuted;
                foreach (Pawn item in from x in PawnsFinder.AllMapsCaravansAndTravelingTransportPods
                         where x.IsColonist || x.IsPrisonerOfColony
                         select x)
                {
                    item.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(def, forcedStage), null);
                }
            }
        }
        private Thought_Situational TryCreateThought(ThoughtDef def)
        {
            Thought_Situational thought_Situational = null;

            try
            {
                if (!ThoughtUtility.CanGetThought(this.pawn, def))
                {
                    return(null);
                }
                if (!def.Worker.CurrentState(this.pawn).ActiveFor(def))
                {
                    return(null);
                }
                thought_Situational      = (Thought_Situational)ThoughtMaker.MakeThought(def);
                thought_Situational.pawn = this.pawn;
                thought_Situational.RecalculateState();
            }
            catch (Exception ex)
            {
                Log.Error(string.Concat(new object[]
                {
                    "Exception while recalculating ",
                    def,
                    " thought state for pawn ",
                    this.pawn,
                    ": ",
                    ex
                }), false);
            }
            return(thought_Situational);
        }
        private Thought_Situational TryCreateThought(ThoughtDef def)
        {
            Thought_Situational thought_Situational = null;

            try
            {
                if (!ThoughtUtility.CanGetThought(pawn, def))
                {
                    return(null);
                }
                if (!def.Worker.CurrentState(pawn).ActiveFor(def))
                {
                    return(null);
                }
                thought_Situational      = (Thought_Situational)ThoughtMaker.MakeThought(def);
                thought_Situational.pawn = pawn;
                thought_Situational.RecalculateState();
                return(thought_Situational);
            }
            catch (Exception ex)
            {
                Log.Error("Exception while recalculating " + def + " thought state for pawn " + pawn + ": " + ex);
                return(thought_Situational);
            }
        }
예제 #4
0
        private Thought_SituationalSocial TryCreateSocialThought(ThoughtDef def, Pawn otherPawn)
        {
            Thought_SituationalSocial thought_SituationalSocial = null;

            try
            {
                if (!ThoughtUtility.CanGetThought_NewTemp(pawn, def))
                {
                    return(null);
                }
                if (!def.Worker.CurrentSocialState(pawn, otherPawn).ActiveFor(def))
                {
                    return(null);
                }
                thought_SituationalSocial           = (Thought_SituationalSocial)ThoughtMaker.MakeThought(def);
                thought_SituationalSocial.pawn      = pawn;
                thought_SituationalSocial.otherPawn = otherPawn;
                thought_SituationalSocial.RecalculateState();
                return(thought_SituationalSocial);
            }
            catch (Exception ex)
            {
                Log.Error(string.Concat("Exception while recalculating ", def, " thought state for pawn ", pawn, ": ", ex));
                return(thought_SituationalSocial);
            }
        }
예제 #5
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);
        }
예제 #6
0
        private static void AddNewlyMarriedThoughts(Pawn pawn, Pawn otherPawn)
        {
            pawn.needs.mood.thoughts.TryGainThought(ThoughtDefOf.GotMarried);
            Thought_SocialMemory thought_SocialMemory = (Thought_SocialMemory)ThoughtMaker.MakeThought(ThoughtDefOf.HoneymoonPhase);

            thought_SocialMemory.SetOtherPawn(otherPawn);
            pawn.needs.mood.thoughts.TryGainThought(thought_SocialMemory);
        }
예제 #7
0
        private void AddNuzzledThought(Pawn initiator, Pawn recipient)
        {
            Thought_Memory newThought = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.Nuzzled);

            if (recipient.needs.mood != null)
            {
                recipient.needs.mood.thoughts.memories.TryGainMemory(newThought);
            }
        }
예제 #8
0
 public virtual void Notify_KilledPawn(Pawn pawn)
 {
     if (def.killThought != null && pawn.needs.mood != null)
     {
         Thought_WeaponTrait thought_WeaponTrait = (Thought_WeaponTrait)ThoughtMaker.MakeThought(def.killThought);
         thought_WeaponTrait.weapon = pawn.equipment.Primary;
         pawn.needs.mood.thoughts.memories.TryGainMemory(thought_WeaponTrait);
     }
 }
        public override void DoEffectOn(Pawn user, Thing target)
        {
            Pawn pawn = (Pawn)target;

            if (!pawn.Dead && pawn.needs != null && pawn.needs.mood != null)
            {
                pawn.needs.mood.thoughts.memories.TryGainMemory((Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.ArtifactMoodBoost));
            }
        }
 public void TryGainMemory(ThoughtDef def, Pawn otherPawn = null)
 {
     if (!def.IsMemory)
     {
         Log.Error(def + " is not a memory thought.", false);
         return;
     }
     this.TryGainMemory((Thought_Memory)ThoughtMaker.MakeThought(def), otherPawn);
 }
        public override void DoEffectOn(Pawn user, Thing target)
        {
            Pawn pawn = (Pawn)target;

            if (pawn.Dead || pawn.needs == null || pawn.needs.mood == null)
            {
                return;
            }
            pawn.needs.mood.thoughts.memories.TryGainMemory((Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.ArtifactMoodBoost), null);
        }
예제 #12
0
 public void TryGainMemory(ThoughtDef def, Pawn otherPawn = null)
 {
     if (!def.IsMemory)
     {
         Log.Error(def + " is not a memory thought.");
     }
     else
     {
         TryGainMemory((Thought_Memory)ThoughtMaker.MakeThought(def), otherPawn);
     }
 }
예제 #13
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;
        }
예제 #14
0
        private static void ApplyBedThoughts(Pawn actor)
        {
            if (actor.needs.mood == null)
            {
                return;
            }
            Building_Bed building_Bed = actor.CurrentBed();

            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInBedroom);
            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInBarracks);
            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptOutside);
            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptOnGround);
            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInCold);
            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInHeat);
            if (actor.GetRoom().PsychologicallyOutdoors)
            {
                actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptOutside);
            }
            if (building_Bed == null || building_Bed.CostListAdjusted().Count == 0)
            {
                actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptOnGround);
            }
            if (actor.AmbientTemperature < actor.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin))
            {
                actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptInCold);
            }
            if (actor.AmbientTemperature > actor.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMax))
            {
                actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptInHeat);
            }
            if (building_Bed == null || building_Bed != actor.ownership.OwnedBed || building_Bed.ForPrisoners || actor.story.traits.HasTrait(TraitDefOf.Ascetic))
            {
                return;
            }
            ThoughtDef thoughtDef = null;

            if (building_Bed.GetRoom().Role == RoomRoleDefOf.Bedroom)
            {
                thoughtDef = ThoughtDefOf.SleptInBedroom;
            }
            else if (building_Bed.GetRoom().Role == RoomRoleDefOf.Barracks)
            {
                thoughtDef = ThoughtDefOf.SleptInBarracks;
            }
            if (thoughtDef != null)
            {
                int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(building_Bed.GetRoom().GetStat(RoomStatDefOf.Impressiveness));
                if (thoughtDef.stages[scoreStageIndex] != null)
                {
                    actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(thoughtDef, scoreStageIndex));
                }
            }
        }
예제 #15
0
        public static void TryGainRecRoomThought(Pawn pawn)
        {
            Room room = pawn.GetRoom();

            if (room != null)
            {
                int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(room.GetStat(RoomStatDefOf.Impressiveness));
                if (pawn.needs.mood != null && ThoughtDefOf.AteInImpressiveDiningRoom.stages[scoreStageIndex] != null)
                {
                    pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(ThoughtDefOf.JoyActivityInImpressiveRecRoom, scoreStageIndex));
                }
            }
        }
        private static void AddInteractionThought(Pawn pawn, Pawn otherPawn, ThoughtDef thoughtDef)
        {
            float          statValue      = otherPawn.GetStatValue(StatDefOf.SocialImpact, true);
            Thought_Memory thought_Memory = (Thought_Memory)ThoughtMaker.MakeThought(thoughtDef);

            thought_Memory.moodPowerFactor = statValue;
            Thought_MemorySocial thought_MemorySocial = thought_Memory as Thought_MemorySocial;

            if (thought_MemorySocial != null)
            {
                thought_MemorySocial.opinionOffset *= statValue;
            }
            pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory, otherPawn);
        }
        public IndividualThoughtToAdd(ThoughtDef thoughtDef, Pawn addTo, Pawn otherPawn = null, float moodPowerFactor = 1f, float opinionOffsetFactor = 1f)
        {
            this.addTo     = addTo;
            this.otherPawn = otherPawn;
            this.thought   = (Thought_Memory)ThoughtMaker.MakeThought(thoughtDef);
            this.thought.moodPowerFactor = moodPowerFactor;
            this.thought.otherPawn       = otherPawn;
            Thought_MemorySocial thought_MemorySocial = this.thought as Thought_MemorySocial;

            if (thought_MemorySocial != null)
            {
                thought_MemorySocial.opinionOffset *= opinionOffsetFactor;
            }
        }
예제 #18
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            yield return(Toils_General.Do(delegate
            {
                job.SetTarget(TargetIndex.B, Throne.InteractionCell + Throne.Rotation.FacingCell);
            }));

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

            Toil toil = new Toil();

            toil.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell);
            toil.FailOn(() => Throne.AssignedPawn != pawn);
            toil.FailOn(() => RoomRoleWorker_ThroneRoom.Validate(Throne.GetRoom()) != null);
            toil.FailOn(() => !MeditationUtility.CanMeditateNow(pawn) || !MeditationUtility.SafeEnvironmentalConditions(pawn, base.TargetLocA, base.Map));
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = job.def.joyDuration;
            toil.tickAction          = delegate
            {
                if (pawn.mindState.applyThroneThoughtsTick == 0)
                {
                    pawn.mindState.applyThroneThoughtsTick = Find.TickManager.TicksGame + 10000;
                }
                else if (pawn.mindState.applyThroneThoughtsTick <= Find.TickManager.TicksGame)
                {
                    pawn.mindState.applyThroneThoughtsTick = Find.TickManager.TicksGame + 60000;
                    ThoughtDef thoughtDef = null;
                    if (Throne.GetRoom().Role == RoomRoleDefOf.ThroneRoom)
                    {
                        thoughtDef = ThoughtDefOf.ReignedInThroneroom;
                    }
                    if (thoughtDef != null)
                    {
                        int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(Throne.GetRoom().GetStat(RoomStatDefOf.Impressiveness));
                        if (thoughtDef.stages[scoreStageIndex] != null)
                        {
                            pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(thoughtDef, scoreStageIndex));
                        }
                    }
                }
                rotateToFace = TargetIndex.B;
                MeditationTick();
                if (job.ignoreJoyTimeAssignment && pawn.IsHashIntervalTick(300))
                {
                    pawn.jobs.CheckForJobOverride();
                }
            };
            yield return(toil);
        }
예제 #19
0
        public static void GiveThoughtsForPawnExecuted(Pawn victim, PawnExecutionKind kind)
        {
            if (!victim.RaceProps.Humanlike)
            {
                return;
            }
            int forcedStage = 1;

            if (victim.guilt.IsGuilty)
            {
                forcedStage = 0;
            }
            else if (kind != PawnExecutionKind.GenericHumane)
            {
                if (kind != PawnExecutionKind.GenericBrutal)
                {
                    if (kind == PawnExecutionKind.OrganHarvesting)
                    {
                        forcedStage = 3;
                    }
                }
                else
                {
                    forcedStage = 2;
                }
            }
            else
            {
                forcedStage = 1;
            }
            ThoughtDef def;

            if (victim.IsColonist)
            {
                def = ThoughtDefOf.KnowColonistExecuted;
            }
            else
            {
                def = ThoughtDefOf.KnowGuestExecuted;
            }
            foreach (Pawn current in from x in PawnsFinder.AllMapsCaravansAndTravelingTransportPods
                     where x.IsColonist || x.IsPrisonerOfColony
                     select x)
            {
                current.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(def, forcedStage), null);
            }
        }
예제 #20
0
        public static Toil FinalizeIngest(Pawn ingester, TargetIndex ingestibleInd)
        {
            Toil toil = new Toil();

            toil.initAction = delegate()
            {
                Pawn  actor  = toil.actor;
                Job   curJob = actor.jobs.curJob;
                Thing thing  = curJob.GetTarget(ingestibleInd).Thing;
                if (ingester.needs.mood != null)
                {
                    if (thing.def.IsNutritionGivingIngestible && thing.def.ingestible.chairSearchRadius > 10f)
                    {
                        if (!(ingester.Position + ingester.Rotation.FacingCell).HasEatSurface(actor.Map) && ingester.GetPosture() == PawnPosture.Standing)
                        {
                            ingester.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.AteWithoutTable, null);
                        }
                        Room room = ingester.GetRoom(RegionType.Set_Passable);
                        if (room != null)
                        {
                            int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(room.GetStat(RoomStatDefOf.Impressiveness));
                            if (ThoughtDefOf.AteInImpressiveDiningRoom.stages[scoreStageIndex] != null)
                            {
                                ingester.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(ThoughtDefOf.AteInImpressiveDiningRoom, scoreStageIndex), null);
                            }
                        }
                    }
                }
                float num = ingester.needs.food.NutritionWanted;
                if (curJob.overeat)
                {
                    num = Mathf.Max(num, 0.75f);
                }
                float num2 = thing.Ingested(ingester, num);
                if (!ingester.Dead)
                {
                    ingester.needs.food.CurLevel += num2;
                }
                ingester.records.AddTo(RecordDefOf.NutritionEaten, num2);
            };
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            return(toil);
        }
예제 #21
0
 public static void GiveThoughtsForPawnExecuted(Pawn victim, PawnExecutionKind kind)
 {
     if (victim.RaceProps.Humanlike)
     {
         int forcedStage = 1;
         if (victim.guilt.IsGuilty)
         {
             forcedStage = 0;
         }
         else if (kind != PawnExecutionKind.GenericHumane)
         {
             if (kind != PawnExecutionKind.GenericBrutal)
             {
                 if (kind == PawnExecutionKind.OrganHarvesting)
                 {
                     forcedStage = 3;
                 }
             }
             else
             {
                 forcedStage = 2;
             }
         }
         else
         {
             forcedStage = 1;
         }
         ThoughtDef def;
         if (victim.IsColonist)
         {
             def = ThoughtDefOf.KnowColonistExecuted;
         }
         else
         {
             def = ThoughtDefOf.KnowGuestExecuted;
         }
         foreach (Pawn pawn in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoners)
         {
             pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(def, forcedStage), null);
         }
     }
 }
예제 #22
0
        private void ApplyOutcome(LordToil_Party toil)
        {
            List <Pawn>        ownedPawns         = lord.ownedPawns;
            LordToilData_Party lordToilData_Party = (LordToilData_Party)toil.data;

            for (int i = 0; i < ownedPawns.Count; i++)
            {
                Pawn pawn = ownedPawns[i];
                bool flag = pawn == organizer;
                if (lordToilData_Party.presentForTicks.TryGetValue(pawn, out int value) && value > 0)
                {
                    if (ownedPawns[i].needs.mood != null)
                    {
                        ThoughtDef     thoughtDef      = flag ? OrganizerThought : AttendeeThought;
                        float          num             = 0.5f / thoughtDef.stages[0].baseMoodEffect;
                        float          moodPowerFactor = Mathf.Min((float)value / (float)durationTicks + num, 1f);
                        Thought_Memory thought_Memory  = (Thought_Memory)ThoughtMaker.MakeThought(thoughtDef);
                        thought_Memory.moodPowerFactor = moodPowerFactor;
                        ownedPawns[i].needs.mood.thoughts.memories.TryGainMemory(thought_Memory);
                    }
                    TaleRecorder.RecordTale(flag ? OrganizerTale : AttendeeTale, ownedPawns[i], organizer);
                }
            }
        }
        public static void GiveThoughtsForPawnExecuted(Pawn victim, PawnExecutionKind kind)
        {
            if (!victim.RaceProps.Humanlike)
            {
                return;
            }
            int forcedStage = 1;

            if (victim.guilt.IsGuilty)
            {
                forcedStage = 0;
            }
            else
            {
                switch (kind)
                {
                case PawnExecutionKind.GenericHumane:
                    forcedStage = 1;
                    break;

                case PawnExecutionKind.GenericBrutal:
                    forcedStage = 2;
                    break;

                case PawnExecutionKind.OrganHarvesting:
                    forcedStage = 3;
                    break;
                }
            }
            ThoughtDef def = ((!victim.IsColonist) ? ThoughtDefOf.KnowGuestExecuted : ThoughtDefOf.KnowColonistExecuted);

            foreach (Pawn allMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoner in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoners)
            {
                if (allMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoner.IsColonist && allMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoner.needs.mood != null)
                {
                    allMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoner.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(def, forcedStage));
                }
            }
        }
 private void AffectPawns(Pawn p, List <Pawn> pawns)
 {
     for (int i = 0; i < pawns.Count; i++)
     {
         Pawn pawn = pawns[i];
         if (p == pawn || !p.RaceProps.Humanlike || pawn.needs == null || pawn.needs.mood == null || pawn.needs.mood.thoughts == null || (p.Spawned && pawn.Spawned && pawn.Position.DistanceTo(p.Position) > Props.range) || pawn.health.hediffSet.HasHediff(HediffDefOf.PsychicHarmonizer))
         {
             continue;
         }
         bool flag = false;
         foreach (Thought_Memory memory in pawn.needs.mood.thoughts.memories.Memories)
         {
             Thought_PsychicHarmonizer thought_PsychicHarmonizer = memory as Thought_PsychicHarmonizer;
             if (thought_PsychicHarmonizer != null && thought_PsychicHarmonizer.harmonizer == parent)
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             Thought_PsychicHarmonizer thought_PsychicHarmonizer2 = (Thought_PsychicHarmonizer)ThoughtMaker.MakeThought(Props.thought);
             thought_PsychicHarmonizer2.harmonizer = parent;
             thought_PsychicHarmonizer2.otherPawn  = parent.pawn;
             pawn.needs.mood.thoughts.memories.TryGainMemory(thought_PsychicHarmonizer2);
         }
     }
 }
예제 #25
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);
            }
예제 #26
0
        public void ReduceTitle(Faction faction)
        {
            RoyalTitleDef currentTitle = GetCurrentTitle(faction);

            if (currentTitle != null && currentTitle.Awardable)
            {
                RoyalTitleDef previousTitle = currentTitle.GetPreviousTitle(faction);
                OnPreTitleChanged(faction, currentTitle, previousTitle);
                CleanupThoughts(currentTitle);
                CleanupThoughts(previousTitle);
                if (currentTitle.awardThought != null && pawn.needs.mood != null)
                {
                    Thought_MemoryRoyalTitle thought_MemoryRoyalTitle = (Thought_MemoryRoyalTitle)ThoughtMaker.MakeThought(currentTitle.lostThought);
                    thought_MemoryRoyalTitle.titleDef = currentTitle;
                    pawn.needs.mood.thoughts.memories.TryGainMemory(thought_MemoryRoyalTitle);
                }
                int index = FindFactionTitleIndex(faction);
                if (previousTitle == null)
                {
                    titles.RemoveAt(index);
                }
                else
                {
                    titles[index].def = previousTitle;
                }
                SetFavor(faction, 0);
                OnPostTitleChanged(faction, previousTitle);
            }
        }
예제 #27
0
        private void UpdateRoyalTitle(Faction faction)
        {
            RoyalTitleDef currentTitle = GetCurrentTitle(faction);

            if (currentTitle != null && !currentTitle.Awardable)
            {
                return;
            }
            RoyalTitleDef nextTitle = currentTitle.GetNextTitle(faction);

            if (nextTitle == null)
            {
                return;
            }
            int num = GetFavor(faction);

            if (num >= nextTitle.favorCost)
            {
                OnPreTitleChanged(faction, currentTitle, nextTitle);
                SetFavor(faction, num - nextTitle.favorCost);
                int index = FindFactionTitleIndex(faction, createIfNotExisting: true);
                titles[index].def = nextTitle;
                CleanupThoughts(currentTitle);
                CleanupThoughts(nextTitle);
                if (nextTitle.awardThought != null && pawn.needs != null && pawn.needs.mood != null)
                {
                    Thought_MemoryRoyalTitle thought_MemoryRoyalTitle = (Thought_MemoryRoyalTitle)ThoughtMaker.MakeThought(nextTitle.awardThought);
                    thought_MemoryRoyalTitle.titleDef = nextTitle;
                    pawn.needs.mood.thoughts.memories.TryGainMemory(thought_MemoryRoyalTitle);
                }
                UpdateRoyalTitle(faction);
            }
        }