|
11 | 11 | var/heat_transfer_rate = 0
|
12 | 12 | ///Maximum allowed transfer percentage
|
13 | 13 | var/max_heat_transfer_rate = 100
|
| 14 | + //Desired temperature |
| 15 | + var/target_temperature = TCMB |
| 16 | + ///Minimum allowed temperature |
| 17 | + var/minimum_temperature = TCMB |
| 18 | + ///Maximum allowed temperature to be set |
| 19 | + var/max_temperature = MAX_TEMPERATURE_SETTING |
| 20 | + // Input cooling / output heating smart mode |
| 21 | + var/inverted = FALSE |
| 22 | + // Checks if heat is being transfered from input to output |
| 23 | + var/is_heat_flowing = FALSE |
14 | 24 |
|
15 | 25 | /obj/machinery/atmospherics/components/binary/temperature_pump/Initialize(mapload)
|
16 | 26 | . = ..()
|
|
38 | 48 | update_appearance()
|
39 | 49 | return ..()
|
40 | 50 |
|
| 51 | +/obj/machinery/atmospherics/components/binary/temperature_pump/examine(mob/user) |
| 52 | + . = ..() |
| 53 | + . += "This device will transfer heat if the temperature of the gas in the [inverted ? "output is lower" : "input is higher"] than the temperature set in the interface." |
| 54 | + if(inverted) |
| 55 | + . += "The device settings can be restored if a multitool is used on it." |
| 56 | + else |
| 57 | + . += "The sensor's settings can be changed by using a multitool on the device." |
| 58 | + |
| 59 | + |
41 | 60 | /obj/machinery/atmospherics/components/binary/temperature_pump/update_icon_nopipes()
|
42 |
| - icon_state = "tpump_[on && is_operational ? "on" : "off"]-[set_overlay_offset(piping_layer)]" |
| 61 | + if(on && is_operational && is_heat_flowing) |
| 62 | + icon_state = "tpump_flow-[set_overlay_offset(piping_layer)]" |
| 63 | + else if(on && is_operational && !is_heat_flowing) |
| 64 | + icon_state = "tpump_on-[set_overlay_offset(piping_layer)]" |
| 65 | + else |
| 66 | + icon_state = "tpump_off-[set_overlay_offset(piping_layer)]" |
43 | 67 |
|
44 | 68 | /obj/machinery/atmospherics/components/binary/temperature_pump/process_atmos()
|
45 | 69 | if(!on || !is_operational)
|
|
48 | 72 | var/datum/gas_mixture/air_input = airs[1]
|
49 | 73 | var/datum/gas_mixture/air_output = airs[2]
|
50 | 74 |
|
51 |
| - if(!QUANTIZE(air_input.total_moles()) || !QUANTIZE(air_output.total_moles())) //Don't transfer if there's no gas |
| 75 | + if(!QUANTIZE(air_input.total_moles()) || !QUANTIZE(air_output.total_moles()) || (heat_transfer_rate<=0)) //Don't transfer if there's no gas or if the transfer rate is zero |
| 76 | + is_heat_flowing = FALSE |
| 77 | + update_icon_nopipes() |
52 | 78 | return
|
53 | 79 | var/datum/gas_mixture/remove_input = air_input.remove_ratio(0.9)
|
54 | 80 | var/datum/gas_mixture/remove_output = air_output.remove_ratio(0.9)
|
55 | 81 |
|
56 | 82 | var/coolant_temperature_delta = remove_input.temperature - remove_output.temperature
|
57 | 83 |
|
58 |
| - if(coolant_temperature_delta > 0) |
| 84 | + if((coolant_temperature_delta > 0) && ((!inverted && (air_input.temperature>target_temperature)) || (inverted && (air_output.temperature<target_temperature)))) |
59 | 85 | var/input_capacity = remove_input.heat_capacity()
|
60 | 86 | var/output_capacity = remove_output.heat_capacity()
|
| 87 | + is_heat_flowing = TRUE |
61 | 88 |
|
62 | 89 | var/cooling_heat_amount = (heat_transfer_rate * 0.01) * CALCULATE_CONDUCTION_ENERGY(coolant_temperature_delta, output_capacity, input_capacity)
|
63 | 90 | remove_output.temperature = max(remove_output.temperature + (cooling_heat_amount / output_capacity), TCMB)
|
64 | 91 | remove_input.temperature = max(remove_input.temperature - (cooling_heat_amount / input_capacity), TCMB)
|
65 | 92 | update_parents()
|
| 93 | + else |
| 94 | + is_heat_flowing = FALSE |
| 95 | + |
| 96 | + update_icon_nopipes() |
66 | 97 |
|
67 | 98 | var/power_usage = 200
|
68 | 99 |
|
|
83 | 114 | data["on"] = on
|
84 | 115 | data["rate"] = round(heat_transfer_rate)
|
85 | 116 | data["max_heat_transfer_rate"] = round(max_heat_transfer_rate)
|
| 117 | + data["temperature"] = round(target_temperature) |
| 118 | + data["min_temperature"] = round(minimum_temperature) |
| 119 | + data["max_temperature"] = round(max_temperature) |
86 | 120 | return data
|
87 | 121 |
|
88 | 122 | /obj/machinery/atmospherics/components/binary/temperature_pump/ui_act(action, params)
|
|
105 | 139 | if(.)
|
106 | 140 | heat_transfer_rate = clamp(rate, 0, max_heat_transfer_rate)
|
107 | 141 | investigate_log("was set to [heat_transfer_rate]% by [key_name(usr)]", INVESTIGATE_ATMOS)
|
| 142 | + if("temperature") |
| 143 | + var/temperature = params["temperature"] |
| 144 | + if(temperature == "tmax") |
| 145 | + temperature = max_temperature |
| 146 | + . = TRUE |
| 147 | + else if(text2num(temperature) != null) |
| 148 | + temperature = text2num(temperature) |
| 149 | + . = TRUE |
| 150 | + if(.) |
| 151 | + target_temperature = clamp(minimum_temperature, temperature, max_temperature) |
| 152 | + investigate_log("was set to [target_temperature] K by [key_name(usr)]", INVESTIGATE_ATMOS) |
108 | 153 | update_appearance()
|
| 154 | + |
| 155 | +/obj/machinery/atmospherics/components/binary/temperature_pump/multitool_act(mob/living/user, obj/item/multitool/Lorem) |
| 156 | + . = ..() |
| 157 | + if (istype(Lorem)) |
| 158 | + inverted = !inverted |
| 159 | + if(inverted) |
| 160 | + to_chat(user, span_notice("You set [src]'s sensors to transfer heat when the output temperature is lower than the setted one.")) |
| 161 | + else |
| 162 | + to_chat(user, span_notice("You set [src]'s sensors to transfer heat when the input temperature is higher than the setted one.")) |
| 163 | + return TRUE |
0 commit comments