From 4debf567f3b6b16c890d55cdd2561710f4293434 Mon Sep 17 00:00:00 2001 From: Sierra Helper <125094432+SierraHelper@users.noreply.github.com> Date: Sun, 24 Nov 2024 23:31:57 +0300 Subject: [PATCH] [MIRROR] Support Lattice Construction Fixes (#2831) Co-authored-by: Hubblenaut <6383576+Hubblenaut@users.noreply.github.com> Co-authored-by: Lexanx <61974560+Lexanx@users.noreply.github.com> --- baystation12.dme | 1 + code/datums/extensions/support_lattice.dm | 48 +++++++++++++++++++++ code/game/turfs/space/space.dm | 44 ++----------------- code/modules/multiz/turf.dm | 43 +++--------------- code/modules/multiz/zmimic/mimic_movable.dm | 6 +-- 5 files changed, 62 insertions(+), 80 deletions(-) create mode 100644 code/datums/extensions/support_lattice.dm diff --git a/baystation12.dme b/baystation12.dme index 20c357e3dc5bc..a1b5f65d8b698 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -312,6 +312,7 @@ #include "code\datums\extensions\local_network.dm" #include "code\datums\extensions\penetration.dm" #include "code\datums\extensions\state_machine.dm" +#include "code\datums\extensions\support_lattice.dm" #include "code\datums\extensions\appearance\appearance.dm" #include "code\datums\extensions\appearance\base_icon_state.dm" #include "code\datums\extensions\appearance\cardborg.dm" diff --git a/code/datums/extensions/support_lattice.dm b/code/datums/extensions/support_lattice.dm new file mode 100644 index 0000000000000..e6e93723f7bf5 --- /dev/null +++ b/code/datums/extensions/support_lattice.dm @@ -0,0 +1,48 @@ +/datum/extension/support_lattice + base_type = /datum/extension/support_lattice + expected_type = /atom + +/datum/extension/support_lattice/proc/try_construct(obj/item/C, mob/living/user) + var/turf/T = get_turf(holder) + if (istype(C, /obj/item/stack/material/rods)) + var/obj/structure/lattice/L = locate(/obj/structure/lattice, T) + if(L) + return L.use_tool(C, user) + var/obj/item/stack/material/rods/R = C + if (!R.can_use(1)) + USE_FEEDBACK_STACK_NOT_ENOUGH(R, 1, "to lay down support lattice.") + return TRUE + + to_chat(user, SPAN_NOTICE("You lay down the support lattice.")) + playsound(T, 'sound/weapons/Genhit.ogg', 50, 1) + T.ReplaceWithLattice(R.material.name) + R.use(1) + return TRUE + + if (istype(C, /obj/item/stack/tile)) + var/obj/structure/lattice/L = locate(/obj/structure/lattice, T) + if(!L) + to_chat(user, SPAN_WARNING("The plating is going to need some support.")) + return TRUE + var/obj/item/stack/tile/floor/S = C + if (!S.can_use(1)) + USE_FEEDBACK_STACK_NOT_ENOUGH(S, 1, "to place the plating.") + return TRUE + + qdel(L) + playsound(T, 'sound/weapons/Genhit.ogg', 50, 1) + T.ChangeTurf(/turf/simulated/floor/plating, keep_air = TRUE) + S.use(1) + return TRUE + + if(isCoil(C)) + var/obj/item/stack/cable_coil/coil = C + var/obj/structure/lattice/L = locate(/obj/structure/lattice, T) + if(L) + coil.PlaceCableOnTurf(T, user) + return TRUE + else + to_chat(user, SPAN_WARNING("The cable needs something to be secured to.")) + return TRUE + + return FALSE diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm index 86c5f9f4e91dc..0d1633df3632a 100644 --- a/code/game/turfs/space/space.dm +++ b/code/game/turfs/space/space.dm @@ -17,6 +17,8 @@ . = ..() update_starlight() + set_extension(src, /datum/extension/support_lattice) + appearance = SSskybox.space_appearance_cache[(((x + y) ^ ~(x * y) + z) % 25) + 1] if(!HasBelow(z)) @@ -77,48 +79,10 @@ remove_starlight() /turf/space/use_tool(obj/item/C, mob/living/user, list/click_params) - if (istype(C, /obj/item/stack/material/rods)) - var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) - if(L) - return L.use_tool(C, user) - var/obj/item/stack/material/rods/R = C - if (!R.can_use(1)) - USE_FEEDBACK_STACK_NOT_ENOUGH(R, 1, "to lay down support lattice.") - return TRUE - - to_chat(user, SPAN_NOTICE("You lay down the support lattice.")) - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - ReplaceWithLattice(R.material.name) - R.use(1) - return TRUE - - if (istype(C, /obj/item/stack/tile)) - var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) - if(!L) - to_chat(user, SPAN_WARNING("The plating is going to need some support.")) - return TRUE - var/obj/item/stack/tile/floor/S = C - if (!S.can_use(1)) - USE_FEEDBACK_STACK_NOT_ENOUGH(S, 1, "to place the plating.") - return TRUE - - qdel(L) - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - ChangeTurf(/turf/simulated/floor/plating, keep_air = TRUE) - S.use(1) + var/datum/extension/support_lattice/sl = get_extension(src, /datum/extension/support_lattice) + if (sl.try_construct(C, user)) return TRUE - //Checking if the user attacked with a cable coil - if(isCoil(C)) - var/obj/item/stack/cable_coil/coil = C - var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) - if(L) - coil.PlaceCableOnTurf(src, user) - return TRUE - else - to_chat(user, SPAN_WARNING("The cable needs something to be secured to.")) - return TRUE - return ..() diff --git a/code/modules/multiz/turf.dm b/code/modules/multiz/turf.dm index 0126675703b1d..d772f4eb7edbd 100644 --- a/code/modules/multiz/turf.dm +++ b/code/modules/multiz/turf.dm @@ -34,6 +34,10 @@ z_flags = ZM_MIMIC_DEFAULTS | ZM_MIMIC_OVERWRITE | ZM_MIMIC_NO_AO | ZM_ALLOW_ATMOS +/turf/simulated/open/Initialize() + . = ..() + set_extension(src, /datum/extension/support_lattice) + /turf/simulated/open/update_dirt() return 0 @@ -64,45 +68,10 @@ return TRUE /turf/simulated/open/use_tool(obj/item/C, mob/living/user, list/click_params) - if (istype(C, /obj/item/stack/material/rods)) - var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) - if(L) - return L.use_tool(C, user) - var/obj/item/stack/material/rods/R = C - if (!R.can_use(1)) - USE_FEEDBACK_STACK_NOT_ENOUGH(R, 1, "to lay down support lattice.") - return TRUE - to_chat(user, SPAN_NOTICE("You lay down the support lattice.")) - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - new /obj/structure/lattice(locate(src.x, src.y, src.z), R.material.name) - return TRUE - - if (istype(C, /obj/item/stack/tile)) - var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) - if(!L) - to_chat(user, SPAN_WARNING("The plating is going to need some support.")) - return TRUE - - var/obj/item/stack/tile/floor/S = C - if (!S.can_use(1)) - USE_FEEDBACK_STACK_NOT_ENOUGH(S, 1, "to plate the lattice.") - return TRUE - - qdel(L) - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - ChangeTurf(/turf/simulated/floor/plating, keep_air = TRUE) + var/datum/extension/support_lattice/sl = get_extension(src, /datum/extension/support_lattice) + if (sl.try_construct(C, user)) return TRUE - //To lay cable. - if(isCoil(C)) - var/obj/item/stack/cable_coil/coil = C - coil.PlaceCableOnTurf(src, user) - return TRUE - - for(var/atom/movable/M in below) - if(M.movable_flags & MOVABLE_FLAG_Z_INTERACT) - return C.resolve_attackby(M, user) - return ..() /turf/simulated/open/attack_hand(mob/user) diff --git a/code/modules/multiz/zmimic/mimic_movable.dm b/code/modules/multiz/zmimic/mimic_movable.dm index fe780df31e673..d57d78e5202be 100644 --- a/code/modules/multiz/zmimic/mimic_movable.dm +++ b/code/modules/multiz/zmimic/mimic_movable.dm @@ -163,9 +163,9 @@ return ..() -/atom/movable/openspace/mimic/can_use_item(obj/item/tool, mob/user, click_params) - USE_FEEDBACK_FAILURE("\The [src] is too far away.") - return FALSE +/atom/movable/openspace/mimic/use_tool(obj/item/tool, mob/user, list/click_params) + SHOULD_CALL_PARENT(FALSE) + return tool.resolve_attackby(loc, user, click_params) /atom/movable/openspace/mimic/attack_hand(mob/user) to_chat(user, SPAN_NOTICE("You cannot reach \the [src] from here."))