mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 15:17:01 +01:00
[MIRROR] Optimized Getallcontents (#2552)
* Optimized Getallcontents (#55964) Optimized Getallcontents, split up it's component procs * Optimized Getallcontents Co-authored-by: TiviPlus <57223640+TiviPlus@users.noreply.github.com>
This commit is contained in:
+17
-22
@@ -414,30 +414,25 @@ Turf and target are separate in case you want to teleport some distance from a t
|
||||
var/y = min(world.maxy, max(1, A.y + dy))
|
||||
return locate(x,y,A.z)
|
||||
|
||||
/*
|
||||
Gets all contents of contents and returns them all in a list.
|
||||
*/
|
||||
|
||||
/atom/proc/GetAllContents(T, ignore_flag_1)
|
||||
///Returns the src and all recursive contents as a list.
|
||||
/atom/proc/GetAllContents()
|
||||
. = list(src)
|
||||
var/i = 0
|
||||
while(i < length(.))
|
||||
var/atom/A = .[++i]
|
||||
. += A.contents
|
||||
|
||||
///identical to getallcontents but returns a list of atoms of the type passed in the argument.
|
||||
/atom/proc/get_all_contents_type(type)
|
||||
var/list/processing_list = list(src)
|
||||
if(T)
|
||||
. = list()
|
||||
var/i = 0
|
||||
while(i < length(processing_list))
|
||||
var/atom/A = processing_list[++i]
|
||||
//Byond does not allow things to be in multiple contents, or double parent-child hierarchies, so only += is needed
|
||||
//This is also why we don't need to check against assembled as we go along
|
||||
if (!(A.flags_1 & ignore_flag_1))
|
||||
processing_list += A.contents
|
||||
if(istype(A,T))
|
||||
. += A
|
||||
else
|
||||
var/i = 0
|
||||
while(i < length(processing_list))
|
||||
var/atom/A = processing_list[++i]
|
||||
if (!(A.flags_1 & ignore_flag_1))
|
||||
processing_list += A.contents
|
||||
return processing_list
|
||||
. = list()
|
||||
while(length(processing_list))
|
||||
var/atom/A = processing_list[1]
|
||||
processing_list.Cut(1, 2)
|
||||
processing_list += A.contents
|
||||
if(istype(A, type))
|
||||
. += A
|
||||
|
||||
/atom/proc/GetAllContentsIgnoring(list/ignore_typecache)
|
||||
if(!length(ignore_typecache))
|
||||
|
||||
@@ -181,7 +181,7 @@ GLOBAL_LIST_EMPTY(bodycontainers) //Let them act as spawnpoints for revenants an
|
||||
icon_state = "morgue1"
|
||||
else
|
||||
icon_state = "morgue2" // Dead, brainded mob.
|
||||
var/list/compiled = GetAllContents(/mob/living) // Search for mobs in all contents.
|
||||
var/list/compiled = get_all_contents_type(/mob/living) // Search for mobs in all contents.
|
||||
if(!length(compiled)) // No mobs?
|
||||
icon_state = "morgue3"
|
||||
return
|
||||
@@ -295,7 +295,7 @@ GLOBAL_LIST_EMPTY(crematoriums)
|
||||
|
||||
/obj/structure/bodycontainer/crematorium/creamatorium/cremate(mob/user)
|
||||
var/list/icecreams = new()
|
||||
for(var/i_scream in GetAllContents(/mob/living))
|
||||
for(var/i_scream in get_all_contents_type(/mob/living))
|
||||
var/obj/item/food/icecream/IC = new()
|
||||
IC.set_cone_type("waffle")
|
||||
IC.add_mob_flavor(i_scream)
|
||||
|
||||
@@ -360,7 +360,7 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999))
|
||||
. = ..()
|
||||
if(istype(AM, /obj/item/hilbertshotel))
|
||||
relocate(AM)
|
||||
var/list/obj/item/hilbertshotel/hotels = AM.GetAllContents(/obj/item/hilbertshotel)
|
||||
var/list/obj/item/hilbertshotel/hotels = AM.get_all_contents_type(/obj/item/hilbertshotel)
|
||||
for(var/obj/item/hilbertshotel/H in hotels)
|
||||
if(parentSphere == H)
|
||||
relocate(H)
|
||||
@@ -399,7 +399,7 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999))
|
||||
var/mob/M = AM
|
||||
if(M.mind)
|
||||
var/stillPopulated = FALSE
|
||||
var/list/currentLivingMobs = GetAllContents(/mob/living) //Got to catch anyone hiding in anything
|
||||
var/list/currentLivingMobs = get_all_contents_type(/mob/living) //Got to catch anyone hiding in anything
|
||||
for(var/mob/living/L in currentLivingMobs) //Check to see if theres any sentient mobs left.
|
||||
if(L.mind)
|
||||
stillPopulated = TRUE
|
||||
|
||||
Reference in New Issue
Block a user