Files
Bubberstation/code/datums/elements/death_gases.dm
FinancialGoose e98cb75c57 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
/🆑
2026-04-21 13:43:47 -07:00

37 lines
1.1 KiB
Plaintext

/**
* ## death gases element!
*
* Bespoke element that spawns one type of gas when a mob is killed
*/
/datum/element/death_gases
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 3
///What gas the target spawns when killed
var/datum/gas/gas_type
///The amount of gas spawned on death
var/amount_of_gas
/datum/element/death_gases/Attach(datum/target, datum/gas/gas_type, amount_of_gas = 10)
. = ..()
if(!isliving(target))
return ELEMENT_INCOMPATIBLE
if(!gas_type)
stack_trace("[type] added to [target] with NO GAS TYPE.")
src.gas_type = gas_type
src.amount_of_gas = amount_of_gas
RegisterSignal(target, COMSIG_LIVING_DEATH, PROC_REF(on_death))
/datum/element/death_gases/Detach(datum/target)
. = ..()
UnregisterSignal(target, COMSIG_LIVING_DEATH)
///signal called by the stat of the target changing
/datum/element/death_gases/proc/on_death(mob/living/target, gibbed)
SIGNAL_HANDLER
var/datum/gas_mixture/mix_to_spawn = new()
mix_to_spawn.add_gas(gas_type)
mix_to_spawn.set_gas(gas_type, amount_of_gas)
mix_to_spawn.set_temperature(T20C)
var/turf/open/our_turf = get_turf(target)
our_turf.assume_air(mix_to_spawn)