Fix building names in research unlocks
Closes #11328
Changes proposed in this pull request
- The building names in the research unlocks no longer use separated translation keys, instead opting to grab them directly through the ResearchEffect instance.
- To achieve this I've started utilizing the ModResearchEffects appropriately, by introducing new registry entries, and dynamically constructing an
IResearchEffectbased on the registry type.- I've consolidated the
ModResearchEffectandModResearchEffectInitializer, simliar to other registries.
- I've consolidated the
- Repurposed the
"effect": truefield to define the effect type, with fallback code that if the value is still true, it will refer the "global" effect type (for datapacks) - Building effect types simply refer to the building ID, which will then be used in the
getName()method. - Modified the
IResearchEffectto returnComponentsin favor ofTranslatableContents, so each effect can independently choose how they go about constructing the name. - Modified the
CITIZENCAPresearch effect to get it's ownIResearchEffectinstance, to cope with the special condition of being based on the citizen limit configuration. This way we can remove the technical debt in the window code with that explicit condition over there, this way it's a little more dynamic. - Datagenned the research files anew, to update them to the new JSON structure
Testing
- [X] Yes I tested this before submitting it.
- [ ] I also did a multiplayer test.
Review please
This breaks all research datapacks right?
No, there's fallback logic, if "effect": true is still detected it always generates a GlobalResearchEffect
I feel like a new effect type for this is overkill. Can't we just in the data define an optional "translationkey"? That we then load for "Unlocks %s" ? If not present, we go for the default key atm.
The problem is with GlobalResearchEffect there's no possible way to add other translation fields into the TranslatableContents, it only ever takes the original 4 arguments. The entire logic behind the class is different.
At least this thing was already a registry and made it so it could support multiple implementations, we just never made use of it until now.
Will this still support third-party buildings from other mods?
Will this still support third-party buildings from other mods?
Yes, the translation string can't be modified, so it'll always say "Unlocks %s", but it'll always cope with whatever the current building name is.