private Thought_SituationalSocial TryCreateSocialThought(ThoughtDef def, Pawn otherPawn) { Thought_SituationalSocial thought_SituationalSocial = null; try { if (!ThoughtUtility.CanGetThought_NewTemp(pawn, def)) { return(null); } if (!def.Worker.CurrentSocialState(pawn, otherPawn).ActiveFor(def)) { return(null); } thought_SituationalSocial = (Thought_SituationalSocial)ThoughtMaker.MakeThought(def); thought_SituationalSocial.pawn = pawn; thought_SituationalSocial.otherPawn = otherPawn; thought_SituationalSocial.RecalculateState(); return(thought_SituationalSocial); } catch (Exception ex) { Log.Error(string.Concat("Exception while recalculating ", def, " thought state for pawn ", pawn, ": ", ex)); return(thought_SituationalSocial); } }
private Thought_SituationalSocial TryCreateSocialThought(ThoughtDef def, Pawn otherPawn) { Thought_SituationalSocial thought_SituationalSocial = null; try { if (!ThoughtUtility.CanGetThought(this.pawn, def)) { return(null); } if (!def.Worker.CurrentSocialState(this.pawn, otherPawn).Active) { return(null); } thought_SituationalSocial = (Thought_SituationalSocial)ThoughtMaker.MakeThought(def); thought_SituationalSocial.pawn = this.pawn; thought_SituationalSocial.otherPawn = otherPawn; thought_SituationalSocial.RecalculateState(); return(thought_SituationalSocial); } catch (Exception ex) { Log.Error("Exception while recalculating " + def + " thought state for pawn " + this.pawn + ": " + ex); return(thought_SituationalSocial); } }
private Thought_SituationalSocial TryCreateSocialThought(ThoughtDef def, Pawn otherPawn) { Thought_SituationalSocial thought_SituationalSocial = null; try { if (!ThoughtUtility.CanGetThought(this.pawn, def)) { Thought_SituationalSocial result = null; return(result); } if (!def.Worker.CurrentSocialState(this.pawn, otherPawn).Active) { Thought_SituationalSocial result = null; return(result); } thought_SituationalSocial = (Thought_SituationalSocial)ThoughtMaker.MakeThought(def); thought_SituationalSocial.pawn = this.pawn; thought_SituationalSocial.otherPawn = otherPawn; thought_SituationalSocial.RecalculateState(); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception while recalculating ", def, " thought state for pawn ", this.pawn, ": ", ex })); } return(thought_SituationalSocial); }
private void CheckRecalculateSocialThoughts(Pawn otherPawn) { try { SituationalThoughtHandler.CachedSocialThoughts cachedSocialThoughts; if (!this.cachedSocialThoughts.TryGetValue(otherPawn, out cachedSocialThoughts)) { cachedSocialThoughts = new SituationalThoughtHandler.CachedSocialThoughts(); this.cachedSocialThoughts.Add(otherPawn, cachedSocialThoughts); } if (cachedSocialThoughts.ShouldRecalculateState) { cachedSocialThoughts.lastRecalculationTick = Find.TickManager.TicksGame; this.tmpCachedSocialThoughts.Clear(); for (int i = 0; i < cachedSocialThoughts.thoughts.Count; i++) { Thought_SituationalSocial thought_SituationalSocial = cachedSocialThoughts.thoughts[i]; thought_SituationalSocial.RecalculateState(); this.tmpCachedSocialThoughts.Add(thought_SituationalSocial.def); } List <ThoughtDef> situationalSocialThoughtDefs = ThoughtUtility.situationalSocialThoughtDefs; int j = 0; int count = situationalSocialThoughtDefs.Count; while (j < count) { if (!this.tmpCachedSocialThoughts.Contains(situationalSocialThoughtDefs[j])) { Thought_SituationalSocial thought_SituationalSocial2 = this.TryCreateSocialThought(situationalSocialThoughtDefs[j], otherPawn); if (thought_SituationalSocial2 != null) { cachedSocialThoughts.thoughts.Add(thought_SituationalSocial2); } } j++; } cachedSocialThoughts.activeThoughts.Clear(); for (int k = 0; k < cachedSocialThoughts.thoughts.Count; k++) { Thought_SituationalSocial thought_SituationalSocial3 = cachedSocialThoughts.thoughts[k]; if (thought_SituationalSocial3.Active) { cachedSocialThoughts.activeThoughts.Add(thought_SituationalSocial3); } } } } finally { } }
private void CheckRecalculateSocialThoughts(Pawn otherPawn) { try { if (!cachedSocialThoughts.TryGetValue(otherPawn, out var value)) { value = new CachedSocialThoughts(); cachedSocialThoughts.Add(otherPawn, value); } if (!value.ShouldRecalculateState) { return; } value.lastRecalculationTick = Find.TickManager.TicksGame; tmpCachedSocialThoughts.Clear(); for (int i = 0; i < value.thoughts.Count; i++) { Thought_SituationalSocial thought_SituationalSocial = value.thoughts[i]; thought_SituationalSocial.RecalculateState(); tmpCachedSocialThoughts.Add(thought_SituationalSocial.def); } List <ThoughtDef> situationalSocialThoughtDefs = ThoughtUtility.situationalSocialThoughtDefs; int j = 0; for (int count = situationalSocialThoughtDefs.Count; j < count; j++) { if (!tmpCachedSocialThoughts.Contains(situationalSocialThoughtDefs[j])) { Thought_SituationalSocial thought_SituationalSocial2 = TryCreateSocialThought(situationalSocialThoughtDefs[j], otherPawn); if (thought_SituationalSocial2 != null) { value.thoughts.Add(thought_SituationalSocial2); } } } value.activeThoughts.Clear(); for (int k = 0; k < value.thoughts.Count; k++) { Thought_SituationalSocial thought_SituationalSocial3 = value.thoughts[k]; if (thought_SituationalSocial3.Active) { value.activeThoughts.Add(thought_SituationalSocial3); } } } finally { } }