diff --git a/code/game/objects/structures/crateshelf.dm b/code/game/objects/structures/crateshelf.dm index 0bf1cfa64c4fd..a637829bd2c2b 100644 --- a/code/game/objects/structures/crateshelf.dm +++ b/code/game/objects/structures/crateshelf.dm @@ -1,4 +1,5 @@ #define DEFAULT_SHELF_CAPACITY 3 // Default capacity of the shelf +#define DEFAULT_SHELF_MAX_CAPACITY 4 #define DEFAULT_SHELF_USE_DELAY 1 SECONDS // Default interaction delay of the shelf #define DEFAULT_SHELF_VERTICAL_OFFSET 10 // Vertical pixel offset of shelving-related things. Set to 10 by default due to this leaving more of the crate on-screen to be clicked. @@ -12,9 +13,13 @@ max_integrity = 50 // Not hard to break var/capacity = DEFAULT_SHELF_CAPACITY + var/max_capacity = DEFAULT_SHELF_MAX_CAPACITY var/use_delay = DEFAULT_SHELF_USE_DELAY var/list/shelf_contents +/obj/structure/crate_shelf/built + capacity = 1 + /obj/structure/crate_shelf/debug capacity = 12 @@ -47,12 +52,40 @@ for(var/obj/structure/closet/crate/crate in shelf_contents) . += " [icon2html(crate, user)] [crate]" +/obj/structure/crate_shelf/proc/add_shelf(num) + if(capacity + num > max_capacity) + return FALSE + var/stack_layer // This is used to generate the sprite layering of the shelf pieces. + var/stack_offset // This is used to generate the vertical offset of the shelf pieces. + var/prev_capacity = capacity + capacity += num + shelf_contents.len = capacity + for(var/i in prev_capacity to (capacity - 1)) + if(i >= 3) // If we're at or above three, we'll be on the way to going off the tile we're on. This allows mobs to be below the shelf when this happens. + stack_layer = ABOVE_MOB_LAYER + (0.02 * i) - 0.01 + else + stack_layer = BELOW_OBJ_LAYER + (0.02 * i) - 0.01 // Make each shelf piece render above the last, but below the crate that should be on it. + stack_offset = DEFAULT_SHELF_VERTICAL_OFFSET * i // Make each shelf piece physically above the last. + overlays += image(icon = 'icons/obj/objects.dmi', icon_state = "shelf_stack", layer = stack_layer, pixel_y = stack_offset) + /obj/structure/crate_shelf/attackby(obj/item/item, mob/living/user, params) if (item.tool_behaviour == TOOL_WRENCH && !(flags_1&NODECONSTRUCT_1)) item.play_tool_sound(src) - if(do_after(user, 3 SECONDS, target = src)) + if(do_after(user, 3 SECONDS, src)) deconstruct(TRUE) return TRUE + if(istype(item, /obj/item/stack/sheet/metal)) + if(capacity < max_capacity) + var/obj/item/stack/sheet/metal/our_sheet = item + if(our_sheet.get_amount() >= 2) + balloon_alert(user, "adding additional shelf to rack") + if(do_after(user, 3 SECONDS, src)) + add_shelf(1) + our_sheet.add(-2) + return TRUE + to_chat(user, span_notice("Adding a shelf to [src] requires more metal.")) + return FALSE + to_chat(user, span_notice("[src] cannot be built any higher!")) return ..() /obj/structure/crate_shelf/relay_container_resist_act(mob/living/user, obj/structure/closet/crate) @@ -143,4 +176,4 @@ /obj/item/rack_parts/shelf name = "crate shelf parts" desc = "Parts of a shelf." - construction_type = /obj/structure/crate_shelf + construction_type = /obj/structure/crate_shelf/built