Enhances algorithm for finding an atom mount (#94076)

## About The Pull Request
Depends on #94064 for the unit test but offers a better method for
finding an atom to mount on
- Finding a mount now takes into consideration the objects pixel x & y
offsets meaning diagonal mounting is now supported. Gives great
flexibility for mappers
- If you don't want to use pixel offsets but default back to using the
objects direction that behaviour is still preserved. Useful if your
object uses directional icon states(lights & cameras for now) AND don't
use offsets
- If no direction could be specified then as the last resort it defaults
back to the objects local turf for mounting

## Changelog
🆑
fix: all mounted objects on tables, fences, windows & walls should fall
of correctly when the atom it is placed on is destroyed
fix: security telescreen now falls off when their mounted wall is
destroyed
fix: defib wall mount falls off when their mounted wall is destroyed
fix: floor lights are mounted to the ground/catwalk/tram floor they are
sitting on meaning destroying it will destroy the light
fix: wall mounted plaques now fall off when their mounted wall is
destroyed
/🆑
This commit is contained in:
SyncIt21
2025-12-01 05:20:16 +05:30
committed by nevimer
parent fc809d7687
commit f640a0e972
54 changed files with 228 additions and 139 deletions
@@ -34,7 +34,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/detectiveboard, 32)
if(istype(item, /obj/item/paper) || istype(item, /obj/item/photo))
item.forceMove(src)
cases[current_case].notices++
find_and_hang_on_atom()
find_and_mount_on_atom()
register_context()
+1 -1
View File
@@ -18,7 +18,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/extinguisher_cabinet, 29)
opened = TRUE
else
stored_extinguisher = new /obj/item/extinguisher(src)
find_and_hang_on_atom()
find_and_mount_on_atom()
update_appearance(UPDATE_ICON)
register_context()
+1 -1
View File
@@ -39,7 +39,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/fireaxecabinet, 32)
held_item = new item_path(src)
update_appearance()
if(mapload)
find_and_hang_on_atom()
find_and_mount_on_atom()
/obj/structure/fireaxecabinet/Destroy()
if(held_item)
+1 -1
View File
@@ -55,7 +55,7 @@
check_reflect_signals = list(SIGNAL_ADDTRAIT(TRAIT_NO_MIRROR_REFLECTION), SIGNAL_REMOVETRAIT(TRAIT_NO_MIRROR_REFLECTION)), \
)
if(mapload)
find_and_hang_on_atom()
find_and_mount_on_atom()
update_choices()
register_context()
+1 -1
View File
@@ -36,7 +36,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/noticeboard, 32)
notices++
update_appearance(UPDATE_ICON)
if(mapload)
find_and_hang_on_atom()
find_and_mount_on_atom()
//attaching papers!!
/obj/structure/noticeboard/attackby(obj/item/O, mob/user, list/modifiers, list/attack_modifiers)
@@ -20,6 +20,8 @@
/obj/structure/plaque/Initialize(mapload)
. = ..()
if(mapload)
find_and_mount_on_atom()
register_context()
/obj/structure/plaque/add_context(atom/source, list/context, obj/item/held_item, mob/user)
@@ -9,6 +9,13 @@
SET_PLANE_IMPLICIT(src, FLOOR_PLANE)
layer = HIGH_TURF_LAYER
/obj/structure/plaque/static_plaque/get_moutable_objects()
return list()
/obj/structure/plaque/static_plaque/find_and_mount_on_atom(mark_for_late_init, late_init)
if(isProbablyWallMounted(src))
return ..()
/obj/structure/plaque/static_plaque/atmos
name = "\improper FEA Atmospherics Division plaque"
desc = "This plaque commemorates the fall of the Atmos FEA division. For all the charred, dizzy, and brittle men who have died in its hands."
+2 -2
View File
@@ -107,10 +107,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/secure_safe, 32)
AddComponent(/datum/component/lockable_storage, stored_lock_code)
if(mapload)
PopulateContents()
find_and_hang_on_atom()
find_and_mount_on_atom()
RegisterSignal(src, COMSIG_LOCKABLE_STORAGE_SET_CODE, PROC_REF(update_lock_code))
/obj/structure/secure_safe/find_and_hang_on_atom(mark_for_late_init = FALSE, late_init = FALSE)
/obj/structure/secure_safe/find_and_mount_on_atom(mark_for_late_init, late_init)
if(!density)
return ..()
+3 -3
View File
@@ -23,11 +23,11 @@
/obj/structure/sign/Initialize(mapload)
. = ..()
register_context()
if(mapload && !find_and_hang_on_atom(mark_for_late_init = TRUE))
if(mapload && !find_and_mount_on_atom(mark_for_late_init = TRUE))
return INITIALIZE_HINT_LATELOAD
/obj/structure/sign/LateInitialize()
find_and_hang_on_atom(late_init = TRUE)
find_and_mount_on_atom(late_init = TRUE)
/obj/structure/sign/add_context(atom/source, list/context, obj/item/held_item, mob/user)
. = ..()
@@ -220,7 +220,7 @@
playsound(target_turf, 'sound/items/deconstruct.ogg', 50, TRUE)
placed_sign.update_integrity(get_integrity())
placed_sign.setDir(dir)
placed_sign.find_and_hang_on_atom()
placed_sign.find_and_mount_on_atom()
qdel(src)
return ITEM_INTERACT_SUCCESS
@@ -16,7 +16,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/urinal, 32)
. = ..()
if(mapload)
hidden_item = new /obj/item/food/urinalcake(src)
find_and_hang_on_atom()
find_and_mount_on_atom()
/obj/structure/urinal/Exited(atom/movable/gone, direction)
. = ..()