From 574b29405868734d56cdc068f2f084fdedb5f249 Mon Sep 17 00:00:00 2001 From: Iajret Creature <122297233+Steals-The-PRs@users.noreply.github.com> Date: Thu, 7 Mar 2024 13:24:16 +0300 Subject: [PATCH] Light It Up! - Craftable wall-mounted torches (#2300) * Creates the logic to add and remove torches from wall-mounted torches * Makes torch mounts craftable and destructible, fixes issues with them * Wall torch mounts no longer take time to craft * Addresses all of the review comments * Update code/__HELPERS/global_lists.dm --------- Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com> Co-authored-by: SomeRandomOwl <2568378+SomeRandomOwl@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> --- code/__HELPERS/global_lists.dm | 3 +- .../items/stacks/sheets/sheet_types.dm | 3 +- .../primitive_structures/code/wall_torch.dm | 161 +++++++++++++++++- .../primitive_structures/icons/lighting.dmi | Bin 2551 -> 2170 bytes 4 files changed, 161 insertions(+), 6 deletions(-) diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index c54c052d05d..370e99646e3 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -270,7 +270,8 @@ GLOBAL_LIST_INIT(WALLITEMS_INTERIOR, typecacheof(list( /obj/machinery/status_display, /obj/machinery/ticket_machine, /obj/machinery/turretid, - /obj/machinery/time_clock, //NOVA EDIT TIME CLOCK + /obj/machinery/time_clock, // NOVA EDIT ADDITION - TIME CLOCK + /obj/structure/wall_torch, // NOVA EDIT ADDITION - Wall-mounted torches /obj/machinery/barsign, /obj/structure/extinguisher_cabinet, /obj/structure/fireaxecabinet, diff --git a/modular_nova/master_files/code/game/objects/items/stacks/sheets/sheet_types.dm b/modular_nova/master_files/code/game/objects/items/stacks/sheets/sheet_types.dm index babf0041f7c..a57a7434170 100644 --- a/modular_nova/master_files/code/game/objects/items/stacks/sheets/sheet_types.dm +++ b/modular_nova/master_files/code/game/objects/items/stacks/sheets/sheet_types.dm @@ -61,7 +61,8 @@ GLOBAL_LIST_INIT(skyrat_rod_recipes, list( new/datum/stack_recipe("towel bin", /obj/structure/towel_bin/empty, 2, time = 0.5 SECONDS, one_per_turf = FALSE, check_density = FALSE, category = CAT_CONTAINERS), new/datum/stack_recipe("guard rail", /obj/structure/deployable_barricade/guardrail, 2, time = 1 SECONDS, on_solid_ground = TRUE, check_direction = TRUE, category = CAT_STRUCTURE), new/datum/stack_recipe("wrestling ropes", /obj/structure/railing/wrestling, 3, time = 1.8 SECONDS, on_solid_ground = TRUE, check_direction = TRUE, check_density = FALSE, category = CAT_STRUCTURE), - new/datum/stack_recipe("crutch", /obj/item/cane/crutch, 3, time = 10, one_per_turf = FALSE, category = CAT_TOOLS), + new/datum/stack_recipe("crutch", /obj/item/cane/crutch, 3, time = 1 SECONDS, one_per_turf = FALSE, category = CAT_TOOLS), + new/datum/stack_recipe("torch mount", /obj/item/wallframe/torch_mount, 2, one_per_turf = FALSE, category = CAT_MISC), )) /obj/item/stack/rods/get_main_recipes() diff --git a/modular_nova/modules/primitive_structures/code/wall_torch.dm b/modular_nova/modules/primitive_structures/code/wall_torch.dm index 14da5b99f5f..c91561d4704 100644 --- a/modular_nova/modules/primitive_structures/code/wall_torch.dm +++ b/modular_nova/modules/primitive_structures/code/wall_torch.dm @@ -7,45 +7,198 @@ anchored = TRUE density = FALSE light_color = LIGHT_COLOR_FIRE + /// Torch contained by the wall torch, if it was mounted manually. + /// Will be `TRUE` if it was intended to spawn in with a torch, + /// without actually initializing a torch in it to save on memory. + var/obj/item/flashlight/flare/torch/mounted_torch = TRUE /// is the bonfire lit? var/burning = FALSE /// Does this torch spawn pre-lit? var/spawns_lit = FALSE + /// What this item turns back into when wrenched off the wall. + var/wallmount_item_type = /obj/item/wallframe/torch_mount MAPPING_DIRECTIONAL_HELPERS(/obj/structure/wall_torch, 28) /obj/structure/wall_torch/Initialize(mapload) . = ..() - if(spawns_lit) + if(mounted_torch && spawns_lit) light_it_up() + + update_appearance(UPDATE_NAME | UPDATE_DESC | UPDATE_ICON_STATE) find_and_hang_on_wall() + +/obj/structure/wall_torch/Destroy() + drop_torch() // So it drops on the floor when destroyed. + return ..() + + +/obj/structure/wall_torch/update_icon_state() + icon_state = "[base_icon_state][mounted_torch ? (burning ? "_on" : "") : "_mount"]" + return ..() + + +/obj/structure/wall_torch/update_name(updates) + . = ..() + name = mounted_torch ? "mounted torch" : "torch mount" + + +/obj/structure/wall_torch/update_desc(updates) + . = ..() + desc = mounted_torch ? "A simple torch mounted to the wall, for lighting and such." : "A simple torch mount, torches go here." + + /obj/structure/wall_torch/attackby(obj/item/used_item, mob/living/user, params) - if(used_item.get_temperature()) + if(!mounted_torch) + if(!istype(used_item, /obj/item/flashlight/flare/torch)) + return ..() + + mounted_torch = used_item + RegisterSignal(used_item, COMSIG_QDELETING, PROC_REF(remove_torch)) + used_item.forceMove(src) + update_appearance(UPDATE_NAME | UPDATE_DESC) + + if(mounted_torch.light_on) + light_it_up() + else + extinguish() + + mounted_torch.turn_off() + + return + + if(!burning && used_item.get_temperature()) light_it_up() else return ..() + /obj/structure/wall_torch/fire_act(exposed_temperature, exposed_volume) light_it_up() + /// Sets the torch's icon to burning and sets the light up /obj/structure/wall_torch/proc/light_it_up() - icon_state = "[base_icon_state]_on" burning = TRUE set_light(4) + update_icon_state() update_appearance(UPDATE_ICON) + /obj/structure/wall_torch/extinguish() . = ..() if(!burning) return - icon_state = base_icon_state + burning = FALSE set_light(0) update_appearance(UPDATE_ICON) + +/obj/structure/wall_torch/attack_hand(mob/living/user, list/modifiers) + . = ..() + if(.) + return + + remove_torch(user) + + +/** + * Helper proc that handles removing the torch and trying to put it in the user's hand. + */ +/obj/structure/wall_torch/proc/remove_torch(mob/living/user, update_visuals = TRUE) + if(!mounted_torch) + return + + if(!istype(mounted_torch)) + mounted_torch = new(src) + + if(burning) + mounted_torch.toggle_light() + + if(user) + mounted_torch.attempt_pickup(user) + + else + mounted_torch.forceMove(drop_location()) + + UnregisterSignal(mounted_torch, COMSIG_QDELETING) + + mounted_torch = null + burning = FALSE + set_light(0) + update_appearance(UPDATE_ICON | UPDATE_NAME | UPDATE_DESC) + + +/obj/structure/wall_torch/wrench_act(mob/living/user, obj/item/tool) + tool.play_tool_sound(src) + to_chat(user, span_notice("You detach [src] from its place.")) + + remove_torch(user) + + var/obj/item/wallframe/torch_mount/mount_item = new /obj/item/wallframe/torch_mount(drop_location()) + transfer_fingerprints_to(mount_item) + + qdel(src) + return TRUE + + +/// Simple helper to drop the torch upon the mount being qdel'd. +/obj/structure/wall_torch/proc/drop_torch() + if(!mounted_torch) + return + + if(!istype(mounted_torch)) + mounted_torch = new(src) + + if(burning) + mounted_torch.toggle_light() + + mounted_torch.forceMove(drop_location()) + + UnregisterSignal(mounted_torch, COMSIG_QDELETING) + + mounted_torch = null + + +/obj/structure/wall_torch/mount_only + name = "torch mount" + mounted_torch = null + +MAPPING_DIRECTIONAL_HELPERS(/obj/structure/wall_torch/mount_only, 28) + + /obj/structure/wall_torch/spawns_lit spawns_lit = TRUE MAPPING_DIRECTIONAL_HELPERS(/obj/structure/wall_torch/spawns_lit, 28) + + +/obj/item/wallframe/torch_mount + name = "torch mount" + desc = "Used to attach torches to walls." + icon = 'modular_nova/modules/primitive_structures/icons/lighting.dmi' + icon_state = "walltorch_mount" + custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT) + result_path = /obj/structure/wall_torch/mount_only + pixel_shift = 28 + + +/obj/item/wallframe/torch_mount/try_build(turf/on_wall, mob/user) + if(get_dist(on_wall,user) > 1) + balloon_alert(user, "you are too far!") + return + + var/floor_to_wall = get_dir(user, on_wall) + if(!(floor_to_wall in GLOB.cardinals)) + balloon_alert(user, "stand in line with wall!") + return + + var/turf/user_turf = get_turf(user) + + if(check_wall_item(user_turf, floor_to_wall, wall_external)) + balloon_alert(user, "already something here!") + return + + return TRUE diff --git a/modular_nova/modules/primitive_structures/icons/lighting.dmi b/modular_nova/modules/primitive_structures/icons/lighting.dmi index b30231de6b7fe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