Files
2023-06-19 09:44:28 +02:00

28 lines
804 B
Plaintext

//This helper applies components to things on the map directly.
/obj/map_helper/component_injector
name = "Component Injector"
late = TRUE
var/target_type
var/target_name
var/component_type
//Late init so everything is likely ready and loaded (no warranty)
/obj/map_helper/component_injector/LateInitialize()
if(!ispath(component_type,/datum/component))
CRASH("Wrong component type in [type] - [component_type] is not a component")
var/turf/T = get_turf(src)
for(var/atom/A in T.get_all_contents())
if(A == src)
continue
if(target_name && A.name != target_name)
continue
if(target_type && !istype(A,target_type))
continue
var/cargs = build_args()
A._AddComponent(cargs)
qdel(src)
return
/obj/map_helper/component_injector/proc/build_args()
return list(component_type)