Temperature Reagent System (#5423)

Overview
This is the github WIP PR for the reagent system project. This is for other developers and users to track progress of the code if they're curious about it, as well as to show that it actually works.
This commit is contained in:
BurgerLUA
2018-11-03 15:17:40 -07:00
committed by Erki
parent 581f9c6153
commit 1b10bb1fe5
39 changed files with 1000 additions and 172 deletions

View File

@@ -7,9 +7,64 @@ var/datum/controller/subsystem/chemistry/SSchemistry
var/list/active_holders = list()
var/list/chemical_reactions
var/list/chemical_reactions_clean = list()
var/list/chemical_reagents
var/tmp/list/processing_holders = list()
/datum/controller/subsystem/chemistry/proc/has_valid_specific_heat(var/datum/reagent/R) //Used for unit tests
if(R.specific_heat > 0)
return TRUE
if(chemical_reagents[R.id].specific_heat > 0) //Don't think this will happen but you never know.
return TRUE
var/datum/chemical_reaction/recipe = find_recipe_by_result(R.id)
if(recipe)
for(var/chem in recipe.required_reagents)
if(!has_valid_specific_heat(chemical_reagents[chem]))
return FALSE
if(R.fallback_specific_heat)
return TRUE
return FALSE
/datum/controller/subsystem/chemistry/proc/check_specific_heat(var/datum/reagent/R)
if(R.specific_heat > 0)
return R.specific_heat
if(chemical_reagents[R.id].specific_heat > 0) //Don't think this will happen but you never know.
return chemical_reagents[R.id].specific_heat
var/datum/chemical_reaction/recipe = find_recipe_by_result(R.id)
if(recipe)
var/final_heat = 0
var/result_amount = recipe.result_amount
for(var/chem in recipe.required_reagents)
var/chem_specific_heat = check_specific_heat(chemical_reagents[chem])
if(!chem_specific_heat)
log_ss("chemistry", "ERROR: [R.type] does not have a specific heat value set, and there is no associated recipe for it! Please fix this by giving it a specific_heat value!")
final_heat += chem_specific_heat * (recipe.required_reagents[chem]/result_amount)
if(final_heat > 0)
chemical_reagents[R.id].specific_heat = final_heat
return final_heat
if(R.fallback_specific_heat)
chemical_reagents[R.id].specific_heat = R.fallback_specific_heat
return R.fallback_specific_heat
log_ss("chemistry", "ERROR: [R.type] does not have a specific heat value set, and there is no associated recipe for it! Please fix this by giving it a specific_heat value!")
chemical_reagents[R.id].specific_heat = 1
return 1
/datum/controller/subsystem/chemistry/proc/find_recipe_by_result(var/result_id)
for(var/key in chemical_reactions_clean)
var/datum/chemical_reaction/CR = chemical_reactions_clean[key]
if(CR.result == result_id && CR.result_amount > 0)
return CR
/datum/controller/subsystem/chemistry/stat_entry()
..("AH:[active_holders.len]")
@@ -46,7 +101,7 @@ var/datum/controller/subsystem/chemistry/SSchemistry
if (MC_TICK_CHECK)
return
/datum/controller/subsystem/chemistry/proc/mark_for_update(var/datum/reagents/holder)
if (holder in active_holders)
return
@@ -122,3 +177,5 @@ var/datum/controller/subsystem/chemistry/SSchemistry
if(!chemical_reactions[reagent_id])
chemical_reactions[reagent_id] = list()
chemical_reactions[reagent_id] += D
if(D.id)
chemical_reactions_clean[D.id] = D