I'm working on a moods dashboard and one of the things I want to list are all the mood-affecting thoughts aggregated across all colonists. I've found how to get the list of mood-affecting thoughts (I don't have the code in front on me right now but it's something like Pawn.needs.mood.ThoughtsAffectingMood). The problem is that whenever I try to get the label to display I get an error in the debug console in-game related to being unable to get the label. I've tried all the fields on the Thought class and none of them appear to contain the display name that is shown in the Needs tab for a colonist (the list under the Mood bar on the right side of the Needs tab).
Does anyone have any idea how to get the display label? I'm also interested in grabbing the tooltip and the mood modifier for each thought.
I've figured out a bit more about how the Thought system works so I figured I'd add a reply in case someone is searching for info in the future.
Thoughts appear to be organized into Thought Groups. Thought Groups appear to be doing two different things at once. This unfortunately makes working with them in code a mess; or else I don't understand something about how they are supposed to work.
First, thought groups are containers for related thoughts in series where only one is active at once (referred to as the "current stage"). An example of this is "Cold" (-5 mood) and "Freezing" (-10 mood). They both share a Thought Group, but a pawn only ever has one of these Thoughts at a time. However, there is nothing I can find that would prevent a pawn from having both of these at once...which would mess up the mood calculations if I am interpreting the code correctly (more on that below).
The second use of Thought Groups is for accumulating multiple instances of the same thought, which may or may not have a reduced mood impact for multiple instances. An example of this is when you see "Disturbed Sleep x4". There are four separate, distinct Thoughts on that pawn, all with the same details but no formal way to see that they are the "same thought". They are in the same thought group and thus the mood calculation uses all of them.
The impact of Thought Groups being used for these two, seemingly separate things is that there does not appear to be anything preventing misuse of the system. I'm not talking about exploiting it, more that unintended side-effects can crop up. If, for example, a pawn was given both a "Cold" and "Freezing" thought, the UI would correctly display only the "Freezing" thought in the list since it's "stage" is higher than the stage for "Cold", but the mood calculation would use BOTH of their mood adjustment values, resulting in an incorrect mood adjustment.
It seems to me that Thought Groups should be separated into two different mechanisms; one for tracking the stages of related thoughts (e.g. Cold -> Hot) such that a pawn cannot have multiple conflicting thought stages at once and another, separate mechanism for stacking thoughts that are the same (and thus including a formal mechanism to identify that two thoughts are the same, which would also be very useful when aggregating data across pawns).
"Cold" and "Freezing" are both different stages of the same ThoughtDef. They are handled by ThoughtWorkers in the game's code.
Quote from: JaxelT on August 25, 2016, 11:54:02 PM
"Cold" and "Freezing" are both different stages of the same ThoughtDef. They are handled by ThoughtWorkers in the game's code.
Yes, this is one thing I was trying to convey. I probably should have clarified that a "Thought Group" is represented by sharing the same ThoughtDef.