[MIRROR] Refactors port types completely and adds the option type. Refactors options to use this new type (#7386)

* Refactors port types completely and adds the option type. Refactors options to use this new type (#60571)

Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>

* Refactors port types completely and adds the option type. Refactors options to use this new type

Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>
This commit is contained in:
SkyratBot
2021-08-04 18:30:56 +01:00
committed by GitHub
co-authored by Watermelon914 Watermelon914
parent 742f11f0d8
commit 3ab1e7ebe2
39 changed files with 487 additions and 271 deletions
@@ -7,6 +7,9 @@
display_name = "Radio"
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."
/// The publicity options. Controls whether it's public or private.
var/datum/port/input/option/public_options
/// Frequency input
var/datum/port/input/freq
/// Signal input
@@ -22,7 +25,7 @@
COMP_RADIO_PUBLIC,
COMP_RADIO_PRIVATE,
)
options = component_options
public_options = add_option_port("Encryption Options", component_options)
/obj/item/circuit_component/radio/Initialize()
. = ..()
@@ -59,7 +62,7 @@
if(signal.data["code"] != round(code.input_value || 0))
return
if(current_option == COMP_RADIO_PRIVATE && parent?.owner_id != signal.data["key"])
if(public_options.input_value == COMP_RADIO_PRIVATE && parent?.owner_id != signal.data["key"])
return
trigger_output.set_output(COMPONENT_SIGNAL)
@@ -8,6 +8,9 @@
desc = "A component that emits a sound when it receives an input. The frequency is a multiplier which determines the speed at which the sound is played"
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
/// Sound to play
var/datum/port/input/option/sound_file
/// Volume of the sound when played
var/datum/port/input/volume
@@ -40,7 +43,7 @@
COMP_SOUND_WARN,
COMP_SOUND_SLOWCLAP,
)
options = component_options
sound_file = add_option_port("Sound Option", component_options)
var/static/options_to_sound = list(
COMP_SOUND_BUZZ = 'sound/machines/buzz-sigh.ogg',
@@ -65,7 +68,7 @@
if(TIMER_COOLDOWN_CHECK(parent, COOLDOWN_CIRCUIT_SOUNDEMITTER))
return
var/sound_to_play = options_map[current_option]
var/sound_to_play = options_map[sound_file.input_value]
if(!sound_to_play)
return