Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverts the removal of get_recipes(), fixes basemat recipes #10701

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions code/controllers/subsystem/materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ SUBSYSTEM_DEF(materials)
for(var/c in ref.categories)
materials_by_category[c] += list(ref)

// Adds the dupe recipes into multiple material recipes
var/list/global_mat_recipes = ref.get_material_recipes()
if(global_mat_recipes)
if(ref.categories[MAT_CATEGORY_BASE_RECIPES])
global_mat_recipes += SSmaterials.rigid_stack_recipes.Copy()
/* put more material recipes here. example:
if(ref.categories[MAT_CATEGORY_SOME_NEW_RECIPES])
global_mat_recipes += SSmaterials.SOME_NEW_RECIPES.Copy()
*/

/datum/controller/subsystem/materials/proc/GetMaterialRef(datum/material/fakemat)
if(!materials)
InitializeMaterials()
Expand Down
15 changes: 14 additions & 1 deletion code/datums/materials/_material.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Simple datum which is instanced once per type and is used for every object of sa
///Materials "Traits". its a map of key = category | Value = Bool. Used to define what it can be used for
var/list/categories = list()
///The type of sheet this material creates. This should be replaced as soon as possible by greyscale sheets
var/sheet_type
var/obj/item/stack/sheet_type
///This is a modifier for force, and resembles the strength of the material
var/strength_modifier = 1
///This is a modifier for integrity, and resembles the strength of the material
Expand Down Expand Up @@ -129,3 +129,16 @@ Simple datum which is instanced once per type and is used for every object of sa
if(type != initial(path.material_skin))
continue
return path


/// Returns GLOB.recipes of a material to modify the recipes.
/// This will be only called once from SSMaterials.
/datum/material/proc/get_material_recipes()
if(!initial(sheet_type.material_type) || !categories[MAT_CATEGORY_BASE_RECIPES])
return
var/obj/item/stack/dummy_stack = new sheet_type(null) // we make a fake object here
if(!dummy_stack)
return
. = dummy_stack.get_recipes() // because we need to get the global list.
// NOTE: returning a GLOB.recipes from each subtype can be a way, but that should override all procs. This is simple.
qdel(dummy_stack)
5 changes: 2 additions & 3 deletions code/game/objects/items/stacks/ores/ore_type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ STACKSIZE_MACRO(/obj/item/stack/ore/iron)
refined_type = /obj/item/stack/sheet/glass
w_class = WEIGHT_CLASS_TINY

/obj/item/stack/ore/glass/get_main_recipes()
. = ..()
. += GLOB.sand_recipes
/obj/item/stack/ore/glass/get_recipes()
return GLOB.sand_recipes

/obj/item/stack/ore/glass/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum)
if(..() || !ishuman(hit_atom))
Expand Down
5 changes: 2 additions & 3 deletions code/game/objects/items/stacks/rods/rods.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
update_icon()
AddElement(/datum/element/openspace_item_click_handler)

/obj/item/stack/rods/get_main_recipes()
. = ..()
. += GLOB.rod_recipes
/obj/item/stack/rods/get_recipes()
return GLOB.rod_recipes

/obj/item/stack/rods/handle_openspace_click(turf/target, mob/user, proximity_flag, click_parameters)
if(proximity_flag)
Expand Down
18 changes: 8 additions & 10 deletions code/game/objects/items/stacks/sheets/mineral/exotics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ Exotic mineral Sheets
merge_type = /obj/item/stack/sheet/mineral/bananium
material_type = /datum/material/bananium

/obj/item/stack/sheet/mineral/bananium/get_main_recipes()
. = ..()
. += GLOB.bananium_recipes
/obj/item/stack/sheet/mineral/bananium/get_recipes()
return GLOB.bananium_recipes


/* Adamantine */
Expand All @@ -33,12 +32,12 @@ Exotic mineral Sheets
item_state = "sheet-adamantine"
singular_name = "adamantine sheet"
mats_per_unit = list(/datum/material/adamantine=MINERAL_MATERIAL_AMOUNT)
merge_type = /obj/item/stack/sheet/mineral/adamantine
grind_results = list(/datum/reagent/liquidadamantine = 10)
merge_type = /obj/item/stack/sheet/mineral/adamantine
material_type = /datum/material/adamantine

/obj/item/stack/sheet/mineral/adamantine/get_main_recipes()
. = ..()
. += GLOB.adamantine_recipes
/obj/item/stack/sheet/mineral/adamantine/get_recipes()
return GLOB.adamantine_recipes

/* Alien Alloy */

Expand All @@ -51,6 +50,5 @@ Exotic mineral Sheets
sheettype = "abductor"
merge_type = /obj/item/stack/sheet/mineral/abductor

/obj/item/stack/sheet/mineral/abductor/get_main_recipes()
. = ..()
. += GLOB.abductor_recipes
/obj/item/stack/sheet/mineral/abductor/get_recipes()
return GLOB.abductor_recipes
30 changes: 12 additions & 18 deletions code/game/objects/items/stacks/sheets/mineral/glass.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
user.visible_message("<span class='suicide'>[user] begins to slice [user.p_their()] neck with \the [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
return BRUTELOSS

/obj/item/stack/sheet/glass/get_main_recipes()
. = ..()
. += GLOB.glass_recipes
/obj/item/stack/sheet/glass/get_recipes()
return GLOB.glass_recipes

/obj/item/stack/sheet/glass/attackby(obj/item/W, mob/user, params)
add_fingerprint(user)
Expand Down Expand Up @@ -103,9 +102,8 @@
source.add_charge(amount * cost)
glasource.add_charge(amount * glacost)

/obj/item/stack/sheet/rglass/get_main_recipes()
. = ..()
. += GLOB.reinforced_glass_recipes
/obj/item/stack/sheet/rglass/get_recipes()
return GLOB.reinforced_glass_recipes

/* Plasma glass */

Expand All @@ -123,9 +121,8 @@
material_flags = NONE
tableVariant = /obj/structure/table/glass/plasma

/obj/item/stack/sheet/plasmaglass/get_main_recipes()
. = ..()
. += GLOB.pglass_recipes
/obj/item/stack/sheet/plasmaglass/get_recipes()
return GLOB.pglass_recipes

/obj/item/stack/sheet/plasmaglass/attackby(obj/item/W, mob/user, params)
add_fingerprint(user)
Expand Down Expand Up @@ -162,9 +159,8 @@
point_value = 23
matter_amount = 8

/obj/item/stack/sheet/plasmarglass/get_main_recipes()
. = ..()
. += GLOB.prglass_recipes
/obj/item/stack/sheet/plasmarglass/get_recipes()
return GLOB.prglass_recipes

/* Titanium glass */

Expand All @@ -179,9 +175,8 @@
resistance_flags = ACID_PROOF
merge_type = /obj/item/stack/sheet/titaniumglass

/obj/item/stack/sheet/titaniumglass/get_main_recipes()
. = ..()
. += GLOB.titaniumglass_recipes
/obj/item/stack/sheet/titaniumglass/get_recipes()
return GLOB.titaniumglass_recipes

/* Plastitanium glass */

Expand All @@ -197,9 +192,8 @@
material_flags = NONE
merge_type = /obj/item/stack/sheet/plastitaniumglass

/obj/item/stack/sheet/plastitaniumglass/get_main_recipes()
. = ..()
. += GLOB.plastitaniumglass_recipes
/obj/item/stack/sheet/plastitaniumglass/get_recipes()
return GLOB.plastitaniumglass_recipes

/*SHARDS FROM HERE ONWARD, NOT A STACK, MOVE IT AS THE PROPHECY FORETOLD*/
/obj/item/shard
Expand Down
46 changes: 19 additions & 27 deletions code/game/objects/items/stacks/sheets/mineral/materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ Mineral Sheets
sheettype = "sandstone"
merge_type = /obj/item/stack/sheet/mineral/sandstone

/obj/item/stack/sheet/mineral/sandstone/get_main_recipes()
. = ..()
. += GLOB.sandstone_recipes
/obj/item/stack/sheet/mineral/sandstone/get_recipes()
return GLOB.sandstone_recipes

/* Diamond */

Expand All @@ -47,9 +46,8 @@ Mineral Sheets
merge_type = /obj/item/stack/sheet/mineral/diamond
material_type = /datum/material/diamond

/obj/item/stack/sheet/mineral/diamond/get_main_recipes()
. = ..()
. += GLOB.diamond_recipes
/obj/item/stack/sheet/mineral/diamond/get_recipes()
return GLOB.diamond_recipes

/* Uranium */

Expand All @@ -65,9 +63,8 @@ Mineral Sheets
merge_type = /obj/item/stack/sheet/mineral/uranium
material_type = /datum/material/uranium

/obj/item/stack/sheet/mineral/uranium/get_main_recipes()
. = ..()
. += GLOB.uranium_recipes
/obj/item/stack/sheet/mineral/uranium/get_recipes()
return GLOB.uranium_recipes

/* Plasma */

Expand All @@ -89,9 +86,8 @@ Mineral Sheets
user.visible_message("<span class='suicide'>[user] begins licking \the [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
return TOXLOSS//dont you kids know that stuff is toxic?

/obj/item/stack/sheet/mineral/plasma/get_main_recipes()
. = ..()
. += GLOB.plasma_recipes
/obj/item/stack/sheet/mineral/plasma/get_recipes()
return GLOB.plasma_recipes

/obj/item/stack/sheet/mineral/plasma/attackby(obj/item/W as obj, mob/user as mob, params)
if(W.is_hot() > 300)//If the temperature of the object is over 300, then ignite
Expand Down Expand Up @@ -122,9 +118,8 @@ Mineral Sheets
merge_type = /obj/item/stack/sheet/mineral/gold
material_type = /datum/material/gold

/obj/item/stack/sheet/mineral/gold/get_main_recipes()
. = ..()
. += GLOB.gold_recipes
/obj/item/stack/sheet/mineral/gold/get_recipes()
return GLOB.gold_recipes

/* Silver */

Expand All @@ -141,9 +136,8 @@ Mineral Sheets
material_type = /datum/material/silver
tableVariant = /obj/structure/table/optable

/obj/item/stack/sheet/mineral/silver/get_main_recipes()
. = ..()
. += GLOB.silver_recipes
/obj/item/stack/sheet/mineral/silver/get_recipes()
return GLOB.silver_recipes

/* Copper */

Expand All @@ -157,11 +151,11 @@ Mineral Sheets
grind_results = list(/datum/reagent/copper = 20)
point_value = 3
merge_type = /obj/item/stack/sheet/mineral/copper
material_type = /datum/material/copper


/obj/item/stack/sheet/mineral/copper/get_main_recipes()
. = ..()
. += GLOB.copper_recipes
/obj/item/stack/sheet/mineral/copper/get_recipes()
return GLOB.copper_recipes

/* Titanium */

Expand All @@ -181,9 +175,8 @@ Mineral Sheets
merge_type = /obj/item/stack/sheet/mineral/titanium
material_type = /datum/material/titanium

/obj/item/stack/sheet/mineral/titanium/get_main_recipes()
. = ..()
. += GLOB.titanium_recipes
/obj/item/stack/sheet/mineral/titanium/get_recipes()
return GLOB.titanium_recipes

/* Plastitanium */

Expand All @@ -203,9 +196,8 @@ Mineral Sheets
merge_type = /obj/item/stack/sheet/mineral/plastitanium
material_flags = NONE

/obj/item/stack/sheet/mineral/plastitanium/get_main_recipes()
. = ..()
. += GLOB.plastitanium_recipes
/obj/item/stack/sheet/mineral/plastitanium/get_recipes()
return GLOB.plastitanium_recipes

/* Coal */

Expand Down
25 changes: 10 additions & 15 deletions code/game/objects/items/stacks/sheets/mineral/metals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ Metals Sheets
new /obj/item/stack/sheet/runed_metal(loc, amount)
qdel(src)

/obj/item/stack/sheet/iron/get_main_recipes()
. = ..()
. += GLOB.metal_recipes
/obj/item/stack/sheet/iron/get_recipes()
return GLOB.metal_recipes

/obj/item/stack/sheet/iron/suicide_act(mob/living/carbon/user)
user.visible_message("<span class='suicide'>[user] begins whacking [user.p_them()]self over the head with \the [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
Expand All @@ -69,9 +68,8 @@ Metals Sheets
matter_amount = 12
material_flags = NONE

/obj/item/stack/sheet/plasteel/get_main_recipes()
. = ..()
. += GLOB.plasteel_recipes
/obj/item/stack/sheet/plasteel/get_recipes()
return GLOB.plasteel_recipes

/* Runed Metal */

Expand Down Expand Up @@ -101,9 +99,8 @@ Metals Sheets
return FALSE
return ..()

/obj/item/stack/sheet/runed_metal/get_main_recipes()
. = ..()
. += GLOB.runed_metal_recipes
/obj/item/stack/sheet/runed_metal/get_recipes()
return GLOB.runed_metal_recipes

/* Brass - the cult one */

Expand Down Expand Up @@ -132,9 +129,8 @@ Metals Sheets
else
return ..()

/obj/item/stack/sheet/brass/get_main_recipes()
. = ..()
. += GLOB.brass_recipes
/obj/item/stack/sheet/brass/get_recipes()
return GLOB.brass_recipes

/obj/item/stack/sheet/brass/Initialize(mapload, new_amount, merge = TRUE)
. = ..()
Expand Down Expand Up @@ -165,9 +161,8 @@ Metals Sheets
else
return ..()

/obj/item/stack/sheet/bronze/get_main_recipes()
. = ..()
. += GLOB.bronze_recipes
/obj/item/stack/sheet/bronze/get_recipes()
return GLOB.bronze_recipes

/obj/item/stack/sheet/bronze/Initialize(mapload, new_amount, merge = TRUE)
. = ..()
Expand Down
Loading
Loading