Merge pull request #12708 from VOREStation/upstream-merge-8511

[MIRROR] updated get_atom_on_turf
This commit is contained in:
Casey
2022-04-11 15:25:19 -04:00
committed by GitHub

View File

@@ -1,10 +1,20 @@
// Returns the atom sitting on the turf.
// For example, using this on a disk, which is in a bag, on a mob, will return the mob because it's on the turf.
/proc/get_atom_on_turf(var/atom/movable/M)
var/atom/mloc = M
while(mloc && mloc.loc && !istype(mloc.loc, /turf/))
mloc = mloc.loc
return mloc
/**
* Returns a best attempt at the least-nested containing movable of subject, or subject.
* eg, if subject is an item in a bag on a mob in a locker in the world, returns the locker.
*/
/proc/get_atom_on_turf(atom/movable/subject)
var/atom/parent = subject?.loc
if (!parent || !ismovable(subject) || isarea(parent))
return subject
var/atom/current = subject
do
parent = current.loc
if (isturf(parent))
return current
current = parent
while (current)
return subject
/proc/iswall(turf/T)
return (istype(T, /turf/simulated/wall) || istype(T, /turf/unsimulated/wall) || istype(T, /turf/simulated/shuttle/wall))