Object redeclaration

Started by avilmask, October 03, 2016, 09:10:39 AM

Previous topic - Next topic

avilmask

I started to learn making MODs, and everything concerning XML is pretty easy. But one thing kept bothering me all they way I was reading manuals and sources of MODS. And looks like it's a main issue, which causes most MOD incompatibilities and compatibility patches. Is lack of object self-redeclaration. It means you can't redeclare the same object with the same name, inheriting all object's properties, and modify only one-two of properties. For example, EPOE redeclared all vanilla prosthetic recipes under "VanillaSurgery" abstract group, as well as all items. And I, myself, tried to add a vanilla simple prosthetics to machining table under special research. I had to make a "full" declare of simple prosthetics, which automatically makes my mod incompatible with any other mods that had to do the same, but for different reason. It's quite wide issue, and I'm sure a lot of MODers already thought about that, and suggestion was made long time ago, maybe even not once. Is there something essential I don't understand? Is it hard to invent for some reason?

Dingo

I don't think this is as big of an issue as you present. EPOE just does things really badly when it comes to inheritance and it used a bad workaround up to 1.82. Check my unofficial 1.83 in the EPOE thread to see what I'm talking about. You should also read up on abstract bases and inheritance in XML.

avilmask


avilmask

Still the same thing.
- we have EPOE. It rewrites Simple Prosthetic Arm with it's own;
- we add EPOE Realistic Medical System. At makes full declaration of all bodyparts to add "states". Means it rewrites existing body parts, doesn't "add" or "replace" new properties to existing ones;
- when we add Improved Surgery. It adds <workerClass>Recipe_InstallNaturalBodyPart_Fix</workerClass> basically to all body parts, but with all other properties vanilla parts use. Obviously it will not be fully compatible with EPOE, but at last vanilla body parts should. But they aren't. Instead Improved Surgery replaces them with its own.
- so we need "Patches". What we see in patches? We see fully declared bodyparts, which include changes from both mods.
- and for Realistic Medical System we require a separate patch, because it replaces bodyparts with it's own, doesn't just "add" features.

That's what I meant. There're really too much copypaste with little variation. It could be avoided by MyClass = class(MyClass) construction, which allows to keep current state of an object, except those properties you define later.

Something like that:
<RecipeDef ParentName="SurgeryFlesh">
<defName>InstallNaturalHeart</defName>
<!-- all default properties -->
</RecipeDef>

...

<RecipeDef ParentName="InstallNaturalHeart">
<defName>InstallNaturalHeart</defName>
<!-- the same name means it reintroducing itself with the same properties -->
<workerClass>Recipe_InstallNaturalBodyPart_Fix</workerClass>
</RecipeDef>


This may make compatibility much easier to keep without Patches.

Dingo

You're describing what CCL already does. And this is probably the worst example because it has about 20 variables, relates to a complex thingdef/recipedef and includes mods that aren't structured perfectly like EPOE/RMS.

avilmask

#5
Oh, so that's basically I just choose a bad set of MODs to learn. I thought getting biggest non-DLL MODS will be a good idea, but looks like I missed :)

Thank you for your response!