[MIRROR] Refactors ambience to a subsystem (#3245)

* Refactors ambience to a subsystem (#56723)

Ambience is now in a subsystem, and plays every now and then without you having to move to a new area for it to play

* Refactors ambience to a subsystem

Co-authored-by: Qustinnus <Floydje123@hotmail.com>
This commit is contained in:
SkyratBot
2021-02-10 00:41:30 +00:00
committed by GitHub
co-authored by Qustinnus
parent 838e95e53a
commit ac561dbf45
10 changed files with 65 additions and 26 deletions
+1 -4
View File
@@ -44,10 +44,7 @@
///////////////
//SOUND STUFF//
///////////////
///Currently playing ambience sound
var/ambience_playing = null
///Whether an ambience sound has been played and one shouldn't be played again, unset by a callback
var/played = FALSE
////////////
//SECURITY//
////////////
+10
View File
@@ -435,6 +435,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
if(!winexists(src, "asset_cache_browser")) // The client is using a custom skin, tell them.
to_chat(src, "<span class='warning'>Unable to access asset cache browser, if you are using a custom skin file, please allow DS to download the updated version, if you are not, then make a bug report. This is not a critical issue but can cause issues with resource downloading, as it is impossible to know when extra resources arrived to you.</span>")
update_ambience_pref()
//This is down here because of the browse() calls in tooltip/New()
if(!tooltips)
@@ -500,6 +501,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
UNSETEMPTY(movingmob.client_mobs_in_contents)
movingmob = null
active_mousedown_item = null
SSambience.ambience_listening_clients -= src
QDEL_NULL(view_size)
QDEL_NULL(void)
QDEL_NULL(tooltips)
@@ -1129,3 +1131,11 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
winset(src, "mapwindow.map", "right-click=false")
winset(src, "default.Shift", "is-disabled=true")
winset(src, "default.ShiftUp", "is-disabled=true")
/client/proc/update_ambience_pref()
if(prefs.toggles & SOUND_AMBIENCE)
if(SSambience.ambience_listening_clients[src] > world.time)
return // If already properly set we don't want to reset the timer.
SSambience.ambience_listening_clients[src] = world.time + 10 SECONDS //Just wait 10 seconds before the next one aight mate? cheers.
else
SSambience.ambience_listening_clients -= src
+1 -1
View File
@@ -239,6 +239,7 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/settings/sound, Toggle_Soundscape)()
to_chat(usr, "You will no longer hear ambient sounds.")
usr.stop_sound_channel(CHANNEL_AMBIENCE)
usr.stop_sound_channel(CHANNEL_BUZZ)
usr.client.update_ambience_pref()
SSblackbox.record_feedback("nested tally", "preferences_verb", 1, list("Toggle Ambience", "[usr.client.prefs.toggles & SOUND_AMBIENCE ? "Enabled" : "Disabled"]")) //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/datum/verbs/menu/settings/sound/Toggle_Soundscape/Get_checked(client/C)
return C.prefs.toggles & SOUND_AMBIENCE
@@ -255,7 +256,6 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/settings/sound, toggle_ship_ambience)()
else
to_chat(usr, "You will no longer hear ship ambience.")
usr.stop_sound_channel(CHANNEL_BUZZ)
usr.client.ambience_playing = 0
SSblackbox.record_feedback("nested tally", "preferences_verb", 1, list("Toggle Ship Ambience", "[usr.client.prefs.toggles & SOUND_SHIP_AMBIENCE ? "Enabled" : "Disabled"]")) //If you are copy-pasting this, I bet you read this comment expecting to see the same thing :^)
/datum/verbs/menu/settings/sound/toggle_ship_ambience/Get_checked(client/C)
return C.prefs.toggles & SOUND_SHIP_AMBIENCE