mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +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 null
|
||||||
return format_text ? format_text(A.name) : A.name
|
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. */
|
/** Checks if any living humans are in a given area. */
|
||||||
/proc/area_is_occupied(var/area/myarea)
|
/proc/area_is_occupied(var/area/myarea)
|
||||||
// Testing suggests looping over human_mob_list is quicker than looping over area contents
|
// 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
|
var/list/mob/living/forced_ambiance_list = new
|
||||||
|
|
||||||
/area/Entered(A)
|
/area/Entered(mob/M)
|
||||||
if(!istype(A,/mob/living)) return
|
if(!istype(M) || !M.ckey)
|
||||||
|
return
|
||||||
|
|
||||||
var/mob/living/L = A
|
if(!isliving(M))
|
||||||
if(!L.ckey) return
|
M.lastarea = src
|
||||||
|
return
|
||||||
|
|
||||||
|
var/mob/living/L = M
|
||||||
if(!L.lastarea)
|
if(!L.lastarea)
|
||||||
L.lastarea = get_area(L.loc)
|
L.lastarea = src
|
||||||
var/area/newarea = get_area(L.loc)
|
|
||||||
var/area/oldarea = L.lastarea
|
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)
|
thunk(L)
|
||||||
L.update_floating( L.Check_Dense_Object() )
|
L.update_floating( L.Check_Dense_Object() )
|
||||||
|
|
||||||
L.lastarea = newarea
|
L.lastarea = src
|
||||||
L.lastareachange = world.time
|
L.lastareachange = world.time
|
||||||
play_ambience(L, initial = TRUE)
|
play_ambience(L, initial = TRUE)
|
||||||
if(no_spoilers)
|
if(no_spoilers)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
M.update_music()
|
M.update_music()
|
||||||
|
|
||||||
/obj/machinery/media/proc/update_media_source()
|
/obj/machinery/media/proc/update_media_source()
|
||||||
var/area/A = get_area_master(src)
|
var/area/A = get_area(src)
|
||||||
if(!A)
|
if(!A)
|
||||||
return
|
return
|
||||||
// Check if there's a media source already.
|
// Check if there's a media source already.
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
master_area = A
|
master_area = A
|
||||||
|
|
||||||
/obj/machinery/media/proc/disconnect_media_source()
|
/obj/machinery/media/proc/disconnect_media_source()
|
||||||
var/area/A = get_area_master(src)
|
var/area/A = get_area(src)
|
||||||
// Sanity
|
// Sanity
|
||||||
if(!A)
|
if(!A)
|
||||||
master_area = null
|
master_area = null
|
||||||
@@ -48,9 +48,9 @@
|
|||||||
// Update Media Source.
|
// Update Media Source.
|
||||||
A.media_source = null
|
A.media_source = null
|
||||||
// Clients
|
// Clients
|
||||||
for(var/mob/M in mobs_in_area(A))
|
for(var/m in mobs_in_area(A))
|
||||||
if(M && M.client)
|
var/mob/M = m
|
||||||
M.update_music()
|
M.update_music()
|
||||||
master_area = null
|
master_area = null
|
||||||
|
|
||||||
/obj/machinery/media/Move()
|
/obj/machinery/media/Move()
|
||||||
|
|||||||
@@ -35,14 +35,14 @@
|
|||||||
|
|
||||||
// Update when moving between areas.
|
// Update when moving between areas.
|
||||||
// TODO - While this direct override might technically be faster, probably better code to use observer or hooks ~Leshana
|
// 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.
|
// Note, we cannot call ..() first, because it would update lastarea.
|
||||||
if(!istype(M))
|
if(!istype(M) || isEye(M))
|
||||||
return ..()
|
return ..()
|
||||||
// Optimization, no need to call update_music() if both are null (or same instance, strange as that would be)
|
// 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)
|
if(M.lastarea?.media_source == src.media_source)
|
||||||
return ..()
|
return ..()
|
||||||
if(M.client && M.client.media && !M.client.media.forced)
|
if(M.client?.media && !M.client.media.forced)
|
||||||
M.update_music()
|
M.update_music()
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
@@ -73,15 +73,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
/mob/proc/update_music()
|
/mob/proc/update_music()
|
||||||
if (client && client.media && !client.media.forced)
|
if (client?.media && !client.media.forced)
|
||||||
client.media.update_music()
|
client.media.update_music()
|
||||||
|
|
||||||
/mob/proc/stop_all_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)
|
/mob/proc/force_music(var/url, var/start, var/volume=1)
|
||||||
if (client && client.media)
|
if (client?.media)
|
||||||
if(url == "")
|
if(url == "")
|
||||||
client.media.forced = 0
|
client.media.forced = 0
|
||||||
client.media.update_music()
|
client.media.update_music()
|
||||||
@@ -168,7 +167,7 @@
|
|||||||
if (forced || !owner || !owner.mob)
|
if (forced || !owner || !owner.mob)
|
||||||
return
|
return
|
||||||
|
|
||||||
var/area/A = get_area_master(owner.mob)
|
var/area/A = get_area(owner.mob)
|
||||||
if(!A)
|
if(!A)
|
||||||
MP_DEBUG("client=[owner], mob=[owner.mob] not in an area! loc=[owner.mob.loc]. Aborting.")
|
MP_DEBUG("client=[owner], mob=[owner.mob] not in an area! loc=[owner.mob.loc]. Aborting.")
|
||||||
stop_music()
|
stop_music()
|
||||||
|
|||||||
@@ -372,8 +372,8 @@ proc/is_blind(A)
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
/proc/mobs_in_area(var/area/A)
|
/proc/mobs_in_area(var/area/A)
|
||||||
var/list/mobs = new
|
var/list/mobs = list()
|
||||||
for(var/mob/living/M in mob_list)
|
for(var/M in mob_list)
|
||||||
if(get_area(M) == A)
|
if(get_area(M) == A)
|
||||||
mobs += M
|
mobs += M
|
||||||
return mobs
|
return mobs
|
||||||
|
|||||||
Reference in New Issue
Block a user