From d390dc30fd5a0ff7ac4d5e5c371c1a1336d23a3c Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sun, 27 Oct 2019 20:35:27 -0700 Subject: [PATCH] Update storage.dm --- code/datums/components/storage/storage.dm | 29 +++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/code/datums/components/storage/storage.dm b/code/datums/components/storage/storage.dm index 308096f8db..526f24e15d 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,8 +150,18 @@ var/datum/component/storage/concrete/master = master() return master? master.real_location() : null -/datum/component/storage/proc/accessible_items() - return contents() +//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_radnom_access_stack_position && (length(contents) > limited_random_access_stack_position)) + if(limited_random_acccess_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() @@ -288,7 +302,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]) @@ -300,7 +314,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/accessible_contents = accessible_items() + var/adjusted_contents = accessible_contents.len //Numbered contents display var/list/datum/numbered_display/numbered_contents @@ -333,7 +348,7 @@ 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" @@ -356,7 +371,7 @@ 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) @@ -364,7 +379,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