diff --git a/code/game/mecha/mech_fabricator.dm b/code/game/mecha/mech_fabricator.dm
index 667b5ad0cf8..dfbb93a20be 100644
--- a/code/game/mecha/mech_fabricator.dm
+++ b/code/game/mecha/mech_fabricator.dm
@@ -3,28 +3,14 @@
icon_state = "fab-idle"
name = "exosuit fabricator"
desc = "Nothing is being built."
- density = 1
- anchored = 1
+ density = TRUE
+ anchored = TRUE
use_power = 1
idle_power_usage = 20
active_power_usage = 5000
var/time_coeff = 1
var/component_coeff = 1
- var/list/resources = list(
- MAT_METAL=0,
- MAT_GLASS=0,
- MAT_BANANIUM=0,
- MAT_TRANQUILLITE=0,
- MAT_DIAMOND=0,
- MAT_GOLD=0,
- MAT_PLASMA=0,
- MAT_SILVER=0,
- MAT_URANIUM=0,
- MAT_TITANIUM=0
- )
- var/res_max_amount = 200000
var/datum/research/files
- var/id
var/sync = 0
var/part_set
var/datum/design/being_built
@@ -49,6 +35,10 @@
)
/obj/machinery/mecha_part_fabricator/New()
+ var/datum/component/material_container/materials = AddComponent(/datum/component/material_container,
+ list(MAT_METAL, MAT_GLASS, MAT_SILVER, MAT_GOLD, MAT_DIAMOND, MAT_PLASMA, MAT_URANIUM, MAT_BANANIUM, MAT_TRANQUILLITE, MAT_TITANIUM, MAT_BLUESPACE), 0,
+ FALSE, list(/obj/item/stack, /obj/item/ore/bluespace_crystal), CALLBACK(src, .proc/is_insertion_ready), CALLBACK(src, .proc/AfterMaterialInsert))
+ materials.precise_insertion = TRUE
..()
component_parts = list()
component_parts += new /obj/item/circuitboard/mechfab(null)
@@ -71,13 +61,19 @@
component_parts += new /obj/item/stock_parts/console_screen(null)
RefreshParts()
+/obj/machinery/mecha_part_fabricator/Destroy()
+ GET_COMPONENT(materials, /datum/component/material_container)
+ materials.retrieve_all()
+ return ..()
+
/obj/machinery/mecha_part_fabricator/RefreshParts()
var/T = 0
- //maximum stocking amount (max 412000)
+ //maximum stocking amount (default 300000, 600000 at T4)
for(var/obj/item/stock_parts/matter_bin/M in component_parts)
T += M.rating
- res_max_amount = (187000+(T * 37500))
+ GET_COMPONENT(materials, /datum/component/material_container)
+ materials.max_amount = (200000 + (T*50000))
//resources adjustment coefficient (1 -> 0.85 -> 0.7 -> 0.55)
T = 1.15
@@ -99,51 +95,59 @@
if(D.build_type & MECHFAB)
if(!(set_name in D.category))
continue
- var/resources_available = check_resources(D)
- output += "
"
+ output += "[output_part_info(D)]
\["
+ if(check_resources(D))
+ output += "
Build | "
+ output += "
Add to queue\]\[
?\]
"
return output
/obj/machinery/mecha_part_fabricator/proc/output_part_info(datum/design/D)
- var/output = "[initial(D.name)] (Cost: [output_part_cost(D)]) [get_construction_time_w_coeff(D)/10] seconds"
+ var/output = "[initial(D.name)] (Cost: [output_part_cost(D)]) [get_construction_time_w_coeff(D)/10]sec"
return output
/obj/machinery/mecha_part_fabricator/proc/output_part_cost(datum/design/D)
var/i = 0
var/output
for(var/c in D.materials)
- if(c in resources)
- output += "[i?" | ":null][get_resource_cost_w_coeff(D,c)] [material2name(c)]"
- i++
+ output += "[i?" | ":null][get_resource_cost_w_coeff(D, c)] [material2name(c)]"
+ i++
return output
/obj/machinery/mecha_part_fabricator/proc/output_available_resources()
var/output
- for(var/resource in resources)
- var/amount = min(res_max_amount, resources[resource])
- output += "[material2name(resource)]: [amount] cm³, [round(resources[resource] / MINERAL_MATERIAL_AMOUNT,0.1)] sheets"
- if(amount>0)
- output += " - Remove \[1\] | \[10\] | \[Custom\] | \[All\]"
+ GET_COMPONENT(materials, /datum/component/material_container)
+ for(var/mat_id in materials.materials)
+ var/datum/material/M = materials.materials[mat_id]
+ output += "[M.name]: [M.amount] cm³"
+ if(M.amount >= MINERAL_MATERIAL_AMOUNT)
+ output += "- Remove \[1\]"
+ if(M.amount >= (MINERAL_MATERIAL_AMOUNT * 10))
+ output += " | \[10\]"
+ output += " | \[All\]"
output += "
"
return output
-/obj/machinery/mecha_part_fabricator/proc/remove_resources(datum/design/D)
- for(var/resource in D.materials)
- if(resource in resources)
- resources[resource] -= get_resource_cost_w_coeff(D,resource)
+/obj/machinery/mecha_part_fabricator/proc/get_resources_w_coeff(datum/design/D)
+ var/list/resources = list()
+ for(var/R in D.materials)
+ resources[R] = get_resource_cost_w_coeff(D, R)
+ return resources
/obj/machinery/mecha_part_fabricator/proc/check_resources(datum/design/D)
- for(var/R in D.materials)
- if(R in resources)
- if(resources[R] < get_resource_cost_w_coeff(D, R))
- return 0
- else
- return 0
- return 1
+ if(D.reagents_list.len) // No reagents storage - no reagent designs.
+ return FALSE
+ GET_COMPONENT(materials, /datum/component/material_container)
+ if(materials.has_materials(get_resources_w_coeff(D)))
+ return TRUE
+ return FALSE
/obj/machinery/mecha_part_fabricator/proc/build_part(datum/design/D)
being_built = D
desc = "It's building \a [initial(D.name)]."
- remove_resources(D)
+ var/list/res_coef = get_resources_w_coeff(D)
+
+ GET_COMPONENT(materials, /datum/component/material_container)
+ materials.use_amount(res_coef)
overlays += "fab-active"
use_power = 2
updateUsrDialog()
@@ -160,13 +164,12 @@
L.origin_tech = I.origin_tech
else
I.loc = get_step(src,SOUTH)
- I.materials[MAT_METAL] = get_resource_cost_w_coeff(D,MAT_METAL)
- I.materials[MAT_GLASS] = get_resource_cost_w_coeff(D,MAT_GLASS)
- visible_message("[bicon(src)] \The [src] beeps, \"\The [I] is complete.\"")
+ I.materials = res_coef
+ atom_say("[I] is complete.")
being_built = null
updateUsrDialog()
- return 1
+ return TRUE
/obj/machinery/mecha_part_fabricator/proc/update_queue_on_page()
send_byjax(usr,"mecha_fabricator.browser","queue",list_queue())
@@ -189,9 +192,9 @@
/obj/machinery/mecha_part_fabricator/proc/remove_from_queue(index)
if(!isnum(index) || !istype(queue) || (index<1 || index>queue.len))
- return 0
+ return FALSE
queue.Cut(index,++index)
- return 1
+ return TRUE
/obj/machinery/mecha_part_fabricator/proc/process_queue()
var/datum/design/D = queue[1]
@@ -204,16 +207,16 @@
temp = null
while(D)
if(stat&(NOPOWER|BROKEN))
- return 0
+ return FALSE
if(!check_resources(D))
- visible_message("[bicon(src)] \The [src] beeps, \"Not enough resources. Queue processing stopped.\"")
+ atom_say("Not enough resources. Queue processing stopped.")
temp = {"Not enough resources to build next part.
Try again | Return"}
- return 0
+ return FALSE
remove_from_queue(1)
build_part(D)
D = listgetindex(queue, 1)
- visible_message("[bicon(src)] \The [src] beeps, \"Queue processing finished successfully.\"")
+ atom_say("Queue processing finished successfully.")
/obj/machinery/mecha_part_fabricator/proc/list_queue()
var/output = "Queue contains:"
@@ -225,7 +228,11 @@
for(var/datum/design/D in queue)
i++
var/obj/part = D.build_path
- output += "[initial(part.name)] - [i>1?"↑":null] [i↓":null] Remove"
+ output += ""
+ output += initial(part.name) + " - "
+ output += "[i>1?"↑":null] "
+ output += "[i↓":null] "
+ output += "Remove"
output += ""
output += "\[Process queue | Clear queue\]"
@@ -246,7 +253,7 @@
temp += "Return"
updateUsrDialog()
- visible_message("[bicon(src)] \The [src] beeps, \"Successfully synchronized with R&D server.\"")
+ atom_say("Successfully synchronized with R&D server.")
return
temp = "Unable to connect to local R&D Database.
Please check your connections and try again.
Return"
@@ -275,9 +282,9 @@
if(..())
return
user.set_machine(src)
- var/turf/exit = get_step(src,SOUTH)
- if(isliving(user) && exit.density)
- visible_message("[bicon(src)] \The [src] beeps, \"Error! Part outlet is obstructed.\"")
+ var/turf/exit = get_step(src,(dir))
+ if(exit.density)
+ atom_say("Error! Part outlet is obstructed.")
return
if(temp)
left_part = temp
@@ -295,8 +302,9 @@
if("parts")
left_part += output_parts_list(part_set)
left_part += "
Return"
- dat = {"
- [name]
+ dat = {"
+
+ [name]