#define DEFAULT_SHELF_CAPACITY 3 // Default capacity of the shelf #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. /obj/structure/crate_shelf name = "crate shelf" desc = "It's a shelf! For storing crates!" icon = 'icons/obj/objects.dmi' icon_state = "shelf_base" density = TRUE anchored = TRUE max_integrity = 50 // Not hard to break layer = ABOVE_MOB_LAYER var/capacity = DEFAULT_SHELF_CAPACITY var/use_delay = DEFAULT_SHELF_USE_DELAY var/offset = DEFAULT_SHELF_VERTICAL_OFFSET var/list/shelf_contents /obj/structure/crate_shelf/tall capacity = 12 /obj/structure/crate_shelf/Initialize(mapload) . = ..() shelf_contents = new/list(capacity) // Initialize our shelf's contents list, this will be used later. 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. for(var/i in 1 to (capacity - 1)) stack_layer = ABOVE_MOB_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 = 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) return /obj/structure/crate_shelf/Destroy() QDEL_LIST(shelf_contents) return ..() /obj/structure/crate_shelf/examine(mob/user) . = ..() . += "There are some bolts holding [src] together." if(shelf_contents.Find(null)) // If there's an empty space in the shelf, let the examiner know. . += "You could drag a crate into [src]." if(contents.len) // If there are any crates in the shelf, let the examiner know. . += "You could drag a crate out of [src]." . += "[src] contains:" for(var/obj/structure/closet/crate/crate in shelf_contents) . += " [icon2html(crate, user)] [crate]" /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)) deconstruct(TRUE) return TRUE return ..() /obj/structure/crate_shelf/relay_container_resist(mob/living/user, obj/structure/closet/crate) to_chat(user, "You begin attempting to knock [crate] out of [src].") if(do_after(user, 30 SECONDS, target = crate)) if(!user || user.stat != CONSCIOUS || user.loc != crate || crate.loc != src) return // If the user is in a strange condition, return early. visible_message("[crate] falls off of [src]!", "You manage to knock [crate] free of [src].", "