mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
[MIRROR] Oops, I refactored Chemistry!
This commit is contained in:
committed by
Darlantan
parent
1f33d5696f
commit
ca996648dd
@@ -1,54 +0,0 @@
|
||||
PROCESSING_SUBSYSTEM_DEF(chemistry)
|
||||
name = "Chemistry"
|
||||
wait = 20
|
||||
flags = SS_BACKGROUND|SS_POST_FIRE_TIMING
|
||||
init_order = INIT_ORDER_CHEMISTRY
|
||||
var/list/chemical_reactions = list()
|
||||
var/list/chemical_reactions_by_reagent = list()
|
||||
var/list/chemical_reagents = list()
|
||||
|
||||
/datum/controller/subsystem/processing/chemistry/Recover()
|
||||
log_debug("[name] subsystem Recover().")
|
||||
if(SSchemistry.current_thing)
|
||||
log_debug("current_thing was: (\ref[SSchemistry.current_thing])[SSchemistry.current_thing]([SSchemistry.current_thing.type]) - currentrun: [SSchemistry.currentrun.len] vs total: [SSchemistry.processing.len]")
|
||||
var/list/old_processing = SSchemistry.processing.Copy()
|
||||
for(var/datum/D in old_processing)
|
||||
if(CHECK_BITFIELD(D.datum_flags, DF_ISPROCESSING))
|
||||
processing |= D
|
||||
|
||||
chemical_reactions = SSchemistry.chemical_reactions
|
||||
chemical_reagents = SSchemistry.chemical_reagents
|
||||
|
||||
/datum/controller/subsystem/processing/chemistry/Initialize()
|
||||
initialize_chemical_reactions()
|
||||
initialize_chemical_reagents()
|
||||
..()
|
||||
|
||||
//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.
|
||||
/datum/controller/subsystem/processing/chemistry/proc/initialize_chemical_reactions()
|
||||
var/paths = typesof(/datum/chemical_reaction) - /datum/chemical_reaction
|
||||
chemical_reactions = list()
|
||||
chemical_reactions_by_reagent = list()
|
||||
|
||||
for(var/path in paths)
|
||||
var/datum/chemical_reaction/D = new path
|
||||
chemical_reactions += D
|
||||
if(D.required_reagents && D.required_reagents.len)
|
||||
var/reagent_id = D.required_reagents[1]
|
||||
LAZYINITLIST(chemical_reactions_by_reagent[reagent_id])
|
||||
chemical_reactions_by_reagent[reagent_id] += D
|
||||
|
||||
//Chemical Reagents - Initialises all /datum/reagent into a list indexed by reagent id
|
||||
/datum/controller/subsystem/processing/chemistry/proc/initialize_chemical_reagents()
|
||||
var/paths = typesof(/datum/reagent) - /datum/reagent
|
||||
chemical_reagents = list()
|
||||
for(var/path in paths)
|
||||
var/datum/reagent/D = new path()
|
||||
if(!D.name)
|
||||
continue
|
||||
chemical_reagents[D.id] = D
|
||||
Reference in New Issue
Block a user