public void AppendSocialThoughts(Pawn otherPawn, List <ISocialThought> outThoughts) { this.CheckRecalculateSocialThoughts(otherPawn); SituationalThoughtHandler.CachedSocialThoughts cachedSocialThoughts = this.cachedSocialThoughts[otherPawn]; cachedSocialThoughts.lastQueryTick = Find.TickManager.TicksGame; List <Thought_SituationalSocial> activeThoughts = cachedSocialThoughts.activeThoughts; for (int i = 0; i < activeThoughts.Count; i++) { outThoughts.Add(activeThoughts[i]); } }
private void RecalculateSocialThoughtsAffectingMood() { try { this.tmpToAdd.Clear(); List <ThoughtDef> situationalSocialThoughtDefs = ThoughtUtility.situationalSocialThoughtDefs; int i = 0; int count = situationalSocialThoughtDefs.Count; while (i < count) { if (situationalSocialThoughtDefs[i].socialThoughtAffectingMood) { foreach (Pawn current in situationalSocialThoughtDefs[i].Worker.PotentialPawnCandidates(this.pawn)) { if (current != this.pawn) { this.tmpToAdd.Add(new Pair <ThoughtDef, Pawn>(situationalSocialThoughtDefs[i], current)); } } } i++; } foreach (KeyValuePair <Pawn, SituationalThoughtHandler.CachedSocialThoughts> current2 in this.cachedSocialThoughtsAffectingMood) { List <Thought_SituationalSocial> thoughts = current2.Value.thoughts; for (int j = thoughts.Count - 1; j >= 0; j--) { if (!this.tmpToAdd.Contains(new Pair <ThoughtDef, Pawn>(thoughts[j].def, current2.Key))) { thoughts.RemoveAt(j); } } } foreach (Pair <ThoughtDef, Pawn> current3 in this.tmpToAdd) { ThoughtDef first = current3.First; Pawn second = current3.Second; SituationalThoughtHandler.CachedSocialThoughts cachedSocialThoughts; bool flag = this.cachedSocialThoughtsAffectingMood.TryGetValue(second, out cachedSocialThoughts); if (flag) { bool flag2 = false; for (int k = 0; k < cachedSocialThoughts.thoughts.Count; k++) { if (cachedSocialThoughts.thoughts[k].def == first) { flag2 = true; break; } } if (flag2) { continue; } } Thought_SituationalSocial thought_SituationalSocial = this.TryCreateSocialThought(first, second); if (thought_SituationalSocial != null) { if (!flag) { cachedSocialThoughts = new SituationalThoughtHandler.CachedSocialThoughts(); this.cachedSocialThoughtsAffectingMood.Add(second, cachedSocialThoughts); } cachedSocialThoughts.thoughts.Add(thought_SituationalSocial); } } this.cachedSocialThoughtsAffectingMood.RemoveAll((KeyValuePair <Pawn, SituationalThoughtHandler.CachedSocialThoughts> x) => x.Value.thoughts.Count == 0); int ticksGame = Find.TickManager.TicksGame; foreach (KeyValuePair <Pawn, SituationalThoughtHandler.CachedSocialThoughts> current4 in this.cachedSocialThoughtsAffectingMood) { SituationalThoughtHandler.CachedSocialThoughts value = current4.Value; List <Thought_SituationalSocial> thoughts2 = value.thoughts; value.activeThoughts.Clear(); for (int l = 0; l < thoughts2.Count; l++) { thoughts2[l].RecalculateState(); value.lastRecalculationTick = ticksGame; if (thoughts2[l].Active) { value.activeThoughts.Add(thoughts2[l]); } } } } finally { } }