mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 13:10:02 +01:00
Locking a storage item now locks you out of other storage items inside it. (#90243)
## About The Pull Request This PR introduces the `set_locked()` proc, which I'll also need for something else later. ## Why It's Good For The Game I could still interact with the storage of a box I placed into a secure safe after I locked the latter. ## Changelog 🆑 fix: Locking a storage item now locks you out of other storage items inside it. /🆑
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
|
||||
src.lock_code = lock_code
|
||||
if(!isnull(lock_code))
|
||||
atom_parent.atom_storage.locked = STORAGE_FULLY_LOCKED
|
||||
atom_parent.atom_storage.set_locked(STORAGE_FULLY_LOCKED)
|
||||
src.can_hack_open = can_hack_open
|
||||
|
||||
atom_parent.update_appearance()
|
||||
@@ -208,9 +208,7 @@
|
||||
//you can't lock it if it's already locked or lacks a lock code.
|
||||
if(source.atom_storage.locked || isnull(lock_code))
|
||||
return TRUE
|
||||
source.atom_storage.locked = STORAGE_FULLY_LOCKED
|
||||
source.atom_storage.hide_contents(usr)
|
||||
source.update_appearance(UPDATE_ICON)
|
||||
source.atom_storage.set_locked(STORAGE_FULLY_LOCKED)
|
||||
return TRUE
|
||||
//setting a password & unlocking
|
||||
if("E")
|
||||
@@ -225,9 +223,8 @@
|
||||
if(numeric_input != lock_code)
|
||||
return TRUE
|
||||
var/atom/source = parent
|
||||
source.atom_storage.locked = STORAGE_NOT_LOCKED
|
||||
source.atom_storage.set_locked(STORAGE_NOT_LOCKED)
|
||||
numeric_input = ""
|
||||
source.update_appearance(UPDATE_ICON)
|
||||
return TRUE
|
||||
//putting digits in.
|
||||
if("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
|
||||
/datum/storage/Destroy()
|
||||
|
||||
for(var/mob/person in is_using)
|
||||
for(var/mob/person as anything in is_using)
|
||||
hide_contents(person)
|
||||
|
||||
is_using.Cut()
|
||||
@@ -671,7 +671,7 @@ GLOBAL_LIST_EMPTY(cached_storage_typecaches)
|
||||
/datum/storage/proc/remove_and_refresh(atom/movable/gone)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
for(var/mob/user in is_using)
|
||||
for(var/mob/user as anything in is_using)
|
||||
if(user.client)
|
||||
var/client/cuser = user.client
|
||||
cuser.screen -= gone
|
||||
@@ -958,9 +958,15 @@ GLOBAL_LIST_EMPTY(cached_storage_typecaches)
|
||||
|
||||
/// Close the storage UI for everyone viewing us.
|
||||
/datum/storage/proc/close_all()
|
||||
for(var/mob/user in is_using)
|
||||
for(var/mob/user as anything in is_using)
|
||||
hide_contents(user)
|
||||
|
||||
/// Closes the storage UIs of this and everything inside the parent for everyone viewing them.
|
||||
/datum/storage/proc/close_all_recursive()
|
||||
close_all()
|
||||
for(var/atom/movable/movable as anything in parent.get_all_contents())
|
||||
movable.atom_storage?.close_all()
|
||||
|
||||
/// Refresh the views of everyone currently viewing the storage.
|
||||
/datum/storage/proc/refresh_views()
|
||||
for (var/mob/user in can_see_contents())
|
||||
@@ -1141,3 +1147,12 @@ GLOBAL_LIST_EMPTY(cached_storage_typecaches)
|
||||
return
|
||||
|
||||
changed.visible_message(span_warning("[changed] falls out of [parent]!"), vision_distance = COMBAT_MESSAGE_RANGE)
|
||||
|
||||
///Assign a new value to the locked variable. If it's higher than NOT_LOCKED, close the UIs and update the appearance of the parent.
|
||||
/datum/storage/proc/set_locked(new_locked)
|
||||
if(locked == new_locked)
|
||||
return
|
||||
locked = new_locked
|
||||
if(new_locked > STORAGE_NOT_LOCKED)
|
||||
close_all_recursive()
|
||||
parent.update_appearance()
|
||||
|
||||
@@ -499,19 +499,16 @@
|
||||
SEND_SIGNAL(src, COMSIG_DUFFEL_ZIP_CHANGE, new_zip)
|
||||
if(zipped_up)
|
||||
slowdown = initial(slowdown)
|
||||
atom_storage.locked = STORAGE_SOFT_LOCKED
|
||||
atom_storage.set_locked(STORAGE_SOFT_LOCKED)
|
||||
atom_storage.display_contents = FALSE
|
||||
for(var/obj/item/weapon as anything in get_all_contents_type(/obj/item)) //close ui of this and all items inside dufflebag
|
||||
weapon.atom_storage?.close_all() //not everything has storage initialized
|
||||
else
|
||||
slowdown = zip_slowdown
|
||||
atom_storage.locked = STORAGE_NOT_LOCKED
|
||||
atom_storage.set_locked(STORAGE_NOT_LOCKED)
|
||||
atom_storage.display_contents = TRUE
|
||||
|
||||
if(isliving(loc))
|
||||
var/mob/living/wearer = loc
|
||||
wearer.update_equipment_speed_mods()
|
||||
update_appearance()
|
||||
|
||||
/obj/item/storage/backpack/duffelbag/cursed
|
||||
name = "living duffel bag"
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
atom_storage.max_specific_storage = WEIGHT_CLASS_NORMAL
|
||||
atom_storage.max_total_storage = 14
|
||||
atom_storage.max_slots = 4
|
||||
atom_storage.locked = STORAGE_FULLY_LOCKED
|
||||
atom_storage.set_locked(STORAGE_FULLY_LOCKED)
|
||||
|
||||
register_context()
|
||||
update_appearance()
|
||||
|
||||
/obj/item/storage/lockbox/tool_act(mob/living/user, obj/item/tool, list/modifiers)
|
||||
var/obj/item/card/card = tool.GetID()
|
||||
@@ -44,13 +43,8 @@
|
||||
return FALSE
|
||||
|
||||
/obj/item/storage/lockbox/proc/toggle_locked(mob/living/user)
|
||||
if(atom_storage.locked)
|
||||
atom_storage.locked = STORAGE_NOT_LOCKED
|
||||
else
|
||||
atom_storage.locked = STORAGE_FULLY_LOCKED
|
||||
atom_storage.close_all()
|
||||
atom_storage.set_locked(atom_storage.locked ? STORAGE_NOT_LOCKED : STORAGE_FULLY_LOCKED)
|
||||
balloon_alert(user, atom_storage.locked ? "locked" : "unlocked")
|
||||
update_appearance()
|
||||
|
||||
/obj/item/storage/lockbox/update_icon_state()
|
||||
. = ..()
|
||||
@@ -66,11 +60,10 @@
|
||||
/obj/item/storage/lockbox/emag_act(mob/user, obj/item/card/emag/emag_card)
|
||||
if(!broken)
|
||||
broken = TRUE
|
||||
atom_storage.locked = STORAGE_NOT_LOCKED
|
||||
atom_storage.set_locked(STORAGE_NOT_LOCKED)
|
||||
balloon_alert(user, "lock destroyed")
|
||||
if (emag_card && user)
|
||||
user.visible_message(span_warning("[user] swipes [emag_card] over [src], breaking it!"))
|
||||
update_appearance()
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
|
||||
@@ -643,7 +643,7 @@
|
||||
|
||||
/obj/item/storage/toolbox/guncase/monkeycase/Initialize(mapload)
|
||||
. = ..()
|
||||
atom_storage.locked = STORAGE_SOFT_LOCKED
|
||||
atom_storage.set_locked(STORAGE_SOFT_LOCKED)
|
||||
|
||||
/obj/item/storage/toolbox/guncase/monkeycase/attack_self(mob/user, modifiers)
|
||||
if(!monkey_check(user))
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
max_specific_storage = WEIGHT_CLASS_GIGANTIC,
|
||||
max_total_storage = 20,
|
||||
)
|
||||
atom_storage.locked = STORAGE_FULLY_LOCKED
|
||||
atom_storage.set_locked(STORAGE_FULLY_LOCKED)
|
||||
|
||||
/obj/item/wallframe/secure_safe/after_attach(obj/attached_to)
|
||||
. = ..()
|
||||
|
||||
@@ -148,9 +148,8 @@ GLOBAL_DATUM_INIT(lost_crew_manager, /datum/lost_crew_manager, new)
|
||||
if(!atom_storage.locked)
|
||||
return
|
||||
|
||||
atom_storage.locked = STORAGE_NOT_LOCKED
|
||||
atom_storage.set_locked(STORAGE_NOT_LOCKED)
|
||||
balloon_alert(user, "unlocked")
|
||||
update_appearance()
|
||||
|
||||
/obj/item/storage/lockbox/mind/add_context(atom/source, list/context, obj/item/held_item, mob/user)
|
||||
if(broken || user.mind != mind)
|
||||
|
||||
@@ -22,19 +22,19 @@
|
||||
. = ..()
|
||||
create_storage(max_specific_storage = max_w_class, max_total_storage = max_combined_w_class, max_slots = max_items)
|
||||
atom_storage.allow_big_nesting = TRUE
|
||||
atom_storage.locked = STORAGE_FULLY_LOCKED
|
||||
atom_storage.set_locked(STORAGE_FULLY_LOCKED)
|
||||
|
||||
/obj/item/mod/module/storage/on_install()
|
||||
var/datum/storage/modstorage = mod.create_storage(max_specific_storage = max_w_class, max_total_storage = max_combined_w_class, max_slots = max_items)
|
||||
modstorage.set_real_location(src)
|
||||
modstorage.allow_big_nesting = big_nesting
|
||||
atom_storage.locked = STORAGE_NOT_LOCKED
|
||||
atom_storage.set_locked(STORAGE_NOT_LOCKED)
|
||||
var/obj/item/clothing/suit = mod.get_part_from_slot(ITEM_SLOT_OCLOTHING)
|
||||
if(istype(suit))
|
||||
RegisterSignal(suit, COMSIG_ITEM_PRE_UNEQUIP, PROC_REF(on_suit_unequip))
|
||||
|
||||
/obj/item/mod/module/storage/on_uninstall(deleting = FALSE)
|
||||
atom_storage.locked = STORAGE_FULLY_LOCKED
|
||||
atom_storage.set_locked(STORAGE_FULLY_LOCKED)
|
||||
QDEL_NULL(mod.atom_storage)
|
||||
if(!deleting)
|
||||
atom_storage.remove_all(mod.drop_location())
|
||||
|
||||
@@ -257,12 +257,7 @@
|
||||
|
||||
/obj/item/storage/portable_chem_mixer/item_ctrl_click(mob/user)
|
||||
if(atom_storage.locked == STORAGE_FULLY_LOCKED)
|
||||
atom_storage.locked = STORAGE_NOT_LOCKED
|
||||
replace_beaker(user)
|
||||
SStgui.close_uis(src)
|
||||
else
|
||||
atom_storage.locked = STORAGE_FULLY_LOCKED
|
||||
atom_storage.hide_contents(user)
|
||||
|
||||
update_appearance()
|
||||
atom_storage.set_locked(atom_storage.locked ? STORAGE_NOT_LOCKED : STORAGE_FULLY_LOCKED)
|
||||
return CLICK_ACTION_SUCCESS
|
||||
|
||||
Reference in New Issue
Block a user