Skip to content

Commit

Permalink
Ambience tweaks again (#1014)
Browse files Browse the repository at this point in the history
* clean up ambience code more

* dont orbit areas idk how you even do that what the fuck
  • Loading branch information
Kapu1178 authored Jul 22, 2024
1 parent 6d0df89 commit c7f9fa5
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 21 deletions.
26 changes: 14 additions & 12 deletions code/controllers/subsystem/ambience.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ SUBSYSTEM_DEF(ambience)
client_old_areas -= client_iterator
continue

if(!client_mob.can_hear())
continue

//Check to see if the client-mob is in a valid area
var/area/current_area = get_area(client_mob)
if(!current_area) //Something's gone horribly wrong
Expand Down Expand Up @@ -99,14 +102,13 @@ SUBSYSTEM_DEF(ambience)
UnregisterSignal(old_tracked_area, COMSIG_AREA_POWER_CHANGE)
ambience_tracked_area = null

if(!client)
playing_ambience = null
return

if(new_area)
ambience_tracked_area = new_area
RegisterSignal(ambience_tracked_area, COMSIG_AREA_POWER_CHANGE, PROC_REF(refresh_looping_ambience), TRUE)

if(!client)
return

refresh_looping_ambience()

///Tries to play looping ambience to the mobs.
Expand All @@ -115,22 +117,22 @@ SUBSYSTEM_DEF(ambience)
if(!client)
return

var/area/my_area = get_area(src)
var/sound_file = ambience_tracked_area?.ambient_buzz

if(!(client.prefs.toggles & SOUND_SHIP_AMBIENCE) || !my_area?.ambient_buzz)
if(!(client.prefs.toggles & SOUND_SHIP_AMBIENCE) || !sound_file || !can_hear())
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
playing_ambience = null
client.playing_ambience = null
return

//Station ambience is dependant on a functioning and charged APC.
if(!is_mining_level(my_area.z) && ((!my_area.apc || !my_area.apc.operating || !my_area.apc.cell?.charge && my_area.requires_power)))
if(!is_mining_level(ambience_tracked_area.z) && ((!ambience_tracked_area.apc || !ambience_tracked_area.apc.operating || !ambience_tracked_area.apc.cell?.charge && ambience_tracked_area.requires_power)))
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
playing_ambience = null
client.playing_ambience = null
return

else
if(playing_ambience == ambience_tracked_area?.ambient_buzz)
if(client.playing_ambience == sound_file)
return

playing_ambience = my_area.ambient_buzz
SEND_SOUND(src, sound(my_area.ambient_buzz, repeat = 1, wait = 0, volume = my_area.ambient_buzz_vol, channel = CHANNEL_BUZZ))
client.playing_ambience = sound_file
SEND_SOUND(src, sound(sound_file, repeat = 1, wait = 0, volume = ambience_tracked_area.ambient_buzz_vol, channel = CHANNEL_BUZZ))
2 changes: 1 addition & 1 deletion code/datums/components/orbiter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
/////////////////////

/atom/movable/proc/orbit(atom/A, radius = 10, clockwise = FALSE, rotation_speed = 20, rotation_segments = 36, pre_rotation = TRUE)
if(!istype(A) || !get_turf(A) || A == src)
if(!istype(A) || !get_turf(A) || A == src || isarea(A))
return

if(istype(A, /atom/movable/openspace/mimic))
Expand Down
9 changes: 5 additions & 4 deletions code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,16 @@ GLOBAL_LIST_EMPTY(teleportlocs)
set waitfor = FALSE
SEND_SIGNAL(src, COMSIG_AREA_ENTERED, arrived, old_area)

if(ismob(arrived))
var/mob/M = arrived
M.update_ambience_area(src)

if(!arrived.important_recursive_contents?[RECURSIVE_CONTENTS_AREA_SENSITIVE])
return

for(var/atom/movable/recipient as anything in arrived.important_recursive_contents[RECURSIVE_CONTENTS_AREA_SENSITIVE])
SEND_SIGNAL(recipient, COMSIG_ENTER_AREA, src)

if(ismob(arrived))
var/mob/M = arrived
M.update_ambience_area(src)

/**
* Called when an atom exits an area
*
Expand Down
3 changes: 3 additions & 0 deletions code/modules/client/client_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,6 @@
//screen_text vars
///lazylist of screen_texts for this client, first in this list is the one playing
var/list/atom/movable/screen/text/screen_text/screen_texts

/// Keeps track of what ambience we are playing. Yeah i know it sucks.
var/playing_ambience
3 changes: 2 additions & 1 deletion code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change)
. = ..()
var/area/new_area = get_area(src)
update_ambience_area(new_area)
if(new_area != ambience_tracked_area)
update_ambience_area(new_area)

/mob/dead/observer/verb/reenter_corpse()
set category = "Ghost"
Expand Down
13 changes: 13 additions & 0 deletions code/modules/mob/living/init_signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@

RegisterSignal(src, list(SIGNAL_ADDTRAIT(TRAIT_BLURRY_VISION), SIGNAL_REMOVETRAIT(TRAIT_BLURRY_VISION)), PROC_REF(blurry_vision_change))

RegisterSignal(src, SIGNAL_ADDTRAIT(TRAIT_DEAF), PROC_REF(on_hearing_loss))
RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_DEAF), PROC_REF(on_hearing_regain))

RegisterSignal(src, list(SIGNAL_ADDTRAIT(TRAIT_NEGATES_GRAVITY), SIGNAL_REMOVETRAIT(TRAIT_NEGATES_GRAVITY)), PROC_REF(on_negate_gravity))
RegisterSignal(src, list(SIGNAL_ADDTRAIT(TRAIT_IGNORING_GRAVITY), SIGNAL_REMOVETRAIT(TRAIT_IGNORING_GRAVITY)), PROC_REF(on_ignore_gravity))
RegisterSignal(src, list(SIGNAL_ADDTRAIT(TRAIT_FORCED_GRAVITY), SIGNAL_REMOVETRAIT(TRAIT_FORCED_GRAVITY)), PROC_REF(on_force_gravity))
Expand Down Expand Up @@ -275,3 +278,13 @@
/mob/living/proc/blurry_vision_change(datum/source)
SIGNAL_HANDLER
update_eye_blur()

///Called when [TRAIT_DEAF] is added to the mob.
/mob/living/proc/on_hearing_loss()
SIGNAL_HANDLER
refresh_looping_ambience()

///Called when [TRAIT_DEAF] is added to the mob.
/mob/living/proc/on_hearing_regain()
SIGNAL_HANDLER
refresh_looping_ambience()
1 change: 0 additions & 1 deletion code/modules/mob/logout.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
SStgui.on_logout(src)
unset_machine()
remove_from_player_list()
update_ambience_area(null) // Unset ambience vars so it plays again on login
..()

if(loc)
Expand Down
2 changes: 0 additions & 2 deletions code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,5 @@

var/interaction_range = 0 //how far a mob has to be to interact with something without caring about obsctruction, defaulted to 0 tiles

/// Keeps track of what ambience we are playing. Yeah i know it sucks.
var/playing_ambience
/// A ref of the area we're taking our ambient loop from.
var/area/ambience_tracked_area

0 comments on commit c7f9fa5

Please sign in to comment.