Implementing XML heddiff into C# code

Started by CrazyMalk, November 02, 2017, 02:40:52 PM

Previous topic - Next topic

CrazyMalk

Hello, i'm a newbie to C#, and would like some help, please :P
I created a custom Heddiff using XML, and using C# i followed jecrell's tutorial.
But, instead of using Plague, like the tutorial used, i wanted to use my own heddiff. How can i implement it into the Visual Studio project?

Varisha

What did you try so far and what seems not to work?

CrazyMalk

It gives me the following error:
Error CS0117 'HediffWithComps' does not contain a definition for 'HediffWithComps_Petrification'

I tried using IlSpy to look into "Plague" so that i could copy the code but change "plague" for my new Heddiff DefName, it did not work.
I tried looking into Jecrell "Sanity Loss" in C# and changing it's Def Names to mine, but it did not work.
I honestly don't know what i can do to make my project read my custom XML and would like to know how to do that :P

Thanks in advance.

Varisha

Can you paste your xml here.
Basically the c# class is linked via the class in the xml definition.

CrazyMalk

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

  <HediffDef Name="FantasyDiseaseBase" Abstract="True">
    <hediffClass>HediffWithComps</hediffClass>
    <defaultLabelColor>(0.8, 0.8, 0.35)</defaultLabelColor>
  </HediffDef>

<HediffDef ParentName="FantasyDiseaseBase">
    <defName>Fantasy.HediffWithComps_Petrification</defName>
    <label>petrification</label>
<hediffClass>Fantasy.HediffWithComps_Petrification</hediffClass>
    <makesSickThought>false</makesSickThought>
    <tendable>true</tendable>
    <comps>
      <li Class="HediffCompProperties_TendDuration">
        <tendDuration>10000</tendDuration>
        <severityPerDayTended>-0.40</severityPerDayTended>
      </li>
      <li Class="HediffCompProperties_Immunizable">
        <immunityPerDayNotSick>-0.5</immunityPerDayNotSick>
        <immunityPerDaySick>0.3</immunityPerDaySick>
        <severityPerDayNotImmune>0</severityPerDayNotImmune>
        <severityPerDayImmune>-0</severityPerDayImmune>
      </li>
    </comps>
    <stages>
      <li>
        <minSeverity>0.001</minSeverity>
    <hungerRateFactor>0</hungerRateFactor>
    <restFallFactor>0</restFallFactor>
        <label>petrified</label>
        <capMods>
          <li>
            <capacity>Consciousness</capacity>
            <offset>-0.9</offset>
          </li>
          <li>
            <capacity>Manipulation</capacity>
            <offset>-1</offset>
          </li>
  <li>
            <capacity>Moving</capacity>
            <offset>-1</offset>
          </li>
  <li>
            <capacity>Hearing</capacity>
            <offset>-1</offset>
          </li>
  <li>
            <capacity>Talking</capacity>
            <offset>-1</offset>
          </li>
  <li>
            <capacity>Sight</capacity>
            <offset>-1</offset>
          </li>
        </capMods>
      </li>
    </stages>
  </HediffDef>
 
</Defs>


Here it is. Any tips?