mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-17 02:54:44 +01:00
[MIRROR] filters can now filter multiple gases at once [MDB IGNORE] (#8914)
* filters can now filter multiple gases at once (#62177) * filters can now filter multiple gases at once Co-authored-by: Ghilker <42839747+Ghilker@users.noreply.github.com>
This commit is contained in:
@@ -226,6 +226,24 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache())
|
||||
garbage_collect(list(gas_id))
|
||||
return removed
|
||||
|
||||
/datum/gas_mixture/proc/remove_specific_ratio(gas_id, ratio)
|
||||
if(ratio <= 0)
|
||||
return null
|
||||
ratio = min(ratio, 1)
|
||||
|
||||
var/list/cached_gases = gases
|
||||
var/datum/gas_mixture/removed = new type
|
||||
var/list/removed_gases = removed.gases //accessing datum vars is slower than proc vars
|
||||
|
||||
removed.temperature = temperature
|
||||
ADD_GAS(gas_id, removed.gases)
|
||||
removed_gases[gas_id][MOLES] = QUANTIZE(cached_gases[gas_id][MOLES] * ratio)
|
||||
cached_gases[gas_id][MOLES] -= removed_gases[gas_id][MOLES]
|
||||
|
||||
garbage_collect(list(gas_id))
|
||||
|
||||
return removed
|
||||
|
||||
///Distributes the contents of two mixes equally between themselves
|
||||
//Returns: bool indicating whether gases moved between the two mixes
|
||||
/datum/gas_mixture/proc/equalize(datum/gas_mixture/other)
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
///Rate of transfer of the gases to the outputs
|
||||
var/transfer_rate = MAX_TRANSFER_RATE
|
||||
///What gas are we filtering
|
||||
var/filter_type = null
|
||||
///What gases are we filtering, by typepath
|
||||
var/list/filter_type = list()
|
||||
///Frequency id for connecting to the NTNet
|
||||
var/frequency = 0
|
||||
///Reference to the radio datum
|
||||
@@ -87,24 +87,21 @@
|
||||
return
|
||||
|
||||
var/filtering = TRUE
|
||||
if(!ispath(filter_type))
|
||||
if(filter_type)
|
||||
filter_type = gas_id2path(filter_type) //support for mappers so they don't need to type out paths
|
||||
else
|
||||
filtering = FALSE
|
||||
if(!filter_type.len)
|
||||
filtering = FALSE
|
||||
|
||||
if(filtering && removed.gases[filter_type])
|
||||
var/datum/gas_mixture/filtered_out = new
|
||||
if(!filtering)
|
||||
return
|
||||
|
||||
filtered_out.temperature = removed.temperature
|
||||
filtered_out.add_gas(filter_type)
|
||||
filtered_out.gases[filter_type][MOLES] = removed.gases[filter_type][MOLES]
|
||||
var/datum/gas_mixture/filtered_out = new
|
||||
|
||||
removed.gases[filter_type][MOLES] = 0
|
||||
removed.garbage_collect()
|
||||
for(var/gas in removed.gases & filter_type)
|
||||
var/datum/gas_mixture/removing = removed.remove_specific_ratio(gas, 1)
|
||||
if(removing)
|
||||
filtered_out.merge(removing)
|
||||
|
||||
var/datum/gas_mixture/target = (air2.return_pressure() < MAX_OUTPUT_PRESSURE ? air2 : air1) //if there's no room for the filtered gas; just leave it in air1
|
||||
target.merge(filtered_out)
|
||||
var/datum/gas_mixture/target = (air2.return_pressure() < MAX_OUTPUT_PRESSURE ? air2 : air1) //if there's no room for the filtered gas; just leave it in air1
|
||||
target.merge(filtered_out)
|
||||
|
||||
air3.merge(removed)
|
||||
|
||||
@@ -127,10 +124,9 @@
|
||||
data["max_rate"] = round(MAX_TRANSFER_RATE)
|
||||
|
||||
data["filter_types"] = list()
|
||||
data["filter_types"] += list(list("name" = "Nothing", "path" = "", "selected" = !filter_type))
|
||||
for(var/path in GLOB.meta_gas_info)
|
||||
var/list/gas = GLOB.meta_gas_info[path]
|
||||
data["filter_types"] += list(list("name" = gas[META_GAS_NAME], "id" = gas[META_GAS_ID], "selected" = (path == gas_id2path(filter_type))))
|
||||
data["filter_types"] += list(list("name" = gas[META_GAS_NAME], "gas_id" = gas[META_GAS_ID], "enabled" = (path in filter_type)))
|
||||
|
||||
return data
|
||||
|
||||
@@ -154,14 +150,17 @@
|
||||
if(.)
|
||||
transfer_rate = clamp(rate, 0, MAX_TRANSFER_RATE)
|
||||
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", INVESTIGATE_ATMOS)
|
||||
if("filter")
|
||||
filter_type = null
|
||||
var/filter_name = "nothing"
|
||||
var/gas = gas_id2path(params["mode"])
|
||||
if(gas in GLOB.meta_gas_info)
|
||||
filter_type = gas
|
||||
filter_name = GLOB.meta_gas_info[gas][META_GAS_NAME]
|
||||
investigate_log("was set to filter [filter_name] by [key_name(usr)]", INVESTIGATE_ATMOS)
|
||||
if("toggle_filter")
|
||||
if(!gas_id2path(params["val"]))
|
||||
return TRUE
|
||||
filter_type ^= gas_id2path(params["val"])
|
||||
var/change
|
||||
if(gas_id2path(params["val"]) in filter_type)
|
||||
change = "added"
|
||||
else
|
||||
change = "removed"
|
||||
var/gas_name = GLOB.meta_gas_info[gas_id2path(params["val"])][META_GAS_NAME]
|
||||
investigate_log("[key_name(usr)] [change] [gas_name] from the filter type.", INVESTIGATE_ATMOS)
|
||||
. = TRUE
|
||||
update_appearance()
|
||||
|
||||
@@ -218,136 +217,136 @@
|
||||
icon_state = "filter_on-0"
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/n2
|
||||
name = "nitrogen filter"
|
||||
filter_type = "n2"
|
||||
filter_type = list(/datum/gas/nitrogen)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/o2
|
||||
name = "oxygen filter"
|
||||
filter_type = "o2"
|
||||
filter_type = list(/datum/gas/oxygen)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/co2
|
||||
name = "carbon dioxide filter"
|
||||
filter_type = "co2"
|
||||
filter_type = list(/datum/gas/carbon_dioxide)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/n2o
|
||||
name = "nitrous oxide filter"
|
||||
filter_type = "n2o"
|
||||
filter_type = list(/datum/gas/nitrous_oxide)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/plasma
|
||||
name = "plasma filter"
|
||||
filter_type = "plasma"
|
||||
filter_type = list(/datum/gas/plasma)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/bz
|
||||
name = "bz filter"
|
||||
filter_type = "bz"
|
||||
filter_type = list(/datum/gas/bz)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/freon
|
||||
name = "freon filter"
|
||||
filter_type = "freon"
|
||||
filter_type = list(/datum/gas/freon)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/halon
|
||||
name = "halon filter"
|
||||
filter_type = "halon"
|
||||
filter_type = list(/datum/gas/halon)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/healium
|
||||
name = "healium filter"
|
||||
filter_type = "healium"
|
||||
filter_type = list(/datum/gas/healium)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/h2
|
||||
name = "hydrogen filter"
|
||||
filter_type = "hydrogen"
|
||||
filter_type = list(/datum/gas/hydrogen)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/hypernoblium
|
||||
name = "hypernoblium filter"
|
||||
filter_type = "nob"
|
||||
filter_type = list(/datum/gas/hypernoblium)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/miasma
|
||||
name = "miasma filter"
|
||||
filter_type = "miasma"
|
||||
filter_type = list(/datum/gas/miasma)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/no2
|
||||
name = "nitryl filter"
|
||||
filter_type = "no2"
|
||||
filter_type = list(/datum/gas/nitryl)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/pluoxium
|
||||
name = "pluoxium filter"
|
||||
filter_type = "pluox"
|
||||
filter_type = list(/datum/gas/pluoxium)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/proto_nitrate
|
||||
name = "proto-nitrate filter"
|
||||
filter_type = "proto_nitrate"
|
||||
filter_type = list(/datum/gas/proto_nitrate)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/stimulum
|
||||
name = "stimulum filter"
|
||||
filter_type = "stim"
|
||||
filter_type = list(/datum/gas/stimulum)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/tritium
|
||||
name = "tritium filter"
|
||||
filter_type = "tritium"
|
||||
filter_type = list(/datum/gas/tritium)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/h2o
|
||||
name = "water vapor filter"
|
||||
filter_type = "water_vapor"
|
||||
filter_type = list(/datum/gas/water_vapor)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/zauker
|
||||
name = "zauker filter"
|
||||
filter_type = "zauker"
|
||||
filter_type = list(/datum/gas/zauker)
|
||||
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/helium
|
||||
name = "helium filter"
|
||||
filter_type = "helium"
|
||||
filter_type = list(/datum/gas/helium)
|
||||
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/antinoblium
|
||||
name = "antinoblium filter"
|
||||
filter_type = "antinoblium"
|
||||
filter_type = list(/datum/gas/antinoblium)
|
||||
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped //This feels wrong, I know
|
||||
icon_state = "filter_on-0_f"
|
||||
flipped = TRUE
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/n2
|
||||
name = "nitrogen filter"
|
||||
filter_type = "n2"
|
||||
filter_type = list(/datum/gas/nitrogen)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/o2
|
||||
name = "oxygen filter"
|
||||
filter_type = "o2"
|
||||
filter_type = list(/datum/gas/oxygen)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/co2
|
||||
name = "carbon dioxide filter"
|
||||
filter_type = "co2"
|
||||
filter_type = list(/datum/gas/carbon_dioxide)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/n2o
|
||||
name = "nitrous oxide filter"
|
||||
filter_type = "n2o"
|
||||
filter_type = list(/datum/gas/nitrous_oxide)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/plasma
|
||||
name = "plasma filter"
|
||||
filter_type = "plasma"
|
||||
filter_type = list(/datum/gas/plasma)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/bz
|
||||
name = "bz filter"
|
||||
filter_type = "bz"
|
||||
filter_type = list(/datum/gas/bz)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/freon
|
||||
name = "freon filter"
|
||||
filter_type = "freon"
|
||||
filter_type = list(/datum/gas/freon)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/halon
|
||||
name = "halon filter"
|
||||
filter_type = "halon"
|
||||
filter_type = list(/datum/gas/halon)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/healium
|
||||
name = "healium filter"
|
||||
filter_type = "healium"
|
||||
filter_type = list(/datum/gas/healium)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/h2
|
||||
name = "hydrogen filter"
|
||||
filter_type = "hydrogen"
|
||||
filter_type = list(/datum/gas/hydrogen)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/hypernoblium
|
||||
name = "hypernoblium filter"
|
||||
filter_type = "nob"
|
||||
filter_type = list(/datum/gas/hypernoblium)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/miasma
|
||||
name = "miasma filter"
|
||||
filter_type = "miasma"
|
||||
filter_type = list(/datum/gas/miasma)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/no2
|
||||
name = "nitryl filter"
|
||||
filter_type = "no2"
|
||||
filter_type = list(/datum/gas/nitryl)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/pluoxium
|
||||
name = "pluoxium filter"
|
||||
filter_type = "pluox"
|
||||
filter_type = list(/datum/gas/pluoxium)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/proto_nitrate
|
||||
name = "proto-nitrate filter"
|
||||
filter_type = "proto_nitrate"
|
||||
filter_type = list(/datum/gas/proto_nitrate)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/stimulum
|
||||
name = "stimulum filter"
|
||||
filter_type = "stim"
|
||||
filter_type = list(/datum/gas/stimulum)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/tritium
|
||||
name = "tritium filter"
|
||||
filter_type = "tritium"
|
||||
filter_type = list(/datum/gas/tritium)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/h2o
|
||||
name = "water vapor filter"
|
||||
filter_type = "water_vapor"
|
||||
filter_type = list(/datum/gas/water_vapor)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/zauker
|
||||
name = "zauker filter"
|
||||
filter_type = "zauker"
|
||||
filter_type = list(/datum/gas/zauker)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/helium
|
||||
name = "helium filter"
|
||||
filter_type = "helium"
|
||||
filter_type = list(/datum/gas/helium)
|
||||
/obj/machinery/atmospherics/components/trinary/filter/atmos/flipped/antinoblium
|
||||
name = "antinoblium filter"
|
||||
filter_type = "antinoblium"
|
||||
filter_type = list(/datum/gas/antinoblium)
|
||||
|
||||
// These two filter types have critical_machine flagged to on and thus causes the area they are in to be exempt from the Grid Check event.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user