Esempio n. 1
0
        private static void AppendThoughts_Relations(Pawn victim, DamageInfo?dinfo, PawnDiedOrDownedThoughtsKind thoughtsKind, List <IndividualThoughtToAdd> outIndividualThoughts, List <ThoughtToAddToAll> outAllColonistsThoughts)
        {
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Banished && victim.RaceProps.Animal)
            {
                List <DirectPawnRelation> directRelations = victim.relations.DirectRelations;
                for (int i = 0; i < directRelations.Count; i++)
                {
                    if (directRelations[i].otherPawn.needs != null && directRelations[i].otherPawn.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(directRelations[i].otherPawn, victim) && directRelations[i].def == PawnRelationDefOf.Bond)
                    {
                        outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.BondedAnimalBanished, directRelations[i].otherPawn, victim));
                    }
                }
            }
            if (thoughtsKind != 0 && thoughtsKind != PawnDiedOrDownedThoughtsKind.BanishedToDie && thoughtsKind != PawnDiedOrDownedThoughtsKind.Lost)
            {
                return;
            }
            bool flag = thoughtsKind == PawnDiedOrDownedThoughtsKind.Lost;

            foreach (Pawn potentiallyRelatedPawn in victim.relations.PotentiallyRelatedPawns)
            {
                if (potentiallyRelatedPawn.needs == null || potentiallyRelatedPawn.needs.mood == null || !PawnUtility.ShouldGetThoughtAbout(potentiallyRelatedPawn, victim))
                {
                    continue;
                }
                PawnRelationDef mostImportantRelation = potentiallyRelatedPawn.GetMostImportantRelation(victim);
                if (mostImportantRelation != null)
                {
                    ThoughtDef thoughtDef = (flag ? mostImportantRelation.GetGenderSpecificLostThought(victim) : mostImportantRelation.GetGenderSpecificDiedThought(victim));
                    if (thoughtDef != null)
                    {
                        outIndividualThoughts.Add(new IndividualThoughtToAdd(thoughtDef, potentiallyRelatedPawn, victim));
                    }
                }
            }
            if (dinfo.HasValue && thoughtsKind != PawnDiedOrDownedThoughtsKind.Lost)
            {
                Pawn pawn = dinfo.Value.Instigator as Pawn;
                if (pawn != null && pawn != victim)
                {
                    foreach (Pawn potentiallyRelatedPawn2 in victim.relations.PotentiallyRelatedPawns)
                    {
                        if (pawn == potentiallyRelatedPawn2 || potentiallyRelatedPawn2.needs == null || potentiallyRelatedPawn2.needs.mood == null)
                        {
                            continue;
                        }
                        PawnRelationDef mostImportantRelation2 = potentiallyRelatedPawn2.GetMostImportantRelation(victim);
                        if (mostImportantRelation2 != null)
                        {
                            ThoughtDef genderSpecificKilledThought = mostImportantRelation2.GetGenderSpecificKilledThought(victim);
                            if (genderSpecificKilledThought != null)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(genderSpecificKilledThought, potentiallyRelatedPawn2, pawn));
                            }
                        }
                        if (potentiallyRelatedPawn2.RaceProps.IsFlesh)
                        {
                            int num = potentiallyRelatedPawn2.relations.OpinionOf(victim);
                            if (num >= 20)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KilledMyFriend, potentiallyRelatedPawn2, pawn, 1f, victim.relations.GetFriendDiedThoughtPowerFactor(num)));
                            }
                            else if (num <= -20)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KilledMyRival, potentiallyRelatedPawn2, pawn, 1f, victim.relations.GetRivalDiedThoughtPowerFactor(num)));
                            }
                        }
                    }
                }
            }
            ThoughtDef thoughtDef2 = ((thoughtsKind == PawnDiedOrDownedThoughtsKind.Lost) ? ThoughtDefOf.PawnWithGoodOpinionLost : ThoughtDefOf.PawnWithGoodOpinionDied);
            ThoughtDef thoughtDef3 = ((thoughtsKind == PawnDiedOrDownedThoughtsKind.Lost) ? ThoughtDefOf.PawnWithBadOpinionLost : ThoughtDefOf.PawnWithBadOpinionDied);

            if (!victim.RaceProps.Humanlike)
            {
                return;
            }
            foreach (Pawn item in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive)
            {
                if (item.needs != null && item.RaceProps.IsFlesh && item.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(item, victim))
                {
                    int num2 = item.relations.OpinionOf(victim);
                    if (num2 >= 20)
                    {
                        outIndividualThoughts.Add(new IndividualThoughtToAdd(thoughtDef2, item, victim, victim.relations.GetFriendDiedThoughtPowerFactor(num2)));
                    }
                    else if (num2 <= -20)
                    {
                        outIndividualThoughts.Add(new IndividualThoughtToAdd(thoughtDef3, item, victim, victim.relations.GetRivalDiedThoughtPowerFactor(num2)));
                    }
                }
            }
        }
 private static void AppendThoughts_Relations(Pawn victim, DamageInfo?dinfo, PawnDiedOrDownedThoughtsKind thoughtsKind, List <IndividualThoughtToAdd> outIndividualThoughts, List <ThoughtDef> outAllColonistsThoughts)
 {
     if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Banished && victim.RaceProps.Animal)
     {
         List <DirectPawnRelation> directRelations = victim.relations.DirectRelations;
         for (int i = 0; i < directRelations.Count; i++)
         {
             if (directRelations[i].otherPawn.needs != null && directRelations[i].otherPawn.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(directRelations[i].otherPawn, victim) && directRelations[i].def == PawnRelationDefOf.Bond)
             {
                 outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.BondedAnimalBanished, directRelations[i].otherPawn, victim));
             }
         }
     }
     if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died || thoughtsKind == PawnDiedOrDownedThoughtsKind.BanishedToDie)
     {
         foreach (Pawn potentiallyRelatedPawn in victim.relations.PotentiallyRelatedPawns)
         {
             if (potentiallyRelatedPawn.needs != null && potentiallyRelatedPawn.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(potentiallyRelatedPawn, victim))
             {
                 PawnRelationDef mostImportantRelation = potentiallyRelatedPawn.GetMostImportantRelation(victim);
                 if (mostImportantRelation != null)
                 {
                     ThoughtDef genderSpecificDiedThought = mostImportantRelation.GetGenderSpecificDiedThought(victim);
                     if (genderSpecificDiedThought != null)
                     {
                         outIndividualThoughts.Add(new IndividualThoughtToAdd(genderSpecificDiedThought, potentiallyRelatedPawn, victim));
                     }
                 }
             }
         }
         if (dinfo.HasValue)
         {
             Pawn pawn = dinfo.Value.Instigator as Pawn;
             if (pawn != null && pawn != victim)
             {
                 foreach (Pawn potentiallyRelatedPawn2 in victim.relations.PotentiallyRelatedPawns)
                 {
                     if (pawn != potentiallyRelatedPawn2 && potentiallyRelatedPawn2.needs != null && potentiallyRelatedPawn2.needs.mood != null)
                     {
                         PawnRelationDef mostImportantRelation2 = potentiallyRelatedPawn2.GetMostImportantRelation(victim);
                         if (mostImportantRelation2 != null)
                         {
                             ThoughtDef genderSpecificKilledThought = mostImportantRelation2.GetGenderSpecificKilledThought(victim);
                             if (genderSpecificKilledThought != null)
                             {
                                 outIndividualThoughts.Add(new IndividualThoughtToAdd(genderSpecificKilledThought, potentiallyRelatedPawn2, pawn));
                             }
                         }
                         if (potentiallyRelatedPawn2.RaceProps.IsFlesh)
                         {
                             int num = potentiallyRelatedPawn2.relations.OpinionOf(victim);
                             if (num >= 20)
                             {
                                 ThoughtDef killedMyFriend = ThoughtDefOf.KilledMyFriend;
                                 Pawn       addTo          = potentiallyRelatedPawn2;
                                 Pawn       otherPawn      = pawn;
                                 float      friendDiedThoughtPowerFactor = victim.relations.GetFriendDiedThoughtPowerFactor(num);
                                 outIndividualThoughts.Add(new IndividualThoughtToAdd(killedMyFriend, addTo, otherPawn, 1f, friendDiedThoughtPowerFactor));
                             }
                             else if (num <= -20)
                             {
                                 ThoughtDef killedMyFriend = ThoughtDefOf.KilledMyRival;
                                 Pawn       otherPawn      = potentiallyRelatedPawn2;
                                 Pawn       addTo          = pawn;
                                 float      friendDiedThoughtPowerFactor = victim.relations.GetRivalDiedThoughtPowerFactor(num);
                                 outIndividualThoughts.Add(new IndividualThoughtToAdd(killedMyFriend, otherPawn, addTo, 1f, friendDiedThoughtPowerFactor));
                             }
                         }
                     }
                 }
             }
         }
         if (victim.RaceProps.Humanlike)
         {
             foreach (Pawn item in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive)
             {
                 if (item.needs != null && item.RaceProps.IsFlesh && item.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(item, victim))
                 {
                     int num2 = item.relations.OpinionOf(victim);
                     if (num2 >= 20)
                     {
                         outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.PawnWithGoodOpinionDied, item, victim, victim.relations.GetFriendDiedThoughtPowerFactor(num2)));
                     }
                     else if (num2 <= -20)
                     {
                         outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.PawnWithBadOpinionDied, item, victim, victim.relations.GetRivalDiedThoughtPowerFactor(num2)));
                     }
                 }
             }
         }
     }
 }