From e3609bac9418d303b3d3b93e24816e94b57d44ef Mon Sep 17 00:00:00 2001 From: mwerezak Date: Sat, 1 Aug 2015 21:03:33 -0400 Subject: [PATCH] Adds common proc to obtain the material of an object Adds a common get_material() proc to objects, and implements overrides where applicable --- code/game/machinery/deployable.dm | 3 +++ code/game/objects/items/weapons/material/material_weapons.dm | 3 +++ code/game/objects/structures/simple_doors.dm | 3 +++ code/game/objects/structures/stool_bed_chair_nest/bed.dm | 3 +++ code/game/turfs/simulated/walls.dm | 5 ++--- code/modules/materials/material_sheets.dm | 3 +++ code/modules/materials/materials.dm | 5 +++++ 7 files changed, 22 insertions(+), 3 deletions(-) diff --git a/code/game/machinery/deployable.dm b/code/game/machinery/deployable.dm index 4f19ab0118b..d2ea405d3fb 100644 --- a/code/game/machinery/deployable.dm +++ b/code/game/machinery/deployable.dm @@ -79,6 +79,9 @@ for reference: maxhealth = material.integrity health = maxhealth +/obj/structure/barricade/get_material() + return material + /obj/structure/barricade/attackby(obj/item/W as obj, mob/user as mob) if (istype(W, /obj/item/stack/material)) var/obj/item/stack/material/D = W diff --git a/code/game/objects/items/weapons/material/material_weapons.dm b/code/game/objects/items/weapons/material/material_weapons.dm index c396f8d4b9b..18181df6b07 100644 --- a/code/game/objects/items/weapons/material/material_weapons.dm +++ b/code/game/objects/items/weapons/material/material_weapons.dm @@ -34,6 +34,9 @@ if(!isnull(matter[material_type])) matter[material_type] *= force_divisor // May require a new var instead. +/obj/item/weapon/material/get_material() + return material + /obj/item/weapon/material/proc/update_force() if(edge || sharp) force = material.get_edge_damage() diff --git a/code/game/objects/structures/simple_doors.dm b/code/game/objects/structures/simple_doors.dm index b3230095c13..10fa149e8b4 100644 --- a/code/game/objects/structures/simple_doors.dm +++ b/code/game/objects/structures/simple_doors.dm @@ -44,6 +44,9 @@ update_nearby_tiles() ..() +/obj/structure/simple_door/get_material() + return material + /obj/structure/simple_door/Bumped(atom/user) ..() if(!state) diff --git a/code/game/objects/structures/stool_bed_chair_nest/bed.dm b/code/game/objects/structures/stool_bed_chair_nest/bed.dm index 1030afd0199..3067b70d361 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/bed.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/bed.dm @@ -33,6 +33,9 @@ padding_material = get_material_by_name(new_padding_material) update_icon() +/obj/structure/bed/get_material() + return material + // Reuse the cache/code from stools, todo maybe unify. /obj/structure/bed/update_icon() // Prep icon. diff --git a/code/game/turfs/simulated/walls.dm b/code/game/turfs/simulated/walls.dm index 662c245da6e..cdcab2eb39f 100644 --- a/code/game/turfs/simulated/walls.dm +++ b/code/game/turfs/simulated/walls.dm @@ -28,7 +28,7 @@ var/list/global/wall_cache = list() materialtype = DEFAULT_WALL_MATERIAL material = get_material_by_name(materialtype) if(!isnull(rmaterialtype)) - reinf_material = name_to_material[rmaterialtype] + reinf_material = get_material_by_name(rmaterialtype) update_material() processing_turfs |= src @@ -38,7 +38,6 @@ var/list/global/wall_cache = list() dismantle_wall(null,null,1) ..() - /turf/simulated/wall/process() // Calling parent will kill processing if(!radiate()) @@ -170,7 +169,7 @@ var/list/global/wall_cache = list() O.loc = src clear_plants() - material = name_to_material["placeholder"] + material = get_material_by_name("placeholder") reinf_material = null check_relatives() diff --git a/code/modules/materials/material_sheets.dm b/code/modules/materials/material_sheets.dm index fb4a0723f99..af818be50b5 100644 --- a/code/modules/materials/material_sheets.dm +++ b/code/modules/materials/material_sheets.dm @@ -39,6 +39,9 @@ update_strings() return 1 +/obj/item/stack/material/get_material() + return material + /obj/item/stack/material/proc/update_strings() // Update from material datum. if(amount>1) diff --git a/code/modules/materials/materials.dm b/code/modules/materials/materials.dm index f47a2a1394f..b382564e34c 100644 --- a/code/modules/materials/materials.dm +++ b/code/modules/materials/materials.dm @@ -27,6 +27,11 @@ // Assoc list containing all material datums indexed by name. var/list/name_to_material +//Returns the material the object is made of, if applicable. +//Will we ever need to return more than one value here? +/obj/proc/get_material() + return null + // Builds the datum list above. /proc/populate_material_list(force_remake=0) if(name_to_material && !force_remake) return // Already set up!