mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 16:47:13 +01:00
## About The Pull Request The overall behaviour of everything should stay the same but the memory & speed of these components has been slightly improved and when you scale that across large plumbing factories you get a substantial improvement. Here's a list of the most noticeable changes along with many others that aren't worth mentioning - Removed vars `use_overlays`, `turn_connects`, `recipient_reagents_holder` - `active` var is now replaced with a proc which simply returns is the machine wrenched or not - `turn_connects` has been removed because all machines have their pipes rotate when the machine is rotated. This also removed all the static icon states ending with `-s` from the `dmi` file thus reducing that file size as well - `extend_pipe_to_edge` var is directly integrated into `cut_overlays()` because it's use cases were limited such for showers & sinks - Simplified `Initialize()` a lot. Removed params `start`, `turn_connects`, `custom_receiver`, `extend_pipe_to_edge`. We now only pass `bolt_layer` making that proc faster & less convoluted - Replaced `set_recipient_reagents_holder()` proc with `recipient_reagents_holder()` which returns the reagent holder for holding reagents instead of storing it in the component. This removes the need to hook a qdel signal on the holder & we don't need to keep track of it - Merged a ton of procs to reduce overhead & reduce file size - Plumbing ducts creating the network at mapload is faster without using recursion and the timer subsystem - Deconstructing plumbing ducts is faster in reconstructing the network without using recursion and the timer subsystem This makes managing plumbing code less convoluted & overall better for the foreseeable future. See the lines of code removed vs added and still preserves behaviour ## Changelog 🆑 qol: added examines & screentips for ducts & stack of ducts qol: you can wrench a stack of ducts on the ground to create a pipe refactor: plumbing code has been improved overall. Report bugs on github sprite: removed unused static(does not rotate with machine) icon states for plumbing connections /🆑 --------- Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
103 lines
4.0 KiB
Plaintext
103 lines
4.0 KiB
Plaintext
/datum/component/plumbing/reaction_chamber
|
|
demand_connects = NORTH
|
|
supply_connects = SOUTH
|
|
|
|
/datum/component/plumbing/reaction_chamber/Initialize(ducting_layer)
|
|
if(!istype(parent, /obj/machinery/plumbing/reaction_chamber))
|
|
return COMPONENT_INCOMPATIBLE
|
|
return ..()
|
|
|
|
/datum/component/plumbing/reaction_chamber/can_give(amount, reagent, datum/ductnet/net)
|
|
. = FALSE
|
|
|
|
var/obj/machinery/plumbing/reaction_chamber/reaction_chamber = parent
|
|
|
|
//cannot give when we outselves are requesting or reacting the reagents
|
|
if(amount <= 0 || !reagents.total_volume || !reaction_chamber.emptying || reagents.is_reacting)
|
|
return
|
|
|
|
//check to see if we can give catalysts only if they are in excess
|
|
var/list/datum/reagent/catalysts = reaction_chamber.catalysts
|
|
for(var/datum/reagent/chemical as anything in reagents.reagent_list)
|
|
if(reagent && chemical.type != reagent)
|
|
continue
|
|
|
|
//we have the exact amounts so no excess to spare
|
|
if(chemical.volume <= (catalysts[chemical.type] || 0))
|
|
if(reagent)
|
|
break
|
|
else
|
|
continue
|
|
|
|
//atleast 1 reagent to give so take whatever
|
|
return TRUE
|
|
|
|
/datum/component/plumbing/reaction_chamber/send_request(dir)
|
|
var/obj/machinery/plumbing/reaction_chamber/chamber = parent
|
|
|
|
if(chamber.emptying)
|
|
return
|
|
|
|
//take in reagents
|
|
var/present_amount
|
|
var/diff
|
|
var/list/datum/reagent/required_reagents = chamber.catalysts | chamber.required_reagents
|
|
for(var/datum/reagent/required_reagent as anything in required_reagents)
|
|
//find how much amount is already present if at all and get the reagent reference
|
|
present_amount = 0
|
|
for(var/datum/reagent/present_reagent as anything in reagents.reagent_list)
|
|
if(required_reagent == present_reagent.type)
|
|
present_amount = present_reagent.volume
|
|
break
|
|
|
|
//compute how much more is needed
|
|
diff = min(required_reagents[required_reagent] - present_amount, MACHINE_REAGENT_TRANSFER)
|
|
if(diff >= CHEMICAL_QUANTISATION_LEVEL) // the closest we can ask for so values like 0.9999 become 1
|
|
process_request(diff, required_reagent, dir)
|
|
if(!chamber.catalysts[required_reagent]) //only block if not a catalyst as they can come in whenever they are available
|
|
return
|
|
|
|
reagents.flags &= ~NO_REACT
|
|
reagents.handle_reactions()
|
|
|
|
chamber.emptying = TRUE //If we move this up, it'll instantly get turned off since any reaction always sets the reagent_total to zero. Other option is make the reaction update
|
|
//everything for every chemical removed, wich isn't a good option either.
|
|
chamber.on_reagent_change(reagents) //We need to check it now, because some reactions leave nothing left.
|
|
if(chamber.emptying) //if we are still emptying then keep checking for reagents until we are emptied out
|
|
chamber.RegisterSignal(reagents, COMSIG_REAGENTS_HOLDER_UPDATED, TYPE_PROC_REF(/obj/machinery/plumbing/reaction_chamber, on_reagent_change))
|
|
|
|
/datum/component/plumbing/buffered
|
|
///The reagent to request into this buffer
|
|
VAR_PROTECTED/datum/reagent/request
|
|
///The buffer meant to store reagents
|
|
VAR_PRIVATE/datum/reagents/buffer
|
|
|
|
/datum/component/plumbing/buffered/Initialize(ducting_layer)
|
|
. = ..()
|
|
buffer = new (maximum = 50, new_flags = NO_REACT)
|
|
buffer.my_atom = parent
|
|
|
|
/datum/component/plumbing/buffered/Destroy()
|
|
QDEL_NULL(buffer)
|
|
return ..()
|
|
|
|
/datum/component/plumbing/buffered/recipient_reagents_holder()
|
|
return buffer
|
|
|
|
/datum/component/plumbing/buffered/send_request(dir)
|
|
process_request(reagent = request, dir = dir)
|
|
|
|
///Special connect that we currently use for reaction chambers. Being used so we can keep certain inputs separate, like into a special internal acid container
|
|
/datum/component/plumbing/buffered/acidic_input
|
|
demand_connects = WEST
|
|
demand_color = COLOR_YELLOW
|
|
ducting_layer = SECOND_DUCT_LAYER
|
|
request = /datum/reagent/reaction_agent/acidic_buffer
|
|
|
|
///Special connect that we currently use for reaction chambers. Being used so we can keep certain inputs separate, like into a special internal base container
|
|
/datum/component/plumbing/buffered/alkaline_input
|
|
demand_connects = EAST
|
|
demand_color = COLOR_VIBRANT_LIME
|
|
ducting_layer = FOURTH_DUCT_LAYER
|
|
request = /datum/reagent/reaction_agent/basic_buffer
|