边缘世界 RimWorld

边缘世界 RimWorld

Encounter Baby Animals
Imranfish 7 月 20 日 下午 10:03
Faster Patch Loop
Hello, great mod. I recently added a new ForEachLoop operation to XML Extensions which is much faster than the old ForEach operation.

<?xml version="1.0" encoding="utf-8" ?> <Patch> <Operation Class="XmlExtensions.ForEachLoop"> <xpath>/Defs/ThingDef[@ParentName = "AnimalThingBase"]/race[lifeExpectancy]</xpath> <mode>LocalPatch</mode> <apply> <Operation Class="XmlExtensions.AggregateValues"> <valueOperations> <li Class="XmlExtensions.CreateVariable"> <storeIn>lifeExpectancy0675</storeIn> <value>race/lifeExpectancy</value> <value2>0.675</value2> <fromXml>true</fromXml> <operation>*</operation> </li> <li Class="XmlExtensions.CreateVariable"> <storeIn>lifeExpectancy075</storeIn> <value>race/lifeExpectancy</value> <value2>0.75</value2> <fromXml>true</fromXml> <operation>*</operation> </li> <li Class="XmlExtensions.CreateVariable"> <storeIn>lifeExpectancy0875</storeIn> <value>race/lifeExpectancy</value> <value2>0.875</value2> <fromXml>true</fromXml> <operation>*</operation> </li> <li Class="XmlExtensions.CreateVariable"> <storeIn>lifeExpectancy1</storeIn> <value>race/lifeExpectancy</value> <fromXml>true</fromXml> </li> <li Class="XmlExtensions.CreateVariable"> <storeIn>lifeExpectancy1125</storeIn> <value>race/lifeExpectancy</value> <value2>1.125</value2> <fromXml>true</fromXml> <operation>*</operation> </li> <li Class="XmlExtensions.CreateVariable"> <storeIn>lifeExpectancy125</storeIn> <value>race/lifeExpectancy</value> <value2>1.25</value2> <fromXml>true</fromXml> <operation>*</operation> </li> </valueOperations> <apply> <Operation Class="XmlExtensions.PatchOperationSafeAdd"> <xpath>race</xpath> <value> <ageGenerationCurve> <points> <li>(0,0)</li> <!-- it's the start of the curve (default value is 0.05*lifeExpectancy) --> <li>(0.001,100)</li> <!-- it allow babies to spawn (default value is 0.1*lifeExpectancy) --> <li>({lifeExpectancy0675},100)</li> <!-- For this line and following, you need to do first value*lifeExpectancy of the Animal (0.675*15 for Mufallo) --> <li>({lifeExpectancy075},30)</li> <li>({lifeExpectancy0875},18)</li> <li>({lifeExpectancy1},10)</li> <li>({lifeExpectancy1125},3)</li> <li>({lifeExpectancy125},0)</li> </points> </ageGenerationCurve> </value> </Operation> </apply> </Operation> </apply> </Operation> </Patch>

If you use this patch, it should make your mod many times faster since it will not need to do a costly xpath lookup for each of the
CreateVariable
or the
PatchOperationSafeAdd
operations. The speedup will be larger the more mods a user has loaded. The
AggregateValues
was added just to reduce nesting.
< >
正在显示第 1 - 1 条,共 1 条留言
Yoann  [开发者] 7 月 26 日 上午 6:41 
Thank you! I updated the mod.
< >
正在显示第 1 - 1 条,共 1 条留言
每页显示数: 1530 50