General maintenance for wall mounts (#93534)

## About The Pull Request
- Fixes #93392
- Replaces all custom callbacks with call to `deconstruct()`. The
callbacks weren't necessary as it did the same thing as `deconstruct()`
but in an round about way
- Removed duplicate `Initialize()` procs and the params `building` &
`ndir` from all wall mounts. Makes everything cleaner

## Changelog
🆑
fix: wall mounts placed by player now falls off when the wall they are
mounted on is destroyed
code: cleaned up wall mount code
/🆑
This commit is contained in:
SyncIt21
2025-10-23 20:56:19 +05:30
committed by GitHub
parent d2a9f9b191
commit 9740c687de
39 changed files with 173 additions and 223 deletions
@@ -34,9 +34,9 @@ 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_wall()
register_context()
find_and_hang_on_wall()
/// Attaching evidences: photo and papers
+3 -3
View File
@@ -12,15 +12,15 @@
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/extinguisher_cabinet, 29)
/obj/structure/extinguisher_cabinet/Initialize(mapload, ndir, building)
/obj/structure/extinguisher_cabinet/Initialize(mapload)
. = ..()
if(building)
if(!mapload)
opened = TRUE
else
stored_extinguisher = new /obj/item/extinguisher(src)
find_and_hang_on_wall()
update_appearance(UPDATE_ICON)
register_context()
find_and_hang_on_wall()
/obj/structure/extinguisher_cabinet/add_context(atom/source, list/context, obj/item/held_item, mob/user)
. = ..()
+2 -1
View File
@@ -38,7 +38,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/fireaxecabinet, 32)
if(populate_contents)
held_item = new item_path(src)
update_appearance()
find_and_hang_on_wall()
if(mapload)
find_and_hang_on_wall()
/obj/structure/fireaxecabinet/Destroy()
if(held_item)
+4 -9
View File
@@ -34,10 +34,6 @@
///List of all Races that can be chosen, decided by its Initialize.
var/list/selectable_races = list()
/obj/structure/mirror/Initialize(mapload)
. = ..()
update_choices()
/obj/structure/mirror/Destroy()
mirror_options = null
selectable_races = null
@@ -58,6 +54,10 @@
update_signals = list(COMSIG_ATOM_BREAK), \
check_reflect_signals = list(SIGNAL_ADDTRAIT(TRAIT_NO_MIRROR_REFLECTION), SIGNAL_REMOVETRAIT(TRAIT_NO_MIRROR_REFLECTION)), \
)
if(mapload)
find_and_hang_on_wall()
update_choices()
register_context()
/obj/structure/mirror/proc/can_reflect(atom/movable/target)
///I'm doing it this way too, because the signal is sent before the broken variable is set to TRUE.
@@ -69,11 +69,6 @@
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
/obj/structure/mirror/Initialize(mapload)
. = ..()
find_and_hang_on_wall()
register_context()
/obj/structure/mirror/broken
icon_state = "mirror_broke"
+2 -1
View File
@@ -35,7 +35,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/noticeboard, 32)
paper.forceMove(src)
notices++
update_appearance(UPDATE_ICON)
find_and_hang_on_wall()
if(mapload)
find_and_hang_on_wall()
//attaching papers!!
/obj/structure/noticeboard/attackby(obj/item/O, mob/user, list/modifiers, list/attack_modifiers)
+6 -5
View File
@@ -104,15 +104,16 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/secure_safe, 32)
/obj/structure/secure_safe/Initialize(mapload)
. = ..()
//this will create the storage for us.
AddComponent(/datum/component/lockable_storage, stored_lock_code)
if(!density)
find_and_hang_on_wall()
AddComponent(/datum/component/lockable_storage, , stored_lock_code)
if(mapload)
PopulateContents()
find_and_hang_on_wall()
RegisterSignal(src, COMSIG_LOCKABLE_STORAGE_SET_CODE, PROC_REF(update_lock_code))
/obj/structure/secure_safe/find_and_hang_on_wall()
if(!density)
return ..()
/obj/structure/secure_safe/atom_deconstruct(disassembled)
if(!density) //if we're a wall item, we'll drop a wall frame.
var/obj/item/wallframe/secure_safe/new_safe = new(get_turf(src))
+9 -21
View File
@@ -14,8 +14,6 @@
var/is_editable = FALSE
///sign_change_name is used to make nice looking, alphabetized and categorized names when you use a pen on any sign item or structure which is_editable.
var/sign_change_name
///Callback to the knock down proc for wallmounting behavior.
var/knock_down_callback
/datum/armor/structure_sign
melee = 50
@@ -25,12 +23,8 @@
/obj/structure/sign/Initialize(mapload)
. = ..()
register_context()
knock_down_callback = CALLBACK(src, PROC_REF(knock_down))
find_and_hang_on_wall(custom_drop_callback = knock_down_callback)
/obj/structure/sign/Destroy()
. = ..()
knock_down_callback = null
if(mapload)
find_and_hang_on_wall()
/obj/structure/sign/add_context(atom/source, list/context, obj/item/held_item, mob/user)
. = ..()
@@ -63,7 +57,7 @@
playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE)
user.visible_message(span_notice("[user] unfastens [src]."), \
span_notice("You unfasten [src]."))
knock_down(user)
deconstruct(TRUE)
return TRUE
/obj/structure/sign/welder_act(mob/living/user, obj/item/I)
@@ -112,16 +106,8 @@
return
return ..()
/**
* This is called when a sign is removed from a wall, either through deconstruction or being knocked down.
* @param mob/living/user The user who removed the sign, if it was knocked down by a mob.
*/
/obj/structure/sign/proc/knock_down(mob/living/user)
var/turf/drop_turf
if(user)
drop_turf = get_turf(user)
else
drop_turf = drop_location()
/obj/structure/sign/atom_deconstruct(disassembled)
var/turf/drop_turf = drop_location()
var/obj/item/sign/unwrenched_sign = new (drop_turf)
if(type != /obj/structure/sign/blank) //If it's still just a basic sign backing, we can (and should) skip some of the below variable transfers.
unwrenched_sign.name = name //Copy over the sign structure variables to the sign item we're creating when we unwrench a sign.
@@ -133,7 +119,6 @@
unwrenched_sign.is_editable = is_editable
unwrenched_sign.update_integrity(get_integrity()) //Transfer how damaged it is.
unwrenched_sign.setDir(dir)
qdel(src) //The sign structure on the wall goes poof and only the sign item from unwrenching remains.
/obj/structure/sign/blank //This subtype is necessary for now because some other things (posters, picture frames, paintings) inherit from the parent type.
icon_state = "backing"
@@ -217,6 +202,9 @@
var/obj/structure/sign/placed_sign = new sign_path(user_turf) //We place the sign on the turf the user is standing, and pixel shift it to the target wall, as below.
//This is to mimic how signs and other wall objects are usually placed by mappers, and so they're only visible from one side of a wall.
var/dir = get_dir(user_turf, target_turf)
if(!(dir in GLOB.cardinals))
balloon_alert(user, "stand in line with wall!")
return
if(dir & NORTH)
placed_sign.pixel_y = 32
else if(dir & SOUTH)
@@ -230,7 +218,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_wall(TRUE, placed_sign.knock_down_callback)
placed_sign.find_and_hang_on_wall()
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_wall()
find_and_hang_on_wall()
/obj/structure/urinal/Exited(atom/movable/gone, direction)
. = ..()