Skip to content
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

Conversation

PatrikLundell
Copy link
Contributor

@PatrikLundell PatrikLundell commented Feb 2, 2022

Summary

Features "Added salt water pipe feature and applied it to camp workshop version 2"

Purpose of change

Provides the functionality requested by #54419

  • Add salt water pump connected to swamp to camp expansion
  • Make use of it in base camp expansion workshop 2 with the addition of a tannery and tanning recipes.

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

  • Figuring out how to dynamically construct blueprints so pipes could use angles other than multiples of 45 degrees.
  • Using more of the logic from the remote defense constructions to have the cost of the changes be dynamic, in particular to have diagonal construction cost more. However, I don't think that system works well with the desire enable multiple parallel projects to speed up the construction time.
  • Have the salt water pipe go to the Canteen (version 2) instead. That was the original implementation, with a switch to the Workshop being done after everything worked, with the (re)testing below performed.

Testing

Lots of failures in getting the functionality to work..

  • Apart from that, construction of the expansion in all possible positions and verifying that the resultant pipe was constructed in the correct way, leading to logical destinations.
  • Constructed the new expansion building in all materials once.
  • Constructed the new expansion building in all orientations and verified that the sample building was rotated. Given that the new building was constructed as a copy-paste of an existing one, modified, and then copied to the other material files to have the relevant parts replaced (4 in each file) that should be sufficient.
  • Verified that the new hide related crafting recipes recipes become available once the salt water pump has been constructed.
  • Verified that salt water becomes available after the salt water pump has been constructed and been made available through a supplies zone. Had a hide tanned using the recipes (although the actual test was done in an earlier iteration where the same things were hooked up to the Canteen rather than the Workshop).

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:
Screenshot (186)

The Tannery made out of wattle-and-daub (the pipe and furniture were tested in the previous session):
Screenshot (187)

The Tannery made out of stone:
Screenshot (188)

The Tannery made out of rammed earth:
Screenshot (189)

The Tannery made out of mi-go resin:
Screenshot (190)

The Tannery made out of metal:
Screenshot (191)

The Tannery made out of logs:
Screenshot (192)

The Tannery made out of concrete:
Screenshot (193)

Finally back to the pipe, now from expansion N (with a mi-go resin Tannery) leading to the same swap well:
Screenshot (195)

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):
Screenshot (196)

Here's the menu for the expansion after starting the initial (swamp) part. Note that you've got 5 different segments available for construction:
Screenshot (197)

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:
Screenshot (198)

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):
Screenshot (199)

The SE expansion, this time the pipe disappears to a different swamp tile, closer to this location:
Screenshot (200)

...with the end being shown here:
Screenshot (201)

The S expansion, with the pipe disappearing to the same swamp tile as the previous one:
Screenshot (202)

The world map as seen from the base camp without any expansions, to give a sense of where the pipes should go:
Screenshot (203)

The SW expansion again goes towards the swamp tile to the north:
Screenshot (204)

As does the W expansion:
Screenshot (206)

And finally, a pipe from a different camp that goes around a Camp and cuts up a road:
Screenshot (207)

@Maleclypse
Copy link
Member

This is gorgeous.

@Maleclypse 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 github-actions bot added the json-styled JSON lint passed, label assigned by github actions label Feb 2, 2022
@github-actions
Copy link
Contributor

github-actions bot commented 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
  • The nineth continuation section of the salt water pipe.
  • This functionality cannot be constructed as no validpath to a swamp has been found with a maximum length (20 tiles) at a maximum range of 10 tiles. Supported terrain is forest, field, and road. This recipe will now be removed from the set of available recipes and won't show up again.

This alert is automatically generated. You can simply disregard if this is inaccurate, or (optionally) you can also add the new words to tools/spell_checker/dictionary.txt so they will not trigger an alert next time.

@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Feb 2, 2022
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 3, 2022
@kevingranade kevingranade merged commit 267e6a5 into CleverRaven:master Feb 3, 2022
@PatrikLundell PatrikLundell deleted the salt_water_pipe_project branch February 4, 2022 07:39
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants