Whats is the <intricate> tag used for in some items

Started by QuantumX, September 02, 2018, 09:05:02 AM

Previous topic - Next topic

QuantumX

So i was updating my mod and noticed the <intricate> tag in ComponentIndustrial and ComponentSpacer vanilla items

Anybody know what this is for?

RawCode

intricate tag used in two places
CacheAccessibleThings
and
SmeltProducts

rest you can find on your own.

Kyuiki

#2
Quote from: QuantumX on September 02, 2018, 09:05:02 AM
So i was updating my mod and noticed the <intricate> tag in ComponentIndustrial and ComponentSpacer vanilla items

Anybody know what this is for?
Hey! I'm going to actually try to give you a proper response, since the previous one was probably purposefully vague. I will contain my thoughts and feelings towards such responses though, since there is a question to be answered!

I'll be honest, I've just started exploring RimWorld (as a modder -- 1100 hours playing the game!) but I'm a pretty quick learner and I think I've figured out the purpose of this tag.

So to answer your question, the obvious use of <intricate> is to override the default smelting logic that returns a % of the resources used in the recipe to create the product. If left just as that, the product would return nothing when smelted. But in combination with <smeltProducts> you can define a static list of resources to be returned, and they could be completely different than what was used in the recipe to create the product. If you defined a <smeltProducts> on a non-<intricate> product that has a recipe, it appears you would get both the % of resources from the recipe used to create the product as well as the resources defined in <smeltProducts>. Thus the need for <intricate> -- to avoid getting both the % of the resources the recipe would return as well as the resources defined in <smeltProducts>.

Now the big question is, since both the ComponentIndustrial and ComponentSpacer ThingDef's aren't smeltable, what's the point? Well it looks like there is some type of caching method that is called and stores all of the return and adjusted return lists for accessible and smeltable items, as well as other items, and this tag, for these specific items, is simply telling that method to not cache them, since they're not designed to give back resources. My guess is it's performance optimization related. What effect would you see if you remove the tag? I'm guessing nothing noticeable functionality wise.

You can explore the code yourself if you're curious -- maybe you'll see something that I missed. Just download a .NET Assembly Decompiler such as ILSpy, dnSpy, etc. and search for a "field" named "intricate" which matches the "tag" named "intricate" in the XML files. Once you find that field, you can analyze what accesses it, and you'll find the two methods that was posted previously by RawCode. From there you can diagnose what the code is doing.

Hopefully this answered your question

RawCode

Quotepurposefully vague

for a very good reason, also you missed "suggestion" to just remove that tag and check what will change.

actually this is most entertaining way to discover things, not as fast and accurate as reading source but still viable, especially if you have no source at hand or unable to read it properly.