64 lines
2.2 KiB
Plaintext
64 lines
2.2 KiB
Plaintext
///a reaction chamber for plumbing. pretty much everything can react, but this one keeps the reagents seperated and only reacts under your given terms
|
|
/obj/machinery/plumbing/reaction_chamber
|
|
name = "reaction chamber"
|
|
desc = "Keeps chemicals seperated until given conditions are met."
|
|
icon_state = "reaction_chamber"
|
|
buffer = 200
|
|
reagent_flags = TRANSPARENT | NO_REACT
|
|
|
|
/**list of set reagents that the reaction_chamber allows in, and must all be present before mixing is enabled.
|
|
* example: list(/datum/reagent/water = 20, /datum/reagent/fuel/oil = 50)
|
|
*/
|
|
var/list/required_reagents = list()
|
|
///our reagent goal has been reached, so now we lock our inputs and start emptying
|
|
var/emptying = FALSE
|
|
|
|
/obj/machinery/plumbing/reaction_chamber/Initialize(mapload, bolt)
|
|
. = ..()
|
|
AddComponent(/datum/component/plumbing/reaction_chamber, bolt)
|
|
|
|
/obj/machinery/plumbing/reaction_chamber/on_reagent_change()
|
|
if(reagents.total_volume == 0 && emptying) //we were emptying, but now we aren't
|
|
emptying = FALSE
|
|
reagent_flags |= NO_REACT
|
|
|
|
/obj/machinery/plumbing/reaction_chamber/power_change()
|
|
. = ..()
|
|
if(use_power != NO_POWER_USE)
|
|
icon_state = initial(icon_state) + "_on"
|
|
else
|
|
icon_state = initial(icon_state)
|
|
|
|
/obj/machinery/plumbing/reaction_chamber/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "ChemReactionChamber", name)
|
|
ui.open()
|
|
|
|
/obj/machinery/plumbing/reaction_chamber/ui_data(mob/user)
|
|
var/list/data = list()
|
|
var/list/text_reagents = list()
|
|
for(var/A in required_reagents) //make a list where the key is text, because that looks alot better in the ui than a typepath
|
|
var/datum/reagent/R = A
|
|
text_reagents[initial(R.name)] = required_reagents[R]
|
|
|
|
data["reagents"] = text_reagents
|
|
data["emptying"] = emptying
|
|
return data
|
|
|
|
/obj/machinery/plumbing/reaction_chamber/ui_act(action, params)
|
|
if(..())
|
|
return
|
|
. = TRUE
|
|
switch(action)
|
|
if("remove")
|
|
var/reagent = get_chem_id(params["chem"])
|
|
if(reagent)
|
|
required_reagents.Remove(reagent)
|
|
if("add")
|
|
var/input_reagent = get_chem_id(params["chem"])
|
|
if(input_reagent && !required_reagents.Find(input_reagent))
|
|
var/input_amount = text2num(params["amount"])
|
|
if(input_amount)
|
|
required_reagents[input_reagent] = input_amount
|