Skip to content

Atmos binary device improvements #6544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions code/__DEFINES/atmospherics/atmos_piping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
//Atmos pipe limits
/// (kPa) What pressure pumps and powered equipment max out at.
#define MAX_OUTPUT_PRESSURE 4500
//Maximum pressure passive devices max out at
#define MAX_PASSIVE_OUTPUT_PRESSURE 1e12
//Maximum temperature setting for devices
#define MAX_TEMPERATURE_SETTING 1e12
/// (L/s) Maximum speed powered equipment can work at.
#define MAX_TRANSFER_RATE 200
/// How many percent of the contents that an overclocked volume pumps leak into the air
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Passive gate is similar to the regular pump except:
/obj/machinery/atmospherics/components/binary/passive_gate/add_context(atom/source, list/context, obj/item/held_item, mob/user)
. = ..()
context[SCREENTIP_CONTEXT_CTRL_LMB] = "Turn [on ? "off" : "on"]"
context[SCREENTIP_CONTEXT_ALT_LMB] = "Maximize target pressure"
context[SCREENTIP_CONTEXT_ALT_LMB] = "Set to maximum recommended target pressure"
return CONTEXTUAL_SCREENTIP_SET

/obj/machinery/atmospherics/components/binary/passive_gate/CtrlClick(mob/user)
Expand Down Expand Up @@ -76,7 +76,7 @@ Passive gate is similar to the regular pump except:
var/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
data["max_pressure"] = round(MAX_PASSIVE_OUTPUT_PRESSURE)
return data

/obj/machinery/atmospherics/components/binary/passive_gate/ui_act(action, params)
Expand All @@ -91,13 +91,13 @@ Passive gate is similar to the regular pump except:
if("pressure")
var/pressure = params["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
pressure = MAX_PASSIVE_OUTPUT_PRESSURE
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = clamp(pressure, 0, ONE_ATMOSPHERE*100)
target_pressure = clamp(pressure, 0, MAX_PASSIVE_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS)
update_appearance()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/obj/machinery/atmospherics/components/binary/pressure_valve/add_context(atom/source, list/context, obj/item/held_item, mob/user)
. = ..()
context[SCREENTIP_CONTEXT_CTRL_LMB] = "Turn [on ? "off" : "on"]"
context[SCREENTIP_CONTEXT_ALT_LMB] = "Maximize target pressure"
context[SCREENTIP_CONTEXT_ALT_LMB] = "Set to maximum recommended target pressure"
return CONTEXTUAL_SCREENTIP_SET

/obj/machinery/atmospherics/components/binary/pressure_valve/CtrlClick(mob/user)
Expand Down Expand Up @@ -77,7 +77,7 @@
var/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(ONE_ATMOSPHERE*100)
data["max_pressure"] = round(MAX_PASSIVE_OUTPUT_PRESSURE)
return data

/obj/machinery/atmospherics/components/binary/pressure_valve/ui_act(action, params)
Expand All @@ -92,13 +92,13 @@
if("pressure")
var/pressure = params["pressure"]
if(pressure == "max")
pressure = ONE_ATMOSPHERE*100
pressure = MAX_PASSIVE_OUTPUT_PRESSURE
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = clamp(pressure, 0, ONE_ATMOSPHERE*100)
target_pressure = clamp(pressure, 0, MAX_PASSIVE_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS)
update_appearance()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
///Minimum allowed temperature
var/minimum_temperature = TCMB
///Maximum allowed temperature to be set
var/max_temperature = 4500
var/max_temperature = MAX_TEMPERATURE_SETTING
//Maximum recommended temperature
var/max_recommended_temperature = 4500
///Check if the sensor should let gas pass if temperature in the mix is less/higher than the target one
var/inverted = FALSE
///Check if the gas is moving from one pipenet to the other
Expand All @@ -24,7 +26,7 @@
/obj/machinery/atmospherics/components/binary/temperature_gate/add_context(atom/source, list/context, obj/item/held_item, mob/user)
. = ..()
context[SCREENTIP_CONTEXT_CTRL_LMB] = "Turn [on ? "off" : "on"]"
context[SCREENTIP_CONTEXT_ALT_LMB] = "Maximize target temperature"
context[SCREENTIP_CONTEXT_ALT_LMB] = "Set to maximum recommended target temperature"
return CONTEXTUAL_SCREENTIP_SET

/obj/machinery/atmospherics/components/binary/temperature_gate/CtrlClick(mob/user)
Expand All @@ -37,7 +39,7 @@

/obj/machinery/atmospherics/components/binary/temperature_gate/AltClick(mob/user)
if(can_interact(user))
target_temperature = max_temperature
target_temperature = max_recommended_temperature
investigate_log("was set to [target_temperature] K by [key_name(user)]", INVESTIGATE_ATMOS)
balloon_alert(user, "target temperature set to [target_temperature] K")
update_appearance()
Expand Down Expand Up @@ -136,7 +138,7 @@
if (istype(I))
inverted = !inverted
if(inverted)
to_chat(user, span_notice("You set the [src]'s sensors to release gases when the temperature is higher than the setted one."))
to_chat(user, span_notice("You set [src]'s sensors to release gases when the temperature is higher than the setted one."))
else
to_chat(user, span_notice("You set the [src]'s sensors to the default settings."))
to_chat(user, span_notice("You set [src]'s sensors to the default settings."))
return TRUE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
var/heat_transfer_rate = 0
///Maximum allowed transfer percentage
var/max_heat_transfer_rate = 100
//Desired temperature
var/target_temperature = TCMB
///Minimum allowed temperature
var/minimum_temperature = TCMB
///Maximum allowed temperature to be set
var/max_temperature = MAX_TEMPERATURE_SETTING
// Input cooling / output heating smart mode
var/inverted = FALSE
// Checks if heat is being transfered from input to output
var/is_heat_flowing = FALSE

/obj/machinery/atmospherics/components/binary/temperature_pump/Initialize(mapload)
. = ..()
Expand Down Expand Up @@ -38,8 +48,22 @@
update_appearance()
return ..()

/obj/machinery/atmospherics/components/binary/temperature_pump/examine(mob/user)
. = ..()
. += "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."
if(inverted)
. += "The device settings can be restored if a multitool is used on it."
else
. += "The sensor's settings can be changed by using a multitool on the device."


/obj/machinery/atmospherics/components/binary/temperature_pump/update_icon_nopipes()
icon_state = "tpump_[on && is_operational ? "on" : "off"]-[set_overlay_offset(piping_layer)]"
if(on && is_operational && is_heat_flowing)
icon_state = "tpump_flow-[set_overlay_offset(piping_layer)]"
else if(on && is_operational && !is_heat_flowing)
icon_state = "tpump_on-[set_overlay_offset(piping_layer)]"
else
icon_state = "tpump_off-[set_overlay_offset(piping_layer)]"

/obj/machinery/atmospherics/components/binary/temperature_pump/process_atmos()
if(!on || !is_operational)
Expand All @@ -48,21 +72,28 @@
var/datum/gas_mixture/air_input = airs[1]
var/datum/gas_mixture/air_output = airs[2]

if(!QUANTIZE(air_input.total_moles()) || !QUANTIZE(air_output.total_moles())) //Don't transfer if there's no gas
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
is_heat_flowing = FALSE
update_icon_nopipes()
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)
if((coolant_temperature_delta > 0) && ((!inverted && (air_input.temperature>target_temperature)) || (inverted && (air_output.temperature<target_temperature))))
var/input_capacity = remove_input.heat_capacity()
var/output_capacity = remove_output.heat_capacity()
is_heat_flowing = TRUE

var/cooling_heat_amount = (heat_transfer_rate * 0.01) * CALCULATE_CONDUCTION_ENERGY(coolant_temperature_delta, output_capacity, input_capacity)
remove_output.temperature = max(remove_output.temperature + (cooling_heat_amount / output_capacity), TCMB)
remove_input.temperature = max(remove_input.temperature - (cooling_heat_amount / input_capacity), TCMB)
update_parents()
else
is_heat_flowing = FALSE

update_icon_nopipes()

var/power_usage = 200

Expand All @@ -83,6 +114,9 @@
data["on"] = on
data["rate"] = round(heat_transfer_rate)
data["max_heat_transfer_rate"] = round(max_heat_transfer_rate)
data["temperature"] = round(target_temperature)
data["min_temperature"] = round(minimum_temperature)
data["max_temperature"] = round(max_temperature)
return data

/obj/machinery/atmospherics/components/binary/temperature_pump/ui_act(action, params)
Expand All @@ -105,4 +139,25 @@
if(.)
heat_transfer_rate = clamp(rate, 0, max_heat_transfer_rate)
investigate_log("was set to [heat_transfer_rate]% by [key_name(usr)]", INVESTIGATE_ATMOS)
if("temperature")
var/temperature = params["temperature"]
if(temperature == "tmax")
temperature = max_temperature
. = TRUE
else if(text2num(temperature) != null)
temperature = text2num(temperature)
. = TRUE
if(.)
target_temperature = clamp(minimum_temperature, temperature, max_temperature)
investigate_log("was set to [target_temperature] K by [key_name(usr)]", INVESTIGATE_ATMOS)
update_appearance()

/obj/machinery/atmospherics/components/binary/temperature_pump/multitool_act(mob/living/user, obj/item/multitool/Lorem)
. = ..()
if (istype(Lorem))
inverted = !inverted
if(inverted)
to_chat(user, span_notice("You set [src]'s sensors to transfer heat when the output temperature is lower than the setted one."))
else
to_chat(user, span_notice("You set [src]'s sensors to transfer heat when the input temperature is higher than the setted one."))
return TRUE
Binary file modified icons/obj/atmospherics/components/binary_devices.dmi
Binary file not shown.
2 changes: 1 addition & 1 deletion tgui/packages/tgui/interfaces/AtmosPump.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const AtmosPump = (props) => {
const { on, max_rate, max_pressure, rate, pressure } = data;

return (
<Window width={335} height={115}>
<Window width={345} height={115}>
<Window.Content>
<Section>
<LabeledList>
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui/interfaces/AtmosTempGate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const AtmosTempGate = (props) => {
const { on, temperature, min_temperature, max_temperature } = data;

return (
<Window width={335} height={115}>
<Window width={345} height={115}>
<Window.Content>
<Section>
<LabeledList>
Expand Down
41 changes: 39 additions & 2 deletions tgui/packages/tgui/interfaces/AtmosTempPump.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ type Data = {
on: BooleanLike;
rate: number;
max_heat_transfer_rate: number;
temperature: number;
min_temperature: number;
max_temperature: number;
};

export const AtmosTempPump = (props) => {
const { act, data } = useBackend<Data>();
const { on, rate, max_heat_transfer_rate } = data;
const {
on,
rate,
max_heat_transfer_rate,
temperature,
min_temperature,
max_temperature,
} = data;

return (
<Window width={335} height={115}>
<Window width={345} height={140}>
<Window.Content>
<Section>
<LabeledList>
Expand Down Expand Up @@ -53,6 +63,33 @@ export const AtmosTempPump = (props) => {
}
/>
</LabeledList.Item>
<LabeledList.Item label="Heat settings">
<NumberInput
animated
value={temperature}
unit="K"
width="75px"
minValue={min_temperature}
maxValue={max_temperature}
step={1}
onChange={(e, value) =>
act('temperature', {
temperature: value,
})
}
/>
<Button
ml={1}
icon="plus"
content="Max"
disabled={temperature === max_temperature}
onClick={() =>
act('temperature', {
temperature: 'tmax',
})
}
/>
</LabeledList.Item>
</LabeledList>
</Section>
</Window.Content>
Expand Down
Loading