mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 05:30:05 +01:00
[MIRROR] Added further limitations on the sound emitter circuit component [MDB IGNORE] (#14401)
* Added further limitations on the sound emitter circuit component (#67540) Added limitations on the sound emitter component Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> * Added further limitations on the sound emitter circuit component 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:
co-authored by
Watermelon914
Watermelon914
parent
b07b1752e5
commit
1464f5ec56
@@ -15,22 +15,35 @@
|
||||
/// Volume of the sound when played
|
||||
var/datum/port/input/volume
|
||||
|
||||
/// Whether to play the sound backwards
|
||||
var/datum/port/input/backwards
|
||||
|
||||
/// 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
|
||||
|
||||
/// The maximum pitch this component can play sounds at.
|
||||
var/max_pitch = 50
|
||||
/// The minimum pitch this component can play sounds at.
|
||||
var/min_pitch = -50
|
||||
/// The maximum volume this component can play sounds at.
|
||||
var/max_volume = 30
|
||||
|
||||
var/list/options_map
|
||||
|
||||
/obj/item/circuit_component/soundemitter/get_ui_notices()
|
||||
. = ..()
|
||||
. += create_ui_notice("Sound Cooldown: [DisplayTimeText(sound_cooldown)]", "orange", "stopwatch")
|
||||
if(CONFIG_GET(flag/disallow_circuit_sounds))
|
||||
. += create_ui_notice("Non-functional", "red", "exclamation")
|
||||
|
||||
|
||||
/obj/item/circuit_component/soundemitter/populate_ports()
|
||||
volume = add_input_port("Volume", PORT_TYPE_NUMBER, default = 35)
|
||||
frequency = add_input_port("Frequency", PORT_TYPE_NUMBER, default = 0)
|
||||
backwards = add_input_port("Play Backwards", PORT_TYPE_NUMBER, default = 0)
|
||||
|
||||
/obj/item/circuit_component/soundemitter/populate_options()
|
||||
var/static/component_options = list(
|
||||
@@ -61,9 +74,16 @@
|
||||
|
||||
/obj/item/circuit_component/soundemitter/pre_input_received(datum/port/input/port)
|
||||
volume.set_value(clamp(volume.value, 0, 100))
|
||||
frequency.set_value(clamp(frequency.value, -100, 100))
|
||||
frequency.set_value(clamp(frequency.value, min_pitch, max_pitch))
|
||||
backwards.set_value(clamp(backwards.value, 0, 1))
|
||||
|
||||
/obj/item/circuit_component/soundemitter/input_received(datum/port/input/port)
|
||||
if(CONFIG_GET(flag/disallow_circuit_sounds))
|
||||
ui_color = "red"
|
||||
return
|
||||
else
|
||||
ui_color = initial(ui_color)
|
||||
|
||||
if(TIMER_COOLDOWN_CHECK(parent, COOLDOWN_CIRCUIT_SOUNDEMITTER))
|
||||
return
|
||||
|
||||
@@ -71,6 +91,12 @@
|
||||
if(!sound_to_play)
|
||||
return
|
||||
|
||||
playsound(src, sound_to_play, volume.value, frequency != 0, frequency = frequency.value)
|
||||
var/actual_frequency = 1 + (frequency.value/100)
|
||||
var/actual_volume = max_volume * (volume.value/100)
|
||||
|
||||
if(backwards.value)
|
||||
actual_frequency = -actual_frequency
|
||||
|
||||
playsound(src, sound_to_play, actual_volume, TRUE, frequency = actual_frequency)
|
||||
|
||||
TIMER_COOLDOWN_START(parent, COOLDOWN_CIRCUIT_SOUNDEMITTER, sound_cooldown)
|
||||
|
||||
Reference in New Issue
Block a user