mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Merge pull request #10528 from VOREStation/Arokha/ghostmusic
Allow ghosts to partake in music
This commit is contained in:
committed by
Chompstation Bot
parent
4e39cb8cfc
commit
50c69ffd77
@@ -39,12 +39,6 @@
|
||||
return null
|
||||
return format_text ? format_text(A.name) : A.name
|
||||
|
||||
/proc/get_area_master(const/O)
|
||||
var/area/A = get_area(O)
|
||||
if (isarea(A))
|
||||
return A
|
||||
|
||||
|
||||
/** Checks if any living humans are in a given area. */
|
||||
/proc/area_is_occupied(var/area/myarea)
|
||||
// Testing suggests looping over human_mob_list is quicker than looping over area contents
|
||||
|
||||
@@ -353,21 +353,23 @@
|
||||
|
||||
var/list/mob/living/forced_ambiance_list = new
|
||||
|
||||
/area/Entered(A)
|
||||
if(!istype(A,/mob/living)) return
|
||||
/area/Entered(mob/M)
|
||||
if(!istype(M) || !M.ckey)
|
||||
return
|
||||
|
||||
var/mob/living/L = A
|
||||
if(!L.ckey) return
|
||||
if(!isliving(M))
|
||||
M.lastarea = src
|
||||
return
|
||||
|
||||
var/mob/living/L = M
|
||||
if(!L.lastarea)
|
||||
L.lastarea = get_area(L.loc)
|
||||
var/area/newarea = get_area(L.loc)
|
||||
L.lastarea = src
|
||||
var/area/oldarea = L.lastarea
|
||||
if((oldarea.has_gravity == 0) && (newarea.has_gravity == 1) && (L.m_intent == "run")) // Being ready when you change areas gives you a chance to avoid falling all together.
|
||||
if((oldarea.has_gravity == 0) && (has_gravity == 1) && (L.m_intent == "run")) // Being ready when you change areas gives you a chance to avoid falling all together.
|
||||
thunk(L)
|
||||
L.update_floating( L.Check_Dense_Object() )
|
||||
|
||||
L.lastarea = newarea
|
||||
L.lastarea = src
|
||||
L.lastareachange = world.time
|
||||
play_ambience(L, initial = TRUE)
|
||||
if(no_spoilers)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
M.update_music()
|
||||
|
||||
/obj/machinery/media/proc/update_media_source()
|
||||
var/area/A = get_area_master(src)
|
||||
var/area/A = get_area(src)
|
||||
if(!A)
|
||||
return
|
||||
// Check if there's a media source already.
|
||||
@@ -36,7 +36,7 @@
|
||||
master_area = A
|
||||
|
||||
/obj/machinery/media/proc/disconnect_media_source()
|
||||
var/area/A = get_area_master(src)
|
||||
var/area/A = get_area(src)
|
||||
// Sanity
|
||||
if(!A)
|
||||
master_area = null
|
||||
@@ -48,9 +48,9 @@
|
||||
// Update Media Source.
|
||||
A.media_source = null
|
||||
// Clients
|
||||
for(var/mob/M in mobs_in_area(A))
|
||||
if(M && M.client)
|
||||
M.update_music()
|
||||
for(var/m in mobs_in_area(A))
|
||||
var/mob/M = m
|
||||
M.update_music()
|
||||
master_area = null
|
||||
|
||||
/obj/machinery/media/Move()
|
||||
|
||||
@@ -35,14 +35,14 @@
|
||||
|
||||
// Update when moving between areas.
|
||||
// TODO - While this direct override might technically be faster, probably better code to use observer or hooks ~Leshana
|
||||
/area/Entered(var/mob/living/M)
|
||||
/area/Entered(var/mob/M)
|
||||
// Note, we cannot call ..() first, because it would update lastarea.
|
||||
if(!istype(M))
|
||||
if(!istype(M) || isEye(M))
|
||||
return ..()
|
||||
// Optimization, no need to call update_music() if both are null (or same instance, strange as that would be)
|
||||
if(M.lastarea?.media_source == src.media_source)
|
||||
return ..()
|
||||
if(M.client && M.client.media && !M.client.media.forced)
|
||||
if(M.client?.media && !M.client.media.forced)
|
||||
M.update_music()
|
||||
return ..()
|
||||
|
||||
@@ -73,15 +73,14 @@
|
||||
//
|
||||
|
||||
/mob/proc/update_music()
|
||||
if (client && client.media && !client.media.forced)
|
||||
if (client?.media && !client.media.forced)
|
||||
client.media.update_music()
|
||||
|
||||
/mob/proc/stop_all_music()
|
||||
if (client && client.media)
|
||||
client.media.stop_music()
|
||||
client?.media.stop_music()
|
||||
|
||||
/mob/proc/force_music(var/url, var/start, var/volume=1)
|
||||
if (client && client.media)
|
||||
if (client?.media)
|
||||
if(url == "")
|
||||
client.media.forced = 0
|
||||
client.media.update_music()
|
||||
@@ -168,7 +167,7 @@
|
||||
if (forced || !owner || !owner.mob)
|
||||
return
|
||||
|
||||
var/area/A = get_area_master(owner.mob)
|
||||
var/area/A = get_area(owner.mob)
|
||||
if(!A)
|
||||
MP_DEBUG("client=[owner], mob=[owner.mob] not in an area! loc=[owner.mob.loc]. Aborting.")
|
||||
stop_music()
|
||||
|
||||
@@ -372,8 +372,8 @@ proc/is_blind(A)
|
||||
return 0
|
||||
|
||||
/proc/mobs_in_area(var/area/A)
|
||||
var/list/mobs = new
|
||||
for(var/mob/living/M in mob_list)
|
||||
var/list/mobs = list()
|
||||
for(var/M in mob_list)
|
||||
if(get_area(M) == A)
|
||||
mobs += M
|
||||
return mobs
|
||||
|
||||
Reference in New Issue
Block a user