XML Patch Not Working

Started by Silt, November 11, 2018, 01:59:22 PM

Previous topic - Next topic

Silt

Hello,
I try to give Stone Chunks a StuffCategory, but when I try to add stuffProps to the ChunkBase via Patch

<stuffProps>
  <categories>
    <li>Chunky</li>
  </categories>
</stuffProps>

or a color to the Chunks

<stuffProps>
  <color>(105,95,97)</color>
</stuffProps>

it gives Errors, except if put it directly in the Core File. Overwriting it with Defs or Patches gives those Errors:
Could not execute post-long-event action. Exception: System.InvalidOperationException: Operation is not valid due to the current state of the object
  at System.Linq.Enumerable.First[ThingDef] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
  at RimWorld.GenStuff.DefaultStuffFor (Verse.BuildableDef bd) [0x00000] in <filename unknown>:0
  at Verse.ThingDef.ResolveIcon () [0x00000] in <filename unknown>:0
  at Verse.BuildableDef.<PostLoad>m__0 () [0x00000] in <filename unknown>:0
  at Verse.LongEventHandler.ExecuteToExecuteWhenFinished () [0x00000] in <filename unknown>:0
Verse.Log:Error(String, Boolean)
Verse.LongEventHandler:ExecuteToExecuteWhenFinished()
Verse.LongEventHandler:UpdateCurrentAsynchronousEvent()
Verse.LongEventHandler:LongEventsUpdate(Boolean&)
Verse.Root:Update_Patch1(Object)
Verse.Root_Entry:Update()

and
Could not execute post-long-event action. Exception: System.InvalidOperationException: Operation is not valid due to the current state of the object
  at System.Linq.Enumerable.First[ThingDef] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
  at RimWorld.GenStuff.DefaultStuffFor (Verse.BuildableDef bd) [0x00000] in <filename unknown>:0
  at RimWorld.Designator_Build.ResetStuffToDefault () [0x00000] in <filename unknown>:0
  at RimWorld.Designator_Build..ctor (Verse.BuildableDef entDef) [0x00000] in <filename unknown>:0
  at Verse.DesignationCategoryDef.ResolveDesignators () [0x00000] in <filename unknown>:0
  at Verse.DesignationCategoryDef.<ResolveReferences>m__0 () [0x00000] in <filename unknown>:0
  at Verse.LongEventHandler.ExecuteToExecuteWhenFinished () [0x00000] in <filename unknown>:0
Verse.Log:Error(String, Boolean)
Verse.LongEventHandler:ExecuteToExecuteWhenFinished()
Verse.LongEventHandler:UpdateCurrentAsynchronousEvent()
Verse.LongEventHandler:LongEventsUpdate(Boolean&)
Verse.Root:Update_Patch1(Object)
Verse.Root_Entry:Update()

If I insert it directly into Various_Stone.xml, it works flawlessly. Even tough I don't think the problem is within my patching, here is the relevant part of it. The other patches work as expected:

<Operation Class="PatchOperationAdd">
  <order>Append</order>
  <xpath>*/ThingDef[@Name="ChunkBase"]</xpath>
  <value>
    <stuffProps>
      <categories>
        <li>Chunky</li>
      </categories>
    </stuffProps>
  </value>
</Operation>

<Operation Class="PatchOperationAdd">
  <order>Append</order>
  <xpath>*/ThingDef[defName="ChunkSandstone"]</xpath>
  <value>
    <stuffProps>
      <color>(126,104,94)</color>
    </stuffProps>
  </value>
</Operation>

I would appreciate any help,
Thanks!

AileTheAlien

Does it work if you do only one of the patches? The only thing I can see, is that you're adding stuffProps in both patches, and that's causing some problem? You could try commenting out one of your patches, or putting both the categories tag and the color tag into the same stuffProps tag, in a single patch.

Silt

Sorry, I was being Stupid. Thanks anyways