private void Payment(List <Thing> payment, bool vassalPay, bool TributePay, string factionList)
        {
            if (GenLocalDate.Year(Find.AnyPlayerHomeMap) >= year)
            {
                year = GenLocalDate.Year(Find.AnyPlayerHomeMap) + 1;
            }
            if (GenLocalDate.DayOfYear(Find.AnyPlayerHomeMap) >= dayOfMonth)
            {
                dayOfMonth = ClosestNumberOf15(GenLocalDate.DayOfYear(Find.AnyPlayerHomeMap) + 1);
            }
            if (!payment.NullOrEmpty())
            {
                string text = "";
                if (vassalPay && TributePay)
                {
                    text += "FactionVassalSilverRecivedBoth".Translate(GenThing.GetMarketValue(payment).ToStringMoney(), GenLabel.ThingsLabel(payment, string.Empty));
                }
                else if (vassalPay)
                {
                    text += "FactionVassalSilverRecivedVassals".Translate(GenThing.GetMarketValue(payment).ToStringMoney(), GenLabel.ThingsLabel(payment, string.Empty));
                }
                else if (TributePay)
                {
                    text += "FactionVassalSilverRecivedTrivutaries".Translate(GenThing.GetMarketValue(payment).ToStringMoney(), GenLabel.ThingsLabel(payment, string.Empty));
                }

                factionList.Remove(factionList.Count() - 1);
                DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(Find.AnyPlayerHomeMap), Find.AnyPlayerHomeMap, payment, 110, false, true, true);
                Find.LetterStack.ReceiveLetter("LetterFactionVassalSilverRecived".Translate(), text + factionList, LetterDefOf.PositiveEvent, null);
            }
        }
Esempio n. 2
0
        public override void Tick()
        {
            base.Tick();
            switch ((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 5) * 60) * 391) % (50 * (13 - ((this.CurStageIndex + 1) * 2))))
            {
            case 0:
                panic          = true;
                this.Severity += 0.00000002f;
                if (pawn.Spawned && pawn.RaceProps.Humanlike)
                {
                    if (pawn.jobs.curJob.def != JobDefOf.FleeAndCower && !pawn.jobs.curDriver.asleep)
                    {
                        pawn.jobs.StartJob(new Job(JobDefOf.FleeAndCower, pawn.Position), JobCondition.InterruptForced, null, false, true, null);
                    }
                    else if (pawn.jobs.curDriver.asleep)
                    {
                        pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.DreamNightmare);
                    }
                }
                break;

            default:
                panic = false;
                break;
            }
        }
Esempio n. 3
0
        public static int NowToTicks(int tileId)
        {
            var day  = GenLocalDate.DayOfYear(tileId);
            var year = GenLocalDate.Year(tileId);

            var ticks = DateToTicks(day, year);

            if (ticks == 0)
            {
                ticks = 1;
            }

            return(ticks);
        }
Esempio n. 4
0
        private void Finished()
        {
            List <Pair <Pawn, int> > voteTally = new List <Pair <Pawn, int> >();

            foreach (Candidate candidate in this.candidates)
            {
                IEnumerable <string> votesForMe = (from v in this.votes
                                                   where v == candidate.pawn.LabelShort
                                                   select v);
                voteTally.Add(new Pair <Pawn, int>(candidate.pawn, votesForMe.Count()));
            }
            //If there ends up being a tie, we'll just assume the least competitive candidates drop out.
            //The chances of there being a tie after that are exceedingly slim, but the result will be essentially random.
            IEnumerable <Pair <Pawn, int> > orderedTally = (from v in voteTally
                                                            orderby PsycheHelper.Comp(v.First).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Competitive) descending
                                                            orderby v.Second descending
                                                            select v);

            if (Prefs.DevMode && Prefs.LogVerbose)
            {
                foreach (Pair <Pawn, int> t in orderedTally)
                {
                    Log.Message("Psychology :: Votes for " + t.First + ": " + t.Second);
                }
            }
            Pair <Pawn, int> winningCandidate = orderedTally.First();

            if (orderedTally.Count() > 1 && orderedTally.First().Second == orderedTally.ElementAt(1).Second)
            {
                Find.LetterStack.ReceiveLetter("LetterLabelTieSettled".Translate(winningCandidate.First), "LetterTieSettled".Translate(winningCandidate.First), LetterDefOf.NeutralEvent, winningCandidate.First);
            }
            StringBuilder issuesString = new StringBuilder();

            for (int i = 0; i < candidates.Find(c => c.pawn == winningCandidate.First).nodes.Count; i++)
            {
                issuesString.AppendFormat("{0}) {1}{2}", i + 1, PsycheHelper.Comp(winningCandidate.First).Psyche.GetPersonalityNodeOfDef(candidates.Find(c => c.pawn == winningCandidate.First).nodes[i]).PlatformIssue, (i != candidates.Find(c => c.pawn == winningCandidate.First).nodes.Count - 1 ? "\n" : ""));
            }
            if (this.map == null)
            {
                this.map = winningCandidate.First.Map;
            }
            Hediff mayor = HediffMaker.MakeHediff(HediffDefOfPsychology.Mayor, winningCandidate.First);

            (mayor as Hediff_Mayor).worldTileElectedOn = map.Tile;
            (mayor as Hediff_Mayor).yearElected        = GenLocalDate.Year(map);
            winningCandidate.First.health.AddHediff(mayor);
            winningCandidate.First.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.WonElection);
            Find.LetterStack.ReceiveLetter("LetterLabelElectionWon".Translate(winningCandidate.First), "LetterElectionWon".Translate(winningCandidate.First, this.baseName, winningCandidate.Second, issuesString.ToString()), LetterDefOf.NeutralEvent, winningCandidate.First);
        }
Esempio n. 5
0
 public static Thought_Memory AddDesensitizedChance(Thought_Memory thought_Memory, Pawn pawn)
 {
     if (thought_Memory != null && thought_Memory.def == ThoughtDefOf.ObservedLayingCorpse)
     {
         if (!pawn.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
         {
             if (((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 5) * 60) * 391) % 1000) == 0)
             {
                 pawn.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                 pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.RecentlyDesensitized);
             }
         }
     }
     return(thought_Memory);
 }
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            switch ((p.GetHashCode() ^ (GenLocalDate.DayOfYear(p) + GenLocalDate.Year(p) + (int)(GenMath.RoundTo(GenLocalDate.DayPercent(p), 0.25f) * 10) * 60) * 391) % 12)
            {
            case 0:
                return((p.story.traits.DegreeOfTrait(SyrTraitDefOf.Neurotic) == 2) ? ThoughtState.ActiveAtStage(0) : ThoughtState.Inactive);

            case 1:
                return(ThoughtState.ActiveAtStage(1));

            case 2:
                return(ThoughtState.ActiveAtStage(1));

            case 3:
                return(ThoughtState.ActiveAtStage(2));

            case 4:
                return(ThoughtState.ActiveAtStage(2));

            case 5:
                return(ThoughtState.Inactive);

            case 6:
                return(ThoughtState.Inactive);

            case 7:
                return(ThoughtState.ActiveAtStage(3));

            case 8:
                return(ThoughtState.ActiveAtStage(3));

            case 9:
                return(ThoughtState.ActiveAtStage(4));

            case 10:
                return(ThoughtState.ActiveAtStage(4));

            case 11:
                return((p.story.traits.DegreeOfTrait(SyrTraitDefOf.Neurotic) == 2) ? ThoughtState.ActiveAtStage(5) : ThoughtState.Inactive);

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 7
0
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            switch ((p.GetHashCode() ^ (GenLocalDate.DayOfYear(p) + GenLocalDate.Year(p) + (int)(GenLocalDate.DayPercent(p) * 10) * 60) * 391) % 12)
            {
            case 0:
                return(ThoughtState.ActiveAtStage(0));

            case 1:
                return(ThoughtState.ActiveAtStage(1));

            case 2:
                return(ThoughtState.ActiveAtStage(1));

            case 3:
                return(ThoughtState.ActiveAtStage(2));

            case 4:
                return(ThoughtState.ActiveAtStage(2));

            case 5:
                return(ThoughtState.Inactive);

            case 6:
                return(ThoughtState.Inactive);

            case 7:
                return(ThoughtState.ActiveAtStage(3));

            case 8:
                return(ThoughtState.ActiveAtStage(3));

            case 9:
                return(ThoughtState.ActiveAtStage(4));

            case 10:
                return(ThoughtState.ActiveAtStage(4));

            case 11:
                return(ThoughtState.ActiveAtStage(5));

            default:
                throw new NotImplementedException();
            }
        }
        //generate PredictableSeed for Verse.Rand
        public static int PredictableSeed()
        {
            int seed = 0;

            try
            {
                Map map = Find.CurrentMap;
                //int seedHourOfDay = GenLocalDate.HourOfDay(map);
                //int seedDayOfYear = GenLocalDate.DayOfYear(map);
                //int seedYear = GenLocalDate.Year(map);
                seed = (GenLocalDate.HourOfDay(map) + GenLocalDate.DayOfYear(map)) * GenLocalDate.Year(map);
                //int seed = (seedHourOfDay + seedDayOfYear) * seedYear;
                //Log.Warning("seedHourOfDay: " + seedHourOfDay + "\nseedDayOfYear: " + seedDayOfYear + "\nseedYear: " + seedYear + "\n" + seed);
            }
            catch
            {
                seed = Rand.Int;
            }
            return(seed);
        }
Esempio n. 9
0
        public static void AppendPsychologyThoughts(TaleNewsPawnDied __instance, Pawn recipient)
        {
            var victim = __instance.Victim;

            // Psychology did a lot of work to exclude thoughts from Bleeding Heart.

            if (recipient.Faction == victim.Faction)
            {
                new IndividualThoughtToAdd(Psycho_ThoughtDefOf.WitnessedDeathAllyBleedingHeart, recipient).Add();
            }
            else if (victim.Faction == null || victim.Faction.HostileTo(recipient.Faction) ||
                     recipient.story.traits.HasTrait(Psycho_TraitDefOf.BleedingHeart))
            {
                new IndividualThoughtToAdd(Psycho_ThoughtDefOf.WitnessedDeathNonAllyBleedingHeart, recipient).Add();
            }

            var traitsDisallowDesensitization = recipient.story.traits.HasTrait(Psycho_TraitDefOf.BleedingHeart) ||
                                                recipient.story.traits.HasTrait(TraitDefOf.Psychopath) ||
                                                recipient.story.traits.HasTrait(TraitDefOf.Bloodlust) ||
                                                recipient.story.traits.HasTrait(Psycho_TraitDefOf.Desensitized);
            // ALL PRAISE GOD RANDY OUR ONE TRUE LORD
            var randyAllowsDesensitization = (recipient.GetHashCode() ^ ((GenLocalDate.DayOfYear(recipient) +
                                                                          GenLocalDate.Year(recipient) +
                                                                          ((int)(GenLocalDate.DayPercent(recipient) *
                                                                                 5f) * 60)) * 391)) % 1000 == 0;

            // No Bleeding Heart + No Psychopath + No Bloodlust + No Desensitised + Random Genner
            if (traitsDisallowDesensitization || !randyAllowsDesensitization)
            {
                return;
            }

            // Gain Desensitized
            recipient.story.traits.GainTrait(new Trait(Psycho_TraitDefOf.Desensitized));
            recipient.needs.mood.thoughts.memories.TryGainMemory(Psycho_ThoughtDefOf.RecentlyDesensitized);
        }
        public override void MapComponentTick()
        {
            base.MapComponentTick();
            if (!WorkManager.Enabled)
            {
                return;
            }
            if (Find.TickManager.CurTimeSpeed == TimeSpeed.Paused || Find.TickManager.TicksGame % 60 != 0)
            {
                return;
            }
            var year        = GenLocalDate.Year(map);
            var day         = GenLocalDate.DayOfYear(map);
            var hourFloat   = GenLocalDate.HourFloat(map);
            var hoursPassed = (year - _workUpdateTime.Year) * 60 * 24 + (day - _workUpdateTime.Day) * 24 + hourFloat -
                              _workUpdateTime.Hour;

            if (Settings.UpdateFrequency == 0)
            {
                Settings.UpdateFrequency = 24;
            }
            if (hoursPassed < 24f / Settings.UpdateFrequency)
            {
                return;
            }
            if (!Current.Game.playSettings.useWorkPriorities)
            {
                Current.Game.playSettings.useWorkPriorities = true;
                foreach (var pawn in PawnsFinder.AllMapsWorldAndTemporary_Alive.Where(pawn =>
                                                                                      pawn.Faction == Faction.OfPlayer))
                {
                    pawn.workSettings?.Notify_UseWorkPrioritiesChanged();
                }
            }
            if (Settings.AssignEveryoneWorkTypes == null)
            {
                Settings.AssignEveryoneWorkTypes =
                    new List <AssignEveryoneWorkType>(Settings.DefaultAssignEveryoneWorkTypes);
            }
            if (Prefs.DevMode && Settings.VerboseLogging)
            {
                Log.Message(
                    $"----- Work Manager: Updating work priorities... (day = {day}, hour = {hourFloat}, passed = {hoursPassed:N1}) -----");
            }
            _workUpdateTime.Year = year;
            _workUpdateTime.Day  = day;
            _workUpdateTime.Hour = hourFloat;
            UpdateCache();
            UpdateWorkPriorities();
            ApplyWorkPriorities();
            if (Settings.ManageWorkSchedule && (year - _scheduleUpdateTime.Year) * 60 * 24 +
                (day - _scheduleUpdateTime.Day) * 24 + hourFloat - _scheduleUpdateTime.Hour >= 24)
            {
                _scheduleUpdateTime.Year = year;
                _scheduleUpdateTime.Day  = day;
                _scheduleUpdateTime.Hour = hourFloat;
                UpdateSchedule();
            }
            if (Prefs.DevMode && Settings.VerboseLogging)
            {
                Log.Message("----------------------------------------------------");
            }
        }
Esempio n. 11
0
        static public void GenerateRandomAge(Pawn pawn, Map map)
        {
            int num = 0;
            int num2;

            do
            {
                if (pawn.RaceProps.ageGenerationCurve != null)
                {
                    num2 = Mathf.RoundToInt(Rand.ByCurve(pawn.RaceProps.ageGenerationCurve, 200));
                }
                else if (pawn.RaceProps.IsMechanoid)
                {
                    num2 = Rand.Range(0, 2500);
                }
                else
                {
                    if (!pawn.RaceProps.Animal)
                    {
                        goto IL_84;
                    }
                    num2 = Rand.Range(1, 10);
                }
                num++;
                if (num > 100)
                {
                    goto IL_95;
                }
            }while (num2 > pawn.kindDef.maxGenerationAge || num2 < pawn.kindDef.minGenerationAge);
            goto IL_A5;
IL_84:
            Log.Warning("Didn't get age for " + pawn);
            return;

IL_95:
            Log.Error("Tried 100 times to generate age for " + pawn);
IL_A5:
            pawn.ageTracker.AgeBiologicalTicks = ((long)(num2 * 3600000f) + Rand.Range(0, 3600000));
            int num3;

            if (Rand.Value < pawn.kindDef.backstoryCryptosleepCommonality)
            {
                float value = Rand.Value;
                if (value < 0.7f)
                {
                    num3 = Rand.Range(0, 100);
                }
                else if (value < 0.95f)
                {
                    num3 = Rand.Range(100, 1000);
                }
                else
                {
                    int num4 = GenLocalDate.Year(map) - 2026 - pawn.ageTracker.AgeBiologicalYears;
                    num3 = Rand.Range(1000, num4);
                }
            }
            else
            {
                num3 = 0;
            }
            long num5 = GenTicks.TicksAbs - pawn.ageTracker.AgeBiologicalTicks;

            num5 -= num3 * 3600000L;
            pawn.ageTracker.BirthAbsTicks = num5;
            if (pawn.ageTracker.AgeBiologicalTicks > pawn.ageTracker.AgeChronologicalTicks)
            {
                pawn.ageTracker.AgeChronologicalTicks = (pawn.ageTracker.AgeBiologicalTicks);
            }
        }
Esempio n. 12
0
        public static void AppendPsychologyThoughts(Pawn victim, DamageInfo?dinfo, PawnDiedOrDownedThoughtsKind thoughtsKind, ref List <IndividualThoughtToAdd> outIndividualThoughts, ref List <ThoughtDef> outAllColonistsThoughts)
        {
            bool flag  = dinfo.HasValue && dinfo.Value.Def.execution;
            bool flag2 = victim.IsPrisonerOfColony && !victim.guilt.IsGuilty && !victim.InAggroMentalState;
            bool flag3 = dinfo.HasValue && dinfo.Value.Def.ExternalViolenceFor(victim) && dinfo.Value.Instigator != null && dinfo.Value.Instigator is Pawn;

            if (flag3)
            {
                Pawn pawn = (Pawn)dinfo.Value.Instigator;
                if (!pawn.Dead && pawn.needs.mood != null && pawn.story != null && pawn != victim)
                {
                    if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died && victim.HostileTo(pawn))
                    {
                        if (victim.Faction != null && victim.Faction.HostileTo(pawn.Faction) && !flag2)
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KilledHumanlikeEnemy, pawn, victim, 1f, 1f));
                        }
                    }
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died && victim.Spawned)
            {
                List <Pawn> allPawnsSpawned = victim.Map.mapPawns.AllPawnsSpawned;
                for (int i = 0; i < allPawnsSpawned.Count; i++)
                {
                    Pawn pawn2 = allPawnsSpawned[i];
                    if (pawn2 != victim && pawn2.needs.mood != null)
                    {
                        if (!flag && (pawn2.MentalStateDef != MentalStateDefOf.SocialFighting || ((MentalState_SocialFighting)pawn2.MentalState).otherPawn != victim))
                        {
                            if (pawn2.Position.InHorDistOf(victim.Position, 12f) && GenSight.LineOfSight(victim.Position, pawn2.Position, victim.Map, false) && pawn2.Awake() && pawn2.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
                            {
                                if (pawn2.Faction == victim.Faction)
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.WitnessedDeathAllyBleedingHeart, pawn2, null, 1f, 1f));
                                }
                                else if (victim.Faction == null || (!victim.Faction.HostileTo(pawn2.Faction) || pawn2.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart)))
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.WitnessedDeathNonAllyBleedingHeart, pawn2, null, 1f, 1f));
                                }
                                if (!pawn2.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn2.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn2.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn2.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
                                {
                                    if (((pawn2.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn2) + GenLocalDate.Year(pawn2) + (int)(GenLocalDate.DayPercent(pawn2) * 5) * 60) * 391) % 1000) == 0)
                                    {
                                        pawn2.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                                        pawn2.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.RecentlyDesensitized, null);
                                    }
                                }
                            }
                            else if (victim.Faction == Faction.OfPlayer && victim.Faction == pawn2.Faction && victim.HostFaction != pawn2.Faction)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KnowColonistDiedBleedingHeart, pawn2, null, 1f, 1f));
                            }
                            if (flag2 && pawn2.Faction == Faction.OfPlayer && !pawn2.IsPrisoner)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KnowPrisonerDiedInnocentBleedingHeart, pawn2, null, 1f, 1f));
                            }
                        }
                    }
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Banished && victim.IsColonist)
            {
                outAllColonistsThoughts.Add(ThoughtDefOfPsychology.ColonistAbandonedBleedingHeart);
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.BanishedToDie)
            {
                if (victim.IsColonist)
                {
                    outAllColonistsThoughts.Add(ThoughtDefOfPsychology.ColonistAbandonedToDieBleedingHeart);
                }
                else if (victim.IsPrisonerOfColony)
                {
                    outAllColonistsThoughts.Add(ThoughtDefOfPsychology.PrisonerAbandonedToDieBleedingHeart);
                }
            }
        }
Esempio n. 13
0
        public static void CancelJob(ref Job __result, Pawn pawn)
        {
            Pawn partner = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);

            if (PsycheHelper.PsychologyEnabled(pawn) && PsycheHelper.PsychologyEnabled(partner) && PsychologyBase.ActivateKinsey())
            {
                float random  = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 2) * 60) * 391));
                float random2 = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(partner) + GenLocalDate.Year(partner) + (int)(GenLocalDate.DayPercent(partner) * 2) * 60) * 391));
                if (random > PsycheHelper.Comp(pawn).Sexuality.AdjustedSexDrive&& random2 > PsycheHelper.Comp(partner).Sexuality.AdjustedSexDrive)
                {
                    __result = null;
                }
            }
        }
Esempio n. 14
0
        public static void CancelJob(ref Job __result, Pawn pawn)
        {
            Pawn           partnerInMyBed = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);
            PsychologyPawn realPawn       = pawn as PsychologyPawn;
            PsychologyPawn realPartner    = partnerInMyBed as PsychologyPawn;

            if (realPawn != null && realPartner != null && PsychologyBase.ActivateKinsey() && realPawn.sexuality != null && realPartner.sexuality != null)
            {
                float random = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 2) * 60) * 391));
                if (random > realPawn.sexuality.AdjustedSexDrive && random > realPartner.sexuality.AdjustedSexDrive)
                {
                    __result = null;
                }
            }
        }
Esempio n. 15
0
        private static void _AppendThoughts_Humanlike(Pawn victim, DamageInfo?dinfo, Hediff hediff, PawnDiedOrDownedThoughtsKind thoughtsKind, List <IndividualThoughtToAdd> outIndividualThoughts, List <ThoughtDef> outAllColonistsThoughts)
        {
            var  IsExecution        = typeof(PawnDiedOrDownedThoughtsUtility).GetMethod("IsExecution", BindingFlags.Static | BindingFlags.NonPublic);
            var  IsInnocentPrisoner = typeof(PawnDiedOrDownedThoughtsUtility).GetMethod("IsInnocentPrisoner", BindingFlags.Static | BindingFlags.NonPublic);
            bool flag  = (bool)IsExecution.Invoke(null, new object[] { dinfo, hediff });
            bool flag2 = (bool)IsInnocentPrisoner.Invoke(null, new object[] { victim });
            bool flag3 = dinfo.HasValue && dinfo.Value.Def.externalViolence && dinfo.Value.Instigator != null && dinfo.Value.Instigator is Pawn;

            if (flag3)
            {
                Pawn pawn = (Pawn)dinfo.Value.Instigator;
                if (!pawn.Dead && pawn.needs.mood != null && pawn.story != null && pawn != victim)
                {
                    if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died)
                    {
                        outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KilledHumanlikeBloodlust, pawn, null, 1f, 1f));
                    }
                    if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died && victim.HostileTo(pawn))
                    {
                        if (victim.Faction != null && PawnUtility.IsFactionLeader(victim) && victim.Faction.HostileTo(pawn.Faction))
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.DefeatedHostileFactionLeader, pawn, victim, 1f, 1f));
                        }
                        else if (victim.Faction != null && victim.Faction.HostileTo(pawn.Faction) && !flag2)
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KilledHumanlikeEnemy, pawn, victim, 1f, 1f));
                        }
                        if (victim.kindDef.combatPower > 250f)
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.DefeatedMajorEnemy, pawn, victim, 1f, 1f));
                        }
                    }
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died && victim.Spawned)
            {
                List <Pawn> allPawnsSpawned = victim.Map.mapPawns.AllPawnsSpawned;
                for (int i = 0; i < allPawnsSpawned.Count; i++)
                {
                    Pawn pawn2 = allPawnsSpawned[i];
                    if (pawn2 != victim && pawn2.needs.mood != null)
                    {
                        if (!flag && (pawn2.MentalStateDef != MentalStateDefOf.SocialFighting || ((MentalState_SocialFighting)pawn2.MentalState).otherPawn != victim))
                        {
                            if (pawn2.Position.InHorDistOf(victim.Position, 12f) && GenSight.LineOfSight(victim.Position, pawn2.Position, victim.Map, false) && pawn2.Awake() && pawn2.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
                            {
                                if (pawn2.Faction == victim.Faction)
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathAlly, pawn2, null, 1f, 1f));
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.WitnessedDeathAllyBleedingHeart, pawn2, null, 1f, 1f));
                                }
                                else if (victim.Faction == null || (!victim.Faction.HostileTo(pawn2.Faction) || pawn2.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart)))
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathNonAlly, pawn2, null, 1f, 1f));
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.WitnessedDeathNonAllyBleedingHeart, pawn2, null, 1f, 1f));
                                }
                                if (pawn2.relations.FamilyByBlood.Contains(victim))
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathFamily, pawn2, null, 1f, 1f));
                                }
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathBloodlust, pawn2, null, 1f, 1f));
                                if (!pawn2.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn2.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn2.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn2.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
                                {
                                    if (((pawn2.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn2) + GenLocalDate.Year(pawn2) + (int)(GenLocalDate.DayPercent(pawn2) * 5) * 60) * 391) % 1000) == 0)
                                    {
                                        pawn2.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                                        pawn2.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.RecentlyDesensitized, null);
                                    }
                                }
                            }
                            else if (victim.Faction == Faction.OfPlayer && victim.Faction == pawn2.Faction && victim.HostFaction != pawn2.Faction)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KnowColonistDied, pawn2, null, 1f, 1f));
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KnowColonistDiedBleedingHeart, pawn2, null, 1f, 1f));
                            }
                            if (flag2 && pawn2.Faction == Faction.OfPlayer && !pawn2.IsPrisoner)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KnowPrisonerDiedInnocent, pawn2, null, 1f, 1f));
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KnowPrisonerDiedInnocentBleedingHeart, pawn2, null, 1f, 1f));
                            }
                        }
                    }
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Abandoned && victim.IsColonist)
            {
                outAllColonistsThoughts.Add(ThoughtDefOf.ColonistAbandoned);
                outAllColonistsThoughts.Add(ThoughtDefOfPsychology.ColonistAbandonedBleedingHeart);
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.AbandonedToDie)
            {
                if (victim.IsColonist)
                {
                    outAllColonistsThoughts.Add(ThoughtDefOf.ColonistAbandonedToDie);
                    outAllColonistsThoughts.Add(ThoughtDefOfPsychology.ColonistAbandonedToDieBleedingHeart);
                }
                else if (victim.IsPrisonerOfColony)
                {
                    outAllColonistsThoughts.Add(ThoughtDefOf.PrisonerAbandonedToDie);
                    outAllColonistsThoughts.Add(ThoughtDefOfPsychology.PrisonerAbandonedToDieBleedingHeart);
                }
            }
        }
Esempio n. 16
0
 public override void Tick(int currentTick)
 {
     //Constituent tick
     if (currentTick % GenDate.TicksPerHour * 2 == 0)
     {
         Map playerFactionMap            = Find.WorldObjects.FactionBases.Find(b => b.Faction.IsPlayer).Map;
         IEnumerable <Pawn> constituents = (from p in playerFactionMap.mapPawns.FreeColonistsSpawned
                                            where !p.health.hediffSet.HasHediff(HediffDefOfPsychology.Mayor) && p.GetTimeAssignment() != TimeAssignmentDefOf.Work && p.Awake()
                                            select p);
         if (constituents.Count() > 0)
         {
             Pawn potentialConstituent       = constituents.RandomElementByWeight(p => 0.0001f + Mathf.Pow(Mathf.Abs(0.7f - p.needs.mood.CurLevel), 2));
             IEnumerable <Pawn> activeMayors = (from m in playerFactionMap.mapPawns.FreeColonistsSpawned
                                                where !m.Dead && m.health.hediffSet.HasHediff(HediffDefOfPsychology.Mayor) && ((Hediff_Mayor)m.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Mayor)).worldTileElectedOn == potentialConstituent.Map.Tile &&
                                                m.GetTimeAssignment() != TimeAssignmentDefOf.Work && m.GetTimeAssignment() != TimeAssignmentDefOf.Sleep && m.GetLord() == null && m.Awake()
                                                select m);
             if (potentialConstituent != null && activeMayors.Count() > 0)
             {
                 Pawn           mayor = activeMayors.RandomElement(); //There should only be one.
                 PsychologyPawn psychologyConstituent = potentialConstituent as PsychologyPawn;
                 IntVec3        gather   = default(IntVec3);
                 bool           foundBed = false;
                 if (mayor.ownership != null && mayor.ownership.OwnedBed != null)
                 {
                     gather   = mayor.ownership.OwnedBed.Position;
                     foundBed = true;
                 }
                 if ((psychologyConstituent == null || Rand.Value < (1f - psychologyConstituent.psyche.GetPersonalityRating(PersonalityNodeDefOf.Independent)) / 5f) && (foundBed || RCellFinder.TryFindPartySpot(mayor, out gather)))
                 {
                     List <Pawn> pawns = new List <Pawn>();
                     pawns.Add(mayor);
                     pawns.Add(potentialConstituent);
                     Lord meeting = LordMaker.MakeNewLord(mayor.Faction, new LordJob_VisitMayor(gather, potentialConstituent, mayor, (potentialConstituent.needs.mood.CurLevel < 0.4f)), mayor.Map, pawns);
                     if (!foundBed)
                     {
                         mayor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.MayorNoBedroom);
                     }
                 }
             }
         }
     }
     //Election tick
     if (currentTick % (GenDate.TicksPerDay / 4f) == 0)
     {
         foreach (FactionBase factionBase in Find.WorldObjects.FactionBases)
         {
             //If the base isn't owned or named by the player, no election can be held.
             if (!factionBase.Faction.IsPlayer || !factionBase.namedByPlayer)
             {
                 continue;
             }
             //Self-explanatory.
             if (!PsychologyBase.ActivateElections())
             {
                 continue;
             }
             //If the base is not at least a year old, no election will be held.
             if ((Find.TickManager.TicksGame - factionBase.creationGameTicks) / GenDate.TicksPerYear < 1)
             {
                 continue;
             }
             //A base must have at least 7 people in it to hold an election.
             if (factionBase.Map.mapPawns.FreeColonistsSpawnedCount < 7)
             {
                 continue;
             }
             //If an election is already being held, don't start a new one.
             if (factionBase.Map.gameConditionManager.ConditionIsActive(GameConditionDefOfPsychology.Election) || factionBase.Map.lordManager.lords.Find(l => l.LordJob is LordJob_Joinable_Election) != null)
             {
                 continue;
             }
             //Elections are held in the fall and during the day.
             if (GenLocalDate.Season(factionBase.Map) != Season.Fall || (GenLocalDate.HourOfDay(factionBase.Map) < 7 || GenLocalDate.HourOfDay(factionBase.Map) > 20))
             {
                 continue;
             }
             //If an election has already been completed this year, don't start a new one.
             IEnumerable <Pawn> activeMayors = (from m in factionBase.Map.mapPawns.FreeColonistsSpawned
                                                where !m.Dead && m.health.hediffSet.HasHediff(HediffDefOfPsychology.Mayor) && ((Hediff_Mayor)m.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Mayor)).worldTileElectedOn == factionBase.Map.Tile && ((Hediff_Mayor)m.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Mayor)).yearElected == GenLocalDate.Year(factionBase.Map.Tile)
                                                select m);
             if (activeMayors.Count() > 0)
             {
                 continue;
             }
             //Try to space out the elections so they don't all proc at once.
             if (Rand.RangeInclusive(1, 15 - GenLocalDate.DayOfSeason(factionBase.Map.Tile)) > 1)
             {
                 continue;
             }
             IncidentParms parms = new IncidentParms();
             parms.target  = factionBase.Map;
             parms.faction = factionBase.Faction;
             FiringIncident fi = new FiringIncident(IncidentDefOfPsychology.Election, null, parms);
             Find.Storyteller.TryFire(fi);
         }
     }
 }
Esempio n. 17
0
 public override void PostMake()
 {
     base.PostMake();
     this.yearElected        = GenLocalDate.Year(this.pawn.Map.Tile);
     this.worldTileElectedOn = this.pawn.Map.Tile;
 }
Esempio n. 18
0
 public override void Tick(int currentTick)
 {
     //Performance reporting tick
     if (EnablePerformanceTesting() && currentTick % GenDate.TicksPerDay == 0 && PerformanceSetup.performanceTotals.Keys.Count > 0)
     {
         Dictionary <string, float> averages = PerformanceSetup.performanceTotals.ToDictionary(x => x.Key, x => (float)x.Value / (float)PerformanceSetup.performanceCalls[x.Key]);
         int topAmt = Math.Min(10, averages.Count);
         List <KeyValuePair <string, float> > avgTicks = (from avg in averages orderby avg.Value descending select avg).Take(topAmt).ToList();
         List <KeyValuePair <string, float> > topTicks = (from avg in averages orderby avg.Value * PerformanceSetup.performanceCalls[avg.Key] descending select avg).Take(topAmt).ToList();
         StringBuilder avgString = new StringBuilder();
         foreach (KeyValuePair <string, float> t in avgTicks)
         {
             avgString.AppendLine(t.Key + " (" + t.Value + ")");
         }
         StringBuilder topString = new StringBuilder();
         foreach (KeyValuePair <string, float> t in topTicks)
         {
             topString.AppendLine(t.Key + " (" + avgTicks.Find(x => x.Key == t.Key).Value + ")");
         }
         Log.Message("Psychology :: Performance Report :: Top " + topAmt + " average tick consumers:\n" + avgString.ToString() + "\nTop " + topAmt + " weighted tick consumers: " + topString.ToString());
     }
     //Constituent tick
     if (currentTick % GenDate.TicksPerHour * 2 == 0)
     {
         Map playerFactionMap            = Find.WorldObjects.SettlementBases.Find(b => b.Faction.IsPlayer).Map;
         IEnumerable <Pawn> constituents = (from p in playerFactionMap.mapPawns.FreeColonistsSpawned
                                            where !p.health.hediffSet.HasHediff(HediffDefOfPsychology.Mayor) && p.GetLord() == null && p.GetTimeAssignment() != TimeAssignmentDefOf.Work && p.Awake()
                                            select p);
         if (constituents.Count() > 0)
         {
             Pawn potentialConstituent       = constituents.RandomElementByWeight(p => 0.0001f + Mathf.Pow(Mathf.Abs(0.7f - p.needs.mood.CurLevel), 2));
             IEnumerable <Pawn> activeMayors = (from m in playerFactionMap.mapPawns.FreeColonistsSpawned
                                                where !m.Dead && m.health.hediffSet.HasHediff(HediffDefOfPsychology.Mayor) && ((Hediff_Mayor)m.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Mayor)).worldTileElectedOn == potentialConstituent.Map.Tile &&
                                                m.GetTimeAssignment() != TimeAssignmentDefOf.Work && m.GetTimeAssignment() != TimeAssignmentDefOf.Sleep && m.GetLord() == null && m.Awake() && m.GetLord() == null
                                                select m);
             if (potentialConstituent != null && !potentialConstituent.Downed && !potentialConstituent.Drafted && potentialConstituent.health.summaryHealth.SummaryHealthPercent >= 1f && potentialConstituent.GetTimeAssignment() != TimeAssignmentDefOf.Work && activeMayors.Count() > 0)
             {
                 Pawn    mayor  = activeMayors.RandomElement(); //There should only be one.
                 IntVec3 gather = default(IntVec3);
                 String  found  = null;
                 if (mayor.Map.GetComponent <OfficeTableMapComponent>().officeTable != null)
                 {
                     gather = mayor.Map.GetComponent <OfficeTableMapComponent>().officeTable.parent.Position;
                     found  = "office";
                 }
                 else if (mayor.ownership != null && mayor.ownership.OwnedBed != null)
                 {
                     gather = mayor.ownership.OwnedBed.Position;
                     found  = "bed";
                 }
                 if (PsycheHelper.PsychologyEnabled(potentialConstituent) && Rand.Chance((1f - PsycheHelper.Comp(potentialConstituent).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Independent)) / 5f) && (found != null || RCellFinder.TryFindPartySpot(mayor, out gather)) &&
                     (!mayor.Drafted && !mayor.Downed && mayor.health.summaryHealth.SummaryHealthPercent >= 1f && mayor.GetTimeAssignment() != TimeAssignmentDefOf.Work && (mayor.CurJob == null || mayor.CurJob.def != JobDefOf.TendPatient)))
                 {
                     List <Pawn> pawns = new List <Pawn>();
                     pawns.Add(mayor);
                     pawns.Add(potentialConstituent);
                     Lord meeting = LordMaker.MakeNewLord(mayor.Faction, new LordJob_VisitMayor(gather, potentialConstituent, mayor, (potentialConstituent.needs.mood.CurLevel < (potentialConstituent.mindState.mentalBreaker.BreakThresholdMinor * 1.25f))), mayor.Map, pawns);
                     mayor.jobs.EndCurrentJob(Verse.AI.JobCondition.InterruptForced);
                     potentialConstituent.jobs.EndCurrentJob(Verse.AI.JobCondition.InterruptForced);
                     if (found == "bed")
                     {
                         mayor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.MayorNoOffice);
                     }
                     else if (found == null)
                     {
                         mayor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.MayorNoBedroom);
                     }
                 }
             }
         }
     }
     //Election tick
     if (currentTick % (GenDate.TicksPerDay / 4f) == 0)
     {
         foreach (Settlement settlement in Find.WorldObjects.Settlements)
         {
             //Self-explanatory.
             if (!PsychologyBase.ActivateElections())
             {
                 continue;
             }
             //If the base isn't owned or named by the player, no election can be held.
             if (!settlement.Faction.IsPlayer || !settlement.namedByPlayer)
             {
                 continue;
             }
             //If the base is not at least a year old, no election will be held.
             if ((Find.TickManager.TicksGame - settlement.creationGameTicks) / GenDate.TicksPerYear < 1)
             {
                 continue;
             }
             //A base must have at least 7 people in it to hold an election.
             if (settlement.Map.mapPawns.FreeColonistsSpawnedCount < 7)
             {
                 continue;
             }
             //If an election is already being held, don't start a new one.
             if (settlement.Map.gameConditionManager.ConditionIsActive(GameConditionDefOfPsychology.Election) || settlement.Map.lordManager.lords.Find(l => l.LordJob is LordJob_Joinable_Election) != null)
             {
                 continue;
             }
             //Elections are held in Septober (because I guess some maps don't have fall?) and during the day.
             if (GenDate.Quadrum(Find.TickManager.TicksAbs, Find.WorldGrid.LongLatOf(settlement.Tile).x) != Quadrum.Septober || (GenLocalDate.HourOfDay(settlement.Map) < 7 || GenLocalDate.HourOfDay(settlement.Map) > 20))
             {
                 continue;
             }
             //If an election has already been completed this year, don't start a new one.
             IEnumerable <Pawn> activeMayors = (from m in settlement.Map.mapPawns.FreeColonistsSpawned
                                                where !m.Dead && m.health.hediffSet.HasHediff(HediffDefOfPsychology.Mayor) && ((Hediff_Mayor)m.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Mayor)).worldTileElectedOn == settlement.Map.Tile && ((Hediff_Mayor)m.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Mayor)).yearElected == GenLocalDate.Year(settlement.Map.Tile)
                                                select m);
             if (activeMayors.Count() > 0)
             {
                 continue;
             }
             //Try to space out the elections so they don't all proc at once.
             if (Rand.RangeInclusive(1, 15 - GenLocalDate.DayOfQuadrum(settlement.Map.Tile)) > 1)
             {
                 continue;
             }
             IncidentParms parms = new IncidentParms();
             parms.target  = settlement.Map;
             parms.faction = settlement.Faction;
             FiringIncident fi = new FiringIncident(IncidentDefOfPsychology.Election, null, parms);
             Find.Storyteller.TryFire(fi);
         }
     }
 }
        internal static void _ObserveSurroundingThings(this PawnObserver _this)
        {
            Pawn pawn = _this.GetPawn();

            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
            {
                return;
            }
            Room room = RoomQuery.RoomAt(pawn);
            int  num  = 0;

            while ((float)num < 100f)
            {
                IntVec3 c = pawn.Position + GenRadial.RadialPattern[num];
                if (c.InBounds(pawn.Map))
                {
                    if (RoomQuery.RoomAt(c, pawn.Map) == room)
                    {
                        List <Thing> thingList = c.GetThingList(pawn.Map);
                        for (int i = 0; i < thingList.Count; i++)
                        {
                            IThoughtGiver thoughtGiver = thingList[i] as IThoughtGiver;
                            if (thoughtGiver != null)
                            {
                                Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought();
                                if (thought_Memory != null)
                                {
                                    if (thought_Memory.def == ThoughtDefOf.ObservedLayingCorpse)
                                    {
                                        if (!pawn.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
                                        {
                                            if (((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 5) * 60) * 391) % 1000) == 0)
                                            {
                                                pawn.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                                                pawn.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.RecentlyDesensitized, null);
                                            }
                                        }
                                    }
                                    pawn.needs.mood.thoughts.memories.TryGainMemoryThought(thought_Memory, null);
                                }
                            }
                        }
                    }
                }
                num++;
            }
        }
Esempio n. 20
0
        public static void DesensitizeViaCorpse(PawnObserver __instance)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
            {
                return;
            }
            RoomGroup roomGroup = pawn.GetRoomGroup();
            Map       map       = pawn.Map;
            int       num       = 0;

            while ((float)num < 100f)
            {
                IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num];
                if (intVec.InBounds(map))
                {
                    if (intVec.GetRoomGroup(map) == roomGroup)
                    {
                        if (GenSight.LineOfSight(intVec, pawn.Position, map, true, null, 0, 0))
                        {
                            List <Thing> thingList = intVec.GetThingList(map);
                            for (int i = 0; i < thingList.Count; i++)
                            {
                                IThoughtGiver thoughtGiver = thingList[i] as IThoughtGiver;
                                if (thoughtGiver != null)
                                {
                                    Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought();
                                    if (thought_Memory != null && thought_Memory.def == ThoughtDefOf.ObservedLayingCorpse)
                                    {
                                        if (!pawn.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
                                        {
                                            if (((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 5) * 60) * 391) % 1000) == 0)
                                            {
                                                pawn.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                                                pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.RecentlyDesensitized, null);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                num++;
            }
        }