Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Mandulis

#1
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 !
#2
Hello everyone,

I just start modding, and I'm trying to done a mod that remove all emote (like sleepZ, heart, ...).
I know how to do it with only xml (just change the <texPath> value by Things/Mote/Transparent). But I want to add settings to the mod, so I try to do it with C#.

I read some links on the wiki, and I think I should use DefModExtension. Below, my code :

XML :
<?xml version="1.0" encoding="utf-8" ?>

<Patch>
<Operation Class="PatchOperationReplace">
<xpath>/Defs/ThingDef[@ParentName = "MoteBase"]/graphicData</xpath>
<value>
<graphicData Class="NoMote.NoMoteTest">
<texPath>Things/Mote/Transparent</texPath>
</graphicData>
</value>
</Operation>
</Patch>


C# :
using Verse;
namespace NoMote
{
    public class NoMoteTest : DefModExtension
    {
        public string texPath = "Things/Mote/Transparent";
    }
}


Unfortunately, I'm doing something wrong, because I have this error code :
Exception loading from System.Xml.XmlElement: System.InvalidCastException: Specified cast is not valid.
  at (wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)

Can someone please explain my mistake ? (And maybe correct it ?)

Many thanks (and sorry for english mistakes, it's not my mother tong)