Skip to content

[MIRROR] [MIRROR] Ambience Buzz Handling Changes + Ambience buzz requires enviorment power [MDB IGNORE] #740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions code/controllers/subsystem/ambience.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,52 @@ SUBSYSTEM_DEF(ambience)
if(!M.has_light_nearby() && prob(0.5))
return ..(M, pick(minecraft_cave_noises))
return ..()

/**
* Ambience buzz handling called by either area/Enter() or refresh_looping_ambience()
*/

/mob/proc/update_ambience_area(area/new_area)

var/old_tracked_area = ambience_tracked_area
if(old_tracked_area)
UnregisterSignal(old_tracked_area, COMSIG_AREA_POWER_CHANGE)
ambience_tracked_area = null
if(!client)
return
if(new_area)
ambience_tracked_area = new_area
RegisterSignal(ambience_tracked_area, COMSIG_AREA_POWER_CHANGE, PROC_REF(refresh_looping_ambience), TRUE)

refresh_looping_ambience()

/mob/proc/refresh_looping_ambience()
SIGNAL_HANDLER

if(!client) // If a tree falls in the woods.
return

var/area/my_area = get_area(src)
var/sound_to_use = my_area.ambient_buzz

if(!sound_to_use || !(client.prefs.read_preference(/datum/preference/toggle/sound_ship_ambience)))
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
client.current_ambient_sound = null
return

if(!can_hear()) // Can the mob hear?
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
client.current_ambient_sound = null
return

//Station ambience is dependant on a functioning and charged APC with enviorment power enabled.
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)))
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
client.current_ambient_sound = null
return
else
if(sound_to_use == client.current_ambient_sound) // Don't reset current loops
return

client.current_ambient_sound = sound_to_use
SEND_SOUND(src, sound(my_area.ambient_buzz, repeat = 1, wait = 0, volume = my_area.ambient_buzz_vol, channel = CHANNEL_BUZZ))
6 changes: 6 additions & 0 deletions code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@
for(var/atom/movable/recipient as anything in arrived.important_recursive_contents[RECURSIVE_CONTENTS_AREA_SENSITIVE])
SEND_SIGNAL(recipient, COMSIG_ENTER_AREA, src)

<<<<<<< HEAD

Check failure on line 543 in code/game/area/areas.dm

View workflow job for this annotation

GitHub Actions / Run Linters

got '<<', expected one of: newline, '/', identifier
if(!isliving(arrived))
return

Expand All @@ -559,6 +560,11 @@
return

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

/**
* Called when an atom exits an area
Expand Down
6 changes: 6 additions & 0 deletions code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
abstract_move(destination) // move like the wind
return TRUE

/mob/dead/observer/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change)
. = ..()
var/area/new_area = get_area(src)
if(new_area != ambience_tracked_area)
update_ambience_area(new_area)

/mob/dead/observer/verb/reenter_corpse()
set category = "Ghost"
set name = "Re-enter Corpse"
Expand Down
7 changes: 7 additions & 0 deletions code/modules/mob/login.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@

update_client_colour()
update_mouse_pointer()
<<<<<<< HEAD
refresh_looping_ambience()
=======
update_ambience_area(get_area(src))

if(!can_hear())
stop_sound_channel(CHANNEL_AMBIENCE)
>>>>>>> c949f8dbb56... [MIRROR] Ambience Buzz Handling Changes + Ambience buzz requires enviorment power [MDB IGNORE] (#3440)

if(client)
if(client.view_size)
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/logout.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
log_message("[key_name(src)] is no longer owning mob [src]([src.type])", LOG_OWNERSHIP)
SStgui.on_logout(src)
remove_from_player_list()
update_ambience_area(null) // Unset ambience vars so it plays again on login
..()

if(loc)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,6 @@
var/active_typing_indicator
///the icon currently used for the thinking indicator's bubble
var/active_thinking_indicator

/// A ref of the area we're taking our ambient loop from.
var/area/ambience_tracked_area
Loading