Ejemplo n.º 1
0
        private static void Recache(Pawn selPawnForSocialInfo)
        {
            SocialCardUtility.cachedForPawn = selPawnForSocialInfo;
            SocialCardUtility.tmpToCache.Clear();
            foreach (Pawn current in selPawnForSocialInfo.relations.RelatedPawns)
            {
                if (SocialCardUtility.ShouldShowPawnRelations(current, selPawnForSocialInfo))
                {
                    SocialCardUtility.tmpToCache.Add(current);
                }
            }
            List <Pawn> list = null;

            if (selPawnForSocialInfo.MapHeld != null)
            {
                list = selPawnForSocialInfo.MapHeld.mapPawns.AllPawnsSpawned;
            }
            else if (selPawnForSocialInfo.IsCaravanMember())
            {
                list = selPawnForSocialInfo.GetCaravan().PawnsListForReading;
            }
            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    Pawn pawn = list[i];
                    if (pawn.RaceProps.Humanlike && pawn != selPawnForSocialInfo && SocialCardUtility.ShouldShowPawnRelations(pawn, selPawnForSocialInfo) && !SocialCardUtility.tmpToCache.Contains(pawn))
                    {
                        if (selPawnForSocialInfo.relations.OpinionOf(pawn) != 0 || pawn.relations.OpinionOf(selPawnForSocialInfo) != 0)
                        {
                            SocialCardUtility.tmpToCache.Add(pawn);
                        }
                    }
                }
            }
            SocialCardUtility.cachedEntries.RemoveAll((SocialCardUtility.CachedSocialTabEntry x) => !SocialCardUtility.tmpToCache.Contains(x.otherPawn));
            SocialCardUtility.tmpCached.Clear();
            for (int j = 0; j < SocialCardUtility.cachedEntries.Count; j++)
            {
                SocialCardUtility.tmpCached.Add(SocialCardUtility.cachedEntries[j].otherPawn);
            }
            foreach (Pawn current2 in SocialCardUtility.tmpToCache)
            {
                if (!SocialCardUtility.tmpCached.Contains(current2))
                {
                    SocialCardUtility.CachedSocialTabEntry cachedSocialTabEntry = new SocialCardUtility.CachedSocialTabEntry();
                    cachedSocialTabEntry.otherPawn = current2;
                    SocialCardUtility.cachedEntries.Add(cachedSocialTabEntry);
                }
            }
            SocialCardUtility.tmpCached.Clear();
            SocialCardUtility.tmpToCache.Clear();
            for (int k = 0; k < SocialCardUtility.cachedEntries.Count; k++)
            {
                SocialCardUtility.RecacheEntry(SocialCardUtility.cachedEntries[k], selPawnForSocialInfo);
            }
            SocialCardUtility.cachedEntries.Sort(SocialCardUtility.CachedEntriesComparer);
        }