-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Adding salt water pipe and tannery to workshop version 2 #55026
Merged
kevingranade
merged 11 commits into
CleverRaven:master
from
PatrikLundell:salt_water_pipe_project
Feb 3, 2022
Merged
Adding salt water pipe and tannery to workshop version 2 #55026
kevingranade
merged 11 commits into
CleverRaven:master
from
PatrikLundell:salt_water_pipe_project
Feb 3, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is gorgeous. |
Maleclypse
added
Map / Mapgen
Overmap, Mapgen, Map extras, Map display
Player Faction Base / Camp
All about the player faction base/camp/site
labels
Feb 2, 2022
github-actions
bot
added
the
json-styled
JSON lint passed, label assigned by github actions
label
Feb 2, 2022
Spell checker encountered unrecognized words in the in-game text added in this pull request. See below for details. Click to expand
This alert is automatically generated. You can simply disregard if this is inaccurate, or (optionally) you can also add the new words to |
github-actions
bot
added
the
astyled
astyled PR, label is assigned by github actions
label
Feb 2, 2022
github-actions
bot
added
the
BasicBuildPassed
This PR builds correctly, label assigned by github actions
label
Feb 3, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
astyled
astyled PR, label is assigned by github actions
BasicBuildPassed
This PR builds correctly, label assigned by github actions
json-styled
JSON lint passed, label assigned by github actions
Map / Mapgen
Overmap, Mapgen, Map extras, Map display
Player Faction Base / Camp
All about the player faction base/camp/site
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.
Summary
Features "Added salt water pipe feature and applied it to camp workshop version 2"
Purpose of change
Provides the functionality requested by #54419
Describe the solution
Code has been added to find the shortest path to a swamp and then enable recipes to construct them. The code makes use of a common blueprint base (referenced by the code) for the pipe and swamp sections that the code then rotates as needed to simulate the burying of a pipe from the swamp to the expansion.
Expansion specific recipes use (some of) the common blueprints as "normal" construction recipes with hand calculated construction costs (as the blueprints contain only the end result, not the simulated work before that), and construction recipes that invoke those blueprints are intercepted by the code to implement the functionality.
When the first recipe (starting the project) is invoked, the code calculates how many tiles the pipe would have to cover, and enable the construction of the corresponding segments (the recipes have to exist as expansion specific ones), allowing the construction to be performed in parallel with multiple segments under construction concurrently.
Once all pieces of the simulated pipe has been constructed the recipe dependency logic enables the construction of the expansion part of the pipe plus a new salt water pump that, once constructed, produces unlimited amounts of salt water (the tile has to be painted with a basecamp supplies zone to be accessible for camp crafting). Since there is no way to switch the salt water supply on or off, the pump section isn't allowed to be constructed until all the other parts are in place.
The simulated work is to dig a row of pits, bury a pipe, and then fill up the pits again, resulting in a line of dirt ground tiles as the end result. The swamp end has a covered salt water well that's supposed to represent filtering the salt water so water reasonably free of blocking solids can be drawn through the pipe. The covered salt water well and the salt water pump are new tiles looking like their normal counterparts and they don't have any player accessible construction recipes as they don't really make sense to be constructed outside of a project like this.
There the code makes use of the mirroring and rotation direction conditional flags of the recipe starting off the project to determine which tile, relative to the expansion, the pipe should attach to the expansion itself, allowing an expansion to rotate the connection direction depending on its location relative to the base camp. I think the logic used and hard coded dependencies required are sufficiently documented in the expansion specific recipe file (recipe_modular_workshop_salt_water_pipe) using the work around for JSON's removed support for comments, and that this should be sufficient for others to add the functionality to their expansions if desired.
The simulated pipe is buried at index 12 for horizontal and vertical orientations. This allows it to connect to an expansion index of 11 and 12 (and 13, but 11 and 12 are mirrored indices, allowing for connection to a mirrored expansion with either index).
The simulated pipe is allowed to cross forest, field, and road terrain, and obviously has to start in a swamp. The code provides feedback if it turns out it isn't possible to construct the pipe (because there is no path through valid terrain to a swamp within reach, or the path is too long).
Edit: Forced to make completely unrelated removal of some unused constants elsewhere as demanded by the code validation. Someone apparently pushed these rejects into Master without checking/bothering about the code validation...
Turns out this is/was/will be fixed by #55035, so we'll see if this results in "conflicts"...
Describe alternatives you've considered
Testing
Lots of failures in getting the functionality to work..
Edit: Forgot the save/load part...
After adding the missing parts it was tested by loading a pre-changed save copy, saving it, loading it adding a workshop 2 expansion, saving, loading, starting the salt pipe project, saving, loading continuing with the salt pipe project a bit more, saving/loading, finishing the pipe part of the project (the pump doesn't interact with the new code), saving/loading.
Obviously, this was after a fair bit of hair pulling while the game crashed, saved data failed to load, etc., and the associated bugs were finally found and squashed.
Additional context
The expansion Tannery built out of wood with its furniture and the salt water pipe leading up to a covered salt water well in the swamp:
The Tannery made out of wattle-and-daub (the pipe and furniture were tested in the previous session):
The Tannery made out of stone:
The Tannery made out of rammed earth:
The Tannery made out of mi-go resin:
The Tannery made out of metal:
The Tannery made out of logs:
The Tannery made out of concrete:
Finally back to the pipe, now from expansion N (with a mi-go resin Tannery) leading to the same swap well:
Here's the prompt you get when starting the project. If you back out you can restart the project (The Tannery has already been constructed):
Here's the menu for the expansion after starting the initial (swamp) part. Note that you've got 5 different segments available for construction:
And here's where all of them have been constructed. The pipe ends in the same tile as previously, but the screen isn't wide enough to show it:
We've constructed the Tannery, but when trying to construct the pipe we're told we can't build it (it would have to be constructed in water), so we'll have to bring salt water the old fashioned way to make use of the Tannery (and yes, the construction project does not appear again):
The SE expansion, this time the pipe disappears to a different swamp tile, closer to this location:
...with the end being shown here:
The S expansion, with the pipe disappearing to the same swamp tile as the previous one:
The world map as seen from the base camp without any expansions, to give a sense of where the pipes should go:
The SW expansion again goes towards the swamp tile to the north:
As does the W expansion:
And finally, a pipe from a different camp that goes around a Camp and cuts up a road: