Merge pull request #10404 from mwerezak/stack-fix

Material stack related fixes
This commit is contained in:
PsiOmegaDelta
2015-08-08 09:56:25 +02:00
44 changed files with 217 additions and 185 deletions

View File

@@ -136,8 +136,8 @@
// Make it a wood-reinforced wooden table. // Make it a wood-reinforced wooden table.
// There are cult materials available, but it'd make the table non-deconstructable with how holotables work. // There are cult materials available, but it'd make the table non-deconstructable with how holotables work.
// Could possibly use a new material var for holographic-ness? // Could possibly use a new material var for holographic-ness?
material = name_to_material["wood"] material = get_material_by_name("wood")
reinforced = name_to_material["wood"] reinforced = get_material_by_name("wood")
update_desc() update_desc()
update_connections(1) update_connections(1)
update_icon() update_icon()

View File

@@ -290,7 +290,7 @@
/obj/machinery/autolathe/dismantle() /obj/machinery/autolathe/dismantle()
for(var/mat in stored_material) for(var/mat in stored_material)
var/material/M = name_to_material[mat] var/material/M = get_material_by_name(mat)
if(!istype(M)) if(!istype(M))
continue continue
var/obj/item/stack/material/S = new M.stack_type(get_turf(src)) var/obj/item/stack/material/S = new M.stack_type(get_turf(src))

View File

@@ -66,19 +66,19 @@
user << "<span class='info'>You inject the blood sample into the bioprinter.</span>" user << "<span class='info'>You inject the blood sample into the bioprinter.</span>"
return return
// Meat for biomass. // Meat for biomass.
else if(!prints_prosthetics && istype(W, /obj/item/weapon/reagent_containers/food/snacks/meat)) if(!prints_prosthetics && istype(W, /obj/item/weapon/reagent_containers/food/snacks/meat))
stored_matter += 50 stored_matter += 50
user.drop_item() user.drop_item()
user << "<span class='info'>\The [src] processes \the [W]. Levels of stored biomass now: [stored_matter]</span>" user << "<span class='info'>\The [src] processes \the [W]. Levels of stored biomass now: [stored_matter]</span>"
qdel(W) qdel(W)
return return
// Steel for matter. // Steel for matter.
else if(prints_prosthetics && istype(W, /obj/item/stack/material/steel)) if(prints_prosthetics && istype(W, /obj/item/stack/material) && W.get_material_name() == DEFAULT_WALL_MATERIAL)
var/obj/item/stack/material/steel/M = W var/obj/item/stack/S = W
stored_matter += M.amount * 10 stored_matter += S.amount * 10
user.drop_item() user.drop_item()
user << "<span class='info'>\The [src] processes \the [W]. Levels of stored matter now: [stored_matter]</span>" user << "<span class='info'>\The [src] processes \the [W]. Levels of stored matter now: [stored_matter]</span>"
qdel(W) qdel(W)
return return
else
return..() return..()

View File

@@ -88,8 +88,8 @@
var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( loc ) var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( loc )
A.amount = 5 A.amount = 5
if(istype(P, /obj/item/stack/material/glass/reinforced)) if(istype(P, /obj/item/stack/material) && P.get_material_name() == "rglass")
var/obj/item/stack/material/glass/reinforced/RG = P var/obj/item/stack/RG = P
if (RG.get_amount() < 2) if (RG.get_amount() < 2)
user << "<span class='warning'>You need two sheets of glass to put in the glass panel.</span>" user << "<span class='warning'>You need two sheets of glass to put in the glass panel.</span>"
return return

View File

@@ -87,8 +87,8 @@
var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( src.loc ) var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( src.loc )
A.amount = 5 A.amount = 5
if(istype(P, /obj/item/stack/material/glass)) if(istype(P, /obj/item/stack/material) && P.get_material_name() == "glass")
var/obj/item/stack/material/glass/G = P var/obj/item/stack/G = P
if (G.get_amount() < 2) if (G.get_amount() < 2)
user << "<span class='warning'>You need two sheets of glass to put in the glass panel.</span>" user << "<span class='warning'>You need two sheets of glass to put in the glass panel.</span>"
return return

View File

@@ -178,13 +178,14 @@
if(istype(P, /obj/item/weapon/crowbar)) // complicated check if(istype(P, /obj/item/weapon/crowbar)) // complicated check
remove_peripheral() remove_peripheral()
if(istype(P, /obj/item/stack/material/glass)) if(istype(P, /obj/item/stack/material) && P.get_material_name() == "glass")
if(P:amount >= 2) var/obj/item/stack/S = P
if(S.amount >= 2)
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
if(do_after(user, 20)) if(do_after(user, 20))
if(P) if(S)
P:use(2) S.use(2)
user << "\blue You put in the glass panel." user << "<span class='notice'>You put in the glass panel.</span>"
src.state = 4 src.state = 4
src.icon_state = "4" src.icon_state = "4"
if(4) if(4)

View File

@@ -79,12 +79,14 @@ for reference:
maxhealth = material.integrity maxhealth = material.integrity
health = maxhealth health = maxhealth
/obj/structure/barricade/get_material()
return material
/obj/structure/barricade/attackby(obj/item/W as obj, mob/user as mob) /obj/structure/barricade/attackby(obj/item/W as obj, mob/user as mob)
if (istype(W, /obj/item/stack/material)) if (istype(W, /obj/item/stack))
var/obj/item/stack/material/D = W var/obj/item/stack/D = W
if(D.material.name != material.name) if(D.get_material_name() != material.name)
user << "<span class='warning'>That is the wrong material needed to repair \the [src].</span>" return //hitting things with the wrong type of stack usually doesn't produce messages, and probably doesn't need to.
return
if (health < maxhealth) if (health < maxhealth)
if (D.get_amount() < 1) if (D.get_amount() < 1)
user << "<span class='warning'>You need one sheet of [material.display_name] to repair \the [src].</span>" user << "<span class='warning'>You need one sheet of [material.display_name] to repair \the [src].</span>"

View File

@@ -48,6 +48,11 @@
return return
..() ..()
/obj/machinery/door/airlock/get_material()
if(mineral)
return get_material_by_name(mineral)
return get_material_by_name(DEFAULT_WALL_MATERIAL)
/obj/machinery/door/airlock/command /obj/machinery/door/airlock/command
name = "Airlock" name = "Airlock"
icon = 'icons/obj/doors/Doorcom.dmi' icon = 'icons/obj/doors/Doorcom.dmi'

View File

@@ -96,12 +96,12 @@
else else
usr << "<span class='notice'>[src]'s motors resist your effort.</span>" usr << "<span class='notice'>[src]'s motors resist your effort.</span>"
return return
if(istype(C, /obj/item/stack/material/plasteel)) if(istype(C, /obj/item/stack/material) && C.get_material_name() == "plasteel")
var/amt = repair_price() var/amt = Ceiling((maxhealth - health)/150)
if(!amt) if(!amt)
usr << "<span class='notice'>\The [src] is already fully repaired.</span>" usr << "<span class='notice'>\The [src] is already fully repaired.</span>"
return return
var/obj/item/stack/material/plasteel/P = C var/obj/item/stack/P = C
if(P.amount < amt) if(P.amount < amt)
usr << "<span class='warning'>You don't have enough sheets to repair this! You need at least [amt] sheets.</span>" usr << "<span class='warning'>You don't have enough sheets to repair this! You need at least [amt] sheets.</span>"
return return
@@ -135,16 +135,6 @@
return return
force_close() force_close()
// Proc: repair_price()
// Parameters: None
// Description: Determines amount of sheets needed for full repair. (max)150HP per sheet, (max)10 emitter hits per sheet.
/obj/machinery/door/blast/proc/repair_price()
var/sheets_needed = 0
var/dam = maxhealth - health
while(dam > 0)
dam -= 150
sheets_needed++
return sheets_needed
// Proc: repair() // Proc: repair()
// Parameters: None // Parameters: None
@@ -154,7 +144,7 @@
if(stat & BROKEN) if(stat & BROKEN)
stat &= ~BROKEN stat &= ~BROKEN
/obj/machinery/door/blast/CanPass(atom/movable/mover, turf/target, height=0, air_group=0) /obj/machinery/door/blast/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if(air_group) return 1 if(air_group) return 1
return ..() return ..()

View File

@@ -203,10 +203,9 @@
/obj/machinery/door/attackby(obj/item/I as obj, mob/user as mob) /obj/machinery/door/attackby(obj/item/I as obj, mob/user as mob)
if(istype(I, /obj/item/device/detective_scanner)) if(istype(I, /obj/item/device/detective_scanner))
return return
if(src.operating > 0 || isrobot(user)) return //borgs can't attack doors open because it conflicts with their AI-like interaction with them.
src.add_fingerprint(user) src.add_fingerprint(user)
if(istype(I, /obj/item/stack/material/steel)) if(istype(I, /obj/item/stack/material) && I.get_material_name() == src.get_material_name())
if(stat & BROKEN) if(stat & BROKEN)
user << "<span class='notice'>It looks like \the [src] is pretty busted. It's going to need more than just patching up now.</span>" user << "<span class='notice'>It looks like \the [src] is pretty busted. It's going to need more than just patching up now.</span>"
return return
@@ -221,20 +220,20 @@
var/amount_needed = (maxhealth - health) / DOOR_REPAIR_AMOUNT var/amount_needed = (maxhealth - health) / DOOR_REPAIR_AMOUNT
amount_needed = (round(amount_needed) == amount_needed)? amount_needed : round(amount_needed) + 1 //Why does BYOND not have a ceiling proc? amount_needed = (round(amount_needed) == amount_needed)? amount_needed : round(amount_needed) + 1 //Why does BYOND not have a ceiling proc?
var/obj/item/stack/material/steel/metalstack = I var/obj/item/stack/stack = I
var/transfer var/transfer
if (repairing) if (repairing)
transfer = metalstack.transfer_to(repairing, amount_needed - repairing.amount) transfer = stack.transfer_to(repairing, amount_needed - repairing.amount)
if (!transfer) if (!transfer)
user << "<span class='warning'>You must weld or remove \the [repairing] from \the [src] before you can add anything else.</span>" user << "<span class='warning'>You must weld or remove \the [repairing] from \the [src] before you can add anything else.</span>"
else else
repairing = metalstack.split(amount_needed) repairing = stack.split(amount_needed)
if (repairing) if (repairing)
repairing.loc = src repairing.loc = src
transfer = repairing.amount transfer = repairing.amount
if (transfer) if (transfer)
user << "<span class='notice'>You fit [transfer] [metalstack.singular_name]\s to damaged and broken parts on \the [src].</span>" user << "<span class='notice'>You fit [transfer] [stack.singular_name]\s to damaged and broken parts on \the [src].</span>"
return return
@@ -274,6 +273,8 @@
take_damage(W.force) take_damage(W.force)
return return
if(src.operating > 0 || isrobot(user)) return //borgs can't attack doors open because it conflicts with their AI-like interaction with them.
if(src.operating) return if(src.operating) return
if(src.density && (operable() && istype(I, /obj/item/weapon/card/emag))) if(src.density && (operable() && istype(I, /obj/item/weapon/card/emag)))

View File

@@ -75,6 +75,8 @@
A.all_doors.Remove(src) A.all_doors.Remove(src)
. = ..() . = ..()
/obj/machinery/door/firedoor/get_material()
return get_material_by_name(DEFAULT_WALL_MATERIAL)
/obj/machinery/door/firedoor/examine(mob/user) /obj/machinery/door/firedoor/examine(mob/user)
. = ..(user, 1) . = ..(user, 1)

View File

@@ -50,7 +50,7 @@
user.visible_message("<span class='notice'>[user] has [!a_dis?"de":""]activated auto-dismantling.</span>", "<span class='notice'>You [!a_dis?"de":""]activate auto-dismantling.</span>") user.visible_message("<span class='notice'>[user] has [!a_dis?"de":""]activated auto-dismantling.</span>", "<span class='notice'>You [!a_dis?"de":""]activate auto-dismantling.</span>")
return return
if(istype(W, /obj/item/stack/material/steel)) if(istype(W, /obj/item/stack/material) && W.get_material_name() == DEFAULT_WALL_MATERIAL)
var/result = load_metal(W) var/result = load_metal(W)
if(isnull(result)) if(isnull(result))
@@ -86,7 +86,7 @@
on=0 on=0
return return
/obj/machinery/pipelayer/proc/load_metal(var/obj/item/stack/material/steel/MM) /obj/machinery/pipelayer/proc/load_metal(var/obj/item/stack/MM)
if(istype(MM) && MM.get_amount()) if(istype(MM) && MM.get_amount())
var/cur_amount = metal var/cur_amount = metal
var/to_load = max(max_metal - round(cur_amount),0) var/to_load = max(max_metal - round(cur_amount),0)

View File

@@ -704,8 +704,8 @@ var/list/turret_icons
return return
if(1) if(1)
if(istype(I, /obj/item/stack/material/steel)) if(istype(I, /obj/item/stack/material) && I.get_material_name() == DEFAULT_WALL_MATERIAL)
var/obj/item/stack/material/steel/M = I var/obj/item/stack/M = I
if(M.use(2)) if(M.use(2))
user << "<span class='notice'>You add some metal armor to the interior frame.</span>" user << "<span class='notice'>You add some metal armor to the interior frame.</span>"
build_step = 2 build_step = 2
@@ -796,8 +796,8 @@ var/list/turret_icons
//attack_hand() removes the prox sensor //attack_hand() removes the prox sensor
if(6) if(6)
if(istype(I, /obj/item/stack/material/steel)) if(istype(I, /obj/item/stack/material) && I.get_material_name() == DEFAULT_WALL_MATERIAL)
var/obj/item/stack/material/steel/M = I var/obj/item/stack/M = I
if(M.use(2)) if(M.use(2))
user << "<span class='notice'>You add some metal armor to the exterior frame.</span>" user << "<span class='notice'>You add some metal armor to the exterior frame.</span>"
build_step = 7 build_step = 7

View File

@@ -12,8 +12,8 @@
active_power_usage = 10000 active_power_usage = 10000
/obj/machinery/robotic_fabricator/attackby(var/obj/item/O as obj, var/mob/user as mob) /obj/machinery/robotic_fabricator/attackby(var/obj/item/O as obj, var/mob/user as mob)
if (istype(O, /obj/item/stack/material/steel)) if (istype(O, /obj/item/stack/material) && O.get_material_name() == DEFAULT_WALL_MATERIAL)
var/obj/item/stack/material/steel/M = O var/obj/item/stack/M = O
if (src.metal_amount < 150000.0) if (src.metal_amount < 150000.0)
var/count = 0 var/count = 0
src.overlays += "fab-load-metal" src.overlays += "fab-load-metal"

View File

@@ -71,8 +71,8 @@
Emag() Emag()
return return
if(istype(W, /obj/item/stack/material/glass)) if(istype(W, /obj/item/stack/material) && W.get_material_name() == "glass")
var/obj/item/stack/material/glass/G = W var/obj/item/stack/G = W
if(uses >= max_uses) if(uses >= max_uses)
user << "<span class='warning'>[src.name] is full." user << "<span class='warning'>[src.name] is full."
return return

View File

@@ -125,8 +125,8 @@
/obj/item/robot_parts/robot_suit/attackby(obj/item/W as obj, mob/user as mob) /obj/item/robot_parts/robot_suit/attackby(obj/item/W as obj, mob/user as mob)
..() ..()
if(istype(W, /obj/item/stack/material/steel) && !l_arm && !r_arm && !l_leg && !r_leg && !chest && !head) if(istype(W, /obj/item/stack/material) && W.get_material_name() == DEFAULT_WALL_MATERIAL && !l_arm && !r_arm && !l_leg && !r_leg && !chest && !head)
var/obj/item/stack/material/steel/M = W var/obj/item/stack/material/M = W
if (M.use(1)) if (M.use(1))
var/obj/item/weapon/secbot_assembly/ed209_assembly/B = new /obj/item/weapon/secbot_assembly/ed209_assembly var/obj/item/weapon/secbot_assembly/ed209_assembly/B = new /obj/item/weapon/secbot_assembly/ed209_assembly
B.loc = get_turf(src) B.loc = get_turf(src)

View File

@@ -22,8 +22,8 @@
user.drop_from_inventory(src) user.drop_from_inventory(src)
qdel(src) qdel(src)
if(istype(O,/obj/item/stack/material/steel)) if(istype(O,/obj/item/stack/material) && O.get_material_name() == DEFAULT_WALL_MATERIAL)
var/obj/item/stack/material/steel/M = O var/obj/item/stack/M = O
if (M.use(1)) if (M.use(1))
use(1) use(1)
new/obj/item/stack/tile/light(get_turf(user)) new/obj/item/stack/tile/light(get_turf(user))

View File

@@ -34,6 +34,9 @@
if(!isnull(matter[material_type])) if(!isnull(matter[material_type]))
matter[material_type] *= force_divisor // May require a new var instead. 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() /obj/item/weapon/material/proc/update_force()
if(edge || sharp) if(edge || sharp)
force = material.get_edge_damage() force = material.get_edge_damage()

View File

@@ -87,4 +87,4 @@
..(loc, "steel") ..(loc, "steel")
/obj/item/weapon/material/shard/phoron/New(loc) /obj/item/weapon/material/shard/phoron/New(loc)
..(loc, "phoron glass") ..(loc, "phglass")

View File

@@ -119,10 +119,10 @@
//verbs += /obj/item/weapon/storage/bag/sheetsnatcher/quick_empty //verbs += /obj/item/weapon/storage/bag/sheetsnatcher/quick_empty
can_be_inserted(obj/item/W as obj, stop_messages = 0) can_be_inserted(obj/item/W as obj, stop_messages = 0)
if(!istype(W,/obj/item/stack/material) || istype(W,/obj/item/stack/material/sandstone) || istype(W,/obj/item/stack/material/wood)) if(!istype(W,/obj/item/stack/material))
if(!stop_messages) if(!stop_messages)
usr << "The snatcher does not accept [W]." usr << "The snatcher does not accept [W]."
return 0 //I don't care, but the existing code rejects them for not being "sheets" *shrug* -Sayu return 0
var/current = 0 var/current = 0
for(var/obj/item/stack/material/S in contents) for(var/obj/item/stack/material/S in contents)
current += S.amount current += S.amount

View File

@@ -236,20 +236,20 @@
electronics = null electronics = null
else if(istype(W, /obj/item/stack/material) && !glass) else if(istype(W, /obj/item/stack/material) && !glass)
var/obj/item/stack/material/S = W var/obj/item/stack/S = W
var/material_name = S.get_material_name()
if (S) if (S)
if (S.get_amount() >= 1) if (S.get_amount() >= 1)
if(istype(S, /obj/item/stack/material/glass/reinforced)) if(material_name == "rglass")
playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1) playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1)
user.visible_message("[user] adds [S.name] to the airlock assembly.", "You start to install [S.name] into the airlock assembly.") user.visible_message("[user] adds [S.name] to the airlock assembly.", "You start to install [S.name] into the airlock assembly.")
if(do_after(user, 40) && !glass) if(do_after(user, 40) && !glass)
if (S.use(1)) if (S.use(1))
user << "<span class='notice'>You installed reinforced glass windows into the airlock assembly.</span>" user << "<span class='notice'>You installed reinforced glass windows into the airlock assembly.</span>"
glass = 1 glass = 1
else if(istype(S, /obj/item/stack/material) && S.default_type) else if(material_name)
var/M = S.default_type
// Ugly hack, will suffice for now. Need to fix it upstream as well, may rewrite mineral walls. ~Z // Ugly hack, will suffice for now. Need to fix it upstream as well, may rewrite mineral walls. ~Z
if(M in list("mhydrogen","osmium","tritium","platinum","iron")) if(!(material_name in list("gold", "silver", "diamond", "uranium", "phoron", "sandstone")))
user << "You cannot make an airlock out of that material." user << "You cannot make an airlock out of that material."
return return
if(S.get_amount() >= 2) if(S.get_amount() >= 2)
@@ -257,8 +257,8 @@
user.visible_message("[user] adds [S.name] to the airlock assembly.", "You start to install [S.name] into the airlock assembly.") user.visible_message("[user] adds [S.name] to the airlock assembly.", "You start to install [S.name] into the airlock assembly.")
if(do_after(user, 40) && !glass) if(do_after(user, 40) && !glass)
if (S.use(2)) if (S.use(2))
user << "<span class='notice'>You installed [M] plating into the airlock assembly.</span>" user << "<span class='notice'>You installed [material_display_name(material_name)] plating into the airlock assembly.</span>"
glass = "[M]" glass = material_name
else if(istype(W, /obj/item/weapon/screwdriver) && state == 2 ) else if(istype(W, /obj/item/weapon/screwdriver) && state == 2 )
playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1) playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)

View File

@@ -108,11 +108,11 @@
else if(istype(W, /obj/item/stack/material)) else if(istype(W, /obj/item/stack/material))
var/obj/item/stack/material/S = W var/obj/item/stack/S = W
if(S.get_amount() < 2) if(S.get_amount() < 2)
return ..() return ..()
var/material/M = name_to_material[S.default_type] var/material/M = S.get_material()
if(!istype(M)) if(!istype(M))
return ..() return ..()
@@ -183,7 +183,7 @@
user << "There is not enough material here to reinforce the girder." user << "There is not enough material here to reinforce the girder."
return return
var/material/M = name_to_material[S.default_type] var/material/M = S.get_material()
if(!istype(M) || M.integrity < 50) if(!istype(M) || M.integrity < 50)
user << "You cannot reinforce \the [src] with that; it is too soft." user << "You cannot reinforce \the [src] with that; it is too soft."
return return

View File

@@ -44,6 +44,9 @@
update_nearby_tiles() update_nearby_tiles()
..() ..()
/obj/structure/simple_door/get_material()
return material
/obj/structure/simple_door/Bumped(atom/user) /obj/structure/simple_door/Bumped(atom/user)
..() ..()
if(!state) if(!state)

View File

@@ -33,6 +33,9 @@
padding_material = get_material_by_name(new_padding_material) padding_material = get_material_by_name(new_padding_material)
update_icon() update_icon()
/obj/structure/bed/get_material()
return material
// Reuse the cache/code from stools, todo maybe unify. // Reuse the cache/code from stools, todo maybe unify.
/obj/structure/bed/update_icon() /obj/structure/bed/update_icon()
// Prep icon. // Prep icon.

View File

@@ -195,16 +195,12 @@ var/list/mechtoys = list(
find_slip = 0 find_slip = 0
continue continue
// Sell phoron // Sell phoron and platinum
if(istype(A, /obj/item/stack/material/phoron)) if(istype(A, /obj/item/stack))
var/obj/item/stack/material/phoron/P = A var/obj/item/stack/P
phoron_count += P.get_amount() switch(P.get_material_name())
if("phoron") phoron_count += P.get_amount()
// Sell platinum if("platinum") plat_count += P.get_amount()
if(istype(A, /obj/item/stack/material/platinum))
var/obj/item/stack/material/platinum/P = A
plat_count += P.get_amount()
qdel(MA) qdel(MA)
if(phoron_count) if(phoron_count)

View File

@@ -8,7 +8,7 @@
else else
construction_stage = null construction_stage = null
if(!material) if(!material)
material = name_to_material[DEFAULT_WALL_MATERIAL] material = get_material_by_name(DEFAULT_WALL_MATERIAL)
if(material) if(material)
explosion_resistance = material.explosion_resistance explosion_resistance = material.explosion_resistance
if(reinf_material && reinf_material.explosion_resistance > explosion_resistance) if(reinf_material && reinf_material.explosion_resistance > explosion_resistance)

View File

@@ -28,7 +28,7 @@ var/list/global/wall_cache = list()
materialtype = DEFAULT_WALL_MATERIAL materialtype = DEFAULT_WALL_MATERIAL
material = get_material_by_name(materialtype) material = get_material_by_name(materialtype)
if(!isnull(rmaterialtype)) if(!isnull(rmaterialtype))
reinf_material = name_to_material[rmaterialtype] reinf_material = get_material_by_name(rmaterialtype)
update_material() update_material()
processing_turfs |= src processing_turfs |= src
@@ -38,7 +38,6 @@ var/list/global/wall_cache = list()
dismantle_wall(null,null,1) dismantle_wall(null,null,1)
..() ..()
/turf/simulated/wall/process() /turf/simulated/wall/process()
// Calling parent will kill processing // Calling parent will kill processing
if(!radiate()) if(!radiate())
@@ -170,7 +169,7 @@ var/list/global/wall_cache = list()
O.loc = src O.loc = src
clear_plants() clear_plants()
material = name_to_material["placeholder"] material = get_material_by_name("placeholder")
reinf_material = null reinf_material = null
check_relatives() check_relatives()

View File

@@ -178,23 +178,29 @@ var/global/list/breach_burn_descriptors = list(
//Handles repairs (and also upgrades). //Handles repairs (and also upgrades).
/obj/item/clothing/suit/space/attackby(obj/item/W as obj, mob/user as mob) /obj/item/clothing/suit/space/attackby(obj/item/W as obj, mob/user as mob)
if(istype(W,/obj/item/stack/material/plastic) || istype(W,/obj/item/stack/material/steel)) if(istype(W,/obj/item/stack/material))
var/repair_power = 0
switch(W.get_material_name())
if(DEFAULT_WALL_MATERIAL)
repair_power = 2
if("plastic")
repair_power = 1
if(!repair_power)
return
if(istype(src.loc,/mob/living)) if(istype(src.loc,/mob/living))
user << "\red How do you intend to patch a hardsuit while someone is wearing it?" user << "<span class='warning'>How do you intend to patch a hardsuit while someone is wearing it?</span>"
return return
if(!damage || !burn_damage) if(!damage || !burn_damage)
user << "There is no surface damage on \the [src] to repair." user << "There is no surface damage on \the [src] to repair."
return return
var/obj/item/stack/material/P = W var/obj/item/stack/P = W
if(P.get_amount() < 3) var/use_amt = min(P.get_amount(), 3)
P.use(P.get_amount()) if(use_amt && P.use(use_amt))
repair_breaches(BURN, ( istype(P,/obj/item/stack/material/plastic) ? P.get_amount() : (P.get_amount()*2) ), user) repair_breaches(BURN, use_amt * repair_power, user)
else
P.use(3)
repair_breaches(BURN, ( istype(P,/obj/item/stack/material/plastic) ? 3 : 5), user)
return return
else if(istype(W, /obj/item/weapon/weldingtool)) else if(istype(W, /obj/item/weapon/weldingtool))

View File

@@ -7,7 +7,7 @@
return return
// Pass repair items on to the chestpiece. // Pass repair items on to the chestpiece.
if(chest && (istype(W,/obj/item/stack/material/plastic) || istype(W,/obj/item/stack/material/steel) || istype(W, /obj/item/weapon/weldingtool))) if(chest && (istype(W,/obj/item/stack/material) || istype(W, /obj/item/weapon/weldingtool)))
return chest.attackby(W,user) return chest.attackby(W,user)
// Lock or unlock the access panel. // Lock or unlock the access panel.

View File

@@ -39,8 +39,13 @@
update_strings() update_strings()
return 1 return 1
/obj/item/stack/material/get_material()
return material
/obj/item/stack/material/proc/update_strings() /obj/item/stack/material/proc/update_strings()
// Update from material datum. // Update from material datum.
singular_name = material.sheet_singular_name
if(amount>1) if(amount>1)
name = "[material.use_name] [material.sheet_plural_name]" name = "[material.use_name] [material.sheet_plural_name]"
desc = "A stack of [material.use_name] [material.sheet_plural_name]." desc = "A stack of [material.use_name] [material.sheet_plural_name]."
@@ -187,15 +192,15 @@
/obj/item/stack/material/glass/reinforced /obj/item/stack/material/glass/reinforced
name = "reinforced glass" name = "reinforced glass"
icon_state = "sheet-rglass" icon_state = "sheet-rglass"
default_type = "reinforced glass" default_type = "rglass"
/obj/item/stack/material/glass/phoronglass /obj/item/stack/material/glass/phoronglass
name = "phoron glass" name = "phoron glass"
singular_name = "phoron glass sheet" singular_name = "phoron glass sheet"
icon_state = "sheet-phoronglass" icon_state = "sheet-phoronglass"
default_type = "phoron glass" default_type = "phglass"
/obj/item/stack/material/glass/phoronrglass /obj/item/stack/material/glass/phoronrglass
name = "reinforced phoron glass" name = "reinforced phoron glass"
icon_state = "sheet-phoronrglass" icon_state = "sheet-phoronrglass"
default_type = "reinforced phoron glass" default_type = "rphglass"

View File

@@ -34,5 +34,5 @@
/obj/item/stack/material/cyborg/glass/reinforced /obj/item/stack/material/cyborg/glass/reinforced
icon_state = "sheet-rglass" icon_state = "sheet-rglass"
default_type = "reinforced glass" default_type = "rglass"
charge_costs = list(500, 1000) charge_costs = list(500, 1000)

View File

@@ -27,6 +27,17 @@
// Assoc list containing all material datums indexed by name. // Assoc list containing all material datums indexed by name.
var/list/name_to_material 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? Or should we just return the "dominant" material.
/obj/proc/get_material()
return null
//mostly for convenience
/obj/proc/get_material_name()
var/material/material = get_material()
if(material)
return material.name
// Builds the datum list above. // Builds the datum list above.
/proc/populate_material_list(force_remake=0) /proc/populate_material_list(force_remake=0)
if(name_to_material && !force_remake) return // Already set up! if(name_to_material && !force_remake) return // Already set up!
@@ -44,6 +55,12 @@ var/list/name_to_material
populate_material_list() populate_material_list()
return name_to_material[name] return name_to_material[name]
/proc/material_display_name(name)
var/material/material = get_material_by_name(name)
if(material)
return material.display_name
return null
// Material definition and procs follow. // Material definition and procs follow.
/material /material
var/name // Unique name for use in indexing the list. var/name // Unique name for use in indexing the list.
@@ -312,7 +329,7 @@ var/list/name_to_material
icon_colour = "#666666" icon_colour = "#666666"
/material/steel/holographic /material/steel/holographic
name = "holographic " + DEFAULT_WALL_MATERIAL name = "holo" + DEFAULT_WALL_MATERIAL
display_name = DEFAULT_WALL_MATERIAL display_name = DEFAULT_WALL_MATERIAL
stack_type = null stack_type = null
shard_type = SHARD_NONE shard_type = SHARD_NONE
@@ -422,7 +439,8 @@ var/list/name_to_material
return (hardness > 35) //todo return (hardness > 35) //todo
/material/glass/reinforced /material/glass/reinforced
name = "reinforced glass" name = "rglass"
display_name = "reinforced glass"
stack_type = /obj/item/stack/material/glass/reinforced stack_type = /obj/item/stack/material/glass/reinforced
flags = MATERIAL_BRITTLE flags = MATERIAL_BRITTLE
icon_colour = "#00E1FF" icon_colour = "#00E1FF"
@@ -440,7 +458,8 @@ var/list/name_to_material
rod_product = null rod_product = null
/material/glass/phoron /material/glass/phoron
name = "phoron glass" name = "phglass"
display_name = "phoron glass"
stack_type = /obj/item/stack/material/glass/phoronglass stack_type = /obj/item/stack/material/glass/phoronglass
flags = MATERIAL_BRITTLE flags = MATERIAL_BRITTLE
ignition_point = PHORON_MINIMUM_BURN_TEMPERATURE+300 ignition_point = PHORON_MINIMUM_BURN_TEMPERATURE+300
@@ -452,7 +471,8 @@ var/list/name_to_material
rod_product = /obj/item/stack/material/glass/phoronrglass rod_product = /obj/item/stack/material/glass/phoronrglass
/material/glass/phoron/reinforced /material/glass/phoron/reinforced
name = "reinforced phoron glass" name = "rphglass"
display_name = "reinforced phoron glass"
stack_type = /obj/item/stack/material/glass/phoronrglass stack_type = /obj/item/stack/material/glass/phoronrglass
stack_origin_tech = "materials=4;phorontech=2" stack_origin_tech = "materials=4;phorontech=2"
composite_material = list() //todo composite_material = list() //todo
@@ -473,7 +493,7 @@ var/list/name_to_material
stack_origin_tech = "materials=3" stack_origin_tech = "materials=3"
/material/plastic/holographic /material/plastic/holographic
name = "holographic plastic" name = "holoplastic"
display_name = "plastic" display_name = "plastic"
stack_type = null stack_type = null
shard_type = SHARD_NONE shard_type = SHARD_NONE
@@ -551,7 +571,7 @@ var/list/name_to_material
sheet_plural_name = "planks" sheet_plural_name = "planks"
/material/wood/holographic /material/wood/holographic
name = "holographic wood" name = "holowood"
display_name = "wood" display_name = "wood"
stack_type = null stack_type = null
shard_type = SHARD_NONE shard_type = SHARD_NONE

View File

@@ -210,7 +210,7 @@
var/can_make = Clamp(ores_stored[metal],0,sheets_per_tick-sheets) var/can_make = Clamp(ores_stored[metal],0,sheets_per_tick-sheets)
if(can_make%2>0) can_make-- if(can_make%2>0) can_make--
var/material/M = name_to_material[O.compresses_to] var/material/M = get_material_by_name(O.compresses_to)
if(!istype(M) || !can_make || ores_stored[metal] < 1) if(!istype(M) || !can_make || ores_stored[metal] < 1)
continue continue
@@ -224,7 +224,7 @@
var/can_make = Clamp(ores_stored[metal],0,sheets_per_tick-sheets) var/can_make = Clamp(ores_stored[metal],0,sheets_per_tick-sheets)
var/material/M = name_to_material[O.smelts_to] var/material/M = get_material_by_name(O.smelts_to)
if(!istype(M) || !can_make || ores_stored[metal] < 1) if(!istype(M) || !can_make || ores_stored[metal] < 1)
continue continue

View File

@@ -37,26 +37,26 @@
/obj/machinery/mineral/mint/process() /obj/machinery/mineral/mint/process()
if ( src.input) if ( src.input)
var/obj/item/stack/material/O var/obj/item/stack/O
O = locate(/obj/item/stack/material, input.loc) O = locate(/obj/item/stack, input.loc)
if(O) if(O)
if (istype(O,/obj/item/stack/material/gold)) var/processed = 1
amt_gold += 100 * O.get_amount() switch(O.get_material_name())
qdel(O) if("gold")
if (istype(O,/obj/item/stack/material/silver)) amt_gold += 100 * O.get_amount()
amt_silver += 100 * O.get_amount() if("silver")
qdel(O) amt_silver += 100 * O.get_amount()
if (istype(O,/obj/item/stack/material/diamond)) if("diamond")
amt_diamond += 100 * O.get_amount() amt_diamond += 100 * O.get_amount()
qdel(O) if("phoron")
if (istype(O,/obj/item/stack/material/phoron)) amt_phoron += 100 * O.get_amount()
amt_phoron += 100 * O.get_amount() if("uranium")
qdel(O) amt_uranium += 100 * O.get_amount()
if (istype(O,/obj/item/stack/material/uranium)) if(DEFAULT_WALL_MATERIAL)
amt_uranium += 100 * O.get_amount() amt_iron += 100 * O.get_amount()
qdel(O) else
if (istype(O,/obj/item/stack/material/steel)) processed = 0
amt_iron += 100 * O.get_amount() if(processed)
qdel(O) qdel(O)
/obj/machinery/mineral/mint/attack_hand(user as mob) /obj/machinery/mineral/mint/attack_hand(user as mob)

View File

@@ -249,15 +249,16 @@
target = null target = null
repairing = 0 repairing = 0
update_icons() update_icons()
else if(istype(A, /obj/item/stack/material/steel) && amount + 3 < maxAmount) else if(istype(A, /obj/item/stack/material) && amount + 4 <= maxAmount)
var/obj/item/stack/material/steel/M = A var/obj/item/stack/material/M = A
visible_message("<span class='notice'>[src] begins to make tiles.</span>") if(M.get_material_name() == DEFAULT_WALL_MATERIAL)
repairing = 1 visible_message("<span class='notice'>[src] begins to make tiles.</span>")
update_icons() repairing = 1
if(do_after(50)) update_icons()
if(M) if(do_after(50))
M.use(1) if(M)
addTiles(4) M.use(1)
addTiles(4)
/mob/living/bot/floorbot/explode() /mob/living/bot/floorbot/explode()
turn_off() turn_off()

View File

@@ -37,7 +37,7 @@
for(var/obj/I in contents) for(var/obj/I in contents)
for(var/mob/M in I.contents) for(var/mob/M in I.contents)
M.death() M.death()
if(istype(I,/obj/item/stack/material))//Only deconsturcts one sheet at a time instead of the entire stack if(istype(I,/obj/item/stack/material))//Only deconstructs one sheet at a time instead of the entire stack
var/obj/item/stack/material/S = I var/obj/item/stack/material/S = I
if(S.get_amount() > 1) if(S.get_amount() > 1)
S.use(1) S.use(1)

View File

@@ -251,7 +251,7 @@ var/list/solars_list = list()
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1) playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
return 1 return 1
if(istype(W, /obj/item/stack/material/glass)) if(istype(W, /obj/item/stack/material) && (W.get_material_name() == "glass" || W.get_material_name() == "rglass"))
var/obj/item/stack/material/S = W var/obj/item/stack/material/S = W
if(S.use(2)) if(S.use(2))
glass_type = W.type glass_type = W.type

View File

@@ -254,9 +254,9 @@
else else
user << "<span class='notice'>You need at least five segments of cable coil to complete this task.</span>" user << "<span class='notice'>You need at least five segments of cable coil to complete this task.</span>"
return return
else if(istype(W,/obj/item/stack/material/plastic)) else if(istype(W,/obj/item/stack/material) && W.get_material_name() == "plastic")
if(buildstate == 3) if(buildstate == 3)
var/obj/item/stack/material/plastic/P = W var/obj/item/stack/material/P = W
if(P.use(3)) if(P.use(3))
user << "<span class='notice'>You assemble and install a heavy plastic lath onto the crossbow.</span>" user << "<span class='notice'>You assemble and install a heavy plastic lath onto the crossbow.</span>"
buildstate++ buildstate++

View File

@@ -167,9 +167,9 @@
buildstate++ buildstate++
update_icon() update_icon()
return return
else if(istype(W,/obj/item/stack/material/steel)) else if(istype(W,/obj/item/stack/material) && W.get_material_name() == DEFAULT_WALL_MATERIAL)
if(buildstate == 2) if(buildstate == 2)
var/obj/item/stack/material/steel/M = W var/obj/item/stack/material/M = W
if(M.use(5)) if(M.use(5))
user << "<span class='notice'>You assemble a chassis around the cannon frame.</span>" user << "<span class='notice'>You assemble a chassis around the cannon frame.</span>"
buildstate++ buildstate++

View File

@@ -104,16 +104,13 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis).
return 1 return 1
if(O.is_open_container()) if(O.is_open_container())
return 0 return 0
// if(!istype(O, /obj/item/stack/material/glass) && !istype(O, /obj/item/stack/material/gold) && !istype(O, /obj/item/stack/material/diamond) && !istype(O, /obj/item/stack/material/uranium))
// user << "<span class='notice'>You cannot insert this item into \the [src]!</span>"
// return 1
if(stat) if(stat)
return 1 return 1
if(busy) if(busy)
user << "<span class='notice'>\The [src] is busy. Please wait for completion of previous operation.</span>" user << "<span class='notice'>\The [src] is busy. Please wait for completion of previous operation.</span>"
return 1 return 1
if(istype(O, /obj/item/stack/material/glass) || istype(O, /obj/item/stack/material/gold) || istype(O, /obj/item/stack/material/diamond) || istype(O, /obj/item/stack/material/uranium)) if(istype(O, /obj/item/stack/material) && O.get_material_name() in list("glass", "gold", "diamond", "uranium"))
var/obj/item/stack/material/stack = O var/obj/item/stack/material/stack = O
if((TotalMaterials() + stack.perunit) > max_material_amount) if((TotalMaterials() + stack.perunit) > max_material_amount)

View File

@@ -144,28 +144,27 @@ Note: Must be placed west/left of and R&D console to function.
icon_state = "protolathe" icon_state = "protolathe"
busy = 1 busy = 1
use_power(max(1000, (3750 * amount / 10))) use_power(max(1000, (3750 * amount / 10)))
var/stacktype = stack.type var/material/material = stack.get_material()
stack.use(amount) if(istype(material) && do_after(user, 16) && stack.use(amount))
if(do_after(user, 16))
user << "<span class='notice'>You add [amount] sheets to \the [src].</span>" user << "<span class='notice'>You add [amount] sheets to \the [src].</span>"
icon_state = "protolathe" icon_state = "protolathe"
switch(stacktype)
if(/obj/item/stack/material/steel) var/amount_to_add = amount * material.stack_per_sheet
m_amount += amount * 3750 switch(material.name)
if(/obj/item/stack/material/glass) if(DEFAULT_WALL_MATERIAL)
g_amount += amount * 3750 m_amount += amount_to_add
if(/obj/item/stack/material/gold) if("glass")
gold_amount += amount * 2000 g_amount += amount_to_add
if(/obj/item/stack/material/silver) if("gold")
silver_amount += amount * 2000 gold_amount += amount_to_add
if(/obj/item/stack/material/phoron) if("silver")
phoron_amount += amount * 2000 silver_amount += amount_to_add
if(/obj/item/stack/material/uranium) if("phoron")
uranium_amount += amount * 2000 phoron_amount += amount_to_add
if(/obj/item/stack/material/diamond) if("uranium")
diamond_amount += amount * 2000 uranium_amount += amount_to_add
else if("diamond")
new stacktype(loc, amount) diamond_amount += amount_to_add
busy = 0 busy = 0
updateUsrDialog() updateUsrDialog()
return return

View File

@@ -439,25 +439,24 @@ won't update every console in existence) but it's more of a hassle to do. Also,
else if(href_list["lathe_ejectsheet"] && linked_lathe) //Causes the protolathe to eject a sheet of material else if(href_list["lathe_ejectsheet"] && linked_lathe) //Causes the protolathe to eject a sheet of material
var/desired_num_sheets = text2num(href_list["amount"]) var/desired_num_sheets = text2num(href_list["amount"])
var/res_amount, type var/res_amount, type
var/material/M = name_to_material[href_list["lathe_ejectsheet"]] var/material/M = get_material_by_name(href_list["lathe_ejectsheet"])
if(istype(M)) if(istype(M))
type = M.stack_type type = M.stack_type
switch(M.name)
switch(name_to_material[href_list["lathe_ejectsheet"]]) if(DEFAULT_WALL_MATERIAL)
if(DEFAULT_WALL_MATERIAL) res_amount = "m_amount"
res_amount = "m_amount" if("glass")
if("glass") res_amount = "g_amount"
res_amount = "g_amount" if("gold")
if("gold") res_amount = "gold_amount"
res_amount = "gold_amount" if("silver")
if("silver") res_amount = "silver_amount"
res_amount = "silver_amount" if("phoron")
if("phoron") res_amount = "phoron_amount"
res_amount = "phoron_amount" if("uranium")
if("uranium") res_amount = "uranium_amount"
res_amount = "uranium_amount" if("diamond")
if("diamond") res_amount = "diamond_amount"
res_amount = "diamond_amount"
if(ispath(type) && hasvar(linked_lathe, res_amount)) if(ispath(type) && hasvar(linked_lathe, res_amount))
var/obj/item/stack/material/sheet = new type(linked_lathe.loc) var/obj/item/stack/material/sheet = new type(linked_lathe.loc)

View File

@@ -63,11 +63,11 @@
icon_state = "holo_preview" icon_state = "holo_preview"
color = "#EEEEEE" color = "#EEEEEE"
New() New()
material = get_material_by_name("holographic [DEFAULT_TABLE_MATERIAL]") material = get_material_by_name("holo[DEFAULT_TABLE_MATERIAL]")
..() ..()
woodentable/holotable woodentable/holotable
icon_state = "holo_preview" icon_state = "holo_preview"
New() New()
material = get_material_by_name("holographic wood") material = get_material_by_name("holowood")
..() ..()

View File

@@ -200,7 +200,7 @@
// Returns the material to set the table to. // Returns the material to set the table to.
/obj/structure/table/proc/common_material_add(obj/item/stack/material/S, mob/user, verb) // Verb is actually verb without 'e' or 'ing', which is added. Works for 'plate'/'plating' and 'reinforce'/'reinforcing'. /obj/structure/table/proc/common_material_add(obj/item/stack/material/S, mob/user, verb) // Verb is actually verb without 'e' or 'ing', which is added. Works for 'plate'/'plating' and 'reinforce'/'reinforcing'.
var/material/M = name_to_material[S.default_type] var/material/M = S.get_material()
if(!istype(M)) if(!istype(M))
user << "<span class='warning'>You cannot [verb]e \the [src] with \the [S].</span>" user << "<span class='warning'>You cannot [verb]e \the [src] with \the [S].</span>"
return null return null