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 <minefap44@gmail.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
This commit is contained in:
LemonInTheDark
2021-01-16 17:06:22 +02:00
committed by GitHub
co-authored by MrMelbert Ghilker
parent 41d9244460
commit cc98bcd019
2 changed files with 23 additions and 11 deletions
@@ -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()
@@ -22,7 +22,7 @@ export const AtmosTempPump = (props, context) => {
<NumberInput
animated
value={parseFloat(data.rate)}
unit="K/s"
unit="%"
width="75px"
minValue={0}
maxValue={data.max_heat_transfer_rate}