Ports typecaches and their use in the tesla

This commit is contained in:
Krausus
2016-08-03 20:08:51 -04:00
parent 3c671d7ae4
commit ea0f5b9802
2 changed files with 33 additions and 4 deletions
+30 -1
View File
@@ -58,12 +58,41 @@
return 0
//Checks for specific types in a list
/proc/is_type_in_list(var/atom/A, var/list/L)
/proc/is_type_in_list(atom/A, list/L)
if(!L || !L.len || !A)
return 0
for(var/type in L)
if(istype(A, type))
return 1
return 0
//Checks for specific types in specifically structured (Assoc "type" = TRUE) lists ('typecaches')
/proc/is_type_in_typecache(atom/A, list/L)
if(!L || !L.len || !A)
return 0
return L[A.type]
//Like typesof() or subtypesof(), but returns a typecache instead of a list
/proc/typecacheof(path, ignore_root_path)
if(ispath(path))
var/list/types = ignore_root_path ? subtypesof(path) : typesof(path)
var/list/L = list()
for(var/T in types)
L[T] = TRUE
return L
else if(islist(path))
var/list/pathlist = path
var/list/L = list()
if(ignore_root_path)
for(var/P in pathlist)
for(var/T in subtypesof(P))
L[T] = TRUE
else
for(var/P in pathlist)
for(var/T in typesof(P))
L[T] = TRUE
return L
//Removes any null entries from the list
/proc/listclearnulls(list/list)
if(istype(list))
+3 -3
View File
@@ -1,7 +1,7 @@
#define TESLA_DEFAULT_POWER 1738260
#define TESLA_MINI_POWER 869130
var/list/blacklisted_tesla_types = list(/obj/machinery/atmospherics,
var/list/blacklisted_tesla_types = typecacheof(list(/obj/machinery/atmospherics,
/obj/machinery/power/emitter,
/obj/machinery/field/generator,
/mob/living/simple_animal,
@@ -15,7 +15,7 @@ var/list/blacklisted_tesla_types = list(/obj/machinery/atmospherics,
/obj/machinery/field/containment,
/obj/structure/disposalpipe,
/obj/structure/sign,
/obj/machinery/gateway)
/obj/machinery/gateway))
/obj/singularity/energy_ball
name = "energy ball"
@@ -175,7 +175,7 @@ var/list/blacklisted_tesla_types = list(/obj/machinery/atmospherics,
closest_atom = A
closest_dist = dist
else if(closest_grounding_rod || is_type_in_list(A, blacklisted_tesla_types))
else if(closest_grounding_rod || is_type_in_typecache(A, blacklisted_tesla_types))
continue
else if(istype(A, /mob/living))