diff --git a/code/__DEFINES/storage.dm b/code/__DEFINES/storage.dm new file mode 100644 index 00000000000..35fb6b396b5 --- /dev/null +++ b/code/__DEFINES/storage.dm @@ -0,0 +1,11 @@ +// Storage component defines + +// Storage collection defines +#define COLLECT_ONE 0 +#define COLLECT_EVERYTHING 1 +#define COLLECT_SAME 2 + +// Drop style defines +#define DROP_NOTHING 0 +#define DROP_AT_PARENT 1 +#define DROP_AT_LOCATION 2 diff --git a/code/datums/components/storage/storage.dm b/code/datums/components/storage/storage.dm index a60b08393a5..8ac4cc5c5e5 100644 --- a/code/datums/components/storage/storage.dm +++ b/code/datums/components/storage/storage.dm @@ -1,11 +1,3 @@ -#define COLLECT_ONE 0 -#define COLLECT_EVERYTHING 1 -#define COLLECT_SAME 2 - -#define DROP_NOTHING 0 -#define DROP_AT_PARENT 1 -#define DROP_AT_LOCATION 2 - // External storage-related logic: // /mob/proc/ClickOn() in /_onclick/click.dm - clicking items in storages // /mob/living/Move() in /modules/mob/living/living.dm - hiding storage boxes on mob movement diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index aad6c52862d..c4f0bca6394 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -42,6 +42,7 @@ #include "reagent_recipe_collisions.dm" #include "resist.dm" #include "say.dm" +#include "serving_tray.dm" #include "siunit.dm" #include "spawn_humans.dm" #include "species_whitelists.dm" diff --git a/code/modules/unit_tests/serving_tray.dm b/code/modules/unit_tests/serving_tray.dm new file mode 100644 index 00000000000..debf689989f --- /dev/null +++ b/code/modules/unit_tests/serving_tray.dm @@ -0,0 +1,47 @@ +/** + * Check that standard food items fit on the serving tray + */ +/datum/unit_test/servingtray/Run() + var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human) + var/obj/structure/table/the_table = allocate(/obj/structure/table) + var/obj/item/storage/bag/tray/test_tray = allocate(/obj/item/storage/bag/tray) + var/obj/item/reagent_containers/food/banana = allocate(/obj/item/reagent_containers/food/snacks/grown/banana) + var/obj/item/food/the_bread = allocate(/obj/item/food/breadslice) + var/obj/item/reagent_containers/food/sugarcookie = allocate(/obj/item/reagent_containers/food/snacks/sugarcookie) + var/obj/item/clothing/under/jumpsuit = allocate(/obj/item/clothing/under/color/black) + + TEST_ASSERT_EQUAL((the_bread in test_tray.contents), FALSE, "The bread is on the serving tray at test start") + + // set the tray to single item mode the dirty way + var/datum/component/storage/tray_storage = test_tray.GetComponent(/datum/component/storage) + tray_storage.collection_mode = COLLECT_ONE + + test_tray.pre_attack(the_bread, human) + + TEST_ASSERT_EQUAL((the_bread in test_tray.contents), TRUE, "The bread did not get picked up by the serving tray") + + test_tray.pre_attack(banana, human) + + TEST_ASSERT_EQUAL((banana in test_tray.contents), TRUE, "The banana did not get picked up by the serving tray") + + the_table.attackby(test_tray, human) + + TEST_ASSERT_EQUAL(test_tray.contents.len, 0, "The serving tray did not drop all items on hitting the table") + + test_tray.pre_attack(sugarcookie, human) + + TEST_ASSERT_EQUAL((sugarcookie in test_tray.contents), TRUE, "The sugarcookie did not get picked up by the serving tray") + + human.equip_to_slot(jumpsuit, ITEM_SLOT_ICLOTHING) + TEST_ASSERT(human.get_item_by_slot(ITEM_SLOT_ICLOTHING), "Human does not have jumpsuit on") + + human.equip_to_slot(test_tray, ITEM_SLOT_LPOCKET) + TEST_ASSERT(human.get_item_by_slot(ITEM_SLOT_LPOCKET), "Serving tray failed to fit in the Left Pocket") + + human.equip_to_slot(test_tray, ITEM_SLOT_RPOCKET) + TEST_ASSERT(human.get_item_by_slot(ITEM_SLOT_RPOCKET), "Serving tray failed to fit in the Right Pocket") + + test_tray.attack(human, human) + + TEST_ASSERT_EQUAL(test_tray.contents.len, 0, "The serving tray did not drop all items on hitting a human") + diff --git a/tgstation.dme b/tgstation.dme index cd76edd91d4..f5b3fafc83d 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -112,6 +112,7 @@ #include "code\__DEFINES\stat.dm" #include "code\__DEFINES\stat_tracking.dm" #include "code\__DEFINES\status_effects.dm" +#include "code\__DEFINES\storage.dm" #include "code\__DEFINES\subsystems.dm" #include "code\__DEFINES\tgs.config.dm" #include "code\__DEFINES\tgs.dm"