diff --git a/code/datums/components/areabound.dm b/code/datums/components/areabound.dm new file mode 100644 index 00000000000..b5c3655cbce --- /dev/null +++ b/code/datums/components/areabound.dm @@ -0,0 +1,25 @@ +/// Movables with this component will automatically return to their original turf if moved outside their initial area +/datum/component/areabound + var/area/bound_area + var/turf/reset_turf + var/datum/movement_detector/move_tracker + +/datum/component/areabound/Initialize() + if(!ismovable(parent)) + return COMPONENT_INCOMPATIBLE + bound_area = get_area(parent) + reset_turf = get_turf(parent) + move_tracker = new(parent,CALLBACK(src,.proc/check_bounds)) + +/datum/component/areabound/proc/check_bounds() + var/atom/movable/AM = parent + var/area/current = get_area(AM) + if(current != bound_area) + if(!reset_turf || reset_turf.loc != bound_area) + stack_trace("Invalid areabound configuration") //qdel(src) + return + AM.forceMove(reset_turf) + +/datum/component/areabound/Destroy(force, silent) + QDEL_NULL(move_tracker) + . = ..() diff --git a/code/modules/mapping/mapping_helpers.dm b/code/modules/mapping/mapping_helpers.dm index dfa98dbe7d0..5dba56e15b6 100644 --- a/code/modules/mapping/mapping_helpers.dm +++ b/code/modules/mapping/mapping_helpers.dm @@ -170,8 +170,9 @@ INITIALIZE_IMMEDIATE(/obj/effect/mapping_helpers/no_lava) /obj/effect/mapping_helpers/component_injector name = "Component Injector" late = TRUE - var/target_type - var/target_name + var/all = FALSE //Will inject into all fitting the criteria if true, otherwise first found + var/target_type //Will inject into atoms of this type + var/target_name //Will inject into atoms with this name var/component_type //Late init so everything is likely ready and loaded (no warranty) @@ -188,8 +189,11 @@ INITIALIZE_IMMEDIATE(/obj/effect/mapping_helpers/no_lava) continue var/cargs = build_args() A._AddComponent(cargs) + if(!all) + qdel(src) + return + if(all) qdel(src) - return /obj/effect/mapping_helpers/component_injector/proc/build_args() return list(component_type) @@ -206,6 +210,12 @@ INITIALIZE_IMMEDIATE(/obj/effect/mapping_helpers/no_lava) var/datum/disease/D = new disease_type() return list(component_type,D) +/obj/effect/mapping_helpers/component_injector/areabound + name = "Areabound Injector" + icon_state = "component_areabound" + component_type = /datum/component/areabound + target_type = /atom/movable + /obj/effect/mapping_helpers/dead_body_placer name = "Dead Body placer" late = TRUE diff --git a/icons/effects/mapping_helpers.dmi b/icons/effects/mapping_helpers.dmi index 075e2ed30e2..d1feca89b36 100644 Binary files a/icons/effects/mapping_helpers.dmi and b/icons/effects/mapping_helpers.dmi differ diff --git a/tgstation.dme b/tgstation.dme index 4a3442336b2..c9d58366bfe 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -377,6 +377,7 @@ #include "code\datums\brain_damage\split_personality.dm" #include "code\datums\components\_component.dm" #include "code\datums\components\anti_magic.dm" +#include "code\datums\components\areabound.dm" #include "code\datums\components\armor_plate.dm" #include "code\datums\components\art.dm" #include "code\datums\components\bane.dm"