mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-27 22:17:32 +01:00
File standardisation (#13131)
* Adds the check components * Adds in trailing newlines * Converts all CRLF to LF * Post merge EOF * Post merge line endings * Final commit
This commit is contained in:
@@ -1,267 +1,267 @@
|
||||
/obj/machinery/atmospherics/trinary/filter
|
||||
icon = 'icons/atmos/filter.dmi'
|
||||
icon_state = "map"
|
||||
|
||||
can_unwrench = 1
|
||||
|
||||
name = "gas filter"
|
||||
|
||||
var/target_pressure = ONE_ATMOSPHERE
|
||||
|
||||
var/filter_type = 0
|
||||
/*
|
||||
Filter types:
|
||||
-1: Nothing
|
||||
0: Toxins: Toxins, Oxygen Agent B
|
||||
1: Oxygen: Oxygen ONLY
|
||||
2: Nitrogen: Nitrogen ONLY
|
||||
3: Carbon Dioxide: Carbon Dioxide ONLY
|
||||
4: Sleeping Agent (N2O)
|
||||
*/
|
||||
|
||||
var/frequency = 0
|
||||
var/datum/radio_frequency/radio_connection
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/CtrlClick(mob/living/user)
|
||||
if(!istype(user) || user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!in_range(src, user) && !issilicon(usr))
|
||||
return
|
||||
if(!ishuman(usr) && !issilicon(usr))
|
||||
return
|
||||
toggle()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/AICtrlClick()
|
||||
toggle()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/AltClick(mob/living/user)
|
||||
if(!istype(user) || user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!in_range(src, user) && !issilicon(usr))
|
||||
return
|
||||
if(!ishuman(usr) && !issilicon(usr))
|
||||
return
|
||||
set_max()
|
||||
return
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/AIAltClick()
|
||||
set_max()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/proc/toggle()
|
||||
if(powered())
|
||||
on = !on
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/proc/set_max()
|
||||
if(powered())
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/Destroy()
|
||||
if(SSradio)
|
||||
SSradio.remove_object(src, frequency)
|
||||
radio_connection = null
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/flipped
|
||||
icon_state = "mmap"
|
||||
flipped = 1
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/proc/set_frequency(new_frequency)
|
||||
SSradio.remove_object(src, frequency)
|
||||
frequency = new_frequency
|
||||
if(frequency)
|
||||
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/update_icon()
|
||||
..()
|
||||
|
||||
if(flipped)
|
||||
icon_state = "m"
|
||||
else
|
||||
icon_state = ""
|
||||
|
||||
if(!powered())
|
||||
icon_state += "off"
|
||||
else if(node2 && node3 && node1)
|
||||
icon_state += on ? "on" : "off"
|
||||
else
|
||||
icon_state += "off"
|
||||
on = 0
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/update_underlays()
|
||||
if(..())
|
||||
underlays.Cut()
|
||||
var/turf/T = get_turf(src)
|
||||
if(!istype(T))
|
||||
return
|
||||
|
||||
add_underlay(T, node1, turn(dir, -180))
|
||||
|
||||
if(flipped)
|
||||
add_underlay(T, node2, turn(dir, 90))
|
||||
else
|
||||
add_underlay(T, node2, turn(dir, -90))
|
||||
|
||||
add_underlay(T, node3, dir)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/power_change()
|
||||
var/old_stat = stat
|
||||
..()
|
||||
if(old_stat != stat)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/process_atmos()
|
||||
..()
|
||||
if(!on)
|
||||
return 0
|
||||
|
||||
var/output_starting_pressure = air3.return_pressure()
|
||||
|
||||
if(output_starting_pressure >= target_pressure || air2.return_pressure() >= target_pressure )
|
||||
//No need to mix if target is already full!
|
||||
return 1
|
||||
|
||||
//Calculate necessary moles to transfer using PV=nRT
|
||||
|
||||
var/pressure_delta = target_pressure - output_starting_pressure
|
||||
var/transfer_moles
|
||||
|
||||
if(air1.temperature > 0)
|
||||
transfer_moles = pressure_delta*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
|
||||
|
||||
//Actually transfer the gas
|
||||
|
||||
if(transfer_moles > 0)
|
||||
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
|
||||
|
||||
if(!removed)
|
||||
return
|
||||
var/datum/gas_mixture/filtered_out = new
|
||||
filtered_out.temperature = removed.temperature
|
||||
|
||||
switch(filter_type)
|
||||
if(0) //removing hydrocarbons
|
||||
filtered_out.toxins = removed.toxins
|
||||
removed.toxins = 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
|
||||
|
||||
if(1) //removing O2
|
||||
filtered_out.oxygen = removed.oxygen
|
||||
removed.oxygen = 0
|
||||
|
||||
if(2) //removing N2
|
||||
filtered_out.nitrogen = removed.nitrogen
|
||||
removed.nitrogen = 0
|
||||
|
||||
if(3) //removing CO2
|
||||
filtered_out.carbon_dioxide = removed.carbon_dioxide
|
||||
removed.carbon_dioxide = 0
|
||||
|
||||
if(4)//removing N2O
|
||||
if(removed.trace_gases.len>0)
|
||||
for(var/datum/gas/trace_gas in removed.trace_gases)
|
||||
if(istype(trace_gas, /datum/gas/sleeping_agent))
|
||||
removed.trace_gases -= trace_gas
|
||||
filtered_out.trace_gases += trace_gas
|
||||
|
||||
else
|
||||
filtered_out = null
|
||||
|
||||
|
||||
air2.merge(filtered_out)
|
||||
air3.merge(removed)
|
||||
|
||||
parent2.update = 1
|
||||
|
||||
parent3.update = 1
|
||||
|
||||
parent1.update = 1
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/atmos_init()
|
||||
set_frequency(frequency)
|
||||
..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/attack_ghost(mob/user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/attack_hand(mob/user)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(!allowed(user))
|
||||
to_chat(user, "<span class='alert'>Access denied.</span>")
|
||||
return
|
||||
|
||||
add_fingerprint(user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
user.set_machine(src)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "atmos_filter.tmpl", name, 475, 155, state = state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["on"] = on
|
||||
data["pressure"] = round(target_pressure)
|
||||
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
|
||||
data["filter_type"] = filter_type
|
||||
return data
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/Topic(href, href_list) // -- TLE
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if(href_list["power"])
|
||||
on = !on
|
||||
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if(href_list["pressure"])
|
||||
var/pressure = href_list["pressure"]
|
||||
if(pressure == "max")
|
||||
pressure = MAX_OUTPUT_PRESSURE
|
||||
. = TRUE
|
||||
else if(pressure == "input")
|
||||
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
|
||||
if(!isnull(pressure) && !..())
|
||||
. = TRUE
|
||||
else if(text2num(pressure) != null)
|
||||
pressure = text2num(pressure)
|
||||
. = TRUE
|
||||
if(.)
|
||||
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
if(href_list["filter"])
|
||||
filter_type = text2num(href_list["filter"])
|
||||
investigate_log("was set to filter [filter_type] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
|
||||
update_icon()
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/pen))
|
||||
var/t = copytext(stripped_input(user, "Enter the name for the filter.", "Rename", name), 1, MAX_NAME_LEN)
|
||||
if(!t)
|
||||
return
|
||||
if(!in_range(src, usr) && loc != usr)
|
||||
return
|
||||
name = t
|
||||
return
|
||||
else
|
||||
return ..()
|
||||
/obj/machinery/atmospherics/trinary/filter
|
||||
icon = 'icons/atmos/filter.dmi'
|
||||
icon_state = "map"
|
||||
|
||||
can_unwrench = 1
|
||||
|
||||
name = "gas filter"
|
||||
|
||||
var/target_pressure = ONE_ATMOSPHERE
|
||||
|
||||
var/filter_type = 0
|
||||
/*
|
||||
Filter types:
|
||||
-1: Nothing
|
||||
0: Toxins: Toxins, Oxygen Agent B
|
||||
1: Oxygen: Oxygen ONLY
|
||||
2: Nitrogen: Nitrogen ONLY
|
||||
3: Carbon Dioxide: Carbon Dioxide ONLY
|
||||
4: Sleeping Agent (N2O)
|
||||
*/
|
||||
|
||||
var/frequency = 0
|
||||
var/datum/radio_frequency/radio_connection
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/CtrlClick(mob/living/user)
|
||||
if(!istype(user) || user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!in_range(src, user) && !issilicon(usr))
|
||||
return
|
||||
if(!ishuman(usr) && !issilicon(usr))
|
||||
return
|
||||
toggle()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/AICtrlClick()
|
||||
toggle()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/AltClick(mob/living/user)
|
||||
if(!istype(user) || user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!in_range(src, user) && !issilicon(usr))
|
||||
return
|
||||
if(!ishuman(usr) && !issilicon(usr))
|
||||
return
|
||||
set_max()
|
||||
return
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/AIAltClick()
|
||||
set_max()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/proc/toggle()
|
||||
if(powered())
|
||||
on = !on
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/proc/set_max()
|
||||
if(powered())
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/Destroy()
|
||||
if(SSradio)
|
||||
SSradio.remove_object(src, frequency)
|
||||
radio_connection = null
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/flipped
|
||||
icon_state = "mmap"
|
||||
flipped = 1
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/proc/set_frequency(new_frequency)
|
||||
SSradio.remove_object(src, frequency)
|
||||
frequency = new_frequency
|
||||
if(frequency)
|
||||
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/update_icon()
|
||||
..()
|
||||
|
||||
if(flipped)
|
||||
icon_state = "m"
|
||||
else
|
||||
icon_state = ""
|
||||
|
||||
if(!powered())
|
||||
icon_state += "off"
|
||||
else if(node2 && node3 && node1)
|
||||
icon_state += on ? "on" : "off"
|
||||
else
|
||||
icon_state += "off"
|
||||
on = 0
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/update_underlays()
|
||||
if(..())
|
||||
underlays.Cut()
|
||||
var/turf/T = get_turf(src)
|
||||
if(!istype(T))
|
||||
return
|
||||
|
||||
add_underlay(T, node1, turn(dir, -180))
|
||||
|
||||
if(flipped)
|
||||
add_underlay(T, node2, turn(dir, 90))
|
||||
else
|
||||
add_underlay(T, node2, turn(dir, -90))
|
||||
|
||||
add_underlay(T, node3, dir)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/power_change()
|
||||
var/old_stat = stat
|
||||
..()
|
||||
if(old_stat != stat)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/process_atmos()
|
||||
..()
|
||||
if(!on)
|
||||
return 0
|
||||
|
||||
var/output_starting_pressure = air3.return_pressure()
|
||||
|
||||
if(output_starting_pressure >= target_pressure || air2.return_pressure() >= target_pressure )
|
||||
//No need to mix if target is already full!
|
||||
return 1
|
||||
|
||||
//Calculate necessary moles to transfer using PV=nRT
|
||||
|
||||
var/pressure_delta = target_pressure - output_starting_pressure
|
||||
var/transfer_moles
|
||||
|
||||
if(air1.temperature > 0)
|
||||
transfer_moles = pressure_delta*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
|
||||
|
||||
//Actually transfer the gas
|
||||
|
||||
if(transfer_moles > 0)
|
||||
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
|
||||
|
||||
if(!removed)
|
||||
return
|
||||
var/datum/gas_mixture/filtered_out = new
|
||||
filtered_out.temperature = removed.temperature
|
||||
|
||||
switch(filter_type)
|
||||
if(0) //removing hydrocarbons
|
||||
filtered_out.toxins = removed.toxins
|
||||
removed.toxins = 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
|
||||
|
||||
if(1) //removing O2
|
||||
filtered_out.oxygen = removed.oxygen
|
||||
removed.oxygen = 0
|
||||
|
||||
if(2) //removing N2
|
||||
filtered_out.nitrogen = removed.nitrogen
|
||||
removed.nitrogen = 0
|
||||
|
||||
if(3) //removing CO2
|
||||
filtered_out.carbon_dioxide = removed.carbon_dioxide
|
||||
removed.carbon_dioxide = 0
|
||||
|
||||
if(4)//removing N2O
|
||||
if(removed.trace_gases.len>0)
|
||||
for(var/datum/gas/trace_gas in removed.trace_gases)
|
||||
if(istype(trace_gas, /datum/gas/sleeping_agent))
|
||||
removed.trace_gases -= trace_gas
|
||||
filtered_out.trace_gases += trace_gas
|
||||
|
||||
else
|
||||
filtered_out = null
|
||||
|
||||
|
||||
air2.merge(filtered_out)
|
||||
air3.merge(removed)
|
||||
|
||||
parent2.update = 1
|
||||
|
||||
parent3.update = 1
|
||||
|
||||
parent1.update = 1
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/atmos_init()
|
||||
set_frequency(frequency)
|
||||
..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/attack_ghost(mob/user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/attack_hand(mob/user)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(!allowed(user))
|
||||
to_chat(user, "<span class='alert'>Access denied.</span>")
|
||||
return
|
||||
|
||||
add_fingerprint(user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
user.set_machine(src)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "atmos_filter.tmpl", name, 475, 155, state = state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["on"] = on
|
||||
data["pressure"] = round(target_pressure)
|
||||
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
|
||||
data["filter_type"] = filter_type
|
||||
return data
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/Topic(href, href_list) // -- TLE
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if(href_list["power"])
|
||||
on = !on
|
||||
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if(href_list["pressure"])
|
||||
var/pressure = href_list["pressure"]
|
||||
if(pressure == "max")
|
||||
pressure = MAX_OUTPUT_PRESSURE
|
||||
. = TRUE
|
||||
else if(pressure == "input")
|
||||
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
|
||||
if(!isnull(pressure) && !..())
|
||||
. = TRUE
|
||||
else if(text2num(pressure) != null)
|
||||
pressure = text2num(pressure)
|
||||
. = TRUE
|
||||
if(.)
|
||||
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
if(href_list["filter"])
|
||||
filter_type = text2num(href_list["filter"])
|
||||
investigate_log("was set to filter [filter_type] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
|
||||
update_icon()
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/filter/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/pen))
|
||||
var/t = copytext(stripped_input(user, "Enter the name for the filter.", "Rename", name), 1, MAX_NAME_LEN)
|
||||
if(!t)
|
||||
return
|
||||
if(!in_range(src, usr) && loc != usr)
|
||||
return
|
||||
name = t
|
||||
return
|
||||
else
|
||||
return ..()
|
||||
|
||||
@@ -1,233 +1,233 @@
|
||||
/obj/machinery/atmospherics/trinary/mixer
|
||||
icon = 'icons/atmos/mixer.dmi'
|
||||
icon_state = "map"
|
||||
|
||||
can_unwrench = 1
|
||||
|
||||
name = "gas mixer"
|
||||
|
||||
var/target_pressure = ONE_ATMOSPHERE
|
||||
var/node1_concentration = 0.5
|
||||
var/node2_concentration = 0.5
|
||||
|
||||
//node 3 is the outlet, nodes 1 & 2 are intakes
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/CtrlClick(mob/living/user)
|
||||
if(!istype(user) || user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!in_range(src, user) && !issilicon(usr))
|
||||
return
|
||||
if(!ishuman(usr) && !issilicon(usr))
|
||||
return
|
||||
toggle()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/AICtrlClick()
|
||||
toggle()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/AltClick(mob/living/user)
|
||||
if(!istype(user) || user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!in_range(src, user) && !issilicon(usr))
|
||||
return
|
||||
if(!ishuman(usr) && !issilicon(usr))
|
||||
return
|
||||
set_max()
|
||||
return
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/AIAltClick()
|
||||
set_max()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/flipped
|
||||
icon_state = "mmap"
|
||||
flipped = 1
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/proc/toggle()
|
||||
if(powered())
|
||||
on = !on
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/proc/set_max()
|
||||
if(powered())
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/update_icon(safety = 0)
|
||||
..()
|
||||
|
||||
if(flipped)
|
||||
icon_state = "m"
|
||||
else
|
||||
icon_state = ""
|
||||
|
||||
if(!powered())
|
||||
icon_state += "off"
|
||||
else if(node2 && node3 && node1)
|
||||
icon_state += on ? "on" : "off"
|
||||
else
|
||||
icon_state += "off"
|
||||
on = 0
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/update_underlays()
|
||||
if(..())
|
||||
underlays.Cut()
|
||||
var/turf/T = get_turf(src)
|
||||
if(!istype(T))
|
||||
return
|
||||
|
||||
add_underlay(T, node1, turn(dir, -180))
|
||||
|
||||
if(flipped)
|
||||
add_underlay(T, node2, turn(dir, 90))
|
||||
else
|
||||
add_underlay(T, node2, turn(dir, -90))
|
||||
|
||||
add_underlay(T, node3, dir)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/power_change()
|
||||
var/old_stat = stat
|
||||
..()
|
||||
if(old_stat != stat)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/New()
|
||||
..()
|
||||
air3.volume = 300
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/process_atmos()
|
||||
..()
|
||||
if(!on)
|
||||
return 0
|
||||
|
||||
var/output_starting_pressure = air3.return_pressure()
|
||||
|
||||
if(output_starting_pressure >= target_pressure)
|
||||
//No need to mix if target is already full!
|
||||
return 1
|
||||
|
||||
//Calculate necessary moles to transfer using PV=nRT
|
||||
|
||||
var/pressure_delta = target_pressure - output_starting_pressure
|
||||
var/transfer_moles1 = 0
|
||||
var/transfer_moles2 = 0
|
||||
|
||||
if(air1.temperature > 0)
|
||||
transfer_moles1 = (node1_concentration*pressure_delta)*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
|
||||
|
||||
if(air2.temperature > 0)
|
||||
transfer_moles2 = (node2_concentration*pressure_delta)*air3.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
|
||||
|
||||
var/air1_moles = air1.total_moles()
|
||||
var/air2_moles = air2.total_moles()
|
||||
|
||||
if((air1_moles < transfer_moles1) || (air2_moles < transfer_moles2))
|
||||
if(!transfer_moles1 || !transfer_moles2) return
|
||||
var/ratio = min(air1_moles/transfer_moles1, air2_moles/transfer_moles2)
|
||||
|
||||
transfer_moles1 *= ratio
|
||||
transfer_moles2 *= ratio
|
||||
|
||||
//Actually transfer the gas
|
||||
|
||||
if(transfer_moles1 > 0)
|
||||
var/datum/gas_mixture/removed1 = air1.remove(transfer_moles1)
|
||||
air3.merge(removed1)
|
||||
|
||||
if(transfer_moles2 > 0)
|
||||
var/datum/gas_mixture/removed2 = air2.remove(transfer_moles2)
|
||||
air3.merge(removed2)
|
||||
|
||||
if(transfer_moles1)
|
||||
parent1.update = 1
|
||||
|
||||
if(transfer_moles2)
|
||||
parent2.update = 1
|
||||
|
||||
parent3.update = 1
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/attack_ghost(mob/user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/attack_hand(mob/user)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(!allowed(user))
|
||||
to_chat(user, "<span class='alert'>Access denied.</span>")
|
||||
return
|
||||
|
||||
add_fingerprint(user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
user.set_machine(src)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "atmos_mixer.tmpl", name, 370, 165, state = state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["on"] = on
|
||||
data["pressure"] = round(target_pressure)
|
||||
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
|
||||
data["node1_concentration"] = round(node1_concentration*100)
|
||||
data["node2_concentration"] = round(node2_concentration*100)
|
||||
return data
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/Topic(href,href_list)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if(href_list["power"])
|
||||
on = !on
|
||||
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if(href_list["pressure"])
|
||||
var/pressure = href_list["pressure"]
|
||||
if(pressure == "max")
|
||||
pressure = MAX_OUTPUT_PRESSURE
|
||||
. = TRUE
|
||||
else if(pressure == "input")
|
||||
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
|
||||
if(!isnull(pressure) && !..())
|
||||
. = TRUE
|
||||
else if(text2num(pressure) != null)
|
||||
pressure = text2num(pressure)
|
||||
. = TRUE
|
||||
if(.)
|
||||
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
if(href_list["node1"])
|
||||
var/value = text2num(href_list["node1"])
|
||||
node1_concentration = max(0, min(1, node1_concentration + value))
|
||||
node2_concentration = max(0, min(1, node2_concentration - value))
|
||||
investigate_log("was set to [node1_concentration] % on node 1 by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if(href_list["node2"])
|
||||
var/value = text2num(href_list["node2"])
|
||||
node2_concentration = max(0, min(1, node2_concentration + value))
|
||||
node1_concentration = max(0, min(1, node1_concentration - value))
|
||||
investigate_log("was set to [node2_concentration] % on node 2 by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
|
||||
update_icon()
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/pen))
|
||||
var/t = copytext(stripped_input(user, "Enter the name for the mixer.", "Rename", name), 1, MAX_NAME_LEN)
|
||||
if(!t)
|
||||
return
|
||||
if(!in_range(src, usr) && loc != usr)
|
||||
return
|
||||
name = t
|
||||
return
|
||||
else
|
||||
return ..()
|
||||
/obj/machinery/atmospherics/trinary/mixer
|
||||
icon = 'icons/atmos/mixer.dmi'
|
||||
icon_state = "map"
|
||||
|
||||
can_unwrench = 1
|
||||
|
||||
name = "gas mixer"
|
||||
|
||||
var/target_pressure = ONE_ATMOSPHERE
|
||||
var/node1_concentration = 0.5
|
||||
var/node2_concentration = 0.5
|
||||
|
||||
//node 3 is the outlet, nodes 1 & 2 are intakes
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/CtrlClick(mob/living/user)
|
||||
if(!istype(user) || user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!in_range(src, user) && !issilicon(usr))
|
||||
return
|
||||
if(!ishuman(usr) && !issilicon(usr))
|
||||
return
|
||||
toggle()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/AICtrlClick()
|
||||
toggle()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/AltClick(mob/living/user)
|
||||
if(!istype(user) || user.incapacitated())
|
||||
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
|
||||
return
|
||||
if(!in_range(src, user) && !issilicon(usr))
|
||||
return
|
||||
if(!ishuman(usr) && !issilicon(usr))
|
||||
return
|
||||
set_max()
|
||||
return
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/AIAltClick()
|
||||
set_max()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/flipped
|
||||
icon_state = "mmap"
|
||||
flipped = 1
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/proc/toggle()
|
||||
if(powered())
|
||||
on = !on
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/proc/set_max()
|
||||
if(powered())
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/update_icon(safety = 0)
|
||||
..()
|
||||
|
||||
if(flipped)
|
||||
icon_state = "m"
|
||||
else
|
||||
icon_state = ""
|
||||
|
||||
if(!powered())
|
||||
icon_state += "off"
|
||||
else if(node2 && node3 && node1)
|
||||
icon_state += on ? "on" : "off"
|
||||
else
|
||||
icon_state += "off"
|
||||
on = 0
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/update_underlays()
|
||||
if(..())
|
||||
underlays.Cut()
|
||||
var/turf/T = get_turf(src)
|
||||
if(!istype(T))
|
||||
return
|
||||
|
||||
add_underlay(T, node1, turn(dir, -180))
|
||||
|
||||
if(flipped)
|
||||
add_underlay(T, node2, turn(dir, 90))
|
||||
else
|
||||
add_underlay(T, node2, turn(dir, -90))
|
||||
|
||||
add_underlay(T, node3, dir)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/power_change()
|
||||
var/old_stat = stat
|
||||
..()
|
||||
if(old_stat != stat)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/New()
|
||||
..()
|
||||
air3.volume = 300
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/process_atmos()
|
||||
..()
|
||||
if(!on)
|
||||
return 0
|
||||
|
||||
var/output_starting_pressure = air3.return_pressure()
|
||||
|
||||
if(output_starting_pressure >= target_pressure)
|
||||
//No need to mix if target is already full!
|
||||
return 1
|
||||
|
||||
//Calculate necessary moles to transfer using PV=nRT
|
||||
|
||||
var/pressure_delta = target_pressure - output_starting_pressure
|
||||
var/transfer_moles1 = 0
|
||||
var/transfer_moles2 = 0
|
||||
|
||||
if(air1.temperature > 0)
|
||||
transfer_moles1 = (node1_concentration*pressure_delta)*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
|
||||
|
||||
if(air2.temperature > 0)
|
||||
transfer_moles2 = (node2_concentration*pressure_delta)*air3.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
|
||||
|
||||
var/air1_moles = air1.total_moles()
|
||||
var/air2_moles = air2.total_moles()
|
||||
|
||||
if((air1_moles < transfer_moles1) || (air2_moles < transfer_moles2))
|
||||
if(!transfer_moles1 || !transfer_moles2) return
|
||||
var/ratio = min(air1_moles/transfer_moles1, air2_moles/transfer_moles2)
|
||||
|
||||
transfer_moles1 *= ratio
|
||||
transfer_moles2 *= ratio
|
||||
|
||||
//Actually transfer the gas
|
||||
|
||||
if(transfer_moles1 > 0)
|
||||
var/datum/gas_mixture/removed1 = air1.remove(transfer_moles1)
|
||||
air3.merge(removed1)
|
||||
|
||||
if(transfer_moles2 > 0)
|
||||
var/datum/gas_mixture/removed2 = air2.remove(transfer_moles2)
|
||||
air3.merge(removed2)
|
||||
|
||||
if(transfer_moles1)
|
||||
parent1.update = 1
|
||||
|
||||
if(transfer_moles2)
|
||||
parent2.update = 1
|
||||
|
||||
parent3.update = 1
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/attack_ghost(mob/user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/attack_hand(mob/user)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(!allowed(user))
|
||||
to_chat(user, "<span class='alert'>Access denied.</span>")
|
||||
return
|
||||
|
||||
add_fingerprint(user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
user.set_machine(src)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "atmos_mixer.tmpl", name, 370, 165, state = state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["on"] = on
|
||||
data["pressure"] = round(target_pressure)
|
||||
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
|
||||
data["node1_concentration"] = round(node1_concentration*100)
|
||||
data["node2_concentration"] = round(node2_concentration*100)
|
||||
return data
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/Topic(href,href_list)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if(href_list["power"])
|
||||
on = !on
|
||||
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if(href_list["pressure"])
|
||||
var/pressure = href_list["pressure"]
|
||||
if(pressure == "max")
|
||||
pressure = MAX_OUTPUT_PRESSURE
|
||||
. = TRUE
|
||||
else if(pressure == "input")
|
||||
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
|
||||
if(!isnull(pressure) && !..())
|
||||
. = TRUE
|
||||
else if(text2num(pressure) != null)
|
||||
pressure = text2num(pressure)
|
||||
. = TRUE
|
||||
if(.)
|
||||
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
if(href_list["node1"])
|
||||
var/value = text2num(href_list["node1"])
|
||||
node1_concentration = max(0, min(1, node1_concentration + value))
|
||||
node2_concentration = max(0, min(1, node2_concentration - value))
|
||||
investigate_log("was set to [node1_concentration] % on node 1 by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if(href_list["node2"])
|
||||
var/value = text2num(href_list["node2"])
|
||||
node2_concentration = max(0, min(1, node2_concentration + value))
|
||||
node1_concentration = max(0, min(1, node1_concentration - value))
|
||||
investigate_log("was set to [node2_concentration] % on node 2 by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
|
||||
update_icon()
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/mixer/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/pen))
|
||||
var/t = copytext(stripped_input(user, "Enter the name for the mixer.", "Rename", name), 1, MAX_NAME_LEN)
|
||||
if(!t)
|
||||
return
|
||||
if(!in_range(src, usr) && loc != usr)
|
||||
return
|
||||
name = t
|
||||
return
|
||||
else
|
||||
return ..()
|
||||
|
||||
@@ -1,213 +1,213 @@
|
||||
/obj/machinery/atmospherics/trinary
|
||||
dir = SOUTH
|
||||
initialize_directions = SOUTH|NORTH|WEST
|
||||
use_power = IDLE_POWER_USE
|
||||
|
||||
var/on = 0
|
||||
layer = GAS_FILTER_LAYER
|
||||
|
||||
var/datum/gas_mixture/air1
|
||||
var/datum/gas_mixture/air2
|
||||
var/datum/gas_mixture/air3
|
||||
|
||||
var/obj/machinery/atmospherics/node1
|
||||
var/obj/machinery/atmospherics/node2
|
||||
var/obj/machinery/atmospherics/node3
|
||||
|
||||
var/datum/pipeline/parent1
|
||||
var/datum/pipeline/parent2
|
||||
var/datum/pipeline/parent3
|
||||
|
||||
var/flipped = 0
|
||||
|
||||
/obj/machinery/atmospherics/trinary/New()
|
||||
..()
|
||||
|
||||
if(!flipped)
|
||||
switch(dir)
|
||||
if(NORTH)
|
||||
initialize_directions = EAST|NORTH|SOUTH
|
||||
if(SOUTH)
|
||||
initialize_directions = SOUTH|WEST|NORTH
|
||||
if(EAST)
|
||||
initialize_directions = EAST|WEST|SOUTH
|
||||
if(WEST)
|
||||
initialize_directions = WEST|NORTH|EAST
|
||||
else
|
||||
switch(dir)
|
||||
if(NORTH)
|
||||
initialize_directions = SOUTH|NORTH|WEST
|
||||
if(SOUTH)
|
||||
initialize_directions = NORTH|SOUTH|EAST
|
||||
if(EAST)
|
||||
initialize_directions = WEST|EAST|NORTH
|
||||
if(WEST)
|
||||
initialize_directions = EAST|WEST|SOUTH
|
||||
|
||||
air1 = new
|
||||
air2 = new
|
||||
air3 = new
|
||||
|
||||
air1.volume = 200
|
||||
air2.volume = 200
|
||||
air3.volume = 200
|
||||
|
||||
/obj/machinery/atmospherics/trinary/Destroy()
|
||||
if(node1)
|
||||
node1.disconnect(src)
|
||||
node1 = null
|
||||
nullifyPipenet(parent1)
|
||||
if(node2)
|
||||
node2.disconnect(src)
|
||||
node2 = null
|
||||
nullifyPipenet(parent2)
|
||||
if(node3)
|
||||
node3.disconnect(src)
|
||||
node3 = null
|
||||
nullifyPipenet(parent3)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/atmos_init()
|
||||
..()
|
||||
//Mixer:
|
||||
//1 and 2 is input
|
||||
//Node 3 is output
|
||||
//If we flip the mixer, 1 and 3 shall exchange positions
|
||||
|
||||
//Filter:
|
||||
//Node 1 is input
|
||||
//Node 2 is filtered output
|
||||
//Node 3 is rest output
|
||||
//If we flip the filter, 1 and 3 shall exchange positions
|
||||
|
||||
var/node1_connect = turn(dir, -180)
|
||||
var/node2_connect = turn(dir, -90)
|
||||
var/node3_connect = dir
|
||||
|
||||
if(flipped)
|
||||
node2_connect = turn(node2_connect, -180)
|
||||
|
||||
for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
|
||||
if(target.initialize_directions & get_dir(target,src))
|
||||
node1 = target
|
||||
break
|
||||
|
||||
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
|
||||
if(target.initialize_directions & get_dir(target,src))
|
||||
node2 = target
|
||||
break
|
||||
|
||||
for(var/obj/machinery/atmospherics/target in get_step(src,node3_connect))
|
||||
if(target.initialize_directions & get_dir(target,src))
|
||||
node3 = target
|
||||
break
|
||||
|
||||
update_icon()
|
||||
update_underlays()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/build_network(remove_deferral = FALSE)
|
||||
if(!parent1)
|
||||
parent1 = new /datum/pipeline()
|
||||
parent1.build_pipeline(src)
|
||||
|
||||
if(!parent2)
|
||||
parent2 = new /datum/pipeline()
|
||||
parent2.build_pipeline(src)
|
||||
|
||||
if(!parent3)
|
||||
parent3 = new /datum/pipeline()
|
||||
parent3.build_pipeline(src)
|
||||
..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/disconnect(obj/machinery/atmospherics/reference)
|
||||
if(reference == node1)
|
||||
if(istype(node1, /obj/machinery/atmospherics/pipe))
|
||||
qdel(parent1)
|
||||
node1 = null
|
||||
else if(reference == node2)
|
||||
if(istype(node2, /obj/machinery/atmospherics/pipe))
|
||||
qdel(parent2)
|
||||
node2 = null
|
||||
else if(reference == node3)
|
||||
if(istype(node3, /obj/machinery/atmospherics/pipe))
|
||||
qdel(parent3)
|
||||
node3 = null
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/nullifyPipenet(datum/pipeline/P)
|
||||
..()
|
||||
if(!P)
|
||||
return
|
||||
if(P == parent1)
|
||||
parent1.other_airs -= air1
|
||||
parent1 = null
|
||||
else if(P == parent2)
|
||||
parent2.other_airs -= air2
|
||||
parent2 = null
|
||||
else if(P == parent3)
|
||||
parent3.other_airs -= air3
|
||||
parent3 = null
|
||||
|
||||
/obj/machinery/atmospherics/trinary/returnPipenetAir(datum/pipeline/P)
|
||||
if(P == parent1)
|
||||
return air1
|
||||
else if(P == parent2)
|
||||
return air2
|
||||
else if(P == parent3)
|
||||
return air3
|
||||
|
||||
/obj/machinery/atmospherics/trinary/pipeline_expansion(datum/pipeline/P)
|
||||
if(P)
|
||||
if(parent1 == P)
|
||||
return list(node1)
|
||||
else if(parent2 == P)
|
||||
return list(node2)
|
||||
else if(parent3 == P)
|
||||
return list(node3)
|
||||
return list(node1, node2, node3)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A)
|
||||
if(A == node1)
|
||||
parent1 = P
|
||||
else if(A == node2)
|
||||
parent2 = P
|
||||
else if(A == node3)
|
||||
parent3 = P
|
||||
|
||||
/obj/machinery/atmospherics/trinary/returnPipenet(obj/machinery/atmospherics/A)
|
||||
if(A == node1)
|
||||
return parent1
|
||||
else if(A == node2)
|
||||
return parent2
|
||||
else if(A == node3)
|
||||
return parent3
|
||||
|
||||
/obj/machinery/atmospherics/trinary/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
|
||||
if(Old == parent1)
|
||||
parent1 = New
|
||||
else if(Old == parent2)
|
||||
parent2 = New
|
||||
else if(Old == parent3)
|
||||
parent3 = New
|
||||
|
||||
/obj/machinery/atmospherics/trinary/unsafe_pressure_release(var/mob/user,var/pressures)
|
||||
..()
|
||||
|
||||
var/turf/T = get_turf(src)
|
||||
if(T)
|
||||
//Remove the gas from air1+air2+air3 and assume it
|
||||
var/datum/gas_mixture/environment = T.return_air()
|
||||
var/lost = pressures*environment.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
|
||||
lost += pressures*environment.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
|
||||
lost += pressures*environment.volume/(air3.temperature * R_IDEAL_GAS_EQUATION)
|
||||
var/shared_loss = lost/3
|
||||
|
||||
var/datum/gas_mixture/to_release = air1.remove(shared_loss)
|
||||
to_release.merge(air2.remove(shared_loss))
|
||||
to_release.merge(air3.remove(shared_loss))
|
||||
T.assume_air(to_release)
|
||||
air_update_turf(1)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/process_atmos()
|
||||
..()
|
||||
return parent1 && parent2 && parent3
|
||||
/obj/machinery/atmospherics/trinary
|
||||
dir = SOUTH
|
||||
initialize_directions = SOUTH|NORTH|WEST
|
||||
use_power = IDLE_POWER_USE
|
||||
|
||||
var/on = 0
|
||||
layer = GAS_FILTER_LAYER
|
||||
|
||||
var/datum/gas_mixture/air1
|
||||
var/datum/gas_mixture/air2
|
||||
var/datum/gas_mixture/air3
|
||||
|
||||
var/obj/machinery/atmospherics/node1
|
||||
var/obj/machinery/atmospherics/node2
|
||||
var/obj/machinery/atmospherics/node3
|
||||
|
||||
var/datum/pipeline/parent1
|
||||
var/datum/pipeline/parent2
|
||||
var/datum/pipeline/parent3
|
||||
|
||||
var/flipped = 0
|
||||
|
||||
/obj/machinery/atmospherics/trinary/New()
|
||||
..()
|
||||
|
||||
if(!flipped)
|
||||
switch(dir)
|
||||
if(NORTH)
|
||||
initialize_directions = EAST|NORTH|SOUTH
|
||||
if(SOUTH)
|
||||
initialize_directions = SOUTH|WEST|NORTH
|
||||
if(EAST)
|
||||
initialize_directions = EAST|WEST|SOUTH
|
||||
if(WEST)
|
||||
initialize_directions = WEST|NORTH|EAST
|
||||
else
|
||||
switch(dir)
|
||||
if(NORTH)
|
||||
initialize_directions = SOUTH|NORTH|WEST
|
||||
if(SOUTH)
|
||||
initialize_directions = NORTH|SOUTH|EAST
|
||||
if(EAST)
|
||||
initialize_directions = WEST|EAST|NORTH
|
||||
if(WEST)
|
||||
initialize_directions = EAST|WEST|SOUTH
|
||||
|
||||
air1 = new
|
||||
air2 = new
|
||||
air3 = new
|
||||
|
||||
air1.volume = 200
|
||||
air2.volume = 200
|
||||
air3.volume = 200
|
||||
|
||||
/obj/machinery/atmospherics/trinary/Destroy()
|
||||
if(node1)
|
||||
node1.disconnect(src)
|
||||
node1 = null
|
||||
nullifyPipenet(parent1)
|
||||
if(node2)
|
||||
node2.disconnect(src)
|
||||
node2 = null
|
||||
nullifyPipenet(parent2)
|
||||
if(node3)
|
||||
node3.disconnect(src)
|
||||
node3 = null
|
||||
nullifyPipenet(parent3)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/atmos_init()
|
||||
..()
|
||||
//Mixer:
|
||||
//1 and 2 is input
|
||||
//Node 3 is output
|
||||
//If we flip the mixer, 1 and 3 shall exchange positions
|
||||
|
||||
//Filter:
|
||||
//Node 1 is input
|
||||
//Node 2 is filtered output
|
||||
//Node 3 is rest output
|
||||
//If we flip the filter, 1 and 3 shall exchange positions
|
||||
|
||||
var/node1_connect = turn(dir, -180)
|
||||
var/node2_connect = turn(dir, -90)
|
||||
var/node3_connect = dir
|
||||
|
||||
if(flipped)
|
||||
node2_connect = turn(node2_connect, -180)
|
||||
|
||||
for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
|
||||
if(target.initialize_directions & get_dir(target,src))
|
||||
node1 = target
|
||||
break
|
||||
|
||||
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
|
||||
if(target.initialize_directions & get_dir(target,src))
|
||||
node2 = target
|
||||
break
|
||||
|
||||
for(var/obj/machinery/atmospherics/target in get_step(src,node3_connect))
|
||||
if(target.initialize_directions & get_dir(target,src))
|
||||
node3 = target
|
||||
break
|
||||
|
||||
update_icon()
|
||||
update_underlays()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/build_network(remove_deferral = FALSE)
|
||||
if(!parent1)
|
||||
parent1 = new /datum/pipeline()
|
||||
parent1.build_pipeline(src)
|
||||
|
||||
if(!parent2)
|
||||
parent2 = new /datum/pipeline()
|
||||
parent2.build_pipeline(src)
|
||||
|
||||
if(!parent3)
|
||||
parent3 = new /datum/pipeline()
|
||||
parent3.build_pipeline(src)
|
||||
..()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/disconnect(obj/machinery/atmospherics/reference)
|
||||
if(reference == node1)
|
||||
if(istype(node1, /obj/machinery/atmospherics/pipe))
|
||||
qdel(parent1)
|
||||
node1 = null
|
||||
else if(reference == node2)
|
||||
if(istype(node2, /obj/machinery/atmospherics/pipe))
|
||||
qdel(parent2)
|
||||
node2 = null
|
||||
else if(reference == node3)
|
||||
if(istype(node3, /obj/machinery/atmospherics/pipe))
|
||||
qdel(parent3)
|
||||
node3 = null
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/trinary/nullifyPipenet(datum/pipeline/P)
|
||||
..()
|
||||
if(!P)
|
||||
return
|
||||
if(P == parent1)
|
||||
parent1.other_airs -= air1
|
||||
parent1 = null
|
||||
else if(P == parent2)
|
||||
parent2.other_airs -= air2
|
||||
parent2 = null
|
||||
else if(P == parent3)
|
||||
parent3.other_airs -= air3
|
||||
parent3 = null
|
||||
|
||||
/obj/machinery/atmospherics/trinary/returnPipenetAir(datum/pipeline/P)
|
||||
if(P == parent1)
|
||||
return air1
|
||||
else if(P == parent2)
|
||||
return air2
|
||||
else if(P == parent3)
|
||||
return air3
|
||||
|
||||
/obj/machinery/atmospherics/trinary/pipeline_expansion(datum/pipeline/P)
|
||||
if(P)
|
||||
if(parent1 == P)
|
||||
return list(node1)
|
||||
else if(parent2 == P)
|
||||
return list(node2)
|
||||
else if(parent3 == P)
|
||||
return list(node3)
|
||||
return list(node1, node2, node3)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A)
|
||||
if(A == node1)
|
||||
parent1 = P
|
||||
else if(A == node2)
|
||||
parent2 = P
|
||||
else if(A == node3)
|
||||
parent3 = P
|
||||
|
||||
/obj/machinery/atmospherics/trinary/returnPipenet(obj/machinery/atmospherics/A)
|
||||
if(A == node1)
|
||||
return parent1
|
||||
else if(A == node2)
|
||||
return parent2
|
||||
else if(A == node3)
|
||||
return parent3
|
||||
|
||||
/obj/machinery/atmospherics/trinary/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
|
||||
if(Old == parent1)
|
||||
parent1 = New
|
||||
else if(Old == parent2)
|
||||
parent2 = New
|
||||
else if(Old == parent3)
|
||||
parent3 = New
|
||||
|
||||
/obj/machinery/atmospherics/trinary/unsafe_pressure_release(var/mob/user,var/pressures)
|
||||
..()
|
||||
|
||||
var/turf/T = get_turf(src)
|
||||
if(T)
|
||||
//Remove the gas from air1+air2+air3 and assume it
|
||||
var/datum/gas_mixture/environment = T.return_air()
|
||||
var/lost = pressures*environment.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
|
||||
lost += pressures*environment.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
|
||||
lost += pressures*environment.volume/(air3.temperature * R_IDEAL_GAS_EQUATION)
|
||||
var/shared_loss = lost/3
|
||||
|
||||
var/datum/gas_mixture/to_release = air1.remove(shared_loss)
|
||||
to_release.merge(air2.remove(shared_loss))
|
||||
to_release.merge(air3.remove(shared_loss))
|
||||
T.assume_air(to_release)
|
||||
air_update_turf(1)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/process_atmos()
|
||||
..()
|
||||
return parent1 && parent2 && parent3
|
||||
|
||||
@@ -177,4 +177,4 @@
|
||||
switch_side()
|
||||
|
||||
#undef TVALVE_STATE_STRAIGHT
|
||||
#undef TVALVE_STATE_SIDE
|
||||
#undef TVALVE_STATE_SIDE
|
||||
|
||||
Reference in New Issue
Block a user