mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
88 lines
2.6 KiB
Plaintext
88 lines
2.6 KiB
Plaintext
/obj/machinery/atmospherics/unary/heat_exchanger
|
|
|
|
icon = 'icons/obj/atmospherics/heat_exchanger.dmi'
|
|
icon_state = "intact"
|
|
pipe_state = "heunary"
|
|
density = TRUE
|
|
|
|
name = "Heat Exchanger"
|
|
desc = "Exchanges heat between two input gases. Setup for fast heat transfer"
|
|
|
|
var/obj/machinery/atmospherics/unary/heat_exchanger/partner = null
|
|
var/update_cycle
|
|
|
|
/obj/machinery/atmospherics/unary/heat_exchanger/update_icon()
|
|
if(node)
|
|
icon_state = "intact"
|
|
else
|
|
icon_state = "exposed"
|
|
|
|
return
|
|
|
|
/obj/machinery/atmospherics/unary/heat_exchanger/atmos_init()
|
|
if(!partner)
|
|
var/partner_connect = turn(dir,180)
|
|
|
|
for(var/obj/machinery/atmospherics/unary/heat_exchanger/target in get_step(src,partner_connect))
|
|
if(target.dir & get_dir(src,target))
|
|
partner = target
|
|
partner.partner = src
|
|
break
|
|
|
|
..()
|
|
|
|
/obj/machinery/atmospherics/unary/heat_exchanger/process()
|
|
..()
|
|
if(!partner)
|
|
return 0
|
|
|
|
if(!SSair || SSair.current_cycle <= update_cycle)
|
|
return 0
|
|
|
|
update_cycle = SSair.current_cycle
|
|
partner.update_cycle = SSair.current_cycle
|
|
|
|
var/air_heat_capacity = air_contents.heat_capacity()
|
|
var/other_air_heat_capacity = partner.air_contents.heat_capacity()
|
|
var/combined_heat_capacity = other_air_heat_capacity + air_heat_capacity
|
|
|
|
var/old_temperature = air_contents.temperature
|
|
var/other_old_temperature = partner.air_contents.temperature
|
|
|
|
if(combined_heat_capacity > 0)
|
|
var/combined_energy = partner.air_contents.temperature*other_air_heat_capacity + air_heat_capacity*air_contents.temperature
|
|
|
|
var/new_temperature = combined_energy/combined_heat_capacity
|
|
air_contents.temperature = new_temperature
|
|
partner.air_contents.temperature = new_temperature
|
|
|
|
if(network)
|
|
if(abs(old_temperature-air_contents.temperature) > 1)
|
|
network.update = 1
|
|
|
|
if(partner.network)
|
|
if(abs(other_old_temperature-partner.air_contents.temperature) > 1)
|
|
partner.network.update = 1
|
|
|
|
return 1
|
|
|
|
/obj/machinery/atmospherics/unary/heat_exchanger/attackby(var/obj/item/W as obj, var/mob/user as mob)
|
|
if (!W.has_tool_quality(TOOL_WRENCH))
|
|
return ..()
|
|
var/turf/T = src.loc
|
|
if (level==1 && isturf(T) && !T.is_plating())
|
|
to_chat(user, span_warning("You must remove the plating first."))
|
|
return 1
|
|
if (!can_unwrench())
|
|
to_chat(user, span_warning("You cannot unwrench \the [src], it is too exerted due to internal pressure."))
|
|
add_fingerprint(user)
|
|
return 1
|
|
playsound(src, W.usesound, 50, 1)
|
|
to_chat(user, span_notice("You begin to unfasten \the [src]..."))
|
|
if (do_after(user, 40 * W.toolspeed))
|
|
user.visible_message( \
|
|
span_infoplain(span_bold("\The [user]") + " unfastens \the [src]."), \
|
|
span_notice("You have unfastened \the [src]."), \
|
|
"You hear a ratchet.")
|
|
deconstruct()
|