diff --git a/code/game/machinery/_machinery.dm b/code/game/machinery/_machinery.dm index 3d2dd05e5db..a5b700df559 100644 --- a/code/game/machinery/_machinery.dm +++ b/code/game/machinery/_machinery.dm @@ -289,7 +289,6 @@ /obj/machinery/proc/process_atmos()//If you dont use process why are you here return PROCESS_KILL - ///Called when we want to change the value of the machine_stat variable. Holds bitflags. /obj/machinery/proc/set_machine_stat(new_value) if(new_value == machine_stat) @@ -914,46 +913,6 @@ to_chat(user, span_notice("You rotate [src].")) return TRUE -/obj/proc/can_be_unfasten_wrench(mob/user, silent) //if we can unwrench this object; returns SUCCESSFUL_UNFASTEN and FAILED_UNFASTEN, which are both TRUE, or CANT_UNFASTEN, which isn't. - if(!(isfloorturf(loc) || isindestructiblefloor(loc)) && !anchored) - to_chat(user, span_warning("[src] needs to be on the floor to be secured!")) - return FAILED_UNFASTEN - return SUCCESSFUL_UNFASTEN - -/obj/proc/default_unfasten_wrench(mob/user, obj/item/wrench, time = 20) //try to unwrench an object in a WONDERFUL DYNAMIC WAY - if((flags_1 & NODECONSTRUCT_1) || wrench.tool_behaviour != TOOL_WRENCH) - return CANT_UNFASTEN - - var/turf/ground = get_turf(src) - if(!anchored && ground.is_blocked_turf(exclude_mobs = TRUE, source_atom = src)) - to_chat(user, span_notice("You fail to secure [src].")) - return CANT_UNFASTEN - var/can_be_unfasten = can_be_unfasten_wrench(user) - if(!can_be_unfasten || can_be_unfasten == FAILED_UNFASTEN) - return can_be_unfasten - if(time) - to_chat(user, span_notice("You begin [anchored ? "un" : ""]securing [src]...")) - wrench.play_tool_sound(src, 50) - var/prev_anchored = anchored - //as long as we're the same anchored state and we're either on a floor or are anchored, toggle our anchored state - if(!wrench.use_tool(src, user, time, extra_checks = CALLBACK(src, PROC_REF(unfasten_wrench_check), prev_anchored, user))) - return FAILED_UNFASTEN - if(!anchored && ground.is_blocked_turf(exclude_mobs = TRUE, source_atom = src)) - to_chat(user, span_notice("You fail to secure [src].")) - return CANT_UNFASTEN - to_chat(user, span_notice("You [anchored ? "un" : ""]secure [src].")) - set_anchored(!anchored) - playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE) - SEND_SIGNAL(src, COMSIG_OBJ_DEFAULT_UNFASTEN_WRENCH, anchored) - return SUCCESSFUL_UNFASTEN - -/obj/proc/unfasten_wrench_check(prev_anchored, mob/user) //for the do_after, this checks if unfastening conditions are still valid - if(anchored != prev_anchored) - return FALSE - if(can_be_unfasten_wrench(user, TRUE) != SUCCESSFUL_UNFASTEN) //if we aren't explicitly successful, cancel the fuck out - return FALSE - return TRUE - /obj/machinery/proc/exchange_parts(mob/user, obj/item/storage/part_replacer/replacer_tool) if(!istype(replacer_tool)) return FALSE diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index 87f6759d046..e1cf9522383 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -10,6 +10,9 @@ /// Icon to use as a 32x32 preview in crafting menus and such var/icon_preview var/icon_state_preview + /// The vertical pixel offset applied when the object is anchored on a tile with table + /// Ignored when set to 0 - to avoid shifting directional wall-mounted objects above tables + var/anchored_tabletop_offset = 0 var/damtype = BRUTE var/force = 0 @@ -62,6 +65,8 @@ GLOBAL_LIST_EMPTY(objects_by_id_tag) /obj/Initialize(mapload) . = ..() + check_on_table() + if (id_tag) GLOB.objects_by_id_tag[id_tag] = src @@ -351,7 +356,7 @@ GLOBAL_LIST_EMPTY(objects_by_id_tag) var/datum/reagent/R = reagent . |= R.expose_obj(src, reagents[R]) -///attempt to freeze this obj if possible. returns TRUE if it succeeded, FALSE otherwise. +/// Attempt to freeze this obj if possible. returns TRUE if it succeeded, FALSE otherwise. /obj/proc/freeze() if(HAS_TRAIT(src, TRAIT_FROZEN)) return FALSE @@ -361,6 +366,55 @@ GLOBAL_LIST_EMPTY(objects_by_id_tag) AddElement(/datum/element/frozen) return TRUE -///unfreezes this obj if its frozen +/// Unfreezes this obj if its frozen /obj/proc/unfreeze() SEND_SIGNAL(src, COMSIG_OBJ_UNFREEZE) + +/// If we can unwrench this object; returns SUCCESSFUL_UNFASTEN and FAILED_UNFASTEN, which are both TRUE, or CANT_UNFASTEN, which isn't. +/obj/proc/can_be_unfasten_wrench(mob/user, silent) + if(!(isfloorturf(loc) || isindestructiblefloor(loc)) && !anchored) + to_chat(user, span_warning("[src] needs to be on the floor to be secured!")) + return FAILED_UNFASTEN + return SUCCESSFUL_UNFASTEN + +/// Try to unwrench an object in a WONDERFUL DYNAMIC WAY +/obj/proc/default_unfasten_wrench(mob/user, obj/item/wrench, time = 20) + if((flags_1 & NODECONSTRUCT_1) || wrench.tool_behaviour != TOOL_WRENCH) + return CANT_UNFASTEN + + var/turf/ground = get_turf(src) + if(!anchored && ground.is_blocked_turf(exclude_mobs = TRUE, source_atom = src)) + to_chat(user, span_notice("You fail to secure [src].")) + return CANT_UNFASTEN + var/can_be_unfasten = can_be_unfasten_wrench(user) + if(!can_be_unfasten || can_be_unfasten == FAILED_UNFASTEN) + return can_be_unfasten + if(time) + to_chat(user, span_notice("You begin [anchored ? "un" : ""]securing [src]...")) + wrench.play_tool_sound(src, 50) + var/prev_anchored = anchored + //as long as we're the same anchored state and we're either on a floor or are anchored, toggle our anchored state + if(!wrench.use_tool(src, user, time, extra_checks = CALLBACK(src, PROC_REF(unfasten_wrench_check), prev_anchored, user))) + return FAILED_UNFASTEN + if(!anchored && ground.is_blocked_turf(exclude_mobs = TRUE, source_atom = src)) + to_chat(user, span_notice("You fail to secure [src].")) + return CANT_UNFASTEN + to_chat(user, span_notice("You [anchored ? "un" : ""]secure [src].")) + set_anchored(!anchored) + check_on_table() + playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE) + SEND_SIGNAL(src, COMSIG_OBJ_DEFAULT_UNFASTEN_WRENCH, anchored) + return SUCCESSFUL_UNFASTEN + +/// For the do_after, this checks if unfastening conditions are still valid +/obj/proc/unfasten_wrench_check(prev_anchored, mob/user) + if(anchored != prev_anchored) + return FALSE + if(can_be_unfasten_wrench(user, TRUE) != SUCCESSFUL_UNFASTEN) //if we aren't explicitly successful, cancel the fuck out + return FALSE + return TRUE + +/// Adjusts the vertical pixel offset when the object is anchored on a tile with table +/obj/proc/check_on_table() + if(anchored_tabletop_offset != 0 && !istype(src, /obj/structure/table) && locate(/obj/structure/table) in loc) + pixel_y = anchored ? anchored_tabletop_offset : initial(pixel_y) diff --git a/code/modules/food_and_drinks/machinery/coffeemaker.dm b/code/modules/food_and_drinks/machinery/coffeemaker.dm index 7a5ea1a177e..122b2325b0f 100644 --- a/code/modules/food_and_drinks/machinery/coffeemaker.dm +++ b/code/modules/food_and_drinks/machinery/coffeemaker.dm @@ -8,7 +8,7 @@ base_icon_state = "coffeemaker" resistance_flags = FIRE_PROOF | ACID_PROOF circuit = /obj/item/circuitboard/machine/coffeemaker - pixel_y = 4 //needed to make it sit nicely on tables + anchored_tabletop_offset = 4 var/obj/item/reagent_containers/cup/coffeepot/coffeepot = null var/brewing = FALSE var/brew_time = 20 SECONDS diff --git a/code/modules/food_and_drinks/machinery/microwave.dm b/code/modules/food_and_drinks/machinery/microwave.dm index 3740f01da2c..59d0a731512 100644 --- a/code/modules/food_and_drinks/machinery/microwave.dm +++ b/code/modules/food_and_drinks/machinery/microwave.dm @@ -26,6 +26,7 @@ pass_flags = PASSTABLE light_color = LIGHT_COLOR_DIM_YELLOW light_power = 3 + anchored_tabletop_offset = 6 var/wire_disabled = FALSE // is its internal wire cut? var/operating = FALSE /// How dirty is it? @@ -53,8 +54,6 @@ wires = new /datum/wires/microwave(src) create_reagents(100) soundloop = new(src, FALSE) - set_on_table() - update_appearance(UPDATE_ICON) /obj/machinery/microwave/Exited(atom/movable/gone, direction) @@ -78,10 +77,6 @@ QDEL_NULL(soundloop) return ..() -/obj/machinery/microwave/set_anchored(anchorvalue) - . = ..() - set_on_table() - /obj/machinery/microwave/RefreshParts() . = ..() efficiency = 0 @@ -518,14 +513,6 @@ open = FALSE update_appearance() -/// Go on top of a table if we're anchored & not varedited -/obj/machinery/microwave/proc/set_on_table() - var/obj/structure/table/counter = locate(/obj/structure/table) in get_turf(src) - if(anchored && counter && !pixel_y) - pixel_y = 6 - else if(!anchored) - pixel_y = initial(pixel_y) - /// Type of microwave that automatically turns it self on erratically. Probably don't use this outside of the holodeck program "Microwave Paradise". /// You could also live your life with a microwave that will continously run in the background of everything while also not having any power draw. I think the former makes more sense. /obj/machinery/microwave/hell diff --git a/code/modules/food_and_drinks/machinery/processor.dm b/code/modules/food_and_drinks/machinery/processor.dm index d5940808143..fa5b0fb3c5d 100644 --- a/code/modules/food_and_drinks/machinery/processor.dm +++ b/code/modules/food_and_drinks/machinery/processor.dm @@ -7,7 +7,9 @@ icon_state = "processor1" layer = BELOW_OBJ_LAYER density = TRUE + pass_flags = PASSTABLE circuit = /obj/item/circuitboard/machine/processor + anchored_tabletop_offset = 8 ///Is the processor blending items at the moment var/processing = FALSE ///The speed at which the processor processes items diff --git a/code/modules/library/lib_machines.dm b/code/modules/library/lib_machines.dm index 337b72a4c9d..316213dc66d 100644 --- a/code/modules/library/lib_machines.dm +++ b/code/modules/library/lib_machines.dm @@ -28,8 +28,7 @@ icon_keyboard = null circuit = /obj/item/circuitboard/computer/libraryconsole desc = "Checked out books MUST be returned on time." - // This fixes consoles to be ON the tables, rather than their keyboards floating a bit - pixel_y = 8 + anchored_tabletop_offset = 8 ///The current title we're searching for var/title = "" ///The category we're searching for diff --git a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm index f00468d02fa..eb04fbf615d 100644 --- a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm +++ b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm @@ -476,7 +476,7 @@ has_panel_overlay = FALSE dispensed_temperature = WATER_MATTERSTATE_CHANGE_TEMP // magical mystery temperature of 274.5, where ice does not melt, and water does not freeze amount = 10 - pixel_y = 6 + anchored_tabletop_offset = 6 circuit = /obj/item/circuitboard/machine/chem_dispenser/drinks working_state = null nopower_state = null diff --git a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm index defc2ffe0e2..8acceeff975 100644 --- a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm +++ b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm @@ -10,6 +10,7 @@ circuit = /obj/item/circuitboard/machine/reagentgrinder pass_flags = PASSTABLE resistance_flags = ACID_PROOF + anchored_tabletop_offset = 8 var/operating = FALSE var/obj/item/reagent_containers/beaker = null var/limit = 10