Exemple #1
0
 public static void Postfix(IndividualThoughtToAdd __instance, Pawn ___otherPawn)
 {
     Log.Message(__instance.addTo + " - " + __instance.thought + " - " + ___otherPawn);
     if (__instance.thought is Thought_MemorySocial thought_MemorySocial && (__instance.addTo.HasTrait(VTEDefOf.VTE_WorldWeary) || ___otherPawn != null &&
                                                                             ___otherPawn.HasTrait(VTEDefOf.VTE_WorldWeary)))
     {
         thought_MemorySocial.opinionOffset /= 2f;
     }
 }
        public static void PawnDiedOrDownedThoughtsUtility_GetThoughts_Postfix(Pawn victim, ref DamageInfo?dinfo, PawnDiedOrDownedThoughtsKind thoughtsKind, List <IndividualThoughtToAdd> outIndividualThoughts, List <ThoughtToAddToAll> outAllColonistsThoughts)
        {
            var raceSettings = DefDatabase <AutomataRaceSettings> .GetNamed(victim.def.defName, errorOnFail : false);

            if (!(raceSettings?.deadThoughtOverrides?.NullOrEmpty() ?? true))
            {
                var oldIndividualThoughts   = new List <IndividualThoughtToAdd>(outIndividualThoughts);
                var oldAllColonistsThoughts = new List <ThoughtToAddToAll>(outAllColonistsThoughts);

                outIndividualThoughts.Clear();
                foreach (var individualThought in oldIndividualThoughts)
                {
                    var overrideData = raceSettings.deadThoughtOverrides.FirstOrDefault(x => x.source == individualThought.thought.def);
                    if (overrideData != null)
                    {
                        if (overrideData.overwrite != null)
                        {
                            var oldThought = individualThought.thought;
                            var newThought = new IndividualThoughtToAdd(
                                overrideData.overwrite,
                                individualThought.addTo,
                                otherPawn: oldThought.otherPawn,
                                moodPowerFactor: oldThought.moodPowerFactor);

                            var newThoughtSocial = newThought.thought as Thought_MemorySocial;
                            if (newThoughtSocial != null)
                            {
                                newThoughtSocial.opinionOffset = (oldThought as Thought_MemorySocial)?.opinionOffset ?? newThoughtSocial.opinionOffset;
                            }

                            outIndividualThoughts.Add(newThought);
                        }
                    }
                    else
                    {
                        outIndividualThoughts.Add(individualThought);
                    }
                }

                outAllColonistsThoughts.Clear();
                foreach (var allColonistThought in oldAllColonistsThoughts)
                {
                    var overrideData = raceSettings.deadThoughtOverrides.FirstOrDefault(x => x.source == allColonistThought.thoughtDef);
                    if (overrideData != null)
                    {
                        if (overrideData.overwrite != null)
                        {
                            outAllColonistsThoughts.Add(new ThoughtToAddToAll(overrideData.overwrite, allColonistThought.otherPawn));
                        }
                    }
                    else
                    {
                        outAllColonistsThoughts.Add(allColonistThought);
                    }
                }
            }
        }
        private void GiveOutHatredTowardsKiller_ForFriendsOrRivals(Pawn recipient)
        {
            int opinion = recipient.relations.OpinionOf(Victim);
            IndividualThoughtToAdd?tempThought = null;

            // Woah we got our asses handed with a bad coding style...
            // The IndividualThoughtToAdd struct does not allow null ThoughtDef
            // So here we are using another way to write concise code
            if (opinion >= 20)
            {
                tempThought = new IndividualThoughtToAdd(ThoughtDefOf.KilledMyFriend, recipient, Killer, 1f, Victim.relations.GetFriendDiedThoughtPowerFactor(opinion));
            }
            else if (opinion <= -20)
            {
                tempThought = new IndividualThoughtToAdd(ThoughtDefOf.KilledMyRival, recipient, Killer, 1f, Victim.relations.GetRivalDiedThoughtPowerFactor(opinion));
            }

            tempThought?.Add();
        }