Merge pull request #3109 from Citadel-Station-13/upstream-merge-31232
[MIRROR] Fixes mech fab runtime
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
var/show_on_examine
|
||||
var/list/allowed_typecache
|
||||
var/last_inserted_type
|
||||
var/last_inserted_id
|
||||
var/last_amount_inserted
|
||||
var/last_insert_success
|
||||
var/datum/callback/precondition
|
||||
@@ -116,7 +117,7 @@
|
||||
if(!amt)
|
||||
return 0
|
||||
|
||||
insert_materials(S,amt)
|
||||
last_inserted_id = insert_materials(S,amt)
|
||||
last_inserted_type = S.type
|
||||
S.use(amt)
|
||||
last_amount_inserted = amt
|
||||
@@ -133,17 +134,22 @@
|
||||
if(!material_amount || !has_space(material_amount))
|
||||
return 0
|
||||
|
||||
insert_materials(I, multiplier)
|
||||
last_inserted_id = insert_materials(I, multiplier)
|
||||
last_inserted_type = I.type
|
||||
last_amount_inserted = material_amount
|
||||
return material_amount
|
||||
|
||||
/datum/component/material_container/proc/insert_materials(obj/item/I, multiplier = 1) //for internal usage only
|
||||
var/datum/material/M
|
||||
var/primary_mat
|
||||
var/max_mat_value = 0
|
||||
for(var/MAT in materials)
|
||||
M = materials[MAT]
|
||||
M.amount += I.materials[MAT] * multiplier
|
||||
total_amount += I.materials[MAT] * multiplier
|
||||
if(I.materials[MAT] > max_mat_value)
|
||||
primary_mat = MAT
|
||||
return primary_mat
|
||||
|
||||
//For consuming material
|
||||
//mats is a list of types of material to use and the corresponding amounts, example: list(MAT_METAL=100, MAT_GLASS=200)
|
||||
|
||||
@@ -134,12 +134,11 @@
|
||||
if(ispath(lit, /obj/item/ore/bluespace_crystal))
|
||||
use_power(max(500,M.last_amount_inserted/10))
|
||||
else
|
||||
var/obj/item/stack/S = lit
|
||||
var/list/initmats = initial(S.materials)
|
||||
if (initmats[MAT_METAL])
|
||||
flick("autolathe_o",src)//plays metal insertion animation
|
||||
if (initmats[MAT_GLASS])
|
||||
flick("autolathe_r",src)//plays glass insertion animation
|
||||
switch(M.last_inserted_id)
|
||||
if (MAT_METAL)
|
||||
flick("autolathe_o",src)//plays metal insertion animation
|
||||
if (MAT_GLASS)
|
||||
flick("autolathe_r",src)//plays glass insertion animation
|
||||
use_power(M.last_amount_inserted*100)
|
||||
updateUsrDialog()
|
||||
|
||||
|
||||
@@ -420,13 +420,7 @@
|
||||
var/datum/component/material_container/M = C
|
||||
if(!M.last_insert_success)
|
||||
return
|
||||
var/lit = M.last_inserted_type
|
||||
var/stack_name
|
||||
if(ispath(lit, /obj/item/ore/bluespace_crystal))
|
||||
stack_name = "bluespace"
|
||||
else
|
||||
var/obj/item/stack/S = lit
|
||||
stack_name = material2name(initial(S.materials)[1])
|
||||
var/stack_name = material2name(M.last_inserted_id)
|
||||
add_overlay("fab-load-[stack_name]")
|
||||
addtimer(CALLBACK(src, /atom/proc/cut_overlay, "fab-load-[stack_name]"), 10)
|
||||
updateUsrDialog()
|
||||
|
||||
Reference in New Issue
Block a user