mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-18 13:04:45 +00:00
## About The Pull Request **1. Material container clean-up & refactor** - Replaced `total_amount` var with `total_amount()` proc, this var can be easily computed by summing up all material amounts rather than storing it as a var which is tedious to update & keep track of when materials are added/removed - Removed unused procs `transer_amt_to()`, `can_insert_amount_mat()`, and `get_categories()`. These procs are not used anywhere in the codebase so let's remove them & make some space. - Callbacks are replaced with signals, the callbacks don't need to be explicitly garbage collected & having macros & procs marked with `SIGNAL_HANDLER` makes your intentions more readable & explicit. - Fixes #76151 All material adding, removal, checking operations are "Integer" operations, i.e. the final value is rounded & them made 1 if the final value is 0 using the macro `OPTIMIZE_COST`[coudn't come up with a better name]. No more dealing with decimal value materials The problem was after the protolathe was upgraded with better parts all the design costs were multiplied with a decimal `efficiency_coeff` value, this means even though in the UI the cost was displayed as 60 bluespace crystals its actual cost was `60.0001` something in the backend causing this check for materials to fail & print the error message. - Replaced `GetComponent(/datum/component_material_container)` with just a simple ref to the material container when adding the component, so we can save some overhead from calling this proc - Gave all procs a ton of documentation with documentation having documentation - Fixes #76506 RCD and other devices that uses the silo link upgrade now have the correct material usages - Fixes #72096. It wasn't just a problem with ancient protolathe but with all machines that used `datum/component/remote_materials` the problem was remote materials would add an instance of `datum/remote/material_container` if it wanted to use local storage but this component would get added before `datum/component/remote_materials` could be registered i.e. it comes before remote_materials in the component list. So when the machine is destroyed it will first destroy `material_container` & then `remote_materials` therefore destroying the materials before they could get ejected - Silo link is established when parent is registered with remote materials raher than adding an external timer which is faster - Everything that uses a material container will auto eject their sheets when destroyed - Moved this & remote materials into its own folder for better organization **2. Material UI Changes** - Removed the x25 & x50 print buttons from the autolathe, now they just have x5 & x10 buttons like the protolathe, These buttons were of no use since you could just type the exact amount you want to print in the `[Max: <some amount>]` side bar. The code to compute these buttons was just plain right nasty & some of it unused in the UI. - The material eject button in the material bar does not gray out when you can eject exactly one sheet - All material cost are integer values rounded - Fixes #76253 Exosuit Fabricator sends the material container static data to the UI so its material bar is not greyed out when there are sufficient materials to eject - Component printer material bar sends the material container static data to the UI so its material bar is not greyed out when there are sufficient materials to eject - Autolathe Material bars now display number of sheets available - Max printable amount of items are now computed & updated correctly in the UI. They were displaying wrong values & now get updated when items are printed, materials are removed - Silo hold actually works now. When a machine is put on hold it calls this proce929cf39cd/code/datums/components/remote_materials.dm (L78-L87)Notice how the key is `src` so we should be consistent during checking if a machine is on hold using the same `src` var. But for some reason we did dumb shit like thise929cf39cd/code/datums/components/remote_materials.dm (L150-L153)What is category? Why do we care for the area the machine is in? None of it made sense so i removed all that junk and just made it check for `src` like it should - Removed redundant `removable` & `sheets` var from the material container ui_data. These vars are unused in the UI - If an item does not have the required materials then upon clicking that item you will not get any error message but instead nothing happens ## Changelog 🆑 fix: items can be printed from autolathe & protolathe when the exact material amounts are present in them after upgrading fix: max printable amount now shows the correct value & updates when items are printed, materials are removed in the autolathe & protolathe fix: component printer material bar is not greyed out when there are sufficient materials to eject fix: rcd and other devices that uses the silo link upgrade now have the correct material usages fix: silo hold actually works fix: machines using local storage to hold materials will eject it's materials as sheets when deconstructed/destroyed refactor: Autolathe Material bars now display number of sheets available refactor: printing an item that does not have enough materials will fail silently with no error messages refactor: Drone dispenser will eject sheets upon deconstruction refactor: all things that store materials will auto ejects its sheets(if there is sufficient material) when destroyed refactor: inserting an item into the material container will display the units consumed as sheets not absolute units refactor: removed x25 & x50 print buttons from the autolathe
78 lines
3.5 KiB
Plaintext
78 lines
3.5 KiB
Plaintext
/// Is the material from an ore? currently unused but exists atm for categorizations sake
|
|
#define MAT_CATEGORY_ORE "ore capable"
|
|
|
|
/// Hard materials, such as iron or silver
|
|
#define MAT_CATEGORY_RIGID "rigid material"
|
|
|
|
/// Materials that can be used to craft items
|
|
#define MAT_CATEGORY_ITEM_MATERIAL "item material"
|
|
|
|
///Use this flag on TRUE if you want the basic recipes
|
|
#define MAT_CATEGORY_BASE_RECIPES "basic recipes"
|
|
|
|
/// Used to make a material initialize at roundstart.
|
|
#define MATERIAL_INIT_MAPLOAD (1<<0)
|
|
/// Used to make a material type able to be instantiated on demand after roundstart.
|
|
#define MATERIAL_INIT_BESPOKE (1<<1)
|
|
|
|
/// Makes sure only integer values are used when consuming, removing & checking for mats
|
|
#define OPTIMAL_COST(cost)(max(1, round(cost)))
|
|
|
|
//Material Container Flags.
|
|
///If the container shows the amount of contained materials on examine.
|
|
#define MATCONTAINER_EXAMINE (1<<0)
|
|
///If the container cannot have materials inserted through attackby().
|
|
#define MATCONTAINER_NO_INSERT (1<<1)
|
|
///if the user can insert mats into the container despite the intent.
|
|
#define MATCONTAINER_ANY_INTENT (1<<2)
|
|
///if the user won't receive a warning when attacking the container with an unallowed item.
|
|
#define MATCONTAINER_SILENT (1<<3)
|
|
|
|
// The following flags are for decomposing alloys. Should be expanded upon and diversified once someone gets around to reworking recycling.
|
|
/// Can reduce an alloy into its component materials.
|
|
#define BREAKDOWN_ALLOYS (1<<4)
|
|
/// Makes the material composition include transmuted materials objects
|
|
#define BREAKDOWN_INCLUDE_ALCHEMY (1<<5)
|
|
/// Breakdown flags used by techfabs and circuit printers.
|
|
#define BREAKDOWN_FLAGS_LATHE (BREAKDOWN_ALLOYS)
|
|
/// Breakdown flags used by the ORM.
|
|
#define BREAKDOWN_FLAGS_ORM (BREAKDOWN_ALLOYS)
|
|
/// Breakdown flags used by the recycler.
|
|
#define BREAKDOWN_FLAGS_RECYCLER (BREAKDOWN_ALLOYS)
|
|
/// Breakdown flags used by the sheetifier.
|
|
#define BREAKDOWN_FLAGS_SHEETIFIER (BREAKDOWN_ALLOYS)
|
|
/// Breakdown flags used by the ore processor.
|
|
#define BREAKDOWN_FLAGS_ORE_PROCESSOR (BREAKDOWN_ALLOYS)
|
|
/// Breakdown flags used by the drone dispenser.
|
|
#define BREAKDOWN_FLAGS_DRONE_DISPENSER (BREAKDOWN_ALLOYS)
|
|
/// Breakdown flags used when exporting materials.
|
|
#define BREAKDOWN_FLAGS_EXPORT (NONE)
|
|
|
|
/// Whether a material's mechanical effects should apply to the atom. This is necessary for other flags to work.
|
|
#define MATERIAL_EFFECTS (1<<0)
|
|
/// Applies the material color to the atom's color. Deprecated, use MATERIAL_GREYSCALE instead
|
|
#define MATERIAL_COLOR (1<<1)
|
|
/// Whether a prefix describing the material should be added to the name
|
|
#define MATERIAL_ADD_PREFIX (1<<2)
|
|
/// Whether a material should affect the stats of the atom
|
|
#define MATERIAL_AFFECT_STATISTICS (1<<3)
|
|
/// Applies the material greyscale color to the atom's greyscale color.
|
|
#define MATERIAL_GREYSCALE (1<<4)
|
|
|
|
/// Wrapper for fetching material references. Exists exclusively so that people don't need to wrap everything in a list every time.
|
|
#define GET_MATERIAL_REF(arguments...) SSmaterials._GetMaterialRef(list(##arguments))
|
|
|
|
#define MATERIAL_SOURCE(mat) "[mat.name]_material"
|
|
|
|
///Special return values of [/datum/component/material_container/insert_item]
|
|
#define MATERIAL_INSERT_ITEM_NO_MATS -1
|
|
#define MATERIAL_INSERT_ITEM_NO_SPACE -2
|
|
#define MATERIAL_INSERT_ITEM_FAILURE 0
|
|
|
|
|
|
// Slowdown values.
|
|
/// The slowdown value of one [SHEET_MATERIAL_AMOUNT] of plasteel.
|
|
#define MATERIAL_SLOWDOWN_PLASTEEL (0.05)
|
|
/// The slowdown value of one [SHEET_MATERIAL_AMOUNT] of alien alloy.
|
|
#define MATERIAL_SLOWDOWN_ALIEN_ALLOY (0.1)
|