Removes ComponentActivated in favor of callbacks

This commit is contained in:
Jordan Brown
2017-12-05 16:41:56 -05:00
committed by CitadelStationBot
parent a6aa181161
commit e1f658a50d
14 changed files with 190 additions and 98 deletions
+52
View File
@@ -27,9 +27,15 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis).
"Computer Parts"
)
<<<<<<< HEAD
/obj/machinery/r_n_d/circuit_imprinter/Initialize()
var/datum/component/material_container/materials = AddComponent(/datum/component/material_container, list(MAT_GLASS, MAT_GOLD, MAT_DIAMOND, MAT_METAL, MAT_BLUESPACE),
FALSE, list(/obj/item/stack, /obj/item/ore/bluespace_crystal), CALLBACK(src, .proc/is_insertion_ready))
=======
/obj/machinery/rnd/circuit_imprinter/Initialize()
materials = AddComponent(/datum/component/material_container, list(MAT_GLASS, MAT_GOLD, MAT_DIAMOND, MAT_METAL, MAT_BLUESPACE),
FALSE, list(/obj/item/stack, /obj/item/ore/bluespace_crystal), CALLBACK(src, .proc/is_insertion_ready), CALLBACK(src, .proc/AfterMaterialInsert))
>>>>>>> 3aba012... Removes ComponentActivated in favor of callbacks (#33274)
materials.precise_insertion = TRUE
create_reagents(0)
return ..()
@@ -77,6 +83,7 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis).
linked_console.linked_imprinter = null
..()
<<<<<<< HEAD
/obj/machinery/r_n_d/circuit_imprinter/ComponentActivated(datum/component/C)
..()
if(istype(C, /datum/component/material_container))
@@ -94,3 +101,48 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis).
use_power(max(1000, (MINERAL_MATERIAL_AMOUNT * M.last_amount_inserted / 10)))
add_overlay("protolathe_[stack_name]")
addtimer(CALLBACK(src, /atom/proc/cut_overlay, "protolathe_[stack_name]"), 10)
=======
/obj/machinery/rnd/circuit_imprinter/proc/user_try_print_id(id)
if((!linked_console && requires_console) || !id)
return FALSE
var/datum/design/D = (linked_console || requires_console)? linked_console.stored_research.researched_designs[id] : get_techweb_design_by_id(id)
if(!istype(D))
return FALSE
var/power = 1000
for(var/M in D.materials)
power += round(D.materials[M] / 5)
power = max(4000, power)
use_power(power)
var/list/efficient_mats = list()
for(var/MAT in D.materials)
efficient_mats[MAT] = D.materials[MAT]/efficiency_coeff
if(!materials.has_materials(efficient_mats))
say("Not enough materials to complete prototype.")
return FALSE
for(var/R in D.reagents_list)
if(!reagents.has_reagent(R, D.reagents_list[R]/efficiency_coeff))
say("Not enough reagents to complete prototype.")
return FALSE
busy = TRUE
flick("circuit_imprinter_ani", src)
materials.use_amount(efficient_mats)
for(var/R in D.reagents_list)
reagents.remove_reagent(R, D.reagents_list[R]/efficiency_coeff)
var/P = D.build_path
addtimer(CALLBACK(src, .proc/reset_busy), 16)
addtimer(CALLBACK(src, .proc/do_print, P, efficient_mats, D.dangerous_construction), 16)
return TRUE
/obj/machinery/rnd/circuit_imprinter/proc/do_print(path, list/matlist, notify_admins)
if(notify_admins && usr)
investigate_log("[key_name(usr)] built [path] at a circuit imprinter.", INVESTIGATE_RESEARCH)
message_admins("[ADMIN_LOOKUPFLW(usr)] has built [path] at a circuit imprinter.")
var/obj/item/I = new path(get_turf(src))
I.materials = matlist.Copy()
SSblackbox.record_feedback("nested_tally", "circuit_printed", 1, list("[type]", "[path]"))
>>>>>>> 3aba012... Removes ComponentActivated in favor of callbacks (#33274)
+57 -1
View File
@@ -35,7 +35,7 @@ Note: Must be placed west/left of and R&D console to function.
create_reagents(0)
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_TITANIUM, MAT_BLUESPACE),
FALSE, list(/obj/item/stack, /obj/item/ore/bluespace_crystal), CALLBACK(src, .proc/is_insertion_ready))
FALSE, list(/obj/item/stack, /obj/item/ore/bluespace_crystal), CALLBACK(src, .proc/is_insertion_ready), CALLBACK(src, .proc/AfterMaterialInsert))
materials.precise_insertion = TRUE
return ..()
@@ -78,6 +78,7 @@ Note: Must be placed west/left of and R&D console to function.
linked_console.linked_lathe = null
..()
<<<<<<< HEAD
/obj/machinery/r_n_d/protolathe/ComponentActivated(datum/component/C)
..()
if(istype(C, /datum/component/material_container))
@@ -95,3 +96,58 @@ Note: Must be placed west/left of and R&D console to function.
use_power(max(1000, (MINERAL_MATERIAL_AMOUNT * M.last_amount_inserted / 10)))
add_overlay("protolathe_[stack_name]")
addtimer(CALLBACK(src, /atom/proc/cut_overlay, "protolathe_[stack_name]"), 10)
=======
/obj/machinery/rnd/protolathe/proc/user_try_print_id(id, amount)
if((!istype(linked_console) && requires_console) || !id)
return FALSE
if(istext(amount))
amount = text2num(amount)
if(isnull(amount))
amount = 1
var/datum/design/D = (linked_console || requires_console)? linked_console.stored_research.researched_designs[id] : get_techweb_design_by_id(id)
if(!istype(D))
return FALSE
if(D.make_reagents.len)
return FALSE
var/power = 1000
amount = Clamp(amount, 1, 10)
for(var/M in D.materials)
power += round(D.materials[M] * amount / 5)
power = max(3000, power)
use_power(power)
var/list/efficient_mats = list()
for(var/MAT in D.materials)
efficient_mats[MAT] = D.materials[MAT]*efficiency_coeff
if(!materials.has_materials(efficient_mats, amount))
say("Not enough materials to complete prototype[amount > 1? "s" : ""].")
return FALSE
for(var/R in D.reagents_list)
if(!reagents.has_reagent(R, D.reagents_list[R]*efficiency_coeff))
say("Not enough reagents to complete prototype[amount > 1? "s" : ""].")
return FALSE
materials.use_amount(efficient_mats, amount)
for(var/R in D.reagents_list)
reagents.remove_reagent(R, D.reagents_list[R]*efficiency_coeff)
busy = TRUE
flick("protolathe_n", src)
var/timecoeff = efficiency_coeff * D.lathe_time_factor
addtimer(CALLBACK(src, .proc/reset_busy), (32 * timecoeff * amount) ** 0.8)
addtimer(CALLBACK(src, .proc/do_print, D.build_path, amount, efficient_mats, D.dangerous_construction), (32 * timecoeff * amount) ** 0.8)
return TRUE
/obj/machinery/rnd/protolathe/proc/do_print(path, amount, list/matlist, notify_admins)
if(notify_admins && usr)
investigate_log("[key_name(usr)] built [amount] of [path] at a protolathe.", INVESTIGATE_RESEARCH)
message_admins("[ADMIN_LOOKUPFLW(usr)] has built [amount] of [path] at a protolathe")
for(var/i in 1 to amount)
var/obj/item/I = new path(get_turf(src))
if(!istype(I, /obj/item/stack/sheet) && !istype(I, /obj/item/ore/bluespace_crystal))
I.materials = matlist.Copy()
SSblackbox.record_feedback("nested_tally", "item_printed", amount, list("[type]", "[path]"))
>>>>>>> 3aba012... Removes ComponentActivated in favor of callbacks (#33274)
+12
View File
@@ -106,3 +106,15 @@
if(loaded_item)
loaded_item.forceMove(loc)
..()
/obj/machinery/rnd/proc/AfterMaterialInsert(type_inserted, id_inserted, amount_inserted)
var/stack_name
if(ispath(type_inserted, /obj/item/ore/bluespace_crystal))
stack_name = "bluespace"
use_power(MINERAL_MATERIAL_AMOUNT / 10)
else
var/obj/item/stack/S = type_inserted
stack_name = initial(S.name)
use_power(max(1000, (MINERAL_MATERIAL_AMOUNT * amount_inserted / 10)))
add_overlay("protolathe_[stack_name]")
addtimer(CALLBACK(src, /atom/proc/cut_overlay, "protolathe_[stack_name]"), 10)