reduce amount of lists that exist during runtime for custom materials (#50832)

This commit is contained in:
William Wallace
2020-05-06 13:00:39 +01:00
committed by GitHub
parent 44aab54b06
commit e007b3dcab
8 changed files with 54 additions and 40 deletions
+11 -7
View File
@@ -320,10 +320,13 @@
if (amount < used)
return FALSE
amount -= used
if(check)
zero_amount()
for(var/i in mats_per_unit)
custom_materials[i] = amount * mats_per_unit[i]
if(check && zero_amount())
return FALSE
if(length(mats_per_unit))
var/temp_materials = custom_materials.Copy()
for(var/i in mats_per_unit)
temp_materials[i] = mats_per_unit[i] * src.amount
set_custom_materials(temp_materials)
update_icon()
update_weight()
return TRUE
@@ -355,10 +358,11 @@
source.add_charge(amount * cost)
else
src.amount += amount
if(mats_per_unit && mats_per_unit.len)
if(length(mats_per_unit))
var/temp_materials = custom_materials.Copy()
for(var/i in mats_per_unit)
custom_materials[i] = mats_per_unit[i] * src.amount
set_custom_materials() //Refresh
temp_materials[i] = mats_per_unit[i] * src.amount
set_custom_materials(temp_materials)
update_icon()
update_weight()