Skip to content

Commit fe6ecac

Browse files
NovaBot13ArkStation-Bot
authored andcommitted
[MIRROR] Ambience Buzz Handling Changes + Ambience buzz requires enviorment power [MDB IGNORE]
1 parent 5220b49 commit fe6ecac

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed

code/controllers/subsystem/ambience.dm

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,52 @@ SUBSYSTEM_DEF(ambience)
8383
if(!M.has_light_nearby() && prob(0.5))
8484
return ..(M, pick(minecraft_cave_noises))
8585
return ..()
86+
87+
/**
88+
* Ambience buzz handling called by either area/Enter() or refresh_looping_ambience()
89+
*/
90+
91+
/mob/proc/update_ambience_area(area/new_area)
92+
93+
var/old_tracked_area = ambience_tracked_area
94+
if(old_tracked_area)
95+
UnregisterSignal(old_tracked_area, COMSIG_AREA_POWER_CHANGE)
96+
ambience_tracked_area = null
97+
if(!client)
98+
return
99+
if(new_area)
100+
ambience_tracked_area = new_area
101+
RegisterSignal(ambience_tracked_area, COMSIG_AREA_POWER_CHANGE, PROC_REF(refresh_looping_ambience), TRUE)
102+
103+
refresh_looping_ambience()
104+
105+
/mob/proc/refresh_looping_ambience()
106+
SIGNAL_HANDLER
107+
108+
if(!client) // If a tree falls in the woods.
109+
return
110+
111+
var/area/my_area = get_area(src)
112+
var/sound_to_use = my_area.ambient_buzz
113+
114+
if(!sound_to_use || !(client.prefs.read_preference(/datum/preference/toggle/sound_ship_ambience)))
115+
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
116+
client.current_ambient_sound = null
117+
return
118+
119+
if(!can_hear()) // Can the mob hear?
120+
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
121+
client.current_ambient_sound = null
122+
return
123+
124+
//Station ambience is dependant on a functioning and charged APC with enviorment power enabled.
125+
if(!is_mining_level(my_area.z) && ((!my_area.apc || !my_area.apc.operating || !my_area.apc.cell?.charge && my_area.requires_power || !my_area.power_environ)))
126+
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
127+
client.current_ambient_sound = null
128+
return
129+
else
130+
if(sound_to_use == client.current_ambient_sound) // Don't reset current loops
131+
return
132+
133+
client.current_ambient_sound = sound_to_use
134+
SEND_SOUND(src, sound(my_area.ambient_buzz, repeat = 1, wait = 0, volume = my_area.ambient_buzz_vol, channel = CHANNEL_BUZZ))

code/game/area/areas.dm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ GLOBAL_LIST_EMPTY(teleportlocs)
540540
for(var/atom/movable/recipient as anything in arrived.important_recursive_contents[RECURSIVE_CONTENTS_AREA_SENSITIVE])
541541
SEND_SIGNAL(recipient, COMSIG_ENTER_AREA, src)
542542

543+
<<<<<<< HEAD
543544
if(!isliving(arrived))
544545
return
545546

@@ -559,6 +560,11 @@ GLOBAL_LIST_EMPTY(teleportlocs)
559560
return
560561

561562
SEND_SOUND(src, sound(my_area.ambient_buzz, repeat = 1, wait = 0, volume = my_area.ambient_buzz_vol, channel = CHANNEL_BUZZ))
563+
=======
564+
if(ismob(arrived))
565+
var/mob/mob = arrived
566+
mob.update_ambience_area(src)
567+
>>>>>>> c949f8dbb56... [MIRROR] Ambience Buzz Handling Changes + Ambience buzz requires enviorment power [MDB IGNORE] (#3440)
562568

563569
/**
564570
* Called when an atom exits an area

code/modules/mob/dead/observer/observer.dm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
364364
abstract_move(destination) // move like the wind
365365
return TRUE
366366

367+
/mob/dead/observer/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change)
368+
. = ..()
369+
var/area/new_area = get_area(src)
370+
if(new_area != ambience_tracked_area)
371+
update_ambience_area(new_area)
372+
367373
/mob/dead/observer/verb/reenter_corpse()
368374
set category = "Ghost"
369375
set name = "Re-enter Corpse"

code/modules/mob/login.dm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@
9999

100100
update_client_colour()
101101
update_mouse_pointer()
102+
<<<<<<< HEAD
102103
refresh_looping_ambience()
104+
=======
105+
update_ambience_area(get_area(src))
106+
107+
if(!can_hear())
108+
stop_sound_channel(CHANNEL_AMBIENCE)
109+
>>>>>>> c949f8dbb56... [MIRROR] Ambience Buzz Handling Changes + Ambience buzz requires enviorment power [MDB IGNORE] (#3440)
103110

104111
if(client)
105112
if(client.view_size)

code/modules/mob/logout.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
log_message("[key_name(src)] is no longer owning mob [src]([src.type])", LOG_OWNERSHIP)
44
SStgui.on_logout(src)
55
remove_from_player_list()
6+
update_ambience_area(null) // Unset ambience vars so it plays again on login
67
..()
78

89
if(loc)

code/modules/mob/mob_defines.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,6 @@
191191
var/active_typing_indicator
192192
///the icon currently used for the thinking indicator's bubble
193193
var/active_thinking_indicator
194+
195+
/// A ref of the area we're taking our ambient loop from.
196+
var/area/ambience_tracked_area

0 commit comments

Comments
 (0)