Merge branch 'master' into air-injector-link-fix

This commit is contained in:
SteelSlayer
2020-03-18 12:54:09 -05:00
1735 changed files with 185676 additions and 185063 deletions
@@ -1,155 +1,155 @@
/obj/machinery/atmospherics/binary
dir = SOUTH
initialize_directions = SOUTH|NORTH
use_power = IDLE_POWER_USE
layer = GAS_PUMP_LAYER
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/obj/machinery/atmospherics/node1
var/obj/machinery/atmospherics/node2
var/datum/pipeline/parent1
var/datum/pipeline/parent2
/obj/machinery/atmospherics/binary/New()
..()
switch(dir)
if(NORTH)
initialize_directions = NORTH|SOUTH
if(SOUTH)
initialize_directions = NORTH|SOUTH
if(EAST)
initialize_directions = EAST|WEST
if(WEST)
initialize_directions = EAST|WEST
air1 = new
air2 = new
air1.volume = 200
air2.volume = 200
/obj/machinery/atmospherics/binary/Destroy()
if(node1)
node1.disconnect(src)
node1 = null
nullifyPipenet(parent1)
if(node2)
node2.disconnect(src)
node2 = null
nullifyPipenet(parent2)
return ..()
/obj/machinery/atmospherics/binary/atmos_init()
..()
var/node2_connect = dir
var/node1_connect = turn(dir, 180)
for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
if(target.initialize_directions & get_dir(target,src))
var/c = check_connect_types(target,src)
if(c)
target.connected_to = c
connected_to = c
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
if(target.initialize_directions & get_dir(target,src))
var/c = check_connect_types(target,src)
if(c)
target.connected_to = c
connected_to = c
node2 = target
break
update_icon()
update_underlays()
/obj/machinery/atmospherics/binary/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)
..()
/obj/machinery/atmospherics/binary/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
update_icon()
/obj/machinery/atmospherics/binary/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
/obj/machinery/atmospherics/binary/returnPipenetAir(datum/pipeline/P)
if(P == parent1)
return air1
else if(P == parent2)
return air2
/obj/machinery/atmospherics/binary/pipeline_expansion(datum/pipeline/P)
if(P)
if(parent1 == P)
return list(node1)
else if(parent2 == P)
return list(node2)
else
return list(node1, node2)
/obj/machinery/atmospherics/binary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A)
if(A == node1)
parent1 = P
else if(A == node2)
parent2 = P
/obj/machinery/atmospherics/binary/returnPipenet(obj/machinery/atmospherics/A)
if(A == node1)
return parent1
else if(A == node2)
return parent2
/obj/machinery/atmospherics/binary/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
if(Old == parent1)
parent1 = New
else if(Old == parent2)
parent2 = New
/obj/machinery/atmospherics/binary/unsafe_pressure_release(var/mob/user,var/pressures)
..()
var/turf/T = get_turf(src)
if(T)
//Remove the gas from air1+air2 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)
var/shared_loss = lost/2
var/datum/gas_mixture/to_release = air1.remove(shared_loss)
to_release.merge(air2.remove(shared_loss))
T.assume_air(to_release)
air_update_turf(1)
/obj/machinery/atmospherics/binary/process_atmos()
..()
return parent1 && parent2
/obj/machinery/atmospherics/binary
dir = SOUTH
initialize_directions = SOUTH|NORTH
use_power = IDLE_POWER_USE
layer = GAS_PUMP_LAYER
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/obj/machinery/atmospherics/node1
var/obj/machinery/atmospherics/node2
var/datum/pipeline/parent1
var/datum/pipeline/parent2
/obj/machinery/atmospherics/binary/New()
..()
switch(dir)
if(NORTH)
initialize_directions = NORTH|SOUTH
if(SOUTH)
initialize_directions = NORTH|SOUTH
if(EAST)
initialize_directions = EAST|WEST
if(WEST)
initialize_directions = EAST|WEST
air1 = new
air2 = new
air1.volume = 200
air2.volume = 200
/obj/machinery/atmospherics/binary/Destroy()
if(node1)
node1.disconnect(src)
node1 = null
nullifyPipenet(parent1)
if(node2)
node2.disconnect(src)
node2 = null
nullifyPipenet(parent2)
return ..()
/obj/machinery/atmospherics/binary/atmos_init()
..()
var/node2_connect = dir
var/node1_connect = turn(dir, 180)
for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
if(target.initialize_directions & get_dir(target,src))
var/c = check_connect_types(target,src)
if(c)
target.connected_to = c
connected_to = c
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
if(target.initialize_directions & get_dir(target,src))
var/c = check_connect_types(target,src)
if(c)
target.connected_to = c
connected_to = c
node2 = target
break
update_icon()
update_underlays()
/obj/machinery/atmospherics/binary/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)
..()
/obj/machinery/atmospherics/binary/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
update_icon()
/obj/machinery/atmospherics/binary/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
/obj/machinery/atmospherics/binary/returnPipenetAir(datum/pipeline/P)
if(P == parent1)
return air1
else if(P == parent2)
return air2
/obj/machinery/atmospherics/binary/pipeline_expansion(datum/pipeline/P)
if(P)
if(parent1 == P)
return list(node1)
else if(parent2 == P)
return list(node2)
else
return list(node1, node2)
/obj/machinery/atmospherics/binary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A)
if(A == node1)
parent1 = P
else if(A == node2)
parent2 = P
/obj/machinery/atmospherics/binary/returnPipenet(obj/machinery/atmospherics/A)
if(A == node1)
return parent1
else if(A == node2)
return parent2
/obj/machinery/atmospherics/binary/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
if(Old == parent1)
parent1 = New
else if(Old == parent2)
parent2 = New
/obj/machinery/atmospherics/binary/unsafe_pressure_release(var/mob/user,var/pressures)
..()
var/turf/T = get_turf(src)
if(T)
//Remove the gas from air1+air2 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)
var/shared_loss = lost/2
var/datum/gas_mixture/to_release = air1.remove(shared_loss)
to_release.merge(air2.remove(shared_loss))
T.assume_air(to_release)
air_update_turf(1)
/obj/machinery/atmospherics/binary/process_atmos()
..()
return parent1 && parent2
@@ -1,125 +1,125 @@
//node1, air1, network1 correspond to input
//node2, air2, network2 correspond to output
/obj/machinery/atmospherics/binary/circulator
name = "circulator/heat exchanger"
desc = "A gas circulator pump and heat exchanger. Its input port is on the south side, and its output port is on the north side."
icon = 'icons/obj/atmospherics/circulator.dmi'
icon_state = "circ1-off"
var/side = CIRC_LEFT
var/global/const/CIRC_LEFT = WEST
var/global/const/CIRC_RIGHT = EAST
var/last_pressure_delta = 0
var/obj/machinery/power/generator/generator
anchored = 1
density = 1
can_unwrench = 1
var/side_inverted = 0
// Creating a custom circulator pipe subtype to be delivered through cargo
/obj/item/pipe/circulator
name = "circulator/heat exchanger fitting"
/obj/item/pipe/circulator/New(loc)
var/obj/machinery/atmospherics/binary/circulator/C = new /obj/machinery/atmospherics/binary/circulator(null)
..(loc, make_from = C)
/obj/machinery/atmospherics/binary/circulator/Destroy()
if(generator && generator.cold_circ == src)
generator.cold_circ = null
else if(generator && generator.hot_circ == src)
generator.hot_circ = null
return ..()
/obj/machinery/atmospherics/binary/circulator/proc/return_transfer_air()
var/datum/gas_mixture/inlet = get_inlet_air()
var/datum/gas_mixture/outlet = get_outlet_air()
var/output_starting_pressure = outlet.return_pressure()
var/input_starting_pressure = inlet.return_pressure()
if(output_starting_pressure >= input_starting_pressure - 10)
//Need at least 10 KPa difference to overcome friction in the mechanism
last_pressure_delta = 0
return null
//Calculate necessary moles to transfer using PV = nRT
if(inlet.temperature > 0)
var/pressure_delta = (input_starting_pressure - output_starting_pressure) / 2
var/transfer_moles = pressure_delta * outlet.volume/(inlet.temperature * R_IDEAL_GAS_EQUATION)
last_pressure_delta = pressure_delta
//log_debug("pressure_delta = [pressure_delta]; transfer_moles = [transfer_moles];")
//Actually transfer the gas
var/datum/gas_mixture/removed = inlet.remove(transfer_moles)
parent1.update = 1
parent2.update = 1
return removed
else
last_pressure_delta = 0
/obj/machinery/atmospherics/binary/circulator/process_atmos()
..()
update_icon()
/obj/machinery/atmospherics/binary/circulator/proc/get_inlet_air()
if(side_inverted==0)
return air2
else
return air1
/obj/machinery/atmospherics/binary/circulator/proc/get_outlet_air()
if(side_inverted==0)
return air1
else
return air2
/obj/machinery/atmospherics/binary/circulator/proc/get_inlet_side()
if(dir==SOUTH||dir==NORTH)
if(side_inverted==0)
return "South"
else
return "North"
/obj/machinery/atmospherics/binary/circulator/proc/get_outlet_side()
if(dir==SOUTH||dir==NORTH)
if(side_inverted==0)
return "North"
else
return "South"
/obj/machinery/atmospherics/binary/circulator/attackby(obj/item/W as obj, mob/user as mob, params)
if(ismultitool(W))
if(side_inverted == 0)
side_inverted = 1
else
side_inverted = 0
to_chat(user, "<span class='notice'>You reverse the circulator's valve settings. The inlet of the circulator is now on the [get_inlet_side(dir)] side.</span>")
desc = "A gas circulator pump and heat exchanger. Its input port is on the [get_inlet_side(dir)] side, and its output port is on the [get_outlet_side(dir)] side."
else
return ..()
/obj/machinery/atmospherics/binary/circulator/update_icon()
..()
if(stat & (BROKEN|NOPOWER))
icon_state = "circ[side]-p"
else if(last_pressure_delta > 0)
if(last_pressure_delta > ONE_ATMOSPHERE)
icon_state = "circ[side]-run"
else
icon_state = "circ[side]-slow"
else
icon_state = "circ[side]-off"
return 1
//node1, air1, network1 correspond to input
//node2, air2, network2 correspond to output
#define CIRC_LEFT WEST
#define CIRC_RIGHT EAST
/obj/machinery/atmospherics/binary/circulator
name = "circulator/heat exchanger"
desc = "A gas circulator pump and heat exchanger. Its input port is on the south side, and its output port is on the north side."
icon = 'icons/obj/atmospherics/circulator.dmi'
icon_state = "circ1-off"
var/side = CIRC_LEFT
var/last_pressure_delta = 0
var/obj/machinery/power/generator/generator
anchored = 1
density = 1
can_unwrench = 1
var/side_inverted = 0
// Creating a custom circulator pipe subtype to be delivered through cargo
/obj/item/pipe/circulator
name = "circulator/heat exchanger fitting"
/obj/item/pipe/circulator/New(loc)
var/obj/machinery/atmospherics/binary/circulator/C = new /obj/machinery/atmospherics/binary/circulator(null)
..(loc, make_from = C)
/obj/machinery/atmospherics/binary/circulator/Destroy()
if(generator && generator.cold_circ == src)
generator.cold_circ = null
else if(generator && generator.hot_circ == src)
generator.hot_circ = null
return ..()
/obj/machinery/atmospherics/binary/circulator/proc/return_transfer_air()
var/datum/gas_mixture/inlet = get_inlet_air()
var/datum/gas_mixture/outlet = get_outlet_air()
var/output_starting_pressure = outlet.return_pressure()
var/input_starting_pressure = inlet.return_pressure()
if(output_starting_pressure >= input_starting_pressure - 10)
//Need at least 10 KPa difference to overcome friction in the mechanism
last_pressure_delta = 0
return null
//Calculate necessary moles to transfer using PV = nRT
if(inlet.temperature > 0)
var/pressure_delta = (input_starting_pressure - output_starting_pressure) / 2
var/transfer_moles = pressure_delta * outlet.volume/(inlet.temperature * R_IDEAL_GAS_EQUATION)
last_pressure_delta = pressure_delta
//log_debug("pressure_delta = [pressure_delta]; transfer_moles = [transfer_moles];")
//Actually transfer the gas
var/datum/gas_mixture/removed = inlet.remove(transfer_moles)
parent1.update = 1
parent2.update = 1
return removed
else
last_pressure_delta = 0
/obj/machinery/atmospherics/binary/circulator/process_atmos()
..()
update_icon()
/obj/machinery/atmospherics/binary/circulator/proc/get_inlet_air()
if(side_inverted==0)
return air2
else
return air1
/obj/machinery/atmospherics/binary/circulator/proc/get_outlet_air()
if(side_inverted==0)
return air1
else
return air2
/obj/machinery/atmospherics/binary/circulator/proc/get_inlet_side()
if(dir==SOUTH||dir==NORTH)
if(side_inverted==0)
return "South"
else
return "North"
/obj/machinery/atmospherics/binary/circulator/proc/get_outlet_side()
if(dir==SOUTH||dir==NORTH)
if(side_inverted==0)
return "North"
else
return "South"
/obj/machinery/atmospherics/binary/circulator/multitool_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(!side_inverted)
side_inverted = TRUE
else
side_inverted = FALSE
to_chat(user, "<span class='notice'>You reverse the circulator's valve settings. The inlet of the circulator is now on the [get_inlet_side(dir)] side.</span>")
desc = "A gas circulator pump and heat exchanger. Its input port is on the [get_inlet_side(dir)] side, and its output port is on the [get_outlet_side(dir)] side."
/obj/machinery/atmospherics/binary/circulator/update_icon()
..()
if(stat & (BROKEN|NOPOWER))
icon_state = "circ[side]-p"
else if(last_pressure_delta > 0)
if(last_pressure_delta > ONE_ATMOSPHERE)
icon_state = "circ[side]-run"
else
icon_state = "circ[side]-slow"
else
icon_state = "circ[side]-off"
return 1