mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
88 lines
2.4 KiB
Plaintext
88 lines
2.4 KiB
Plaintext
/obj/machinery/atmospherics/unary/vent_scrubber
|
|
icon = 'vent_scrubber.dmi'
|
|
icon_state = "off"
|
|
|
|
name = "Air Scrubber"
|
|
desc = "Has a valve and pump attached to it"
|
|
|
|
level = 1
|
|
|
|
var/on = 0
|
|
var/scrubbing = 1 //0 = siphoning, 1 = scrubbing
|
|
var/scrub_CO2 = 1
|
|
var/scrub_Toxins = 0
|
|
|
|
var/volume_rate = 120
|
|
|
|
update_icon()
|
|
if(on&&node)
|
|
if(scrubbing)
|
|
icon_state = "[level == 1 && istype(loc, /turf/simulated) ? "h" : "" ]on"
|
|
else
|
|
icon_state = "[level == 1 && istype(loc, /turf/simulated) ? "h" : "" ]in"
|
|
else
|
|
icon_state = "[level == 1 && istype(loc, /turf/simulated) ? "h" : "" ]off"
|
|
on = 0
|
|
|
|
return
|
|
|
|
process()
|
|
..()
|
|
if(!on)
|
|
return 0
|
|
|
|
var/datum/gas_mixture/environment = loc.return_air()
|
|
|
|
if(scrubbing)
|
|
if((environment.toxins>0) || (environment.carbon_dioxide>0) || (environment.trace_gases.len>0))
|
|
var/transfer_moles = min(1, volume_rate/environment.volume)*environment.total_moles()
|
|
|
|
//Take a gas sample
|
|
var/datum/gas_mixture/removed = loc.remove_air(transfer_moles)
|
|
|
|
//Filter it
|
|
var/datum/gas_mixture/filtered_out = new
|
|
filtered_out.temperature = removed.temperature
|
|
if(scrub_Toxins)
|
|
filtered_out.toxins = removed.toxins
|
|
removed.toxins = 0
|
|
if(scrub_CO2)
|
|
filtered_out.carbon_dioxide = removed.carbon_dioxide
|
|
removed.carbon_dioxide = 0
|
|
|
|
if(removed.trace_gases.len>0)
|
|
for(var/datum/gas/trace_gas in removed.trace_gases)
|
|
if(istype(trace_gas, /datum/gas/oxygen_agent_b))
|
|
removed.trace_gases -= trace_gas
|
|
filtered_out.trace_gases += trace_gas
|
|
|
|
//Remix the resulting gases
|
|
air_contents.merge(filtered_out)
|
|
|
|
loc.assume_air(removed)
|
|
|
|
if(network)
|
|
network.update = 1
|
|
|
|
else //Just siphoning all air
|
|
var/transfer_moles = environment.total_moles()*(volume_rate/environment.volume)
|
|
|
|
var/datum/gas_mixture/removed = loc.remove_air(transfer_moles)
|
|
|
|
air_contents.merge(removed)
|
|
|
|
if(network)
|
|
network.update = 1
|
|
|
|
return 1
|
|
|
|
hide(var/i) //to make the little pipe section invisible, the icon changes.
|
|
if(on&&node)
|
|
if(scrubbing)
|
|
icon_state = "[i == 1 && istype(loc, /turf/simulated) ? "h" : "" ]on"
|
|
else
|
|
icon_state = "[i == 1 && istype(loc, /turf/simulated) ? "h" : "" ]in"
|
|
else
|
|
icon_state = "[i == 1 && istype(loc, /turf/simulated) ? "h" : "" ]off"
|
|
on = 0
|
|
return |