Refactor gasmix mole change into a proc (#95327)

## About The Pull Request
Refactor the majority of the current gasmix mole change use cases into a
proc called adjust_gas which simply adds the designated mole count of
the species into the gas mix while also handling asserting the gas and
garbage_collect()
I also added adjust_multiple_gases and convert_gas() for modifying
multiple gases and within a gasmix

## Why It's Good For The Game
Lemon wanted this to be done as part of the air group refactor 

## Changelog

🆑
refactor: refactored majority of gas_mix mole change into adjust_gas()
proc
/🆑
This commit is contained in:
FinancialGoose
2026-04-21 13:43:47 -07:00
committed by GitHub
parent 55366497a3
commit e98cb75c57
30 changed files with 211 additions and 218 deletions
@@ -291,10 +291,9 @@
QDEL_NULL(hotspot)
var/datum/gas_mixture/air = location.air
var/list/gases = air.gases
if (gases[/datum/gas/plasma])
var/scrub_amt = min(30, gases[/datum/gas/plasma][MOLES]) //Absorb some plasma
gases[/datum/gas/plasma][MOLES] -= scrub_amt
if (air.gases[/datum/gas/plasma])
var/scrub_amt = min(30, air.gases[/datum/gas/plasma][MOLES]) //Absorb some plasma
air.adjust_gas(/datum/gas/plasma, -scrub_amt)
absorbed_plasma += scrub_amt
if (air.temperature > T20C)
air.temperature = max(air.temperature / 2, T20C)
@@ -297,11 +297,10 @@
if(!distcheck || get_dist(location, chilly) < blast) // Otherwise we'll get silliness like people using Nanofrost to kill people through walls with cold air
air.temperature = temperature
var/list/gases = air.gases
if(gases[/datum/gas/plasma])
air.assert_gas(/datum/gas/nitrogen)
gases[/datum/gas/nitrogen][MOLES] += gases[/datum/gas/plasma][MOLES]
gases[/datum/gas/plasma][MOLES] = 0
if(air.gases[/datum/gas/plasma])
var/mole_count = air.gases[/datum/gas/plasma][MOLES]
air.adjust_gas(/datum/gas/nitrogen, mole_count)
air.adjust_gas(/datum/gas/plasma, -mole_count)
air.garbage_collect()
for(var/obj/effect/hotspot/fire in chilly)
@@ -44,14 +44,11 @@
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = 1413
second_gasmix.temperature = 141.3
first_gasmix.set_temperature(1413)
second_gasmix.set_temperature(141.3)
first_gasmix.assert_gas(/datum/gas/plasma)
second_gasmix.assert_gas(/datum/gas/oxygen)
first_gasmix.gases[/datum/gas/plasma][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
first_gasmix.set_gas(/datum/gas/plasma, calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1))
second_gasmix.set_gas(/datum/gas/oxygen, calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1))
/obj/effect/spawner/newbomb/tritium
@@ -60,16 +57,13 @@
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = 8000
second_gasmix.temperature = 43
first_gasmix.set_temperature(8000)
second_gasmix.set_temperature(43)
first_gasmix.assert_gas(/datum/gas/plasma)
second_gasmix.assert_gas(/datum/gas/oxygen)
second_gasmix.assert_gas(/datum/gas/tritium)
first_gasmix.set_gas(/datum/gas/plasma, calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1))
first_gasmix.gases[/datum/gas/plasma][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = 0.67 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = 0.33 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.set_gas(/datum/gas/oxygen, 0.67 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1))
second_gasmix.set_gas(/datum/gas/tritium, 0.33 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1))
/obj/effect/spawner/newbomb/isolated_tritium
@@ -78,16 +72,13 @@
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1
second_gasmix.temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1
first_gasmix.set_temperature(FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1)
second_gasmix.set_temperature(FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1)
first_gasmix.assert_gas(/datum/gas/hypernoblium)
first_gasmix.assert_gas(/datum/gas/tritium)
second_gasmix.assert_gas(/datum/gas/oxygen)
first_gasmix.set_gas(/datum/gas/hypernoblium, REACTION_OPPRESSION_THRESHOLD - 0.01,)
first_gasmix.set_gas( /datum/gas/tritium, 0.5 * calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1))
first_gasmix.gases[/datum/gas/hypernoblium][MOLES] = REACTION_OPPRESSION_THRESHOLD - 0.01
first_gasmix.gases[/datum/gas/tritium][MOLES] = 0.5 * calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE-1)
second_gasmix.set_gas(/datum/gas/oxygen, calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE-1))
/obj/effect/spawner/newbomb/noblium
@@ -96,14 +87,11 @@
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = 2.7
second_gasmix.temperature = 2.7
first_gasmix.set_temperature(2.7)
second_gasmix.set_temperature(2.7)
first_gasmix.assert_gas(/datum/gas/nitrogen)
second_gasmix.assert_gas(/datum/gas/tritium)
first_gasmix.gases[/datum/gas/nitrogen][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
first_gasmix.set_gas(/datum/gas/nitrogen, calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1))
second_gasmix.set_gas(/datum/gas/tritium, calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1))
/obj/effect/spawner/newbomb/pressure
@@ -112,11 +100,8 @@
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = 20000
second_gasmix.temperature = 2.7
first_gasmix.set_temperature(20000)
second_gasmix.set_temperature(2.7)
first_gasmix.assert_gas(/datum/gas/hypernoblium)
second_gasmix.assert_gas(/datum/gas/tritium)
first_gasmix.gases[/datum/gas/hypernoblium][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
first_gasmix.set_gas(/datum/gas/hypernoblium, calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1))
second_gasmix.set_gas(/datum/gas/tritium, calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1))