From d048bca6ae6211a111c2340dd97ae37b36b3f705 Mon Sep 17 00:00:00 2001 From: SabreML <57483089+SabreML@users.noreply.github.com> Date: Sat, 5 Dec 2020 10:28:36 +0000 Subject: [PATCH] Donut box folding (#15027) --- .../objects/items/weapons/storage/boxes.dm | 34 ++----------------- .../objects/items/weapons/storage/fancy.dm | 2 ++ .../objects/items/weapons/storage/storage.dm | 30 +++++++++++++++- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/code/game/objects/items/weapons/storage/boxes.dm b/code/game/objects/items/weapons/storage/boxes.dm index 000cb96d720..f65801f14f4 100644 --- a/code/game/objects/items/weapons/storage/boxes.dm +++ b/code/game/objects/items/weapons/storage/boxes.dm @@ -25,42 +25,15 @@ icon_state = "box" item_state = "syringe_kit" resistance_flags = FLAMMABLE - var/foldable = /obj/item/stack/sheet/cardboard - var/amt = 1 - -/obj/item/storage/box/attack_self(mob/user) - ..() - - if(!foldable) - return - if(contents.len) - to_chat(user, "You can't fold this box with items still inside!") - return - if(!ispath(foldable)) - return - - // Close any open UI windows first - var/found = 0 - for(var/mob/M in range(1)) - if(M.s_active == src) - close(M) - if(M == user) - found = 1 - if(!found) // User is too far away - return - - to_chat(user, "You fold [src] flat.") - var/obj/item/stack/I = new foldable(get_turf(src), amt) - user.put_in_hands(I) - qdel(src) + foldable = /obj/item/stack/sheet/cardboard + foldable_amt = 1 /obj/item/storage/box/large name = "large box" desc = "You could build a fort with this." icon_state = "largebox" w_class = 4 // Big, bulky. - foldable = /obj/item/stack/sheet/cardboard - amt = 4 + foldable_amt = 4 storage_slots = 21 max_combined_w_class = 42 // 21*2 @@ -897,7 +870,6 @@ icon_state = "light" desc = "This box is shaped on the inside so that only light tubes and bulbs fit." item_state = "syringe_kit" - foldable = /obj/item/stack/sheet/cardboard storage_slots=21 can_hold = list(/obj/item/light/tube, /obj/item/light/bulb) max_combined_w_class = 21 diff --git a/code/game/objects/items/weapons/storage/fancy.dm b/code/game/objects/items/weapons/storage/fancy.dm index 417e5e451f7..644cd45ce19 100644 --- a/code/game/objects/items/weapons/storage/fancy.dm +++ b/code/game/objects/items/weapons/storage/fancy.dm @@ -46,6 +46,8 @@ storage_slots = 6 can_hold = list(/obj/item/reagent_containers/food/snacks/donut) icon_type = "donut" + foldable = /obj/item/stack/sheet/cardboard + foldable_amt = 1 /obj/item/storage/fancy/donut_box/update_icon() overlays.Cut() diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index 205c110215b..68b1acf1ab7 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -24,6 +24,11 @@ var/collection_mode = 1; //0 = pick one at a time, 1 = pick all on tile var/use_sound = "rustle" //sound played when used. null for no sound. + /// What kind of [/obj/item/stack] can this be folded into. (e.g. Boxes and cardboard) + var/foldable = null + /// How much of the stack item do you get. + var/foldable_amt = 0 + /obj/item/storage/MouseDrop(obj/over_object as obj) if(ishuman(usr)) //so monkeys can take off their backpacks -- Urist var/mob/M = usr @@ -502,11 +507,34 @@ O.hear_message(M, msg) /obj/item/storage/attack_self(mob/user) - //Clicking on itself will empty it, if allow_quick_empty is TRUE if(allow_quick_empty && user.is_in_active_hand(src)) drop_inventory(user) + else if(foldable) + fold(user) + +/obj/item/storage/proc/fold(mob/user) + if(length(contents)) + to_chat(user, "You can't fold this [name] with items still inside!") + return + if(!ispath(foldable)) + return + + var/found = FALSE + for(var/mob/M in range(1)) + if(M.s_active == src) // Close any open UI windows first + close(M) + if(M == user) + found = TRUE + if(!found) // User is too far away + return + + to_chat(user, "You fold [src] flat.") + var/obj/item/stack/I = new foldable(get_turf(src), foldable_amt) + user.put_in_hands(I) + qdel(src) + //Returns the storage depth of an atom. This is the number of storage items the atom is contained in before reaching toplevel (the area). //Returns -1 if the atom was not found on container. /atom/proc/storage_depth(atom/container)