mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-02 21:11:57 +00:00
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
This commit is contained in:
@@ -154,6 +154,7 @@
|
||||
#define FIRE_PRIORITY_SERVER_MAINT 10
|
||||
#define FIRE_PRIORITY_RESEARCH 10
|
||||
#define FIRE_PRIORITY_VIS 10
|
||||
#define FIRE_PRIORITY_AMBIENCE 10
|
||||
#define FIRE_PRIORITY_GARBAGE 15
|
||||
#define FIRE_PRIORITY_WET_FLOORS 20
|
||||
#define FIRE_PRIORITY_AIR 20
|
||||
|
||||
27
code/controllers/subsystem/ambience.dm
Normal file
27
code/controllers/subsystem/ambience.dm
Normal file
@@ -0,0 +1,27 @@
|
||||
/// The subsystem used to play ambience to users every now and then, makes them real excited.
|
||||
SUBSYSTEM_DEF(ambience)
|
||||
name = "Ambience"
|
||||
flags = SS_BACKGROUND|SS_NO_INIT
|
||||
priority = FIRE_PRIORITY_AMBIENCE
|
||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
||||
wait = 1 SECONDS
|
||||
///Assoc list of listening client - next ambience time
|
||||
var/list/ambience_listening_clients = list()
|
||||
|
||||
/datum/controller/subsystem/ambience/fire(resumed)
|
||||
for(var/client/client_iterator as anything in ambience_listening_clients)
|
||||
|
||||
if(isnull(client_iterator))
|
||||
ambience_listening_clients -= client_iterator
|
||||
continue
|
||||
|
||||
if(ambience_listening_clients[client_iterator] > world.time)
|
||||
continue //Not ready for the next sound
|
||||
|
||||
var/area/current_area = get_area(client_iterator.mob)
|
||||
|
||||
var/sound = pick(current_area.ambientsounds)
|
||||
|
||||
SEND_SOUND(client_iterator.mob, sound(sound, repeat = 0, wait = 0, volume = 25, channel = CHANNEL_AMBIENCE))
|
||||
|
||||
ambience_listening_clients[client_iterator] = world.time + rand(current_area.min_ambience_cooldown, current_area.max_ambience_cooldown)
|
||||
@@ -85,6 +85,11 @@
|
||||
///Used to decide what kind of reverb the area makes sound have
|
||||
var/sound_environment = SOUND_ENVIRONMENT_NONE
|
||||
|
||||
///Used to decide what the minimum time between ambience is
|
||||
var/min_ambience_cooldown = 30 SECONDS
|
||||
///Used to decide what the maximum time between ambience is
|
||||
var/max_ambience_cooldown = 90 SECONDS
|
||||
|
||||
/**
|
||||
* A list of teleport locations
|
||||
*
|
||||
@@ -574,22 +579,10 @@ GLOBAL_LIST_EMPTY(teleportlocs)
|
||||
if(!L.ckey)
|
||||
return
|
||||
|
||||
// Ambience goes down here -- make sure to list each area separately for ease of adding things in later, thanks! Note: areas adjacent to each other should have the same sounds to prevent cutoff when possible.- LastyScratch
|
||||
if(L.client && !L.client.ambience_playing && L.client.prefs.toggles & SOUND_SHIP_AMBIENCE)
|
||||
L.client.ambience_playing = 1
|
||||
//Ship ambience just loops if turned on.
|
||||
if(L.client?.prefs.toggles & SOUND_SHIP_AMBIENCE)
|
||||
SEND_SOUND(L, sound('sound/ambience/shipambience.ogg', repeat = 1, wait = 0, volume = 35, channel = CHANNEL_BUZZ))
|
||||
|
||||
if(!(L.client && (L.client.prefs.toggles & SOUND_AMBIENCE)))
|
||||
return //General ambience check is below the ship ambience so one can play without the other
|
||||
|
||||
if(prob(35))
|
||||
var/sound = pick(ambientsounds)
|
||||
|
||||
if(!L.client.played)
|
||||
SEND_SOUND(L, sound(sound, repeat = 0, wait = 0, volume = 25, channel = CHANNEL_AMBIENCE))
|
||||
L.client.played = TRUE
|
||||
addtimer(CALLBACK(L.client, /client/proc/ResetAmbiencePlayed), 600)
|
||||
|
||||
///Divides total beauty in the room by roomsize to allow us to get an average beauty per tile.
|
||||
/area/proc/update_beauty()
|
||||
if(!areasize)
|
||||
@@ -610,11 +603,6 @@ GLOBAL_LIST_EMPTY(teleportlocs)
|
||||
SEND_SIGNAL(src, COMSIG_AREA_EXITED, M)
|
||||
SEND_SIGNAL(M, COMSIG_EXIT_AREA, src) //The atom that exits the area
|
||||
|
||||
/**
|
||||
* Reset the played var to false on the client
|
||||
*/
|
||||
/client/proc/ResetAmbiencePlayed()
|
||||
played = FALSE
|
||||
|
||||
/**
|
||||
* Setup an area (with the given name)
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
ambience_index = AMBIENCE_MINING
|
||||
area_flags = VALID_TERRITORY | UNIQUE_AREA | NO_ALERTS
|
||||
sound_environment = SOUND_AREA_STANDARD_STATION
|
||||
min_ambience_cooldown = 70 SECONDS
|
||||
max_ambience_cooldown = 220 SECONDS
|
||||
|
||||
/area/mine/unexplored
|
||||
name = "Mine"
|
||||
@@ -31,6 +33,8 @@
|
||||
flags_1 = NONE
|
||||
ambience_index = AMBIENCE_MINING
|
||||
area_flags = VALID_TERRITORY | UNIQUE_AREA | FLORA_ALLOWED | CAVES_ALLOWED | NO_ALERTS
|
||||
min_ambience_cooldown = 70 SECONDS
|
||||
max_ambience_cooldown = 220 SECONDS
|
||||
|
||||
/area/mine/lobby
|
||||
name = "Mining Station"
|
||||
@@ -104,6 +108,8 @@
|
||||
requires_power = TRUE
|
||||
ambience_index = AMBIENCE_MINING
|
||||
area_flags = VALID_TERRITORY | UNIQUE_AREA | FLORA_ALLOWED | NO_ALERTS
|
||||
min_ambience_cooldown = 70 SECONDS
|
||||
max_ambience_cooldown = 220 SECONDS
|
||||
|
||||
/area/lavaland/underground
|
||||
name = "Lavaland Caves"
|
||||
@@ -115,7 +121,8 @@
|
||||
power_light = FALSE
|
||||
ambience_index = AMBIENCE_MINING
|
||||
area_flags = VALID_TERRITORY | UNIQUE_AREA | FLORA_ALLOWED | NO_ALERTS
|
||||
|
||||
min_ambience_cooldown = 70 SECONDS
|
||||
max_ambience_cooldown = 220 SECONDS
|
||||
|
||||
/area/lavaland/surface/outdoors
|
||||
name = "Lavaland Wastes"
|
||||
@@ -155,6 +162,8 @@
|
||||
requires_power = TRUE
|
||||
ambience_index = AMBIENCE_MINING
|
||||
area_flags = UNIQUE_AREA | FLORA_ALLOWED | NO_ALERTS
|
||||
min_ambience_cooldown = 70 SECONDS
|
||||
max_ambience_cooldown = 220 SECONDS
|
||||
|
||||
/area/icemoon/surface/outdoors // weather happens here
|
||||
name = "Icemoon Wastes"
|
||||
@@ -185,6 +194,8 @@
|
||||
power_light = FALSE
|
||||
ambience_index = AMBIENCE_MINING
|
||||
area_flags = UNIQUE_AREA | FLORA_ALLOWED | NO_ALERTS
|
||||
min_ambience_cooldown = 70 SECONDS
|
||||
max_ambience_cooldown = 220 SECONDS
|
||||
|
||||
/area/icemoon/underground/unexplored // mobs and megafauna and ruins spawn here
|
||||
name = "Icemoon Caves"
|
||||
|
||||
@@ -63,6 +63,8 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
|
||||
ambience_index = AMBIENCE_MINING
|
||||
flags_1 = CAN_BE_DIRTY_1
|
||||
sound_environment = SOUND_AREA_ASTEROID
|
||||
min_ambience_cooldown = 70 SECONDS
|
||||
max_ambience_cooldown = 220 SECONDS
|
||||
|
||||
/area/asteroid/nearstation
|
||||
dynamic_lighting = DYNAMIC_LIGHTING_FORCED
|
||||
@@ -922,6 +924,8 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
|
||||
ambience_index = AMBIENCE_MEDICAL
|
||||
airlock_wires = /datum/wires/airlock/medbay
|
||||
sound_environment = SOUND_AREA_STANDARD_STATION
|
||||
min_ambience_cooldown = 90 SECONDS
|
||||
max_ambience_cooldown = 180 SECONDS
|
||||
|
||||
/area/medical/abandoned
|
||||
name = "Abandoned Medbay"
|
||||
|
||||
@@ -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//
|
||||
////////////
|
||||
|
||||
@@ -431,6 +431,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)
|
||||
@@ -496,6 +497,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)
|
||||
@@ -1099,3 +1101,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
|
||||
|
||||
@@ -238,6 +238,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
|
||||
@@ -254,7 +255,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
|
||||
|
||||
@@ -278,6 +278,7 @@
|
||||
#include "code\controllers\subsystem\achievements.dm"
|
||||
#include "code\controllers\subsystem\adjacent_air.dm"
|
||||
#include "code\controllers\subsystem\air.dm"
|
||||
#include "code\controllers\subsystem\ambience.dm"
|
||||
#include "code\controllers\subsystem\assets.dm"
|
||||
#include "code\controllers\subsystem\atoms.dm"
|
||||
#include "code\controllers\subsystem\augury.dm"
|
||||
|
||||
Reference in New Issue
Block a user