/* So much of atmospherics.dm was used solely by components, so separating this makes things all a lot cleaner. On top of that, now people can add component-speciic procs/vars if they want! */ /obj/machinery/atmospherics/components var/welded = FALSE //Used on pumps and scrubbers var/showpipe = FALSE var/list/datum/pipeline/parents var/list/datum/gas_mixture/airs /obj/machinery/atmospherics/components/New() parents = new(device_type) airs = new(device_type) ..() for(var/i in 1 to device_type) var/datum/gas_mixture/A = new A.volume = 200 airs[i] = A /* Iconnery */ /obj/machinery/atmospherics/components/proc/update_icon_nopipes() return /obj/machinery/atmospherics/components/update_icon() update_icon_nopipes() underlays.Cut() var/turf/T = loc if(level == 2 || !T.intact) showpipe = TRUE plane = GAME_PLANE else showpipe = FALSE plane = FLOOR_PLANE if(!showpipe) return //no need to update the pipes if they aren't showing var/connected = 0 //Direction bitset for(var/i in 1 to device_type) //adds intact pieces if(nodes[i]) connected |= icon_addintact(nodes[i]) icon_addbroken(connected) //adds broken pieces /* Pipenet stuff; housekeeping */ /obj/machinery/atmospherics/components/nullifyNode(i) if(nodes[i]) nullifyPipenet(parents[i]) QDEL_NULL(airs[i]) ..() /obj/machinery/atmospherics/components/on_construction() ..() update_parents() /obj/machinery/atmospherics/components/build_network() for(var/i in 1 to device_type) if(!parents[i]) parents[i] = new /datum/pipeline() var/datum/pipeline/P = parents[i] P.build_pipeline(src) /obj/machinery/atmospherics/components/proc/nullifyPipenet(datum/pipeline/reference) if(!reference) CRASH("nullifyPipenet(null) called by [type] on [COORD(src)]") return var/i = parents.Find(reference) reference.other_airs -= airs[i] reference.other_atmosmch -= src parents[i] = null /obj/machinery/atmospherics/components/returnPipenetAir(datum/pipeline/reference) return airs[parents.Find(reference)] /obj/machinery/atmospherics/components/pipeline_expansion(datum/pipeline/reference) if(reference) return list(nodes[parents.Find(reference)]) return ..() /obj/machinery/atmospherics/components/setPipenet(datum/pipeline/reference, obj/machinery/atmospherics/A) parents[nodes.Find(A)] = reference /obj/machinery/atmospherics/components/returnPipenet(obj/machinery/atmospherics/A = nodes[1]) //returns parents[1] if called without argument return parents[nodes.Find(A)] /obj/machinery/atmospherics/components/replacePipenet(datum/pipeline/Old, datum/pipeline/New) parents[parents.Find(Old)] = New /obj/machinery/atmospherics/components/unsafe_pressure_release(var/mob/user, var/pressures) ..() var/turf/T = get_turf(src) if(T) //Remove the gas from airs and assume it var/datum/gas_mixture/environment = T.return_air() var/lost = null var/times_lost = 0 for(var/i in 1 to device_type) var/datum/gas_mixture/air = airs[i] lost += pressures*environment.volume/(air.temperature * R_IDEAL_GAS_EQUATION) times_lost++ var/shared_loss = lost/times_lost var/datum/gas_mixture/to_release for(var/i in 1 to device_type) var/datum/gas_mixture/air = airs[i] if(!to_release) to_release = air.remove(shared_loss) continue to_release.merge(air.remove(shared_loss)) T.assume_air(to_release) air_update_turf(1) /obj/machinery/atmospherics/components/proc/safe_input(var/title, var/text, var/default_set) var/new_value = input(usr,text,title,default_set) as num if(usr.canUseTopic(src)) return new_value return default_set /* Helpers */ /obj/machinery/atmospherics/components/proc/update_parents() for(var/i in 1 to device_type) var/datum/pipeline/parent = parents[i] if(!parent) throw EXCEPTION("Component is missing a pipenet! Rebuilding...") build_network() parent.update = 1 /obj/machinery/atmospherics/components/returnPipenets() . = list() for(var/i in 1 to device_type) . += returnPipenet(nodes[i]) /* UI Stuff */ /obj/machinery/atmospherics/components/ui_status(mob/user) if(allowed(user)) return ..() to_chat(user, "Access denied.") return UI_CLOSE /* Tool acts */ /obj/machinery/atmospherics/components/analyzer_act(mob/living/user, obj/item/I) atmosanalyzer_scan(airs, user, src)