A preliminary implementation of chem gases

This commit is contained in:
Putnam3145
2021-06-27 07:58:35 -07:00
parent d2dc56123d
commit b213aaec2e
14 changed files with 165 additions and 20 deletions
+14 -4
View File
@@ -15,6 +15,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
/proc/_auxtools_register_gas(datum/gas/gas) // makes sure auxtools knows stuff about this gas
/datum/auxgm
var/done_initializing = FALSE
var/list/datums = list()
var/list/specific_heats = list()
var/list/names = list()
@@ -24,6 +25,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
var/list/ids = list()
var/list/typepaths = list()
var/list/fusion_powers = list()
var/list/turf_reagents = list()
var/list/breathing_classes = list()
var/list/breath_results = list()
var/list/breath_reagents = list()
@@ -36,18 +38,19 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
var/list/fire_products = list()
var/list/fire_burn_rates = list()
/datum/gas
var/id = ""
var/specific_heat = 0
var/name = ""
var/gas_overlay = "" //icon_state in icons/effects/atmospherics.dmi
var/color = "#ffff"
var/moles_visible = null
var/flags = NONE //currently used by canisters
var/fusion_power = 0 // How much the gas destabilizes a fusion reaction
var/breath_results = GAS_CO2 // what breathing this breathes out
var/breath_reagent = null // what breathing this adds to your reagents
var/breath_reagent_dangerous = null // what breathing this adds to your reagents IF it's above a danger threshold
var/datum/reagent/turf_reagent = null
var/datum/reagent/breath_reagent = null // what breathing this adds to your reagents
var/datum/reagent/breath_reagent_dangerous = null // what breathing this adds to your reagents IF it's above a danger threshold
var/list/breath_alert_info = null // list for alerts that pop up when you have too much/not enough of something
var/oxidation_temperature = null // temperature above which this gas is an oxidizer; null for none
var/oxidation_rate = 1 // how many moles of this can oxidize how many moles of material
@@ -87,7 +90,8 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
breath_reagents[g] = gas.breath_reagent
if(gas.breath_reagent_dangerous)
breath_reagents_dangerous[g] = gas.breath_reagent_dangerous
if(gas.turf_reagent)
turf_reagents[g] = gas.turf_reagent
if(gas.oxidation_temperature)
oxidation_temperatures[g] = gas.oxidation_temperature
oxidation_rates[g] = gas.oxidation_rate
@@ -102,6 +106,11 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
fire_enthalpies[g] = gas.fire_energy_released
_auxtools_register_gas(gas)
if(done_initializing)
for(var/r in SSair.gas_reactions)
var/datum/gas_reaction/R = r
R.init_reqs()
SSair.auxtools_update_reactions()
/proc/finalize_gas_refs()
@@ -112,6 +121,7 @@ GLOBAL_LIST_INIT(nonreactive_gases, typecacheof(list(GAS_O2, GAS_N2, GAS_CO2, GA
for(var/breathing_class_path in subtypesof(/datum/breathing_class))
var/datum/breathing_class/class = new breathing_class_path
breathing_classes[breathing_class_path] = class
done_initializing = TRUE
finalize_gas_refs()
@@ -56,17 +56,62 @@
min_requirements = list(GAS_H2O = MOLES_GAS_VISIBLE)
/datum/gas_reaction/water_vapor/react(datum/gas_mixture/air, datum/holder)
var/turf/open/location = isturf(holder) ? holder : null
. = NO_REACTION
var/turf/open/location = holder
if(!istype(location))
return NO_REACTION
if (air.return_temperature() <= WATER_VAPOR_FREEZE)
if(location && location.freon_gas_act())
. = REACTING
return REACTING
else if(location && location.water_vapor_gas_act())
air.adjust_moles(GAS_H2O,-MOLES_GAS_VISIBLE)
. = REACTING
return REACTING
// no test cause it's entirely based on location
/datum/gas_reaction/reagent_stuff
priority = 0
name = "Condensation"
id = "condense"
/datum/gas_reaction/condensation/init_reqs()
var/highest_condensation_temp = -INFINITY
var/list/reagents = GLOB.gas_data.turf_reagents
for(var/gas in reagents)
var/datum/reagent/R = reagents[gas]
highest_condensation_temp = max(highest_condensation_temp, initial(R.boiling_point))
min_requirements = list(
"MAX_TEMP" = highest_condensation_temp,
"ANY_REAGENT" = 1
)
/datum/gas_reaction/condensation/react(datum/gas_mixture/air, datum/holder)
var/turf/open/location = holder
if(!istype(location))
return NO_REACTION
var/list/gas_reagents = GLOB.gas_data.turf_reagents
var/temperature = air.return_temperature()
. = NO_REACTION
var/static/datum/reagents/reagents_holder = new
reagents_holder.clear_reagents()
reagents_holder.chem_temp = temperature
for(var/G in air.get_gases())
if(G in gas_reagents)
var/datum/reagent/R = gas_reagents[G]
if(temperature < initial(R.boiling_point))
var/amt = air.get_moles(G)
air.adjust_moles(G, -min(initial(R.condensation_amount), amt))
reagents_holder.add_reagent(R, amt)
. = REACTING
if(. == REACTING)
for(var/atom/movable/AM in location)
if(location.intact && AM.level == 1) //hidden under the floor
continue
reagents_holder.reaction(AM, TOUCH)
reagents_holder.reaction(location, TOUCH)
//tritium combustion: combustion of oxygen and tritium (treated as hydrocarbons). creates hotspots. exothermic
/datum/gas_reaction/tritfire
priority = -1 //fire should ALWAYS be last, but tritium fires happen before plasma fires