Skip to content
This repository has been archived by the owner on Sep 17, 2018. It is now read-only.

Patch Method #1

Closed
ghost opened this issue May 26, 2017 · 7 comments
Closed

Patch Method #1

ghost opened this issue May 26, 2017 · 7 comments

Comments

@ghost
Copy link

ghost commented May 26, 2017

"PatchOperationSequence will perform each operation in its list in sequence, aborting if an operation fails."

So what you do is check for a StuffedFloors def as the first step in the sequence (using PatchOperationTest), and then if it succeeds, it continues the sequence which removes every single def defined in the DesignationCategoryDefs and TerrainDefs folder. If it fails, it does not do that.

@cuproPanda
Copy link
Owner

I'll try it again, but I'm pretty sure I've already tried this and it either always removes the defs with or without the other mod, or throws an error upon fail.

@ghost
Copy link
Author

ghost commented May 26, 2017

I'm working with ZorbaTHut atm and I think I'll have a solution to you shortly.

@ghost
Copy link
Author

ghost commented May 26, 2017

So here's the problem: xml patches are evaluated on a per-file basis. But there's a workaround.

namespace STN
{
  class PatchOperationCheckForStuffed : PatchOperation
  {
    public override bool ApplyWorker(XmlDocument xml)
    {
      return ModsConfig.ActiveModsInLoadOrder.Any(mod => mod.meta.name == "Stuffed Floors");
    }
  }
}
<Operation Class="PatchOperationSequence">
 <success>Always</success>
 <operations>
  <li Class="STN.PatchOperationCheckForStuffed"></li>
  <li Class="PatchOperationRemove">
   <xpath>//TerrainDef[DefName = "TileClaystone"]</xpath>
  </li>
 </operations>
</Operation>

I have not tried to compile it yet, but this should be a step in the right direction.

@cuproPanda
Copy link
Owner

This is seriously awesome. It seems so obvious now, just override the ApplyWorker. Thank you!

@ghost
Copy link
Author

ghost commented May 26, 2017

Supposedly it's supposed to be 'mode.name' and not 'mod.meta.name' but you probably figured that out.

@ghost
Copy link
Author

ghost commented May 26, 2017

PMed you something important on the Ludeon forum, you should read it before finishing up your update.

@cuproPanda
Copy link
Owner

PMs go straight to my inbox, so I knew. Thank you, though, that's very important to know for the patches. Even after making my first patch I noticed a significant slowdown.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant