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 17:26:19 +02:00
committed by GitHub
parent d2a9f9b191
commit 9740c687de
39 changed files with 173 additions and 223 deletions
+2 -1
View File
@@ -261,7 +261,8 @@
AddElement(/datum/element/contextual_screentip_bare_hands, rmb_text = "Toggle interface lock")
AddElement(/datum/element/contextual_screentip_mob_typechecks, hovering_mob_typechecks)
find_and_hang_on_wall()
if(mapload)
find_and_hang_on_wall()
/obj/machinery/power/apc/Destroy()
if(malfai)
+18 -34
View File
@@ -118,8 +118,12 @@
RegisterSignal(src, COMSIG_LIGHT_EATER_ACT, PROC_REF(on_light_eater))
AddElement(/datum/element/atmos_sensitive, mapload)
AddElement(/datum/element/contextual_screentip_bare_hands, rmb_text = "Remove bulb")
if(mapload)
find_and_hang_on_wall()
/obj/machinery/light/find_and_hang_on_wall()
if(break_if_moved)
find_and_hang_on_wall(custom_drop_callback = CALLBACK(src, PROC_REF(knock_down)))
return ..()
/obj/machinery/light/post_machine_initialize()
. = ..()
@@ -141,6 +145,11 @@
QDEL_NULL(cell)
return ..()
/obj/machinery/light/Exited(atom/movable/gone, direction)
. = ..()
if(gone == cell)
cell = null
/obj/machinery/light/setDir(newdir)
. = ..()
set_light(l_dir = REVERSE_DIR(dir))
@@ -407,34 +416,26 @@
electrocute_mob(user, get_area(src), src, (rand(7,10) * 0.1), TRUE)
/obj/machinery/light/on_deconstruction(disassembled)
var/obj/structure/light_construct/new_light = null
var/current_stage = 2
if(!disassembled)
current_stage = 1
var/atom/drop_point = drop_location()
var/obj/item/wallframe/light_fixture/frame = null
switch(fitting)
if("tube")
new_light = new /obj/structure/light_construct(loc)
new_light.icon_state = "tube-construct-stage[current_stage]"
frame = new /obj/item/wallframe/light_fixture(drop_point)
if("bulb")
new_light = new /obj/structure/light_construct/small(loc)
new_light.icon_state = "bulb-construct-stage[current_stage]"
new_light.setDir(dir)
new_light.stage = current_stage
frame = new /obj/item/wallframe/light_fixture/small(drop_point)
if(!disassembled)
new_light.take_damage(new_light.max_integrity * 0.5, sound_effect=FALSE)
frame.take_damage(frame.max_integrity * 0.5, sound_effect = FALSE)
if(status != LIGHT_BROKEN)
break_light_tube()
if(status != LIGHT_EMPTY)
drop_light_tube()
new /obj/item/stack/cable_coil(loc, 1, "red")
transfer_fingerprints_to(new_light)
transfer_fingerprints_to(frame)
var/obj/item/stock_parts/power_store/real_cell = get_cell()
if(!QDELETED(real_cell))
new_light.cell = real_cell
real_cell.forceMove(new_light)
cell = null
real_cell.forceMove(drop_point)
/obj/machinery/light/attacked_by(obj/item/attacking_object, mob/living/user, list/modifiers, list/attack_modifiers)
. = ..()
@@ -716,23 +717,6 @@
continue
INVOKE_ASYNC(src, PROC_REF(flicker))
/**
* All the effects that occur when a light falls off a wall that it was hung onto.
*/
/obj/machinery/light/proc/knock_down()
if (fitting == "bulb")
new /obj/item/wallframe/light_fixture/small(drop_location())
else
new /obj/item/wallframe/light_fixture(drop_location())
new /obj/item/stack/cable_coil(drop_location(), 1, "red")
if(status != LIGHT_BROKEN)
break_light_tube(FALSE)
if(status != LIGHT_EMPTY)
drop_light_tube()
if(cell)
cell.forceMove(drop_location())
qdel(src)
/obj/machinery/light/floor
name = "floor light"
desc = "A lightbulb you can walk on without breaking it, amazing."
@@ -28,11 +28,10 @@
fire = 80
acid = 50
/obj/structure/light_construct/Initialize(mapload, ndir, building)
/obj/structure/light_construct/Initialize(mapload)
. = ..()
if(building)
setDir(ndir)
find_and_hang_on_wall()
if(mapload)
find_and_hang_on_wall()
/obj/structure/light_construct/Destroy()
QDEL_NULL(cell)
@@ -107,11 +106,9 @@
return
to_chat(user, span_notice("You begin deconstructing [src]..."))
if (tool.use_tool(src, user, 30, volume=50))
new /obj/item/stack/sheet/iron(drop_location(), sheets_refunded)
user.visible_message(span_notice("[user.name] deconstructs [src]."), \
span_notice("You deconstruct [src]."), span_hear("You hear a ratchet."))
playsound(src, 'sound/items/deconstruct.ogg', 75, TRUE)
qdel(src)
return
if(istype(tool, /obj/item/stack/cable_coil))
@@ -159,10 +156,12 @@
/obj/structure/light_construct/blob_act(obj/structure/blob/attacking_blob)
if(attacking_blob && attacking_blob.loc == loc)
qdel(src)
deconstruct(FALSE)
/obj/structure/light_construct/atom_deconstruct(disassembled = TRUE)
/obj/structure/light_construct/atom_deconstruct(disassembled)
new /obj/item/stack/sheet/iron(loc, sheets_refunded)
if(stage == LIGHT_CONSTRUCT_WIRED)
new /obj/item/stack/cable_coil(drop_location(), 1, "red")
/obj/structure/light_construct/small
name = "small light fixture frame"