Files
Bubberstation/code/modules/plumbing/plumbers/splitters.dm
SyncIt21 49e4a8bc19 Plumbing RCD Refactors (#77563)
## About The Pull Request
- Removed the `category` var from all plumbing machinery, now all the
designs are organized by category in a single static list(1 list for
each plumbing rcd type). This makes it easy to add new designs to 1 list
in the future and since the list is static memory is saved when multiple
plumbing RCDs are made in game
- Removed redundant `machinery_data` list. This list simply stored the
cost of designs from the `plumbing_designs` list. Rather than wasting
memory with this list we can derive the cost from `plumbing_designs`
list ourselves
- Removed unused list `choices`. No idea what that did back then
- When low on ammo the plumbing RCD would display multiple balloon
alerts. That's fixed now
- Made the icon sizes of designs in the UI slightly smaller so they
don't clip and look blurry

## Changelog
🆑
fix: multiple balloon alerts when the plumbing RCD is low on ammo
code: organized all plumbing designs into static lists for memory
savings
refactor: removed unused vars for further memory savings
/🆑
2023-08-15 09:29:07 -07:00

52 lines
1.8 KiB
Plaintext

///it splits the reagents however you want. So you can "every 60 units, 45 goes left and 15 goes straight". The side direction is EAST, you can change this in the component
/obj/machinery/plumbing/splitter
name = "chemical splitter"
desc = "A chemical splitter for smart chemical factorization. Waits till a set of conditions is met and then stops all input and splits the buffer evenly or other in two ducts."
icon_state = "splitter"
active_power_usage = BASE_MACHINE_ACTIVE_CONSUMPTION * 2
buffer = 100
density = FALSE
///constantly switches between TRUE and FALSE. TRUE means the batch tick goes straight, FALSE means the next batch goes in the side duct.
var/turn_straight = TRUE
///how much we must transfer straight. note input can be as high as 10 reagents per process, usually
var/transfer_straight = 5
///how much we must transfer to the side
var/transfer_side = 5
//the maximum you can set the transfer to
var/max_transfer = 9
/obj/machinery/plumbing/splitter/Initialize(mapload, bolt, layer)
. = ..()
AddComponent(/datum/component/plumbing/splitter, bolt, layer)
/obj/machinery/plumbing/splitter/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "ChemSplitter", name)
ui.open()
/obj/machinery/plumbing/splitter/ui_data(mob/user)
var/list/data = list()
data["straight"] = transfer_straight
data["side"] = transfer_side
data["max_transfer"] = max_transfer
return data
/obj/machinery/plumbing/splitter/ui_act(action, params)
. = ..()
if(.)
return
. = TRUE
switch(action)
if("set_amount")
var/direction = params["target"]
var/value = clamp(text2num(params["amount"]), 1, max_transfer)
switch(direction)
if("straight")
transfer_straight = value
if("side")
transfer_side = value
else
return FALSE