diff --git a/code/datums/components/storage/storage.dm b/code/datums/components/storage/storage.dm index 9f6ca0ffbb..a92ae9e629 100644 --- a/code/datums/components/storage/storage.dm +++ b/code/datums/components/storage/storage.dm @@ -57,6 +57,10 @@ var/screen_start_x = 4 //These two are where the storage starts being rendered, screen_loc wise. var/screen_start_y = 2 //End + + var/limited_random_access = FALSE //Quick if statement in accessible_items to determine if we care at all about what people can access at once. + var/limited_random_access_stack_position = 0 //If >0, can only access top items + var/limited_random_access_stack_bottom_up = FALSE //If TRUE, above becomes bottom items /datum/component/storage/Initialize(datum/component/storage/concrete/master) if(!isatom(parent)) @@ -146,6 +150,19 @@ var/datum/component/storage/concrete/master = master() return master? master.real_location() : null +//What players can access +//this proc can probably eat a refactor at some point. +/datum/component/storage/proc/accessible_items(random_access = TRUE) + var/list/contents = contents() + if(contents) + if(limited_random_access && random_access) + if(limited_random_access_stack_position && (length(contents) > limited_random_access_stack_position)) + if(limited_random_access_stack_bottom_up) + contents.Cut(1, limited_random_access_stack_position + 1) + else + contents.Cut(1, length(contents) - limited_random_access_stack_position + 1) + return contents + /datum/component/storage/proc/canreach_react(datum/source, list/next) var/datum/component/storage/concrete/master = master() if(!master) @@ -284,8 +301,7 @@ /datum/component/storage/proc/_process_numerical_display() . = list() - var/atom/real_location = real_location() - for(var/obj/item/I in real_location.contents) + for(var/obj/item/I in accessible_items()) if(QDELETED(I)) continue if(!.[I.type]) @@ -296,8 +312,8 @@ //This proc determines the size of the inventory to be displayed. Please touch it only if you know what you're doing. /datum/component/storage/proc/orient2hud(mob/user, maxcolumns) - var/atom/real_location = real_location() - var/adjusted_contents = real_location.contents.len + var/list/accessible_contents = accessible_items() + var/adjusted_contents = length(accessible_contents) //Numbered contents display var/list/datum/numbered_display/numbered_contents @@ -329,8 +345,7 @@ if(cy - screen_start_y >= rows) break else - var/atom/real_location = real_location() - for(var/obj/O in real_location) + for(var/obj/O in accessible_items()) if(QDELETED(O)) continue O.mouse_opacity = MOUSE_OPACITY_OPAQUE //This is here so storage items that spawn with contents correctly have the "click around item to equip" @@ -351,9 +366,8 @@ return FALSE var/list/cview = getviewsize(M.client.view) var/maxallowedscreensize = cview[1]-8 - var/atom/real_location = real_location() if(M.active_storage != src && (M.stat == CONSCIOUS)) - for(var/obj/item/I in real_location) + for(var/obj/item/I in accessible_items()) if(I.on_found(M)) return FALSE if(M.active_storage) @@ -361,7 +375,7 @@ orient2hud(M, (isliving(M) ? maxallowedscreensize : 7)) M.client.screen |= boxes M.client.screen |= closer - M.client.screen |= real_location.contents + M.client.screen |= accessible_items() M.active_storage = src LAZYOR(is_using, M) return TRUE diff --git a/code/game/objects/items/storage/bags.dm b/code/game/objects/items/storage/bags.dm index 13efe72686..eafa79798e 100644 --- a/code/game/objects/items/storage/bags.dm +++ b/code/game/objects/items/storage/bags.dm @@ -49,6 +49,8 @@ STR.max_combined_w_class = 30 STR.max_items = 30 STR.cant_hold = typecacheof(list(/obj/item/disk/nuclear)) + STR.limited_random_access = TRUE + STR.limited_random_access_stack_position = 3 /obj/item/storage/bag/trash/suicide_act(mob/user) user.visible_message("[user] puts [src] over [user.p_their()] head and starts chomping at the insides! Disgusting!") @@ -88,6 +90,7 @@ var/datum/component/storage/STR = GetComponent(/datum/component/storage) STR.max_combined_w_class = 60 STR.max_items = 60 + STR.limited_random_access_stack_position = 5 /obj/item/storage/bag/trash/bluespace/cyborg insertable = FALSE