Files
Bubberstation/code/game/atom/atom_storage.dm
MrMelbert 12afcb911e Comprehensive cleanup of storage datum, replaces the weakrefs with just refs (because they were managed already) (#81120)
## About The Pull Request

- Large amount of storage datum cleanup.
   - Documentation.
   - Maybe more consistent use of parent vs real_location. 
   - Removes the weakrefs, replaces it with just references.
      - These were already managed references anyways so why bother?
- Removes a bunch of arguments no one used and would ever used so only
the most useful args are left.
 
- Some bugfixes. 

## Why It's Good For The Game

Aiming to make storage easier to work with. The whole intent of this was
to bugfix the whole "weight class" thing that keeps popping up but I had
to do this first.

## Changelog

🆑 Melbert
fix: When placing an item into storage (such as backpacks), all nearby
mobs now get a message, rather than just the first mob.
fix: TGC decks of cards should act a bit less odd when looking inside.  
refactor: Refactored a bit of storage, cleaned up a fair bit of its
code. Let me know if you notice anything funky about storage (like
backpacks).
/🆑
2024-02-05 11:42:03 -08:00

44 lines
1.3 KiB
Plaintext

/atom
/// the datum handler for our contents - see create_storage() for creation method
var/datum/storage/atom_storage
/// A quick and easy way to create a storage datum for an atom
/atom/proc/create_storage(
max_slots,
max_specific_storage,
max_total_storage,
list/canhold,
list/canthold,
storage_type = /datum/storage,
)
RETURN_TYPE(/datum/storage)
if(atom_storage)
QDEL_NULL(atom_storage)
atom_storage = new storage_type(src, max_slots, max_specific_storage, max_total_storage)
if(canhold || canthold)
atom_storage.set_holdable(canhold, canthold)
return atom_storage
/**
* A quick and easy way to /clone/ a storage datum for an atom (does not copy over contents, only the datum details)
*
* Imperfect, does not copy over ALL variables, only important ones (max storage size, etc)
*/
/atom/proc/clone_storage(datum/storage/cloning)
RETURN_TYPE(/datum/storage)
if(atom_storage)
QDEL_NULL(atom_storage)
atom_storage = new cloning.type(src, cloning.max_slots, cloning.max_specific_storage, cloning.max_total_storage)
if(cloning.can_hold || cloning.cant_hold)
if(!atom_storage.can_hold && !atom_storage.cant_hold) //In the event that the can/can't hold lists are already in place (such as from storage objects added on initialize).
atom_storage.set_holdable(cloning.can_hold, cloning.cant_hold)
return atom_storage