Minor refactor of how gas IDs are handled

This commit is contained in:
duncathan salt
2017-10-11 13:04:12 -06:00
committed by CitadelStationBot
parent 5b4e26cb06
commit c0e9cde5c2
52 changed files with 438 additions and 331 deletions
+4 -4
View File
@@ -31,11 +31,11 @@ GLOBAL_LIST_EMPTY(rad_collectors)
/obj/machinery/power/rad_collector/process()
if(loaded_tank)
if(!loaded_tank.air_contents.gases["plasma"])
if(!loaded_tank.air_contents.gases[/datum/gas/plasma])
investigate_log("<font color='red'>out of fuel</font>.", INVESTIGATE_SINGULO)
eject()
else
loaded_tank.air_contents.gases["plasma"][MOLES] -= 0.001*drainratio
loaded_tank.air_contents.gases[/datum/gas/plasma][MOLES] -= 0.001*drainratio
loaded_tank.air_contents.garbage_collect()
return
@@ -50,7 +50,7 @@ GLOBAL_LIST_EMPTY(rad_collectors)
"<span class='notice'>You turn the [src.name] [active? "on":"off"].</span>")
var/fuel
if(loaded_tank)
fuel = loaded_tank.air_contents.gases["plasma"]
fuel = loaded_tank.air_contents.gases[/datum/gas/plasma]
fuel = fuel ? fuel[MOLES] : 0
investigate_log("turned [active?"<font color='green'>on</font>":"<font color='red'>off</font>"] by [user.key]. [loaded_tank?"Fuel: [round(fuel/0.29)]%":"<font color='red'>It is empty</font>"].", INVESTIGATE_SINGULO)
return
@@ -139,7 +139,7 @@ GLOBAL_LIST_EMPTY(rad_collectors)
/obj/machinery/power/rad_collector/proc/receive_pulse(pulse_strength)
if(loaded_tank && active)
var/power_produced = loaded_tank.air_contents.gases["plasma"] ? loaded_tank.air_contents.gases["plasma"][MOLES] : 0
var/power_produced = loaded_tank.air_contents.gases[/datum/gas/plasma] ? loaded_tank.air_contents.gases[/datum/gas/plasma][MOLES] : 0
power_produced *= pulse_strength*10
add_avail(power_produced)
last_power = power_produced
+10 -10
View File
@@ -284,17 +284,17 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_shard)
if(damage > damage_archived && prob(10))
playsound(get_turf(src), 'sound/effects/empulse.ogg', 50, 1)
removed.assert_gases("o2", "plasma", "co2", "n2o", "n2", "freon")
removed.assert_gases(/datum/gas/oxygen, /datum/gas/plasma, /datum/gas/carbon_dioxide, /datum/gas/nitrous_oxide, /datum/gas/nitrogen, /datum/gas/freon)
//calculating gas related values
combined_gas = max(removed.total_moles(), 0)
plasmacomp = max(removed.gases["plasma"][MOLES]/combined_gas, 0)
o2comp = max(removed.gases["o2"][MOLES]/combined_gas, 0)
co2comp = max(removed.gases["co2"][MOLES]/combined_gas, 0)
plasmacomp = max(removed.gases[/datum/gas/plasma][MOLES]/combined_gas, 0)
o2comp = max(removed.gases[/datum/gas/oxygen][MOLES]/combined_gas, 0)
co2comp = max(removed.gases[/datum/gas/carbon_dioxide][MOLES]/combined_gas, 0)
n2ocomp = max(removed.gases["n2o"][MOLES]/combined_gas, 0)
n2comp = max(removed.gases["n2"][MOLES]/combined_gas, 0)
freoncomp = max(removed.gases["freon"][MOLES]/combined_gas, 0)
n2ocomp = max(removed.gases[/datum/gas/nitrous_oxide][MOLES]/combined_gas, 0)
n2comp = max(removed.gases[/datum/gas/nitrogen][MOLES]/combined_gas, 0)
freoncomp = max(removed.gases[/datum/gas/freon][MOLES]/combined_gas, 0)
gasmix_power_ratio = min(max(plasmacomp + o2comp + co2comp - n2comp - freoncomp, 0), 1)
@@ -348,12 +348,12 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_shard)
removed.temperature = max(0, min(removed.temperature, 2500 * dynamic_heat_modifier))
//Calculate how much gas to release
removed.gases["plasma"][MOLES] += max((device_energy * dynamic_heat_modifier) / PLASMA_RELEASE_MODIFIER, 0)
removed.gases[/datum/gas/plasma][MOLES] += max((device_energy * dynamic_heat_modifier) / PLASMA_RELEASE_MODIFIER, 0)
removed.gases["o2"][MOLES] += max(((device_energy + removed.temperature * dynamic_heat_modifier) - T0C) / OXYGEN_RELEASE_MODIFIER, 0)
removed.gases[/datum/gas/oxygen][MOLES] += max(((device_energy + removed.temperature * dynamic_heat_modifier) - T0C) / OXYGEN_RELEASE_MODIFIER, 0)
if(combined_gas < 50)
removed.gases["freon"][MOLES] = max((removed.gases["freon"][MOLES] + device_energy) * freoncomp / FREON_BREEDING_MODIFIER, 0)
removed.gases[/datum/gas/freon][MOLES] = max((removed.gases[/datum/gas/freon][MOLES] + device_energy) * freoncomp / FREON_BREEDING_MODIFIER, 0)
if(produces_gas)
env.merge(removed)