shpaass / yafc-ce

Powerful Factorio calculator/analyser that works with mods
GNU General Public License v3.0
54 stars 20 forks source link

More options for fixed amounts #240

Closed DaleStan closed 1 month ago

DaleStan commented 1 month ago

I've seen a few requests for this on Discord; e.g. "How do I force a recipe to run at a specific amount in YAFC? I want to eat 4.4 Auogs per second." and possibly "I would like to set one [electricity production line each] for biomass, oil and coal."

This allows you to directly set fixed fuel consumption, fixed ingredient consumption, or fixed product production, instead of having to set that indirectly via the fixed building count. Only one item per row may be fixed at any given time. A fixed fuel consumption will be cleared if you change to a crafter that uses a different fuel source (e.g. a burner furnace to an electric furnace). Other than that, changing the crafter, fuel, modules, or beacons will adjust the rest of the row to preserve the specified fixed amount, the same as it currently works for the fixed building amount.

There's a new button on the dropdowns, labeled "Set fixed description": image Once selected, the fixed amount can be configured as usual: image The button on that item will change to "Clear fixed ...", and the corresponding buttons on other items in the row will transfer configuration of the row's fixed amount to that item.

shpaass commented 1 month ago

It's a great change, but since it's a Model change, we will need some tests.

Ideally, in-model unit-tests. Passably, playtests.

What testing was conducted for this PR?

DaleStan commented 1 month ago

Play tests:

I would have caught the Automated factory issues with my planned unit tests, but they're going to take a while to implement. The UI is doing too many calculations right now. One of the first steps for making unit tests meaningful is removing expressions like recipe.recipesPerSecond * product.GetAmount(recipe.parameters.productivity) from the UI.