Adds GetTypeInAllContents, which should be self-explanatory. Recursively checks for a typepath locating in an atom.

It's used by cavity implants to make sure you can't slip the nuke disk in.
This commit is contained in:
Pete Goodfellow
2013-03-28 13:00:32 +00:00
parent 818b0a94ef
commit bb82a0f2c3
2 changed files with 13 additions and 1 deletions
+12
View File
@@ -627,6 +627,7 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl
sleep(max(sleeptime, 15))
del(animation)
//Will return the contents of an atom recursivly to a depth of 'searchDepth'
/atom/proc/GetAllContents(searchDepth = 5)
var/list/toReturn = list()
@@ -638,6 +639,17 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl
return toReturn
/atom/proc/GetTypeInAllContents(typepath, searchDepth = 5)
for(var/atom/part in contents)
if(istype(part, typepath))
return 1
if(part.contents.len && searchDepth)
if(part.GetTypeInAllContents(typepath, searchDepth - 1))
return 1
return 0
//Step-towards method of determining whether one atom can see another. Similar to viewers()
/proc/can_see(var/atom/source, var/atom/target, var/length=5) // I couldnt be arsed to do actual raycasting :I This is horribly inaccurate.
var/turf/current = get_turf(source)
+1 -1
View File
@@ -24,7 +24,7 @@
/datum/surgery_step/handle_cavity/success(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(tool)
if(IC || tool.w_class > 3 || istype(tool, /obj/item/weapon/disk/nuclear) || istype(tool, /obj/item/organ))
if(IC || tool.w_class > 3 || tool.GetTypeInAllContents(/obj/item/weapon/disk/nuclear) || istype(tool, /obj/item/organ))
user.visible_message("<span class='notice'>[user] can't seem to fit [tool] in [target]'s [target_zone].</span>")
return 0
else