Files
tmyqlfpirandGitHub 901a1d4450 Add USB ports to emitters/temperature pumps/temperature machines (#95497)
## 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
/🆑
2026-04-29 16:52:55 +02:00

101 lines
3.7 KiB
Plaintext

/**
* USB wiremod interface for temperature control unit machines
*/
/obj/item/circuit_component/thermomachine
display_name = "Temperature Control Unit"
desc = "The interface for communicating with a temperature control unit."
///Set the target temperature
var/datum/port/input/temperature
///Activate the machine
var/datum/port/input/on
///Deactivate the machine
var/datum/port/input/off
///Signals the circuit to retrieve the machine's current pressure and temperature
var/datum/port/input/request_data
///Pressure of the port
var/datum/port/output/port_pressure
///Temperature of the port port
var/datum/port/output/port_temperature
///Whether the machine is currently active
var/datum/port/output/is_active
///Send a signal when the machine is turned on
var/datum/port/output/turned_on
///Send a signal when the machine is turned off
var/datum/port/output/turned_off
///The component parent object
var/obj/machinery/atmospherics/components/unary/thermomachine/connected_machine
/obj/item/circuit_component/thermomachine/populate_ports()
temperature = add_input_port("Set Temperature", PORT_TYPE_NUMBER, trigger = PROC_REF(set_temperature))
on = add_input_port("Turn On", PORT_TYPE_SIGNAL, trigger = PROC_REF(set_machine_on))
off = add_input_port("Turn Off", PORT_TYPE_SIGNAL, trigger = PROC_REF(set_machine_off))
request_data = add_input_port("Request Port Data", PORT_TYPE_SIGNAL, trigger = PROC_REF(request_pump_data))
port_pressure = add_output_port("Pressure", PORT_TYPE_NUMBER)
port_temperature = add_output_port("Temperature", PORT_TYPE_NUMBER)
is_active = add_output_port("Active", PORT_TYPE_NUMBER)
turned_on = add_output_port("Turned On", PORT_TYPE_SIGNAL)
turned_off = add_output_port("Turned Off", PORT_TYPE_SIGNAL)
/obj/item/circuit_component/thermomachine/register_usb_parent(atom/movable/shell)
. = ..()
if(istype(shell, /obj/machinery/atmospherics/components/unary/thermomachine))
connected_machine = shell
RegisterSignal(connected_machine, COMSIG_ATMOS_MACHINE_SET_ON, PROC_REF(handle_pump_activation))
/obj/item/circuit_component/thermomachine/unregister_usb_parent(atom/movable/shell)
UnregisterSignal(connected_machine, COMSIG_ATMOS_MACHINE_SET_ON)
connected_machine = null
return ..()
/obj/item/circuit_component/thermomachine/pre_input_received(datum/port/input/port)
if(connected_machine)
var/min = connected_machine.min_temperature
var/max = connected_machine.max_temperature
temperature.set_value(clamp(temperature.value, min, max))
/obj/item/circuit_component/thermomachine/proc/handle_pump_activation(datum/source, active)
SIGNAL_HANDLER
is_active.set_output(active)
if(active)
turned_on.set_output(COMPONENT_SIGNAL)
else
turned_off.set_output(COMPONENT_SIGNAL)
/obj/item/circuit_component/thermomachine/proc/set_temperature()
CIRCUIT_TRIGGER
if(!connected_machine)
return
var/min = connected_machine.min_temperature
var/max = connected_machine.max_temperature
connected_machine.target_temperature = clamp(temperature.value, min, max)
connected_machine.update_icon_state()
/obj/item/circuit_component/thermomachine/proc/set_machine_on()
CIRCUIT_TRIGGER
if(!connected_machine)
return
connected_machine.set_on(TRUE)
connected_machine.update_use_power(ACTIVE_POWER_USE)
/obj/item/circuit_component/thermomachine/proc/set_machine_off()
CIRCUIT_TRIGGER
if(!connected_machine)
return
connected_machine.set_on(FALSE)
connected_machine.update_use_power(IDLE_POWER_USE)
connected_machine.update_appearance(UPDATE_ICON)
/obj/item/circuit_component/thermomachine/proc/request_pump_data()
CIRCUIT_TRIGGER
if(!connected_machine)
return
var/datum/gas_mixture/port = connected_machine.airs[1]
port_pressure.set_output(port.return_pressure())
port_temperature.set_output(port.return_temperature())