private Thought_Situational TryCreateThought(ThoughtDef def) { Thought_Situational thought_Situational = null; try { if (!ThoughtUtility.CanGetThought_NewTemp(pawn, def)) { return(null); } if (!def.Worker.CurrentState(pawn).ActiveFor(def)) { return(null); } thought_Situational = (Thought_Situational)ThoughtMaker.MakeThought(def); thought_Situational.pawn = pawn; thought_Situational.RecalculateState(); return(thought_Situational); } catch (Exception ex) { Log.Error(string.Concat("Exception while recalculating ", def, " thought state for pawn ", pawn, ": ", ex)); return(thought_Situational); } }
private void CheckRecalculateMoodThoughts() { int ticksGame = Find.TickManager.TicksGame; if (ticksGame - lastMoodThoughtsRecalculationTick < 100) { return; } lastMoodThoughtsRecalculationTick = ticksGame; try { tmpCachedThoughts.Clear(); for (int i = 0; i < cachedThoughts.Count; i++) { cachedThoughts[i].RecalculateState(); tmpCachedThoughts.Add(cachedThoughts[i].def); } List <ThoughtDef> situationalNonSocialThoughtDefs = ThoughtUtility.situationalNonSocialThoughtDefs; int j = 0; for (int count = situationalNonSocialThoughtDefs.Count; j < count; j++) { if (!tmpCachedThoughts.Contains(situationalNonSocialThoughtDefs[j])) { Thought_Situational thought_Situational = TryCreateThought(situationalNonSocialThoughtDefs[j]); if (thought_Situational != null) { cachedThoughts.Add(thought_Situational); } } } } finally { } }
private Thought_Situational TryCreateThought(ThoughtDef def) { Thought_Situational thought_Situational = null; try { if (!ThoughtUtility.CanGetThought(this.pawn, def)) { return(null); } if (!def.Worker.CurrentState(this.pawn).Active) { return(null); } thought_Situational = (Thought_Situational)ThoughtMaker.MakeThought(def); thought_Situational.pawn = this.pawn; thought_Situational.RecalculateState(); return(thought_Situational); } catch (Exception ex) { Log.Error("Exception while recalculating " + def + " thought state for pawn " + this.pawn + ": " + ex); return(thought_Situational); } }
private Thought_Situational TryCreateThought(ThoughtDef def) { Thought_Situational thought_Situational = null; try { if (!ThoughtUtility.CanGetThought(this.pawn, def)) { Thought_Situational result = null; return(result); } if (!def.Worker.CurrentState(this.pawn).Active) { Thought_Situational result = null; return(result); } thought_Situational = (Thought_Situational)ThoughtMaker.MakeThought(def); thought_Situational.pawn = this.pawn; thought_Situational.RecalculateState(); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception while recalculating ", def, " thought state for pawn ", this.pawn, ": ", ex })); } return(thought_Situational); }
public void AppendMoodThoughts(List <Thought> outThoughts) { CheckRecalculateMoodThoughts(); for (int i = 0; i < cachedThoughts.Count; i++) { Thought_Situational thought_Situational = cachedThoughts[i]; if (thought_Situational.Active) { outThoughts.Add(thought_Situational); } } }
private void CheckRecalculateMoodThoughts() { int ticksGame = Find.TickManager.TicksGame; if (ticksGame - this.lastMoodThoughtsRecalculationTick < 100) { return; } this.lastMoodThoughtsRecalculationTick = ticksGame; try { this.tmpCachedThoughts.Clear(); for (int i = 0; i < this.cachedThoughts.Count; i++) { this.cachedThoughts[i].RecalculateState(); this.tmpCachedThoughts.Add(this.cachedThoughts[i].def); } List <ThoughtDef> situationalNonSocialThoughtDefs = ThoughtUtility.situationalNonSocialThoughtDefs; int j = 0; int count = situationalNonSocialThoughtDefs.Count; while (j < count) { if (!this.tmpCachedThoughts.Contains(situationalNonSocialThoughtDefs[j])) { Thought_Situational thought_Situational = this.TryCreateThought(situationalNonSocialThoughtDefs[j]); if (thought_Situational != null) { this.cachedThoughts.Add(thought_Situational); } } j++; } this.RecalculateSocialThoughtsAffectingMood(); } finally { } }
public void AppendMoodThoughts(List <Thought> outThoughts) { this.CheckRecalculateMoodThoughts(); for (int i = 0; i < this.cachedThoughts.Count; i++) { Thought_Situational thought_Situational = this.cachedThoughts[i]; if (thought_Situational.Active) { outThoughts.Add(thought_Situational); } } int ticksGame = Find.TickManager.TicksGame; foreach (KeyValuePair <Pawn, CachedSocialThoughts> item in this.cachedSocialThoughtsAffectingMood) { item.Value.lastQueryTick = ticksGame; List <Thought_SituationalSocial> activeThoughts = item.Value.activeThoughts; for (int j = 0; j < activeThoughts.Count; j++) { outThoughts.Add(activeThoughts[j]); } } }