[C#][HugsLib] How to find/change "sub" properties

Started by Mandulis, June 19, 2021, 04:06:46 AM

Previous topic - Next topic

Mandulis

Hello everyone,

Maybe this subject is already discuss on the forum / google, but I'm french and I think I don't have correct key words to find it :/

I already have done some mods (CustomStack) and I know how to find a ThingDef with a specific property :
foreach (ThingDef thingDef in DefDatabase<ThingDef>.AllDefs)
{
if (thingDef.stackLimit > 1)
{
...
}
}


But now, i'm trying to find ThingDef with a property in a sublist, and I don't find how to do. In my case, I'm trying to find all ThingDef which has a <stages><li>baseMoodEffect>0</baseMoodEffect></li></stages>.

Here an example of ThingDef to find :
<ThoughtDef ParentName="DeathMemory">
    <defName>KnowGuestExecuted</defName>
    <durationDays>6</durationDays>
    <nullifyingTraits>
      <li>Psychopath</li>
      <li>Bloodlust</li>
    </nullifyingTraits>
    <stages>
<li>
<label>justified execution</label>
<description>A guilty prisoner or guest was executed. It was justified, but still sad.</description>
<baseMoodEffect>0</baseMoodEffect>
</li>
      <li>
        <label>someone was euthanized</label>
        <!-- generic humane -->
        <description>A prisoner or guest was euthanized. It was humane, but still sad.</description>
        <baseMoodEffect>0</baseMoodEffect>
      </li>
      <li>
        <label>someone was executed</label>
        <!-- generic brutal -->
        <description>A prisoner or guest was killed in cold blood. It seemed a bit evil.</description>
        <baseMoodEffect>0</baseMoodEffect>
      </li>
      <li>
        <label>someone was organ-murdered</label>
        <!-- died because of organ harvesting -->
        <description>A prisoner or guest died because the colony took body parts from him. It's horrible.</description>
        <baseMoodEffect>0</baseMoodEffect>
      </li>
    </stages>
  </ThoughtDef>


Thanks for your help !

RawCode

there is no "data storage magic"

did you typed "stages" in dnspy full assembly search, if not, why?

Mandulis

Many thanks for your help ...
Two points to understand why I was lose :
- I didn't see the difference between ThingDefs and ThoughtDefs
- I didn't read back the tuto (didn't make mods since fews month)

Sorry for the inconvenience

RawCode

probably "full assembly search" and "dnspy" was too hard?

Mandulis

More complicate : beacause I'm french, I have a bad translation of "Thought" ...
And I totally forgot to launch a search with dnspy because I didn't remember this tool.

RawCode

after search you will need to google

c# generics
c# list
c# nested loops

do not search in french, you likely to get random garbage from random people instead of usable articles.

also if you happen to land on very specific site, do not select "french" as language, all docs are english only and all other languages are machine translated garbage