From faf4a4121a78feef5beef38647e3d5008355f537 Mon Sep 17 00:00:00 2001 From: Cerebulon Date: Mon, 23 Aug 2021 00:45:08 +0100 Subject: [PATCH 1/2] Ports sliding things along tables --- code/_onclick/drag_drop.dm | 17 +++++----- code/modules/mob/inventory.dm | 2 +- code/modules/mob/living/inventory.dm | 4 +-- code/modules/tables/interactions.dm | 51 ++++++++++++++++++++++------ 4 files changed, 52 insertions(+), 22 deletions(-) diff --git a/code/_onclick/drag_drop.dm b/code/_onclick/drag_drop.dm index 65974fe009..9f7848b3d3 100644 --- a/code/_onclick/drag_drop.dm +++ b/code/_onclick/drag_drop.dm @@ -15,14 +15,13 @@ return FALSE // should stop you from dragging through windows return TRUE -/atom/MouseDrop(atom/over) - if(!usr || !over) return - if(!Adjacent(usr) || !over.Adjacent(usr)) return // should stop you from dragging through windows +/atom/MouseDrop(atom/over, src_location, over_location, src_control, over_control, params) + if(!usr || !over) + return + if(!Adjacent(usr) || !over.Adjacent(usr)) + return // should stop you from dragging through windows - spawn(0) - over.MouseDrop_T(src,usr) - return + INVOKE_ASYNC(over, /atom/.proc/MouseDrop_T, src, usr, src_location, over_location, src_control, over_control, params) -// recieve a mousedrop -/atom/proc/MouseDrop_T(atom/dropping, mob/user) - return +/atom/proc/MouseDrop_T(atom/dropping, mob/user, src_location, over_location, src_control, over_control, params) + return \ No newline at end of file diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 35df5ef8a1..4362320fc5 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -75,7 +75,7 @@ var/list/slot_equipment_priority = list( \ /mob/proc/equip_voidsuit_to_slot_or_del_with_refit(obj/item/clothing/suit/space/void/W as obj, slot, species = SPECIES_HUMAN) W.refit_for_species(species) return equip_to_slot_if_possible(W, slot, 1, 1, 0) - + /mob/proc/equip_voidhelm_to_slot_or_del_with_refit(obj/item/clothing/head/helmet/space/void/W as obj, slot, species = SPECIES_HUMAN) W.refit_for_species(species) return equip_to_slot_if_possible(W, slot, 1, 1, 0) diff --git a/code/modules/mob/living/inventory.dm b/code/modules/mob/living/inventory.dm index d5bc104add..ba41ff0f3d 100644 --- a/code/modules/mob/living/inventory.dm +++ b/code/modules/mob/living/inventory.dm @@ -301,7 +301,7 @@ if(istype(H.w_uniform, /obj/item/clothing/under)) suit = H.w_uniform - + var/list/slots = list() for(var/entry in H.species.hud.gear) var/list/slot_ref = H.species.hud.gear[entry] @@ -316,7 +316,7 @@ ))) data["slots"] = slots - + var/list/specialSlots = list() if(H.species.hud.has_hands) specialSlots.Add(list(list( diff --git a/code/modules/tables/interactions.dm b/code/modules/tables/interactions.dm index fee9550cbe..65978a020c 100644 --- a/code/modules/tables/interactions.dm +++ b/code/modules/tables/interactions.dm @@ -60,14 +60,37 @@ return 1 -/obj/structure/table/MouseDrop_T(obj/O as obj, mob/user as mob) +/obj/structure/table/MouseDrop_T(obj/O, mob/user, src_location, over_location, src_control, over_control, params) + if(ismob(O.loc)) //If placing an item + to_world("It's a drop!") + if(!isitem(O) || user.get_active_hand() != O) + return ..() + if(isrobot(user)) + return + user.drop_item() + if(O.loc != src.loc) + step(O, get_dir(O, src)) + to_world("Dropping Item On Table") - if ((!( istype(O, /obj/item/weapon) ) || user.get_active_hand() != O)) - return ..() - if(isrobot(user)) - return - user.unEquip(O, 0, src.loc) - return + else if(isturf(O.loc) && isitem(O)) //If pushing an item on the tabletop + to_world("It's a slide!") + var/obj/item/I = O + if(I.anchored) + to_world("Item is anchored and cannot be pushed") + return + + if((isliving(user)) && (Adjacent(user)) && !(user.incapacitated())) + to_world("Should be pushing...") + if(O.w_class <= user.can_pull_size) + O.forceMove(loc) + auto_align(I, params, TRUE) + to_world("Woosh!") + else + to_chat(user, SPAN_WARNING("\The [I] is too big for you to move!")) + return + to_world("Exiting the drop loop") + + return ..() /obj/structure/table/attackby(obj/item/W as obj, mob/user as mob, var/hit_modifier, var/click_parameters) @@ -159,7 +182,7 @@ Note: This proc can be overwritten to allow for different types of auto-alignmen /obj/item/var/list/center_of_mass = list("x" = 16,"y" = 16) -/obj/structure/table/proc/auto_align(obj/item/W, click_parameters) +/obj/structure/table/proc/auto_align(obj/item/W, click_parameters, var/animate = FALSE) if(!W.center_of_mass) W.randpixel_xy() return @@ -176,8 +199,16 @@ Note: This proc can be overwritten to allow for different types of auto-alignmen var/cell_x = max(0, min(CELLS-1, round(mouse_x/CELLSIZE))) var/cell_y = max(0, min(CELLS-1, round(mouse_y/CELLSIZE))) - W.pixel_x = (CELLSIZE * (0.5 + cell_x)) - W.center_of_mass["x"] - W.pixel_y = (CELLSIZE * (0.5 + cell_y)) - W.center_of_mass["y"] + var/target_x = (CELLSIZE * (cell_x + 0.5)) - W.center_of_mass["x"] + var/target_y = (CELLSIZE * (cell_y + 0.5)) - W.center_of_mass["y"] + if(animate) + var/dist_x = abs(W.pixel_x - target_x) + var/dist_y = abs(W.pixel_y - target_y) + var/dist = sqrt((dist_x*dist_x)+(dist_y*dist_y)) + animate(W, pixel_x=target_x, pixel_y=target_y,time=dist*0.5) + else + W.pixel_x = target_x + W.pixel_y = target_y #undef CELLS #undef CELLSIZE From de245fb082ddaed2528c0eac8e86ffcd411b3aa9 Mon Sep 17 00:00:00 2001 From: Cerebulon Date: Mon, 23 Aug 2021 00:48:30 +0100 Subject: [PATCH 2/2] remove debugs --- code/modules/tables/interactions.dm | 7 ------- 1 file changed, 7 deletions(-) diff --git a/code/modules/tables/interactions.dm b/code/modules/tables/interactions.dm index 65978a020c..c9eb7dbbd0 100644 --- a/code/modules/tables/interactions.dm +++ b/code/modules/tables/interactions.dm @@ -62,7 +62,6 @@ /obj/structure/table/MouseDrop_T(obj/O, mob/user, src_location, over_location, src_control, over_control, params) if(ismob(O.loc)) //If placing an item - to_world("It's a drop!") if(!isitem(O) || user.get_active_hand() != O) return ..() if(isrobot(user)) @@ -70,25 +69,19 @@ user.drop_item() if(O.loc != src.loc) step(O, get_dir(O, src)) - to_world("Dropping Item On Table") else if(isturf(O.loc) && isitem(O)) //If pushing an item on the tabletop - to_world("It's a slide!") var/obj/item/I = O if(I.anchored) - to_world("Item is anchored and cannot be pushed") return if((isliving(user)) && (Adjacent(user)) && !(user.incapacitated())) - to_world("Should be pushing...") if(O.w_class <= user.can_pull_size) O.forceMove(loc) auto_align(I, params, TRUE) - to_world("Woosh!") else to_chat(user, SPAN_WARNING("\The [I] is too big for you to move!")) return - to_world("Exiting the drop loop") return ..()