mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-01-05 23:13:06 +00:00
Revert "Un-kevinzes nanoui and chemistry subsystems back into processes for greater good"
This commit is contained in:
@@ -12,27 +12,24 @@
|
||||
my_atom = A
|
||||
|
||||
//I dislike having these here but map-objects are initialised before world/New() is called. >_>
|
||||
if(!chemical_reagents_list)
|
||||
if(!SSchemistry.chemical_reagents)
|
||||
//Chemical Reagents - Initialises all /datum/reagent into a list indexed by reagent id
|
||||
var/paths = typesof(/datum/reagent) - /datum/reagent
|
||||
chemical_reagents_list = list()
|
||||
SSchemistry.chemical_reagents = list()
|
||||
for(var/path in paths)
|
||||
var/datum/reagent/D = new path()
|
||||
if(!D.name)
|
||||
continue
|
||||
chemical_reagents_list[D.id] = D
|
||||
SSchemistry.chemical_reagents[D.id] = D
|
||||
|
||||
/datum/reagents/Destroy()
|
||||
. = ..()
|
||||
if(chemistryProcess)
|
||||
chemistryProcess.active_holders -= src
|
||||
|
||||
STOP_PROCESSING(SSchemistry, src)
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
qdel(R)
|
||||
reagent_list.Cut()
|
||||
reagent_list = null
|
||||
if(my_atom && my_atom.reagents == src)
|
||||
my_atom.reagents = null
|
||||
return ..()
|
||||
|
||||
/* Internal procs */
|
||||
|
||||
@@ -80,15 +77,14 @@
|
||||
return
|
||||
|
||||
/datum/reagents/proc/handle_reactions()
|
||||
if(chemistryProcess)
|
||||
chemistryProcess.mark_for_update(src)
|
||||
START_PROCESSING(SSchemistry, src)
|
||||
|
||||
//returns 1 if the holder should continue reactiong, 0 otherwise.
|
||||
/datum/reagents/proc/process_reactions()
|
||||
/datum/reagents/process()
|
||||
if(QDELETED(my_atom)) //No container, no reaction.
|
||||
return 0
|
||||
return PROCESS_KILL
|
||||
if(my_atom.flags & NOREACT) // No reactions here
|
||||
return 0
|
||||
return PROCESS_KILL
|
||||
|
||||
var/reaction_occured
|
||||
var/list/effect_reactions = list()
|
||||
@@ -98,7 +94,7 @@
|
||||
|
||||
//need to rebuild this to account for chain reactions
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
eligible_reactions |= chemical_reactions_list[R.id]
|
||||
eligible_reactions |= SSchemistry.chemical_reactions[R.id]
|
||||
|
||||
for(var/datum/chemical_reaction/C in eligible_reactions)
|
||||
if(C.can_happen(src) && C.process(src))
|
||||
@@ -114,7 +110,8 @@
|
||||
C.post_reaction(src)
|
||||
|
||||
update_total()
|
||||
return reaction_occured
|
||||
if(!reaction_occured)
|
||||
return PROCESS_KILL
|
||||
|
||||
/* Holder-to-chemical */
|
||||
|
||||
@@ -136,7 +133,7 @@
|
||||
if(my_atom)
|
||||
my_atom.on_reagent_change()
|
||||
return 1
|
||||
var/datum/reagent/D = chemical_reagents_list[id]
|
||||
var/datum/reagent/D = SSchemistry.chemical_reagents[id]
|
||||
if(D)
|
||||
var/datum/reagent/R = new D.type()
|
||||
reagent_list += R
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
|
||||
data["bottleSpritesAmount"] = list(1, 2, 3, 4) //how many bottle sprites there are. Sprites are taken from chemical.dmi and can be found in nano/images/pill.png
|
||||
|
||||
ui = GLOB.nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "chem_master.tmpl", src.name, 575, 400)
|
||||
ui.set_initial_data(data)
|
||||
@@ -282,7 +282,7 @@
|
||||
else if(href_list["bottle_sprite"])
|
||||
bottlesprite = href_list["bottle_sprite"]
|
||||
|
||||
GLOB.nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/chem_master/attack_ai(mob/user as mob)
|
||||
return src.attack_hand(user)
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
//Chemical Reagents - Initialises all /datum/reagent into a list indexed by reagent id
|
||||
/proc/initialize_chemical_reagents()
|
||||
var/paths = typesof(/datum/reagent) - /datum/reagent
|
||||
chemical_reagents_list = list()
|
||||
for(var/path in paths)
|
||||
var/datum/reagent/D = new path()
|
||||
if(!D.name)
|
||||
continue
|
||||
chemical_reagents_list[D.id] = D
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
|
||||
//Chemical Reactions - Initialises all /datum/chemical_reaction into a list
|
||||
// It is filtered into multiple lists within a list.
|
||||
// For example:
|
||||
// chemical_reaction_list["phoron"] is a list of all reactions relating to phoron
|
||||
// Note that entries in the list are NOT duplicated. So if a reaction pertains to
|
||||
// more than one chemical it will still only appear in only one of the sublists.
|
||||
/proc/initialize_chemical_reactions()
|
||||
var/paths = typesof(/datum/chemical_reaction) - /datum/chemical_reaction
|
||||
chemical_reactions_list = list()
|
||||
|
||||
for(var/path in paths)
|
||||
var/datum/chemical_reaction/D = new path()
|
||||
if(D.required_reagents && D.required_reagents.len)
|
||||
var/reagent_id = D.required_reagents[1]
|
||||
if(!chemical_reactions_list[reagent_id])
|
||||
chemical_reactions_list[reagent_id] = list()
|
||||
chemical_reactions_list[reagent_id] += D
|
||||
|
||||
//helper that ensures the reaction rate holds after iterating
|
||||
//Ex. REACTION_RATE(0.3) means that 30% of the reagents will react each chemistry tick (~2 seconds by default).
|
||||
#define REACTION_RATE(rate) (1.0 - (1.0-rate)**(1.0/PROCESS_REACTION_ITER))
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
. = ..()
|
||||
if(spawn_reagent)
|
||||
reagents.add_reagent(spawn_reagent, volume)
|
||||
var/datum/reagent/R = chemical_reagents_list[spawn_reagent]
|
||||
var/datum/reagent/R = SSchemistry.chemical_reagents[spawn_reagent]
|
||||
setLabel(R.name)
|
||||
|
||||
/obj/item/weapon/reagent_containers/chem_disp_cartridge/examine(mob/user)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/client/proc/spawn_chemdisp_cartridge(size in list("small", "medium", "large"), reagent in chemical_reagents_list)
|
||||
/client/proc/spawn_chemdisp_cartridge(size in list("small", "medium", "large"), reagent in SSchemistry.chemical_reagents)
|
||||
set name = "Spawn Chemical Dispenser Cartridge"
|
||||
set category = "Admin"
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
if("medium") C = new /obj/item/weapon/reagent_containers/chem_disp_cartridge/medium(usr.loc)
|
||||
if("large") C = new /obj/item/weapon/reagent_containers/chem_disp_cartridge(usr.loc)
|
||||
C.reagents.add_reagent(reagent, C.volume)
|
||||
var/datum/reagent/R = chemical_reagents_list[reagent]
|
||||
var/datum/reagent/R = SSchemistry.chemical_reagents[reagent]
|
||||
C.setLabel(R.name)
|
||||
log_admin("[key_name(usr)] spawned a [size] reagent container containing [reagent] at ([usr.x],[usr.y],[usr.z])")
|
||||
|
||||
@@ -55,12 +55,12 @@
|
||||
C.loc = src
|
||||
cartridges[C.label] = C
|
||||
cartridges = sortAssoc(cartridges)
|
||||
GLOB.nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/chemical_dispenser/proc/remove_cartridge(label)
|
||||
. = cartridges[label]
|
||||
cartridges -= label
|
||||
GLOB.nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/chemical_dispenser/attackby(obj/item/weapon/W, mob/user)
|
||||
if(W.is_wrench())
|
||||
@@ -106,7 +106,7 @@
|
||||
user.drop_from_inventory(RC)
|
||||
RC.loc = src
|
||||
to_chat(user, "<span class='notice'>You set \the [RC] on \the [src].</span>")
|
||||
GLOB.nanomanager.update_uis(src) // update all UIs attached to src
|
||||
SSnanoui.update_uis(src) // update all UIs attached to src
|
||||
|
||||
else
|
||||
return ..()
|
||||
@@ -140,7 +140,7 @@
|
||||
data["chemicals"] = chemicals
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = GLOB.nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "chem_disp.tmpl", ui_title, 390, 680)
|
||||
ui.set_initial_data(data)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
process_tick = 15
|
||||
. = 0
|
||||
for(var/id in dispense_reagents)
|
||||
var/datum/reagent/R = chemical_reagents_list[id]
|
||||
var/datum/reagent/R = SSchemistry.chemical_reagents[id]
|
||||
if(!R)
|
||||
crash_with("[src] at [x],[y],[z] failed to find reagent '[id]'!")
|
||||
dispense_reagents -= id
|
||||
@@ -25,7 +25,7 @@
|
||||
C.reagents.add_reagent(id, to_restore)
|
||||
. = 1
|
||||
if(.)
|
||||
GLOB.nanomanager.update_uis(src)
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/chemical_dispenser
|
||||
dispense_reagents = list(
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
for(var/T in reagent_ids)
|
||||
reagent_volumes[T] = volume
|
||||
var/datum/reagent/R = chemical_reagents_list[T]
|
||||
var/datum/reagent/R = SSchemistry.chemical_reagents[T]
|
||||
reagent_names += R.name
|
||||
|
||||
START_PROCESSING(SSobj, src)
|
||||
@@ -112,14 +112,14 @@
|
||||
if(t)
|
||||
playsound(loc, 'sound/effects/pop.ogg', 50, 0)
|
||||
mode = t
|
||||
var/datum/reagent/R = chemical_reagents_list[reagent_ids[mode]]
|
||||
var/datum/reagent/R = SSchemistry.chemical_reagents[reagent_ids[mode]]
|
||||
usr << "<span class='notice'>Synthesizer is now producing '[R.name]'.</span>"
|
||||
|
||||
/obj/item/weapon/reagent_containers/borghypo/examine(mob/user)
|
||||
if(!..(user, 2))
|
||||
return
|
||||
|
||||
var/datum/reagent/R = chemical_reagents_list[reagent_ids[mode]]
|
||||
var/datum/reagent/R = SSchemistry.chemical_reagents[reagent_ids[mode]]
|
||||
|
||||
user << "<span class='notice'>It is currently producing [R.name] and has [reagent_volumes[reagent_ids[mode]]] out of [volume] units left.</span>"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user