Adds the airlock shell, refactors USB code to be easier to use, implements USB cables for the binary valve and more. (#59728)

Adds the airlock shell. The circuit has full control over the airlock.
Refactors USB code to be easier to use for less experienced coders.
Implements USB cables for the binary valve to be able to open/close the valve.
Adds a private channel for radios that only lets circuits with the same owner's ID to interact with it.
This commit is contained in:
Watermelon914
2021-06-24 14:22:19 -03:00
committed by GitHub
parent 6985c5f663
commit 921416b5d8
16 changed files with 313 additions and 49 deletions
@@ -5,7 +5,7 @@
*/
/obj/item/circuit_component/radio
display_name = "Radio"
display_desc = "A component that can listen and send frequencies."
display_desc = "A component that can listen and send frequencies. If set to private, the component will only receive signals from other components attached to circuitboards with the same owner id."
/// Frequency input
var/datum/port/input/freq
@@ -17,10 +17,18 @@
var/datum/radio_frequency/radio_connection
/obj/item/circuit_component/radio/populate_options()
var/static/component_options = list(
COMP_RADIO_PUBLIC,
COMP_RADIO_PRIVATE,
)
options = component_options
/obj/item/circuit_component/radio/Initialize()
. = ..()
freq = add_input_port("Frequency", PORT_TYPE_NUMBER, default = FREQ_SIGNALER)
code = add_input_port("Code", PORT_TYPE_NUMBER, default = DEFAULT_SIGNALER_CODE)
TRIGGER_CIRCUIT_COMPONENT(src, null)
// These are cleaned up on the parent
trigger_input = add_input_port("Send", PORT_TYPE_SIGNAL)
trigger_output = add_output_port("Received", PORT_TYPE_SIGNAL)
@@ -44,7 +52,7 @@
current_freq = frequency
if(COMPONENT_TRIGGERED_BY(trigger_input, port))
var/datum/signal/signal = new(list("code" = round(code.input_value) || 0))
var/datum/signal/signal = new(list("code" = round(code.input_value) || 0, "key" = parent?.owner_id))
radio_connection.post_signal(src, signal)
/obj/item/circuit_component/radio/receive_signal(datum/signal/signal)
@@ -54,4 +62,7 @@
if(signal.data["code"] != round(code.input_value || 0))
return
if(current_option == COMP_RADIO_PRIVATE && parent?.owner_id != signal.data["key"])
return
trigger_output.set_output(COMPONENT_SIGNAL)