diff --git a/code/__DEFINES/wiremod.dm b/code/__DEFINES/wiremod.dm index e15c2c010e2..b0106f10d9d 100644 --- a/code/__DEFINES/wiremod.dm +++ b/code/__DEFINES/wiremod.dm @@ -88,6 +88,16 @@ #define COMP_RADIO_PUBLIC "public" #define COMP_RADIO_PRIVATE "private" +// Sound component +#define COMP_SOUND_BUZZ "Buzz" +#define COMP_SOUND_BUZZ_TWO "Buzz Twice" +#define COMP_SOUND_CHIME "Chime" +#define COMP_SOUND_HONK "Honk" +#define COMP_SOUND_PING "Ping" +#define COMP_SOUND_SAD "Sad Trombone" +#define COMP_SOUND_WARN "Warn" +#define COMP_SOUND_SLOWCLAP "Slow Clap" + // Security Arrest Console #define COMP_STATE_ARREST "*Arrest*" #define COMP_STATE_PRISONER "Incarcerated" diff --git a/code/modules/research/designs/wiremod_designs.dm b/code/modules/research/designs/wiremod_designs.dm index 14c15a26d5d..1c90cd0e883 100644 --- a/code/modules/research/designs/wiremod_designs.dm +++ b/code/modules/research/designs/wiremod_designs.dm @@ -173,6 +173,11 @@ id = "comp_pull" build_path = /obj/item/circuit_component/pull +/datum/design/component/soundemitter + name = "Sound Emitter Component" + id = "comp_soundemitter" + build_path = /obj/item/circuit_component/soundemitter + /datum/design/component/mmi name = "MMI Component" id = "comp_mmi" diff --git a/code/modules/research/techweb/all_nodes.dm b/code/modules/research/techweb/all_nodes.dm index 3daf00032db..37e5d2ed924 100644 --- a/code/modules/research/techweb/all_nodes.dm +++ b/code/modules/research/techweb/all_nodes.dm @@ -219,6 +219,7 @@ "comp_random", "comp_select_query", "comp_self", + "comp_soundemitter", "comp_species", "comp_speech", "comp_speech", diff --git a/code/modules/wiremod/components/action/soundemitter.dm b/code/modules/wiremod/components/action/soundemitter.dm new file mode 100644 index 00000000000..ab12455314b --- /dev/null +++ b/code/modules/wiremod/components/action/soundemitter.dm @@ -0,0 +1,81 @@ +/** + * # Sound Emitter Component + * + * A component that emits a sound when it receives an input. + */ +/obj/item/circuit_component/soundemitter + display_name = "Sound Emitter" + display_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 + + /// Volume of the sound when played + var/datum/port/input/volume + + /// Frequency of the sound when played + var/datum/port/input/frequency + + /// The cooldown for this component of how often it can play sounds. + var/sound_cooldown = 2 SECONDS + + var/list/options_map + + COOLDOWN_DECLARE(next_sound) + +/obj/item/circuit_component/soundemitter/get_ui_notices() + . = ..() + . += create_ui_notice("Sound Cooldown: [DisplayTimeText(sound_cooldown)]", "orange", "stopwatch") + + +/obj/item/circuit_component/soundemitter/Initialize() + . = ..() + volume = add_input_port("Volume", PORT_TYPE_NUMBER, default = 35) + frequency = add_input_port("Frequency", PORT_TYPE_NUMBER, default = 0) + +/obj/item/circuit_component/soundemitter/Destroy() + frequency = null + volume = null + return ..() + +/obj/item/circuit_component/soundemitter/populate_options() + var/static/component_options = list( + COMP_SOUND_BUZZ, + COMP_SOUND_BUZZ_TWO, + COMP_SOUND_CHIME, + COMP_SOUND_HONK, + COMP_SOUND_PING, + COMP_SOUND_SAD, + COMP_SOUND_WARN, + COMP_SOUND_SLOWCLAP, + ) + options = component_options + + var/static/options_to_sound = list( + COMP_SOUND_BUZZ = 'sound/machines/buzz-sigh.ogg', + COMP_SOUND_BUZZ_TWO = 'sound/machines/buzz-two.ogg', + COMP_SOUND_CHIME = 'sound/machines/chime.ogg', + COMP_SOUND_HONK = 'sound/items/bikehorn.ogg', + COMP_SOUND_PING = 'sound/machines/ping.ogg', + COMP_SOUND_SAD = 'sound/misc/sadtrombone.ogg', + COMP_SOUND_WARN = 'sound/machines/warning-buzzer.ogg', + COMP_SOUND_SLOWCLAP = 'sound/machines/slowclap.ogg', + ) + options_map = options_to_sound + + +/obj/item/circuit_component/soundemitter/input_received(datum/port/input/port) + . = ..() + volume.set_input(clamp(volume.input_value, 0, 100), FALSE) + frequency.set_input(clamp(frequency.input_value, -100, 100), FALSE) + if(.) + return + + if(!COOLDOWN_FINISHED(src, next_sound)) + return + + var/sound_to_play = options_map[current_option] + if(!sound_to_play) + return + + playsound(src, sound_to_play, volume.input_value, FALSE, frequency = frequency.input_value) + + COOLDOWN_START(src, next_sound, sound_cooldown) diff --git a/tgstation.dme b/tgstation.dme index 1cc75080094..40e4fe0ee0a 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3577,6 +3577,7 @@ #include "code\modules\wiremod\components\action\mmi.dm" #include "code\modules\wiremod\components\action\pull.dm" #include "code\modules\wiremod\components\action\radio.dm" +#include "code\modules\wiremod\components\action\soundemitter.dm" #include "code\modules\wiremod\components\action\speech.dm" #include "code\modules\wiremod\components\atom\direction.dm" #include "code\modules\wiremod\components\atom\gps.dm"