Files
Bubberstation/code/game/atom/atom_storage.dm
SkyratBot 138d1324b8 [MIRROR] Comprehensive cleanup of storage datum, replaces the weakrefs with just refs (because they were managed already) (#26357)
* Comprehensive cleanup of storage datum, replaces the weakrefs with just refs (because they were managed already)

* fixes

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: jjpark-kb <mccorvey.norman@gmail.com>
2024-02-07 14:12:31 -05: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