-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIRROR] Improves upon setting custom materials for printed items (#615)
* Improves upon setting custom materials for printed items (#81015) ## About The Pull Request This is an improvement on #80839 regarding how custom materials are set on items, it's based on the following findings. 1. `set_custom_materials()` proc already comes with an prebuilt `multiplier` var https://github.com/tgstation/tgstation/blob/1e8d511946d194f92f744f5f957a7c41683d84a6/code/game/atom/atom_materials.dm#L11 This means we can pass the machine's cost coefficiency directly to this proc rather than creating our own list of materials with their values scaled by the factor like so https://github.com/tgstation/tgstation/blob/1e8d511946d194f92f744f5f957a7c41683d84a6/code/game/machinery/autolathe.dm#L192-L193 We can instead just do `set_custom_materials(design.materials, material_cost_coefficient)` without ever needing this list, thus making code cleaner, with that the changes propogate to how `has_materials()` & `use_materials()` procs are also used as we can now use their `coefficiency` param rather than seeing it go to waste 2. All items custom materials will now always be integer values. With this `SSmaterials.FindOrCreateMaterialCombo` now has better performance because when computing the key for caching values like `1.5` or `1.7` it will become just `1` and will point to the same cache thus reducing memory usage 3. Materials are now uniformly split among all the contents of a printed item from techfab or autolathe. What this means is items like the foam ammo box printed from autolathe will have both the ammo case and their 40 bullets each set with custom materials such that their final sum becomes equal to the design cost. For info on how that's done see the documentation of `split_materials_uniformly` proc. One downside of this proc is when items have a very small amount of `custom_materials`(less than 2). In that case values like `0.8` or `1.5` or `1.7` ends up getting rounded to 1 which means you end up getting less materials when recycling than what you used for printing that item. In this case You get 0.48 iron from both the box & it's ammo instead of 0.79 iron used for printing in tier1 autolathe(Or 0.50 for tier4 autolathe). This shouldn't be an issue as you still can't make any profits from this but at least everything in the box is now recyclable. ## Changelog :cl: fix: items that contain recursive contents inside them (like foam dart boxes from autolathes) now have their custom materials set to match with its design cost rather than being nullified, meaning they are now recyclable. code: all custom materials are now integer values. Improved code for how materials are used in techfab & auto lathe for printing /:cl: * Improves upon setting custom materials for printed items --------- Co-authored-by: SyncIt21 <[email protected]>
- Loading branch information
1 parent
c18c4c3
commit ee7e15d
Showing
5 changed files
with
95 additions
and
42 deletions.
There are no files selected for viewing
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 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 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 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 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