Allow independent toggling of Space Age crafting machines #264
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Currently, for Space Age, the calculator does a somewhat odd grouping of crafting machines and imposes an ordering on them, and you can only select the "maximum" machine. This produces strange results when you select assembling machine 3 for example, which also enables cryogenics plants, which normally would get unlocked much later (on reaching Aquilo).
But the notion of ordering itself here is not great; you could go to different planets in different orders and therefore unlock biochambers or foundries at different times. And the machines have some caveats; biochambers need nutrients, and foundries need calcite, so you may not want to use them in some cases where you have them unlocked.
Solution
This changes the building settings to use the old method for assemblers, smelters, and drills, but moves the rest into an "advanced buildings" section where each building is individually toggled on and off. This allows much more flexible and natural customization, such as disabling biochambers but allowing cryogenics.
Design
Because the underlying system of building groups itself was somewhat flawed, I had to rework it. Previously, building groups are merged if any building shares any recipe category with any building of another group. This ensures that each building is in each group only once. Now, each recipe category forms its own building group, and a building can be in multiple groups. When setting a preferred building, all relevant groups are found and the building is set as preferred in each.
This doesn't work very well for the settings page, however, so that is reworked to show groups for specific categories:
crafting
(assemblers),smelting
(furnaces),basic-solids
(drills); these work just as before, though (with the caveat mentioned above of getting set in each relevant building groups).metallurgy
,organic
,electromagnetics
,cryogenics
; any machine with these is thrown into the "Advanced building" selector section. Because preferred building selection should happen both on selecting and deselecting a building, selecting works as with the buildings above, but deselecting finds the building one step down in each group and sets that as preferred. This approach may not work well if groups have more overlap then they do now, but currently it seems to work fine.Testing
I've played around with this under the Space Age setting a fair bit, and everything seems to work fine. I've also tried loading the other data sets and confirmed that settings look as expected, but have not exhaustively verified that everything still works.
Example
Fixes #253