-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
basecamps: add support for automatic calculation of blueprint ingredients #31209
basecamps: add support for automatic calculation of blueprint ingredients #31209
Conversation
jenkins rebuild |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty cool.
I may have missed something in get_changed_ids_from_update()
as I'm not too familiar with the map/mapgen code, but the rest of it looks good to me. No awesome ways to make things way faster/cleaner came to mind while reading this, though I'll continue to cogitate on it.
Mostly minor suggestions, sorry that the review is a little disorganized/out of order.
9ea675f
to
cc9c484
Compare
thanks for the review, changes made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, I swung by for round 2
cc9c484
to
cd2b7aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
basecamps should be able to autocalculate their upgrade build time and requirements. For that to happen, all common terrain constructions need to have a construction definition, but some constructions, like deep and shallow pits, are not meant to be selectable by the user. add the concept of a hidden construction, and add definitions for the shallow pit and deep pit construction.
add a new "blueprint_autocalculate" field to blueprint recipes. When it is present, recipe::finalize calls a function that: 1. calls a mapgen_update function that creates a tinymap of dirt, applies the blueprint mapgen_update to that tinymap, and then returns maps of all the non-dirt ter_ids and furn_ids to their respective counts. 2. then passes those maps to function in construction that takes all those ter_ids/furn_ids, finds the construction(s) that result in those ids, and then returns a map of requirement_ids to counts of those requirements. 3. those requirements are then added to the reqs_internal and resolved normally. 4. one more function then eliminates any duplicated tools or qualities and consolidates similar components.
cd2b7aa
to
277c63e
Compare
Summary
SUMMARY: Infrastructure "basecamps: add support for automatic calculation of blueprint ingredients"
Purpose of change
Part of #31115
Add a way to have construction blueprints calculate their resource requirements from the underlying construction tasks. Doing this makes it easier to add new basecamp upgrades, since you don't have to figure out how long it takes to build things, and guarantees that basecamp construction requirements will stay in sync with any changes to construction.json.
Describe the solution
Create construction definitions for the shallow pit and deep pit, but add a new "on_display" keyword to constructions and set it to false for those pits. Constructions with
"on_display": false
are never displayed to the player and cannot be constructed.add a new "blueprint_autocalculate" field to blueprint recipes. When it is present, recipe::finalize calls a function that:
Describe alternatives you've considered
This was extremely complicated to write. I tried to optimize it with some std:: functions, but got confused and wrote it as simple and stupid as I could. Better optimization suggestions would be appreciated.
Additional context
Part of #31115