Materials Repath (#22388)

Soft-ish port of https://github.com/NebulaSS13/Nebula/pull/540. Except
we call them singletons.

Repaths all materials as singletons instead of datums, and replaces
material defines from strings to paths so that we can just run
GET_SINGLETON instead of needing to use SSMaterials. This is Step One.

This PR has no player-facing changes.

changes:
  - refactor: "Repaths /material to /singleton/material."
- refactor: "Replaces all material string defines to path defines,
replacing SSmaterials procs w/ GET_SINGLETON instead."
- refactor: "Removes all material var edited objects from all maps,
adding new presets where necessary."
- refactor: "Updates recipes unit test to run all recipes against all
material singletons."

---------

Signed-off-by: Batrachophreno <Batrochophreno@gmail.com>
Co-authored-by: kano-dot <bhutanlikanoxy@gmail.com>
This commit is contained in:
Batrachophreno
2026-07-10 18:45:58 +00:00
committed by GitHub
co-authored by kano-dot
parent 2e61d8fd15
commit eebb8b971c
83 changed files with 696 additions and 782 deletions
+13 -13
View File
@@ -117,19 +117,19 @@ Class Procs:
var/power_init_complete = FALSE
/// What power channel does this fall under in APCs? Possible channels include: AREA_USAGE_EQUIP, AREA_USAGE_ENVIRON or AREA_USAGE_LIGHT
var/power_channel = AREA_USAGE_EQUIP
/* List of types that should be spawned as component_parts for this machine.
Structure:
type -> num_objects
num_objects is optional, and will be treated as 1 if omitted.
example:
component_types = list(
/obj/foo/bar,
/obj/baz = 2
)
*/
/**
* List of types that should be spawned as component_parts for this machine.
* Structure:
* type -> num_objects
*
* num_objects is optional, and will be treated as 1 if omitted.
*
* example:
* component_types = list(
* /obj/foo/bar,
* /obj/baz = 2
* )
**/
var/list/component_types
/// List of all the parts used to build it, if made from certain kinds of frames.
var/list/component_parts = null
+2 -2
View File
@@ -102,7 +102,7 @@ GLOBAL_LIST_EMPTY(total_active_bonfires)
return
else if(istype(attacking_item, /obj/item/material))
var/obj/item/material/M = attacking_item
if(M.material.name in burnable_materials)
if(M.material.type in burnable_materials)
var/fuel_add = burnable_materials[M.material] * (M.w_class / 5) //if you crafted a small item, it's not worth as much fuel
fuel = min(fuel + fuel_add, max_fuel)
user.visible_message(SPAN_NOTICE("\The [user] tosses \the [M] into \the [src]."))
@@ -359,7 +359,7 @@ GLOBAL_LIST_EMPTY(total_active_bonfires)
fuel = 0 //don't start with fuel
if(!material_name)
material_name = MATERIAL_MARBLE
material = SSmaterials.get_material_by_name(material_name)
material = GET_SINGLETON(material_name)
if(!material)
qdel(src)
return
+1 -1
View File
@@ -6,7 +6,7 @@ ABSTRACT_TYPE(/obj/structure/cart)
density = TRUE
climbable = TRUE
build_amt = 15
material = DEFAULT_WALL_MATERIAL
material = MATERIAL_STEEL
slowdown = 0
atom_flags = CRITICAL_ATOM
var/movesound = 'sound/effects/roll.ogg'
+1 -1
View File
@@ -12,7 +12,7 @@
/obj/structure/curtain/Initialize()
. = ..()
material = SSmaterials.get_material_by_name(curtain_material)
material = GET_SINGLETON(curtain_material)
AddComponent(/datum/component/turf_hand)
/obj/structure/curtain/open
@@ -7,7 +7,7 @@
anchored = TRUE
opacity = TRUE
climbable = TRUE
material = DEFAULT_WALL_MATERIAL
material = MATERIAL_STEEL
/obj/structure/fluff/evidenceshelf/attackby(obj/item/attacking_item, mob/user)
+3 -3
View File
@@ -12,7 +12,7 @@
/// How much cover the girder provides against projectiles.
var/cover = 50
build_amt = 2
var/material/reinf_material
var/singleton/material/reinf_material
var/reinforcing = 0
var/plating = FALSE
@@ -232,7 +232,7 @@
to_chat(user, SPAN_NOTICE("There isn't enough material here to construct a wall."))
return 0
var/material/material = SSmaterials.get_material_by_name(mat_stack.default_type)
var/singleton/material/material = GET_SINGLETON(mat_stack.default_type)
if(!istype(material))
return 0
@@ -282,7 +282,7 @@
to_chat(user, SPAN_NOTICE("There isn't enough material here to reinforce the girder."))
return 0
var/material/material = SSmaterials.get_material_by_name(mat_stack.default_type)
var/singleton/material/material = GET_SINGLETON(mat_stack.default_type)
if(!istype(material) || material.integrity < 50)
to_chat(user, "You cannot reinforce \the [src] with that; it is too soft.")
return 0
@@ -31,7 +31,7 @@ Deployable Kits
/obj/structure/blocker/proc/set_material(var/material_name)
if(force_material)
material_name = force_material
material = SSmaterials.get_material_by_name(material_name)
material = GET_SINGLETON(material_name)
if(!material)
qdel(src)
return
@@ -54,8 +54,6 @@
var/obj/structure/machinery/door/airlock/close_other
/// The ID of the connected door to close.
var/close_other_id
/// String (One of `MATERIAL_*`). The material the door is made from. If not set, defaults to steel.
var/mineral
/// Boolean. Whether or not the door's safeties are enabled. Tied to the safety wire.
var/safe = TRUE
/// Airlock electronics.
@@ -127,7 +125,7 @@
/// String (One of `MATERIAL_*`). The material used for the door's window if `glass` is set. Used to set `window_material` during init.
var/init_material_window = MATERIAL_GLASS
/// The material of the door's window.
var/material/window_material
var/singleton/material/window_material
hashatch = TRUE
@@ -243,7 +241,7 @@
if (glass)
paintable |= AIRLOCK_PAINTABLE_WINDOW
window_material = SSmaterials.get_material_by_name(init_material_window)
window_material = GET_SINGLETON(init_material_window)
opacity = FALSE
update_icon()
@@ -284,9 +282,9 @@
..()
/obj/structure/machinery/door/airlock/get_material()
if(mineral)
return SSmaterials.get_material_by_name(mineral)
return SSmaterials.get_material_by_name(DEFAULT_WALL_MATERIAL)
if(material)
return GET_SINGLETON(material)
return GET_SINGLETON(MATERIAL_STEEL)
/obj/structure/machinery/door/airlock/external//External airlocks start here
name = "external airlock"
@@ -718,23 +716,23 @@
/obj/structure/machinery/door/airlock/gold
name = "Gold Airlock"
door_color = COLOR_GOLD
mineral = "gold"
material = MATERIAL_GOLD
/obj/structure/machinery/door/airlock/silver
name = "Silver Airlock"
door_color = COLOR_SILVER
mineral = "silver"
material = MATERIAL_SILVER
/obj/structure/machinery/door/airlock/diamond
name = "Diamond Airlock"
door_color = COLOR_DIAMOND
mineral = "diamond"
material = MATERIAL_DIAMOND
maxhealth = OBJECT_HEALTH_EXTREMELY_HIGH
/obj/structure/machinery/door/airlock/sandstone
name = "Sandstone Airlock"
door_color = COLOR_BEIGE
mineral = "sandstone"
material = MATERIAL_SANDSTONE
/obj/structure/machinery/door/airlock/palepurple
door_color = COLOR_PURPLE
@@ -784,6 +782,7 @@
MELEE = ARMOR_MELEE_MINOR,
BULLET = ARMOR_BALLISTIC_MINOR
)
material = MATERIAL_DIONA
/// Placeholder object until it gets new sprites.
/obj/structure/machinery/door/airlock/diona/external
@@ -794,7 +793,7 @@
name = "Uranium Airlock"
desc = "And they said I was crazy."
door_color = COLOR_GREEN
mineral = "uranium"
material = MATERIAL_URANIUM
var/last_event = 0
/obj/structure/machinery/door/airlock/uranium/process()
@@ -809,7 +808,7 @@
name = "Phoron Airlock"
desc = "No way this can end badly."
door_color = COLOR_VIOLET
mineral = MATERIAL_PHORON
material = MATERIAL_PHORON
/obj/structure/machinery/door/airlock/phoron/fire_act(exposed_temperature, exposed_volume)
. = ..()
@@ -1719,8 +1718,8 @@ About the new airlock wires panel:
da.set_dir(src.dir)
da.anchored = 1
if(mineral)
da.glass = mineral
if(material)
da.glass = material
else if(glass && !da.glass)
da.glass = 1
da.state = 1
@@ -204,7 +204,7 @@
..()
/obj/structure/machinery/door/firedoor/get_material()
return SSmaterials.get_material_by_name(DEFAULT_WALL_MATERIAL)
return GET_SINGLETON(DEFAULT_WALL_MATERIAL)
/obj/structure/machinery/door/firedoor/CollidedWith(atom/bumped_atom)
if(p_open || operating)
@@ -231,7 +231,7 @@
var/obj/item/stack/material/M = attacking_item
if(!M.material)
return ..()
if(!(M.material.name in list(MATERIAL_STEEL, MATERIAL_GLASS, MATERIAL_GOLD, MATERIAL_SILVER, MATERIAL_DIAMOND, MATERIAL_PHORON, MATERIAL_URANIUM, MATERIAL_PLASTEEL, MATERIAL_ALUMINIUM, MATERIAL_LEAD)))
if(!(M.material.type in list(MATERIAL_STEEL, MATERIAL_GLASS, MATERIAL_GOLD, MATERIAL_SILVER, MATERIAL_DIAMOND, MATERIAL_PHORON, MATERIAL_URANIUM, MATERIAL_PLASTEEL, MATERIAL_ALUMINIUM, MATERIAL_LEAD)))
to_chat(user, SPAN_WARNING("\The [src] cannot hold [M.material.name]."))
return TRUE
@@ -465,7 +465,7 @@
if(!amount)
return
material = lowertext(material)
var/material/mattype = SSmaterials.get_material_by_name(material)
var/singleton/material/mattype = GET_SINGLETON(material)
var/stack_type = mattype.stack_type
var/real_amount = round(amount / SHEET_MATERIAL_AMOUNT)
+1 -1
View File
@@ -23,7 +23,7 @@
/obj/structure/plasticflaps/Initialize()
. = ..()
material = SSmaterials.get_material_by_name(MATERIAL_PLASTIC)
material = GET_SINGLETON(MATERIAL_PLASTIC)
update_icon()
/obj/structure/plasticflaps/update_icon()
+2 -2
View File
@@ -66,7 +66,7 @@
/obj/structure/railing/mapped/no_density/low
icon_state = "railing0-0"
/obj/structure/railing/New(var/newloc, var/material_key = DEFAULT_WALL_MATERIAL)
/obj/structure/railing/New(var/newloc, var/material_key = MATERIAL_STEEL)
material = material_key // Converted to datum in initialize().
..(newloc)
@@ -81,7 +81,7 @@
if(!non_material_object)
if(!isnull(material) && !istype(material))
material = SSmaterials.get_material_by_name(material)
material = GET_SINGLETON(material)
if(!istype(material))
return INITIALIZE_HINT_QDEL
+4 -4
View File
@@ -30,11 +30,11 @@
health -= material.combustion_effect(get_turf(src),temperature, 0.3)
CheckHealth()
/obj/structure/simple_door/New(var/newloc, var/material_name, var/locked)
/obj/structure/simple_door/New(var/newloc, var/newmaterial, var/locked)
..()
if(!material_name)
material_name = DEFAULT_WALL_MATERIAL
material = SSmaterials.get_material_by_name(material_name)
if(!newmaterial)
newmaterial = MATERIAL_STEEL
material = GET_SINGLETON(newmaterial)
if(!material)
qdel(src)
return
@@ -25,23 +25,27 @@
buckle_lying = 1
build_amt = 2
pass_flags_self = PASSTABLE
var/material/padding_material
var/singleton/material/padding_material
var/base_icon = "bed"
var/buckling_sound = 'sound/effects/buckle.ogg'
var/painted_colour // Used for paint gun and preset colours. I know this name sucks.
/// Used for paint gun and preset colours. I know this name sucks.
var/painted_colour
var/can_dismantle = TRUE
var/can_pad = TRUE
var/makes_rolling_sound = FALSE
var/held_item = null // Set to null if you don't want people to pick this up.
/// Set to null if you don't want people to pick this up.
var/held_item = null
slowdown = 2.5
var/driving = FALSE // Shit for wheelchairs. Doesn't really get used here, but it's for code cleanliness.
/// Shit for wheelchairs. Doesn't really get used here, but it's for code cleanliness.
var/driving = FALSE
var/mob/living/pulling = null
var/propelled = 0 // Check for fire-extinguisher-driven chairs
/// Check for fire-extinguisher-driven chairs
var/propelled = 0
/obj/structure/bed/mechanics_hints()
. = list()
@@ -76,12 +80,12 @@
/obj/structure/bed/New(newloc, new_material = MATERIAL_STEEL, new_padding_material, new_painted_colour)
..(newloc)
material = SSmaterials.get_material_by_name(new_material)
material = GET_SINGLETON(new_material)
if(!istype(material))
qdel(src)
return
if(new_padding_material)
padding_material = SSmaterials.get_material_by_name(new_padding_material)
padding_material = GET_SINGLETON(new_padding_material)
if(new_painted_colour)
painted_colour = new_painted_colour
update_icon()
@@ -104,7 +108,7 @@
generate_overlay_cache(padding_material, CACHE_TYPE_PADDING, apply_painted_colour = TRUE)
/obj/structure/bed/proc/generate_overlay_cache(var/new_material, var/cache_type, var/cache_layer = layer, var/apply_painted_colour = FALSE) // Cache type refers to what cache we're making. Material type refers if we're taking from the padding or the chair material itself.
var/material/overlay_material = new_material
var/singleton/material/overlay_material = new_material
var/list/furniture_cache = SSicon_cache.furniture_cache
var/cache_key = "[base_icon]-[overlay_material.name]" // Basically, generates a cache key for an overlay.
if(cache_type)
@@ -180,7 +184,7 @@
else if(istype(attacking_item,/obj/item/stack/material))
var/obj/item/stack/material/M = attacking_item
if(M.material && (M.material.flags & MATERIAL_PADDING))
padding_type = "[M.material.name]"
padding_type = M.material.type
if(!padding_type)
to_chat(user, "You cannot pad \the [src] with that.")
return
@@ -249,8 +253,8 @@
generate_strings(TRUE)
update_icon()
/obj/structure/bed/proc/add_padding(padding_type)
padding_material = SSmaterials.get_material_by_name(padding_type)
/obj/structure/bed/proc/add_padding(var/padding_type)
padding_material = GET_SINGLETON(padding_type)
generate_strings(TRUE)
update_icon()
@@ -21,7 +21,7 @@
if(!held_item || use_check_and_message(user) || buckled || (anchored && padding_material)) // Make sure held_item = null if you don't want it to get picked up.
return
user.visible_message(SPAN_NOTICE("[user] [withdraw_verb]s \the [src.name]."), SPAN_NOTICE("You [withdraw_verb] \the [src.name]."))
var/obj/item/material/stool/S = new held_item(src.loc, material.name, padding_material?.name, painted_colour) // Handles all the material code so you don't have to.
var/obj/item/material/stool/S = new held_item(src.loc, material.type, padding_material?.type, painted_colour) // Handles all the material code so you don't have to.
if(material_alteration & MATERIAL_ALTERATION_COLOR) // For snowflakes like wood chairs.
S.color = material.icon_colour
if(material_alteration & MATERIAL_ALTERATION_NAME)
@@ -182,7 +182,7 @@
force_divisor = 0.4
w_class = WEIGHT_CLASS_HUGE
contained_sprite = TRUE
var/material/padding_material
var/singleton/material/padding_material
var/obj/structure/bed/stool/origin_type = /obj/structure/bed/stool
var/deploy_verb = "right"
var/painted_colour
@@ -194,7 +194,7 @@
/obj/item/material/stool/New(var/newloc, var/new_material, var/new_padding_material, var/new_painted_colour)
..(newloc, new_material) // new_material handled in material_weapons.dm
if(new_padding_material)
padding_material = SSmaterials.get_material_by_name(new_padding_material)
padding_material = GET_SINGLETON(new_padding_material)
if(new_painted_colour)
painted_colour = new_painted_colour
update_icon()
@@ -242,7 +242,7 @@
user.visible_message(SPAN_NOTICE("[user] [deploy_verb]s \the [src.name]."), SPAN_NOTICE("You [deploy_verb] \the [name]."))
// playsound(src, deploy_sound ? deploy_sound : drop_sound, DROP_SOUND_VOLUME)
user.drop_from_inventory(src)
var/obj/structure/bed/stool/S = new origin_type(get_turf(loc), material?.name, padding_material?.name, painted_colour) // Fuck me.
var/obj/structure/bed/stool/S = new origin_type(get_turf(loc), material?.type, padding_material?.type, painted_colour) // Fuck me.
S.dir = user.dir // Plant it where the user's facing
if(blood_DNA)
S.blood_DNA |= blood_DNA // Transfer blood.
+1 -1
View File
@@ -11,7 +11,7 @@
/obj/structure/target_stake/Initialize(mapload)
. = ..()
material = SSmaterials.get_material_by_name(MATERIAL_STEEL)
material = GET_SINGLETON(MATERIAL_STEEL)
/obj/structure/target_stake/attackby(obj/item/attacking_item, mob/user)
if(istype(attacking_item, /obj/item/target))