diff --git a/code/datums/recipe/material_recipe.dm b/code/datums/recipe/material_recipe.dm index e8c57e5de08d..2f2345e1eabc 100644 --- a/code/datums/recipe/material_recipe.dm +++ b/code/datums/recipe/material_recipe.dm @@ -16,5 +16,5 @@ /datum/stack_recipe/material/check(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) return ..() -/datum/stack_recipe/material/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) +/datum/stack_recipe/material/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) return ..() diff --git a/code/datums/recipe/material_recipes/furniture.dm b/code/datums/recipe/material_recipes/furniture.dm index e2db6dd78d9c..8616cba36f05 100644 --- a/code/datums/recipe/material_recipes/furniture.dm +++ b/code/datums/recipe/material_recipes/furniture.dm @@ -11,8 +11,10 @@ exclusitivity = /obj/structure/bed cost = 2 -/datum/stack_recipe/material/furniture/bed/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) - return new /obj/structure/bed(where, stack.material) +/datum/stack_recipe/material/furniture/bed/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) + for(var/i in 1 to amount) + created += new /obj/structure/bed(where, stack.material) + return TRUE /datum/stack_recipe/material/furniture/double_bed name = "double bed" @@ -20,8 +22,10 @@ exclusitivity = /obj/structure/bed cost = 3 -/datum/stack_recipe/material/furniture/double_bed/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) - return new /obj/structure/bed/double(where, stack.material) +/datum/stack_recipe/material/furniture/double_bed/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) + for(var/i in 1 to amount) + created += new /obj/structure/bed/double(where, stack.material) + return TRUE /datum/stack_recipe/material/furniture/stool name = "stool" @@ -29,8 +33,10 @@ exclusitivity = /obj/item/stool cost = 3 -/datum/stack_recipe/material/furniture/stool/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) - return new /obj/item/stool(where, stack.material) +/datum/stack_recipe/material/furniture/stool/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) + for(var/i in 1 to amount) + created += new /obj/item/stool(where, stack.material) + return TRUE /datum/stack_recipe/material/furniture/chair name = "chair" @@ -38,5 +44,7 @@ exclusitivity = /obj/structure/bed cost = 3 -/datum/stack_recipe/material/furniture/chair/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) - return new /obj/structure/bed/chair(where, stack.material) +/datum/stack_recipe/material/furniture/chair/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) + for(var/i in 1 to amount) + created += new /obj/structure/bed/chair(where, stack.material) + return TRUE diff --git a/code/datums/recipe/material_recipes/structures.dm b/code/datums/recipe/material_recipes/structures.dm index 3d5872ef09a9..15117cf3345b 100644 --- a/code/datums/recipe/material_recipes/structures.dm +++ b/code/datums/recipe/material_recipes/structures.dm @@ -10,42 +10,47 @@ result_type = /obj/structure/simple_door cost = 5 -/datum/stack_recipe/material/structure/door/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) +/datum/stack_recipe/material/structure/door/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) for(var/i in 1 to amount) - new /obj/structure/simple_door(where, stack.material) + created += new /obj/structure/simple_door(where, stack.material) + return TRUE /datum/stack_recipe/material/structure/barricade name = "barricade" result_type = /obj/structure/barricade cost = 5 -/datum/stack_recipe/material/structure/barricade/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) +/datum/stack_recipe/material/structure/barricade/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) for(var/i in 1 to amount) - new /obj/structure/barricade(where, stack.material) + created += new /obj/structure/barricade(where, stack.material) + return TRUE /datum/stack_recipe/material/structure/girder name = "girder" result_type = /obj/structure/girder cost = 2 -/datum/stack_recipe/material/structure/girder/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) +/datum/stack_recipe/material/structure/girder/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) for(var/i in 1 to amount) - new /obj/structure/girder(where, stack.material) + created += new /obj/structure/girder(where, stack.material) + return TRUE /datum/stack_recipe/material/structure/low_wall name = "low walls" result_type = /obj/structure/wall_frame cost = 2 -/datum/stack_recipe/material/structure/low_wall/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) +/datum/stack_recipe/material/structure/low_wall/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) for(var/i in 1 to amount) - new /obj/structure/wall_frame(where, stack.material) + created += new /obj/structure/wall_frame(where, stack.material) + return TRUE /datum/stack_recipe/material/structure/sculpting_block name = "sculpting block" result_type = /obj/structure/sculpting_block cost = 15 -/datum/stack_recipe/material/structure/sculpting_block/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) +/datum/stack_recipe/material/structure/sculpting_block/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) for(var/i in 1 to amount) - new /obj/structure/sculpting_block(where, stack.material) + created += new /obj/structure/sculpting_block(where, stack.material) + return TRUE diff --git a/code/datums/recipe/material_recipes/tools.dm b/code/datums/recipe/material_recipes/tools.dm index 122e4ca6d85d..304f62e948cf 100644 --- a/code/datums/recipe/material_recipes/tools.dm +++ b/code/datums/recipe/material_recipes/tools.dm @@ -10,16 +10,20 @@ result_type = /obj/item/clothing/gloves/ring/material cost = 1 -/datum/stack_recipe/material/tools/ring/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) - return new /obj/item/clothing/gloves/ring/material(where, stack.material) +/datum/stack_recipe/material/tools/ring/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) + for(var/i in 1 to amount) + created += new /obj/item/clothing/gloves/ring/material(where, stack.material) + return TRUE /datum/stack_recipe/material/tools/braclet name = "ring" result_type = /obj/item/clothing/accessory/bracelet/material cost = 1 -/datum/stack_recipe/material/tools/ring/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) - return new /obj/item/clothing/accessory/bracelet/material(where, stack.material) +/datum/stack_recipe/material/tools/ring/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) + for(var/i in 1 to amount) + created += new /obj/item/clothing/accessory/bracelet/material(where, stack.material) + return TRUE /** * for the /obj/item/material path @@ -27,9 +31,10 @@ /datum/stack_recipe/material/tools/simple abstract_type = /datum/stack_recipe/material/tools/simple -/datum/stack_recipe/material/tools/simple/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir) +/datum/stack_recipe/material/tools/simple/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list()) ASSERT(ispath(result_type, /obj/item/material)) - return new result_type(where, stack.material) + new result_type(where, stack.material) + return TRUE /datum/stack_recipe/material/tools/simple/baseball_bat name = "baseball bat" diff --git a/code/datums/recipe/stack_recipe.dm b/code/datums/recipe/stack_recipe.dm index c088ba6f2c1c..4d716d4e31ec 100644 --- a/code/datums/recipe/stack_recipe.dm +++ b/code/datums/recipe/stack_recipe.dm @@ -111,6 +111,8 @@ * this is past point of no return * shouldn't cancel under any circumstances * + * * When overriding this proc you **must** ensure list/created has a = list() in the args, if it doesn't call ..() first. Otherwise, the pattern being used will runtime. + * * @params * * where - where to spawn result * * amount - amount @@ -118,8 +120,9 @@ * * user - (optional) person crafting * * silent - (optional) suppress feedback to user * * use_dir - (optional) override dir if no user to get it from + * * creating - (optional) list will be populated of objects created. supply a list so you can read it, or don't to ignore. */ -/datum/stack_recipe/proc/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir) +/datum/stack_recipe/proc/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir, list/created = list()) if(result_is_stack) var/obj/item/stack/casted = result_type var/max_amount = initial(casted.max_amount) @@ -127,12 +130,14 @@ while(amount) if(!--safety) CRASH("safety hit") - var/obj/item/stack/created = new result_type(where, min(amount, max_amount)) - amount -= created.amount + var/obj/item/stack/creating = new result_type(where, min(amount, max_amount)) + amount -= creating.amount + created += creating else for(var/i in 1 to min(amount, 50)) - var/atom/movable/created = new result_type(where) - created.setDir(use_dir) + var/atom/movable/creating = new result_type(where) + creating.setDir(use_dir) + created += creating return TRUE /** diff --git a/code/datums/recipe/stack_recipes/misc.dm b/code/datums/recipe/stack_recipes/misc.dm index a7532e57e39f..cd148b86d6ac 100644 --- a/code/datums/recipe/stack_recipes/misc.dm +++ b/code/datums/recipe/stack_recipes/misc.dm @@ -6,56 +6,60 @@ result_type = /obj/item/oar cost = 2 -/datum/stack_recipe/oar/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir) +/datum/stack_recipe/oar/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir, list/created = list()) var/obj/item/stack/material/material_stack = stack if(istype(material_stack)) for(var/i in 1 to amount) - new result_type(where, material_stack.material) + created += new result_type(where, material_stack.material) else for(var/i in 1 to amount) - new result_type(where) + created += new result_type(where) + return TRUE /datum/stack_recipe/boat name = "boat" result_type = /obj/vehicle/ridden/boat cost = 15 -/datum/stack_recipe/boat/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir) +/datum/stack_recipe/boat/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir, list/created = list()) var/obj/item/stack/material/material_stack = stack if(istype(material_stack)) for(var/i in 1 to amount) - new result_type(where, material_stack.material) + created += new result_type(where, material_stack.material) else for(var/i in 1 to amount) - new result_type(where) + created += new result_type(where) + return TRUE /datum/stack_recipe/dragon_boat name = "dragon boat" result_type = /obj/vehicle/ridden/boat/dragon cost = 25 -/datum/stack_recipe/dragon_boat/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir) +/datum/stack_recipe/dragon_boat/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir, list/created = list()) var/obj/item/stack/material/material_stack = stack if(istype(material_stack)) for(var/i in 1 to amount) - new result_type(where, material_stack.material) + created += new result_type(where, material_stack.material) else for(var/i in 1 to amount) - new result_type(where) + created += new result_type(where) + return TRUE /datum/stack_recipe/pew abstract_type = /datum/stack_recipe/pew exclusitivity = /obj/structure/bed cost = 1 -/datum/stack_recipe/pew/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir) +/datum/stack_recipe/pew/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir, list/created = list()) var/obj/item/stack/material/material_stack = stack if(istype(material_stack)) for(var/i in 1 to amount) - new result_type(where, material_stack.material) + created += new result_type(where, material_stack.material) else for(var/i in 1 to amount) - new result_type(where) + created += new result_type(where) + return TRUE /datum/stack_recipe/pew/middle name = "pew (middle)" diff --git a/code/datums/recipe/stack_recipes/structures.dm b/code/datums/recipe/stack_recipes/structures.dm index 55d9ef9eac8c..3e03f2a1d5cd 100644 --- a/code/datums/recipe/stack_recipes/structures.dm +++ b/code/datums/recipe/stack_recipes/structures.dm @@ -22,9 +22,11 @@ return FALSE return TRUE -/datum/stack_recipe/railing/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir = user?.dir) +/datum/stack_recipe/railing/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir = user?.dir, list/created = list()) if(isnull(use_dir)) return - var/obj/structure/railing/built = new(where, TRUE) - built.setDir(use_dir) - return built + for(var/i in 1 to amount) + var/obj/structure/railing/built = new(where, TRUE) + built.setDir(use_dir) + created += built + return TRUE