Mapping component helper (#37314)

* Mapping component helper

* GetAllContents so you can manipulate things in crates/onmobs/whatever

* More verbose warning.
This commit is contained in:
AnturK
2018-04-23 02:18:59 +02:00
committed by ShizCalev
parent 7f6887cd1b
commit ec40cb1e71
2 changed files with 42 additions and 1 deletions

View File

@@ -85,10 +85,11 @@
/obj/effect/mapping_helpers
icon = 'icons/effects/mapping_helpers.dmi'
icon_state = ""
var/late = FALSE
/obj/effect/mapping_helpers/Initialize()
..()
return INITIALIZE_HINT_QDEL
return late ? INITIALIZE_HINT_LATELOAD : INITIALIZE_HINT_QDEL
//airlock helpers
@@ -156,3 +157,43 @@ GLOBAL_LIST_EMPTY(z_is_planet)
var/turf/T = get_turf(src)
GLOB.z_is_planet["[T.z]"] = TRUE
//This helper applies components to things on the map directly.
/obj/effect/mapping_helpers/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/effect/mapping_helpers/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.GetAllContents())
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(arglist(cargs))
qdel(src)
return
/obj/effect/mapping_helpers/component_injector/proc/build_args()
return list(component_type)
/obj/effect/mapping_helpers/component_injector/infective
name = "Infective Injector"
icon_state = "component_infective"
component_type = /datum/component/infective
var/disease_type
/obj/effect/mapping_helpers/component_injector/infective/build_args()
if(!ispath(disease_type,/datum/disease))
CRASH("Wrong disease type passed in.")
var/datum/disease/D = new disease_type()
return list(component_type,D)