mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-17 02:54:44 +01:00
901a1d4450
## About The Pull Request This PR adds USB functionality to temperature pumps, emitters and temperature control unit machines. <img width="1082" height="340" alt="working" src="https://github.com/user-attachments/assets/25e40c17-33ab-4159-b431-b3ccbe83626d" /> ### New USB Components <img width="139" height="101" alt="emitter" src="https://github.com/user-attachments/assets/66580351-6cca-4dfe-9de4-3813cf62678c" /> * Emitter New exposed controls allow you to manually fire a single beam, and get signals whenever it is toggled on/off/fired. It doesn't allow a player to toggle it on/off (must be done physically). ID locking the emitter will also lock out the ability to fire the emitter via USB. <img width="303" height="226" alt="temp pump" src="https://github.com/user-attachments/assets/4d0e6758-d653-4ac1-a080-d8e31d64408d" /> * Temperature Pump This works exactly the same as the other USB controlled pumps, with the addition of setting the heat rate. <img width="267" height="151" alt="temperature control" src="https://github.com/user-attachments/assets/6fff5148-bd70-4a1c-9899-10c997279669" /> * Temperature Control Unit The USB interface now allows this to be remotely turned off and on like the other USB pump interfaces. ## Why It's Good For The Game These three parts are crucial to engineering/atmos projects, and gives experienced players more depth to toy with circuits. ## Changelog 🆑 add: Added USB interface to emitters, temperature pumps and temperature control unit machines /🆑
134 lines
4.8 KiB
Plaintext
134 lines
4.8 KiB
Plaintext
/obj/machinery/atmospherics/components/binary/temperature_pump
|
|
icon_state = "tpump_map-3"
|
|
name = "temperature pump"
|
|
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
|
|
construction_type = /obj/item/pipe/directional
|
|
pipe_state = "tpump"
|
|
vent_movement = NONE
|
|
///Percent of the heat delta to transfer
|
|
var/heat_transfer_rate = 0
|
|
///Maximum allowed transfer percentage
|
|
var/max_heat_transfer_rate = 100
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/Initialize(mapload)
|
|
. = ..()
|
|
AddComponent(/datum/component/usb_port, typecacheof(list(/obj/item/circuit_component/atmos_temperature_pump), only_root_path = TRUE))
|
|
register_context()
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/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 transfer rate"
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/click_ctrl(mob/user)
|
|
if(is_operational)
|
|
set_on(!on)
|
|
balloon_alert(user, "turned [on ? "on" : "off"]")
|
|
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", INVESTIGATE_ATMOS)
|
|
return CLICK_ACTION_SUCCESS
|
|
return CLICK_ACTION_BLOCKING
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/click_alt(mob/user)
|
|
if(heat_transfer_rate == max_heat_transfer_rate)
|
|
return CLICK_ACTION_BLOCKING
|
|
|
|
heat_transfer_rate = max_heat_transfer_rate
|
|
investigate_log("was set to [heat_transfer_rate]% by [key_name(user)]", INVESTIGATE_ATMOS)
|
|
balloon_alert(user, "transfer rate set to [heat_transfer_rate]%")
|
|
update_appearance(UPDATE_ICON)
|
|
return CLICK_ACTION_SUCCESS
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/update_icon_nopipes()
|
|
icon_state = "tpump_[on && is_operational ? "on" : "off"]-[set_overlay_offset(piping_layer)]"
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/process_atmos()
|
|
if(!on || !is_operational)
|
|
return
|
|
|
|
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
|
|
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 = remove_output.heat_capacity()
|
|
|
|
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()
|
|
|
|
var/power_usage = 200
|
|
|
|
air_input.merge(remove_input)
|
|
air_output.merge(remove_output)
|
|
|
|
if(power_usage)
|
|
use_energy(power_usage)
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "AtmosTempPump", name)
|
|
ui.open()
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/ui_data()
|
|
var/data = list()
|
|
data["on"] = on
|
|
data["rate"] = round(heat_transfer_rate)
|
|
data["max_heat_transfer_rate"] = round(max_heat_transfer_rate)
|
|
return data
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
switch(action)
|
|
if("power")
|
|
set_on(!on)
|
|
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", INVESTIGATE_ATMOS)
|
|
. = TRUE
|
|
if("rate")
|
|
var/rate = params["rate"]
|
|
if(rate == "max")
|
|
rate = max_heat_transfer_rate
|
|
. = TRUE
|
|
else if(text2num(rate) != null)
|
|
rate = text2num(rate)
|
|
. = TRUE
|
|
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)
|
|
update_appearance(UPDATE_ICON)
|
|
|
|
//mapping
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/layer2
|
|
icon_state = "tpump_map-2"
|
|
piping_layer = 2
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/layer4
|
|
icon_state = "tpump_map-4"
|
|
piping_layer = 4
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/on
|
|
on = TRUE
|
|
icon_state = "tpump_on_map-3"
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/on/layer2
|
|
icon_state = "tpump_on_map-2"
|
|
piping_layer = 2
|
|
|
|
/obj/machinery/atmospherics/components/binary/temperature_pump/on/layer4
|
|
icon_state = "tpump_on_map-4"
|
|
piping_layer = 4
|