Ludeon Forums

RimWorld => Mods => Help => Topic started by: Mandulis on June 19, 2021, 04:06:46 AM

Title: [C#][HugsLib] How to find/change "sub" properties
Post by: Mandulis on June 19, 2021, 04:06:46 AM
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 !
Title: Re: [C#][HugsLib] How to find/change "sub" properties
Post by: RawCode on June 21, 2021, 07:52:13 AM
there is no "data storage magic"

did you typed "stages" in dnspy full assembly search, if not, why?
Title: Re: [C#][HugsLib] How to find/change "sub" properties
Post by: Mandulis on June 21, 2021, 08:35:53 AM
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
Title: Re: [C#][HugsLib] How to find/change "sub" properties
Post by: RawCode on June 21, 2021, 09:28:40 AM
probably "full assembly search" and "dnspy" was too hard?
Title: Re: [C#][HugsLib] How to find/change "sub" properties
Post by: Mandulis on June 21, 2021, 09:42:09 AM
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.
Title: Re: [C#][HugsLib] How to find/change "sub" properties
Post by: RawCode on June 21, 2021, 12:53:11 PM
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