You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<OperationClass="[YOUR C# MOD NAMESPACE].PatchOperationAddOrReplace">
<xpath>/Defs/ThingDef[defName="Plant_TreeBirch"]/plant</xpath>
<key>growDays</key>
<value>22</value>
</Operation>
The class you need to add to your C# code
usingSystem;usingSystem.Collections;usingSystem.Xml;usingVerse;namespace[INSERTYOUR MOD NAMESPACE HERE]{/* * A custom patch operation to simplify sequence patch operations when defensively adding fields * Code by Lanilor (https://github.com/Lanilor) * This code is provided "as-is" without any warrenty whatsoever. Use it on your own risk. */publicclassPatchOperationAddOrReplace: PatchOperationPathed
{protectedstringkey;privateXmlContainervalue;protectedoverrideboolApplyWorker(XmlDocumentxml){XmlNodevalNode=value.node;boolresult=false;IEnumeratorenumerator=xml.SelectNodes(xpath).GetEnumerator();try{while(enumerator.MoveNext()){objectobj=enumerator.Current;result=true;XmlNodeparentNode=objasXmlNode;XmlNodexmlNode=parentNode.SelectSingleNode(key);if(xmlNode==null){// Add - Add node if not existingxmlNode=parentNode.OwnerDocument.CreateElement(key);parentNode.AppendChild(xmlNode);}else{// Replace - Clear existing childrenxmlNode.RemoveAll();}// (Re)add valuexmlNode.AppendChild(parentNode.OwnerDocument.ImportNode(valNode.FirstChild,true));}}finally{IDisposabledisposable=enumeratorasIDisposable;if(disposable!=null){disposable.Dispose();}}returnresult;}}}