From cc98bcd0191b91fe40f9361e00f2d3e51abb5bb6 Mon Sep 17 00:00:00 2001 From: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Date: Sat, 16 Jan 2021 07:06:22 -0800 Subject: [PATCH] Temperature Pump Sanity (#55926) * fix temperature pump * Cleanup and ui stuff * Punctuation is important you know Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> * tgui rebuild Co-authored-by: Ghilker Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- .../binary_devices/temperature_pump.dm | 32 +++++++++++++------ .../packages/tgui/interfaces/AtmosTempPump.js | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/temperature_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/temperature_pump.dm index fb18f1da664..3c604ccbe49 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/temperature_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/temperature_pump.dm @@ -1,15 +1,15 @@ /obj/machinery/atmospherics/components/binary/temperature_pump icon_state = "tpump_map-3" name = "temperature pump" - desc = "A pump that moves heat only." + desc = "A pump that moves heat from one pipeline to another. The input will get cooler, and the output will get hotter." can_unwrench = TRUE shift_underlay_only = FALSE - ///Value of the amount of rate of heat exchange + ///Percent of the heat delta to transfer var/heat_transfer_rate = 0 - ///Maximum allowed amount for the heat exchange - var/max_heat_transfer_rate = 4500 + ///Maximum allowed transfer percentage + var/max_heat_transfer_rate = 100 construction_type = /obj/item/pipe/directional pipe_state = "tpump" @@ -24,7 +24,7 @@ /obj/machinery/atmospherics/components/binary/temperature_pump/AltClick(mob/user) if(can_interact(user) && !(heat_transfer_rate == max_heat_transfer_rate)) heat_transfer_rate = max_heat_transfer_rate - investigate_log("was set to [heat_transfer_rate] K/s by [key_name(user)]", INVESTIGATE_ATMOS) + investigate_log("was set to [heat_transfer_rate]% by [key_name(user)]", INVESTIGATE_ATMOS) update_icon() return ..() @@ -39,11 +39,24 @@ var/datum/gas_mixture/air_input = airs[1] var/datum/gas_mixture/air_output = airs[2] - if((air_output.temperature + heat_transfer_rate) >= air_input.temperature || (air_input.temperature - heat_transfer_rate) <= TCRYO) + if(!QUANTIZE(air_input.total_moles()) || !QUANTIZE(air_output.total_moles())) //Don't transfer if there's no gas return + var/datum/gas_mixture/remove_input = air_input.remove_ratio(0.9) + var/datum/gas_mixture/remove_output = air_output.remove_ratio(0.9) + + var/coolant_temperature_delta = remove_input.temperature - remove_output.temperature + + if(coolant_temperature_delta > 0) + var/input_capacity = remove_input.heat_capacity() + var/output_capacity = air_output.heat_capacity() + + var/cooling_heat_amount = (heat_transfer_rate * 0.01) * coolant_temperature_delta * (input_capacity * output_capacity / (input_capacity + output_capacity)) + remove_input.temperature = max(remove_input.temperature - (cooling_heat_amount / input_capacity), TCMB) + remove_output.temperature = max(remove_output.temperature + (cooling_heat_amount / output_capacity), TCMB) + + air_input.merge(remove_input) + air_output.merge(remove_output) - air_input.temperature -= heat_transfer_rate - air_output.temperature += heat_transfer_rate update_parents() /obj/machinery/atmospherics/components/binary/temperature_pump/ui_interact(mob/user, datum/tgui/ui) @@ -78,6 +91,5 @@ . = TRUE if(.) heat_transfer_rate = clamp(rate, 0, max_heat_transfer_rate) - investigate_log("was set to [heat_transfer_rate] K/s by [key_name(usr)]", INVESTIGATE_ATMOS) + investigate_log("was set to [heat_transfer_rate]% by [key_name(usr)]", INVESTIGATE_ATMOS) update_icon() - diff --git a/tgui/packages/tgui/interfaces/AtmosTempPump.js b/tgui/packages/tgui/interfaces/AtmosTempPump.js index a90c0c73dca..3c0195bafda 100644 --- a/tgui/packages/tgui/interfaces/AtmosTempPump.js +++ b/tgui/packages/tgui/interfaces/AtmosTempPump.js @@ -22,7 +22,7 @@ export const AtmosTempPump = (props, context) => {