Reapplies material componets

This commit is contained in:
Poojawa
2017-09-22 09:31:39 -05:00
parent 54bd982d6b
commit 573a81a4d9
20 changed files with 416 additions and 445 deletions
+9 -29
View File
@@ -5,59 +5,39 @@
desc = "Lost prototype of advanced clown tech. Powered by bananium, these shoes leave a trail of chaos in their wake."
icon_state = "clown_prototype_off"
var/on = FALSE
var/datum/material_container/bananium
actions_types = list(/datum/action/item_action/toggle)
/obj/item/clothing/shoes/clown_shoes/banana_shoes/New()
..()
bananium = new/datum/material_container(src,list(MAT_BANANIUM),200000)
/obj/item/clothing/shoes/clown_shoes/banana_shoes/Initialize()
. = ..()
AddComponent(/datum/component/material_container, list(MAT_BANANIUM), 200000, TRUE)
AddComponent(/datum/component/squeak, list('sound/items/bikehorn.ogg'=1), 75)
/obj/item/clothing/shoes/clown_shoes/banana_shoes/step_action()
. = ..()
if(on)
if(footstep > 1)//honks when its on
playsound(src, 'sound/items/bikehorn.ogg', 75, 1)
footstep = 0
else
footstep++
new/obj/item/grown/bananapeel/specialpeel(get_step(src,turn(usr.dir, 180))) //honk
GET_COMPONENT(bananium, /datum/component/material_container)
bananium.use_amount_type(100, MAT_BANANIUM)
if(bananium.amount(MAT_BANANIUM) < 100)
on = !on
flags_1 &= ~NOSLIP_1
update_icon()
to_chat(loc, "<span class='warning'>You ran out of bananium!</span>")
else
..()
/obj/item/clothing/shoes/clown_shoes/banana_shoes/attack_self(mob/user)
GET_COMPONENT(bananium, /datum/component/material_container)
var/sheet_amount = bananium.retrieve_all()
if(sheet_amount)
to_chat(user, "<span class='notice'>You retrieve [sheet_amount] sheets of bananium from the prototype shoes.</span>")
else
to_chat(user, "<span class='notice'>You cannot retrieve any bananium from the prototype shoes.</span>")
/obj/item/clothing/shoes/clown_shoes/banana_shoes/attackby(obj/item/O, mob/user, params)
if(!bananium.get_item_material_amount(O))
to_chat(user, "<span class='notice'>This item has no bananium!</span>")
return
if(!user.dropItemToGround(O))
to_chat(user, "<span class='notice'>You can't drop [O]!</span>")
return
var/bananium_amount = bananium.insert_item(O)
if(bananium_amount)
to_chat(user, "<span class='notice'>You insert [O] into the prototype shoes.</span>")
qdel(O)
else
to_chat(user, "<span class='notice'>You are unable to insert more bananium!</span>")
/obj/item/clothing/shoes/clown_shoes/banana_shoes/examine(mob/user)
..()
var/ban_amt = bananium.amount(MAT_BANANIUM)
to_chat(user, "<span class='notice'>The shoes are [on ? "enabled" : "disabled"]. There is [ban_amt ? ban_amt : "no"] bananium left.</span>")
to_chat(user, "<span class='notice'>The shoes are [on ? "enabled" : "disabled"]</span>")
/obj/item/clothing/shoes/clown_shoes/banana_shoes/ui_action_click(mob/user)
GET_COMPONENT(bananium, /datum/component/material_container)
if(bananium.amount(MAT_BANANIUM))
on = !on
update_icon()
+7 -3
View File
@@ -66,7 +66,6 @@
density = TRUE
anchored = TRUE
var/obj/machinery/mineral/CONSOLE = null
var/datum/material_container/materials
var/on = FALSE
var/selected_material = MAT_METAL
var/selected_alloy = null
@@ -75,12 +74,11 @@
/obj/machinery/mineral/processing_unit/Initialize()
. = ..()
proximity_monitor = new(src, 1)
materials = new(src, list(MAT_METAL, MAT_GLASS, MAT_SILVER, MAT_GOLD, MAT_DIAMOND, MAT_PLASMA, MAT_URANIUM, MAT_BANANIUM, MAT_TITANIUM, MAT_BLUESPACE),INFINITY)
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), INFINITY)
files = new /datum/research/smelter(src)
/obj/machinery/mineral/processing_unit/Destroy()
CONSOLE = null
QDEL_NULL(materials)
QDEL_NULL(files)
return ..()
@@ -89,6 +87,7 @@
process_ore(AM)
/obj/machinery/mineral/processing_unit/proc/process_ore(obj/item/ore/O)
GET_COMPONENT(materials, /datum/component/material_container)
var/material_amount = materials.get_item_material_amount(O)
if(!materials.has_space(material_amount))
unload_mineral(O)
@@ -100,6 +99,7 @@
/obj/machinery/mineral/processing_unit/proc/get_machine_data()
var/dat = "<b>Smelter control console</b><br><br>"
GET_COMPONENT(materials, /datum/component/material_container)
for(var/mat_id in materials.materials)
var/datum/material/M = materials.materials[mat_id]
dat += "<span class=\"res_name\">[M.name]: </span>[M.amount] cm&sup3;"
@@ -165,6 +165,7 @@
continue*/
/obj/machinery/mineral/processing_unit/proc/smelt_ore()
GET_COMPONENT(materials, /datum/component/material_container)
var/datum/material/mat = materials.materials[selected_material]
if(mat)
var/sheets_to_remove = (mat.amount >= (MINERAL_MATERIAL_AMOUNT * SMELT_AMOUNT) ) ? SMELT_AMOUNT : round(mat.amount / MINERAL_MATERIAL_AMOUNT)
@@ -187,6 +188,7 @@
on = FALSE
return
GET_COMPONENT(materials, /datum/component/material_container)
materials.use_amount(alloy.materials, amount)
generate_mineral(alloy.build_path)
@@ -197,6 +199,7 @@
var/build_amount = SMELT_AMOUNT
GET_COMPONENT(materials, /datum/component/material_container)
for(var/mat_id in D.materials)
var/M = D.materials[mat_id]
@@ -214,6 +217,7 @@
unload_mineral(O)
/obj/machinery/mineral/processing_unit/on_deconstruction()
GET_COMPONENT(materials, /datum/component/material_container)
materials.retrieve_all()
..()
+8 -10
View File
@@ -22,17 +22,15 @@
var/list/ore_values = list(MAT_GLASS = 1, MAT_METAL = 1, MAT_PLASMA = 15, MAT_SILVER = 16, MAT_GOLD = 18, MAT_TITANIUM = 30, MAT_URANIUM = 30, MAT_DIAMOND = 50, MAT_BLUESPACE = 50, MAT_BANANIUM = 60)
var/message_sent = FALSE
var/list/ore_buffer = list()
var/datum/material_container/materials
var/datum/research/files
var/obj/item/disk/design_disk/inserted_disk
/obj/machinery/mineral/ore_redemption/Initialize()
. = ..()
materials = new(src, list(MAT_METAL, MAT_GLASS, MAT_SILVER, MAT_GOLD, MAT_DIAMOND, MAT_PLASMA, MAT_URANIUM, MAT_BANANIUM, MAT_TITANIUM, MAT_BLUESPACE),INFINITY)
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),INFINITY)
files = new /datum/research/smelter(src)
/obj/machinery/mineral/ore_redemption/Destroy()
QDEL_NULL(materials)
QDEL_NULL(files)
return ..()
@@ -57,6 +55,7 @@
if(O && O.refined_type)
points += O.points * point_upgrade
GET_COMPONENT(materials, /datum/component/material_container)
var/material_amount = materials.get_item_material_amount(O)
if(!material_amount)
@@ -75,6 +74,7 @@
var/build_amount = 0
GET_COMPONENT(materials, /datum/component/material_container)
for(var/mat_id in D.materials)
var/M = D.materials[mat_id]
var/datum/material/redemption_mat = materials.materials[mat_id]
@@ -110,6 +110,7 @@
var/has_minerals = FALSE
GET_COMPONENT(materials, /datum/component/material_container)
for(var/mat_id in materials.materials)
var/datum/material/M = materials.materials[mat_id]
var/mineral_amount = M.amount / MINERAL_MATERIAL_AMOUNT
@@ -148,6 +149,7 @@
/obj/machinery/mineral/ore_redemption/attackby(obj/item/W, mob/user, params)
if(exchange_parts(user, W))
return
GET_COMPONENT(materials, /datum/component/material_container)
if(default_pry_open(W))
materials.retrieve_all()
return
@@ -181,16 +183,10 @@
if(user.transferItemToLoc(W, src))
inserted_disk = W
return TRUE
if(istype(W, /obj/item/stack/sheet))
var/obj/item/stack/sheet/S = W
var/inserted = materials.insert_stack(S, S.amount)
to_chat(user, "<span class='notice'>You add [inserted] [S] sheets to \the [src].</span>")
return
return ..()
/obj/machinery/mineral/ore_redemption/on_deconstruction()
GET_COMPONENT(materials, /datum/component/material_container)
materials.retrieve_all()
..()
@@ -213,6 +209,7 @@
data["claimedPoints"] = inserted_id.mining_points
data["materials"] = list()
GET_COMPONENT(materials, /datum/component/material_container)
for(var/mat_id in materials.materials)
var/datum/material/M = materials.materials[mat_id]
var/sheet_amount = M.amount ? M.amount / MINERAL_MATERIAL_AMOUNT : "0"
@@ -236,6 +233,7 @@
/obj/machinery/mineral/ore_redemption/ui_act(action, params)
if(..())
return
GET_COMPONENT(materials, /datum/component/material_container)
switch(action)
if("Eject")
if(!inserted_id)
+95 -99
View File
@@ -1,107 +1,103 @@
/**********************Mint**************************/
/obj/machinery/mineral/mint
name = "coin press"
icon = 'icons/obj/economy.dmi'
icon_state = "coinpress0"
/**********************Mint**************************/
/obj/machinery/mineral/mint
name = "coin press"
icon = 'icons/obj/economy.dmi'
icon_state = "coinpress0"
density = TRUE
anchored = TRUE
var/datum/material_container/materials
var/newCoins = 0 //how many coins the machine made in it's last load
var/newCoins = 0 //how many coins the machine made in it's last load
var/processing = FALSE
var/chosen = MAT_METAL //which material will be used to make coins
var/coinsToProduce = 10
speed_process = 1
var/chosen = MAT_METAL //which material will be used to make coins
var/coinsToProduce = 10
speed_process = 1
/obj/machinery/mineral/mint/Initialize()
. = ..()
materials = new /datum/material_container(src,
list(MAT_METAL, MAT_PLASMA, MAT_SILVER, MAT_GOLD, MAT_URANIUM, MAT_DIAMOND, MAT_BANANIUM),
max_amt = MINERAL_MATERIAL_AMOUNT*50)
/obj/machinery/mineral/mint/Destroy()
QDEL_NULL(materials)
return ..()
/obj/machinery/mineral/mint/process()
var/turf/T = get_step(src, input_dir)
if(!T)
return
for(var/obj/item/stack/sheet/O in T)
materials.insert_stack(O, O.amount)
/obj/machinery/mineral/mint/attack_hand(mob/user)
var/dat = "<b>Coin Press</b><br>"
for(var/mat_id in materials.materials)
var/datum/material/M = materials.materials[mat_id]
if(!M.amount && chosen != mat_id)
continue
dat += "<br><b>[M.name] amount:</b> [M.amount] cm<sup>3</sup> "
if (chosen == mat_id)
dat += "<b>Chosen</b>"
else
dat += "<A href='?src=\ref[src];choose=[mat_id]'>Choose</A>"
var/datum/material/M = materials.materials[chosen]
dat += "<br><br>Will produce [coinsToProduce] [lowertext(M.name)] coins if enough materials are available.<br>"
dat += "<A href='?src=\ref[src];chooseAmt=-10'>-10</A> "
dat += "<A href='?src=\ref[src];chooseAmt=-5'>-5</A> "
dat += "<A href='?src=\ref[src];chooseAmt=-1'>-1</A> "
dat += "<A href='?src=\ref[src];chooseAmt=1'>+1</A> "
dat += "<A href='?src=\ref[src];chooseAmt=5'>+5</A> "
dat += "<A href='?src=\ref[src];chooseAmt=10'>+10</A> "
dat += "<br><br>In total this machine produced <font color='green'><b>[newCoins]</b></font> coins."
dat += "<br><A href='?src=\ref[src];makeCoins=[1]'>Make coins</A>"
user << browse(dat, "window=mint")
/obj/machinery/mineral/mint/Topic(href, href_list)
if(..())
return
usr.set_machine(src)
src.add_fingerprint(usr)
if(processing==1)
to_chat(usr, "<span class='notice'>The machine is processing.</span>")
return
if(href_list["choose"])
if(materials.materials[href_list["choose"]])
chosen = href_list["choose"]
if(href_list["chooseAmt"])
coinsToProduce = Clamp(coinsToProduce + text2num(href_list["chooseAmt"]), 0, 1000)
if(href_list["makeCoins"])
var/temp_coins = coinsToProduce
AddComponent(/datum/component/material_container, list(MAT_METAL, MAT_PLASMA, MAT_SILVER, MAT_GOLD, MAT_URANIUM, MAT_DIAMOND, MAT_BANANIUM), MINERAL_MATERIAL_AMOUNT * 50)
/obj/machinery/mineral/mint/process()
var/turf/T = get_step(src, input_dir)
if(!T)
return
GET_COMPONENT(materials, /datum/component/material_container)
for(var/obj/item/stack/sheet/O in T)
materials.insert_stack(O, O.amount)
/obj/machinery/mineral/mint/attack_hand(mob/user)
var/dat = "<b>Coin Press</b><br>"
GET_COMPONENT(materials, /datum/component/material_container)
for(var/mat_id in materials.materials)
var/datum/material/M = materials.materials[mat_id]
if(!M.amount && chosen != mat_id)
continue
dat += "<br><b>[M.name] amount:</b> [M.amount] cm<sup>3</sup> "
if (chosen == mat_id)
dat += "<b>Chosen</b>"
else
dat += "<A href='?src=\ref[src];choose=[mat_id]'>Choose</A>"
var/datum/material/M = materials.materials[chosen]
dat += "<br><br>Will produce [coinsToProduce] [lowertext(M.name)] coins if enough materials are available.<br>"
dat += "<A href='?src=\ref[src];chooseAmt=-10'>-10</A> "
dat += "<A href='?src=\ref[src];chooseAmt=-5'>-5</A> "
dat += "<A href='?src=\ref[src];chooseAmt=-1'>-1</A> "
dat += "<A href='?src=\ref[src];chooseAmt=1'>+1</A> "
dat += "<A href='?src=\ref[src];chooseAmt=5'>+5</A> "
dat += "<A href='?src=\ref[src];chooseAmt=10'>+10</A> "
dat += "<br><br>In total this machine produced <font color='green'><b>[newCoins]</b></font> coins."
dat += "<br><A href='?src=\ref[src];makeCoins=[1]'>Make coins</A>"
user << browse(dat, "window=mint")
/obj/machinery/mineral/mint/Topic(href, href_list)
if(..())
return
usr.set_machine(src)
src.add_fingerprint(usr)
if(processing==1)
to_chat(usr, "<span class='notice'>The machine is processing.</span>")
return
GET_COMPONENT(materials, /datum/component/material_container)
if(href_list["choose"])
if(materials.materials[href_list["choose"]])
chosen = href_list["choose"]
if(href_list["chooseAmt"])
coinsToProduce = Clamp(coinsToProduce + text2num(href_list["chooseAmt"]), 0, 1000)
if(href_list["makeCoins"])
var/temp_coins = coinsToProduce
processing = TRUE
icon_state = "coinpress1"
var/coin_mat = MINERAL_MATERIAL_AMOUNT * 0.2
var/datum/material/M = materials.materials[chosen]
if(!M || !M.coin_type)
updateUsrDialog()
return
while(coinsToProduce > 0 && materials.use_amount_type(coin_mat, chosen))
create_coins(M.coin_type)
coinsToProduce--
newCoins++
src.updateUsrDialog()
sleep(5)
icon_state = "coinpress0"
icon_state = "coinpress1"
var/coin_mat = MINERAL_MATERIAL_AMOUNT * 0.2
var/datum/material/M = materials.materials[chosen]
if(!M || !M.coin_type)
updateUsrDialog()
return
while(coinsToProduce > 0 && materials.use_amount_type(coin_mat, chosen))
create_coins(M.coin_type)
coinsToProduce--
newCoins++
src.updateUsrDialog()
sleep(5)
icon_state = "coinpress0"
processing = FALSE
coinsToProduce = temp_coins
src.updateUsrDialog()
return
/obj/machinery/mineral/mint/proc/create_coins(P)
var/turf/T = get_step(src,output_dir)
if(T)
var/obj/item/O = new P(src)
var/obj/item/storage/bag/money/M = locate(/obj/item/storage/bag/money, T)
if(!M)
M = new /obj/item/storage/bag/money(src)
unload_mineral(M)
coinsToProduce = temp_coins
src.updateUsrDialog()
return
/obj/machinery/mineral/mint/proc/create_coins(P)
var/turf/T = get_step(src,output_dir)
if(T)
var/obj/item/O = new P(src)
var/obj/item/storage/bag/money/M = locate(/obj/item/storage/bag/money, T)
if(!M)
M = new /obj/item/storage/bag/money(src)
unload_mineral(M)
O.loc = M
+20 -53
View File
@@ -11,7 +11,6 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis).
container_type = OPENCONTAINER_1
circuit = /obj/item/circuitboard/machine/circuit_imprinter
var/datum/material_container/materials
var/efficiency_coeff
var/list/categories = list(
@@ -29,20 +28,18 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis).
)
/obj/machinery/r_n_d/circuit_imprinter/Initialize()
materials = new(src, list(MAT_GLASS, MAT_GOLD, MAT_DIAMOND, MAT_METAL, MAT_BLUESPACE))
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))
create_reagents(0)
return ..()
/obj/machinery/r_n_d/circuit_imprinter/Destroy()
QDEL_NULL(materials)
return ..()
/obj/machinery/r_n_d/circuit_imprinter/RefreshParts()
reagents.maximum_volume = 0
for(var/obj/item/reagent_containers/glass/G in component_parts)
reagents.maximum_volume += G.volume
G.reagents.trans_to(src, G.reagents.total_volume)
GET_COMPONENT(materials, /datum/component/material_container)
materials.max_amount = 0
for(var/obj/item/stock_parts/matter_bin/M in component_parts)
materials.max_amount += M.rating * 75000
@@ -59,6 +56,7 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis).
/obj/machinery/r_n_d/circuit_imprinter/proc/check_mat(datum/design/being_built, M) // now returns how many times the item can be built with the material
var/list/all_materials = being_built.reagents_list + being_built.materials
GET_COMPONENT(materials, /datum/component/material_container)
var/A = materials.amount(M)
if(!A)
A = reagents.get_reagent_amount(M)
@@ -69,6 +67,7 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis).
/obj/machinery/r_n_d/circuit_imprinter/on_deconstruction()
for(var/obj/item/reagent_containers/glass/G in component_parts)
reagents.trans_to(G, G.reagents.maximum_volume)
GET_COMPONENT(materials, /datum/component/material_container)
materials.retrieve_all()
..()
@@ -77,52 +76,20 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis).
linked_console.linked_imprinter = null
..()
/obj/machinery/r_n_d/circuit_imprinter/Insert_Item(obj/item/O, mob/user)
if(istype(O, /obj/item/stack/sheet))
. = 1
if(!is_insertion_ready(user))
/obj/machinery/r_n_d/circuit_imprinter/ComponentActivated(datum/component/C)
..()
if(istype(C, /datum/component/material_container))
var/datum/component/material_container/M = C
if(!M.last_insert_success)
return
var/sheet_material = materials.get_item_material_amount(O)
if(!sheet_material)
return
if(!materials.has_space(sheet_material))
to_chat(user, "<span class='warning'>The [src.name]'s material bin is full! Please remove material before adding more.</span>")
return 1
var/obj/item/stack/sheet/stack = O
var/amount = round(input("How many sheets do you want to add?") as num)//No decimals
if(!in_range(src, stack) || !user.Adjacent(src))
return
var/amount_inserted = materials.insert_stack(O,amount)
if(!amount_inserted)
return 1
var/lit = M.last_inserted_type
var/stack_name
if(ispath(lit, /obj/item/ore/bluespace_crystal))
stack_name = "bluespace"
use_power(MINERAL_MATERIAL_AMOUNT / 10)
else
use_power(max(1000, (MINERAL_MATERIAL_AMOUNT*amount_inserted/10)))
to_chat(user, "<span class='notice'>You add [amount_inserted] sheets to the [src.name].</span>")
updateUsrDialog()
else if(istype(O, /obj/item/ore/bluespace_crystal)) //Bluespace crystals can be either a stack or an item
. = 1
if(!is_insertion_ready(user))
return
var/bs_material = materials.get_item_material_amount(O)
if(!bs_material)
return
if(!materials.has_space(bs_material))
to_chat(user, "<span class='warning'>The [src.name]'s material bin is full! Please remove material before adding more.</span>")
return 1
materials.insert_item(O)
use_power(MINERAL_MATERIAL_AMOUNT/10)
to_chat(user, "<span class='notice'>You add [O] to the [src.name].</span>")
qdel(O)
updateUsrDialog()
else if(user.a_intent != INTENT_HARM)
to_chat(user, "<span class='warning'>You cannot insert this item into the [name]!</span>")
return 1
else
return 0
var/obj/item/stack/S = lit
stack_name = initial(S.name)
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)
+2 -1
View File
@@ -418,8 +418,9 @@
if(exp == SCANTYPE_OBLITERATE)
visible_message("<span class='warning'>[exp_on] activates the crushing mechanism, [exp_on] is destroyed!</span>")
if(linked_console.linked_lathe)
GET_COMPONENT_FROM(linked_materials, /datum/component/material_container, linked_console.linked_lathe)
for(var/material in exp_on.materials)
linked_console.linked_lathe.materials.insert_amount( min((linked_console.linked_lathe.materials.max_amount - linked_console.linked_lathe.materials.total_amount), (exp_on.materials[material])), material)
linked_materials.insert_amount( min((linked_materials.max_amount - linked_materials.total_amount), (exp_on.materials[material])), material)
if(prob(EFFECT_PROB_LOW) && criticalReaction)
visible_message("<span class='warning'>[src]'s crushing mechanism slowly and smoothly descends, flattening the [exp_on]!</span>")
new /obj/item/stack/sheet/plasteel(get_turf(pick(oview(1,src))))
+21 -64
View File
@@ -14,7 +14,6 @@ Note: Must be placed west/left of and R&D console to function.
container_type = OPENCONTAINER_1
circuit = /obj/item/circuitboard/machine/protolathe
var/datum/material_container/materials
var/efficiency_coeff
var/list/categories = list(
@@ -34,11 +33,9 @@ Note: Must be placed west/left of and R&D console to function.
/obj/machinery/r_n_d/protolathe/Initialize()
create_reagents(0)
materials = new(src, list(MAT_METAL, MAT_GLASS, MAT_SILVER, MAT_GOLD, MAT_DIAMOND, MAT_PLASMA, MAT_URANIUM, MAT_BANANIUM, MAT_TITANIUM, MAT_BLUESPACE))
return ..()
/obj/machinery/r_n_d/protolathe/Destroy()
QDEL_NULL(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))
return ..()
/obj/machinery/r_n_d/protolathe/RefreshParts()
@@ -47,6 +44,7 @@ Note: Must be placed west/left of and R&D console to function.
reagents.maximum_volume += G.volume
G.reagents.trans_to(src, G.reagents.total_volume)
GET_COMPONENT(materials, /datum/component/material_container)
materials.max_amount = 0
for(var/obj/item/stock_parts/matter_bin/M in component_parts)
materials.max_amount += M.rating * 75000
@@ -59,6 +57,7 @@ Note: Must be placed west/left of and R&D console to function.
/obj/machinery/r_n_d/protolathe/proc/check_mat(datum/design/being_built, M) // now returns how many times the item can be built with the material
var/list/all_materials = being_built.reagents_list + being_built.materials
GET_COMPONENT(materials, /datum/component/material_container)
var/A = materials.amount(M)
if(!A)
A = reagents.get_reagent_amount(M)
@@ -69,6 +68,7 @@ Note: Must be placed west/left of and R&D console to function.
/obj/machinery/r_n_d/protolathe/on_deconstruction()
for(var/obj/item/reagent_containers/glass/G in component_parts)
reagents.trans_to(G, G.reagents.maximum_volume)
GET_COMPONENT(materials, /datum/component/material_container)
materials.retrieve_all()
..()
@@ -77,63 +77,20 @@ Note: Must be placed west/left of and R&D console to function.
linked_console.linked_lathe = null
..()
/obj/machinery/r_n_d/protolathe/Insert_Item(obj/item/O, mob/user)
if(istype(O, /obj/item/stack/sheet))
. = 1
if(!is_insertion_ready(user))
/obj/machinery/r_n_d/protolathe/ComponentActivated(datum/component/C)
..()
if(istype(C, /datum/component/material_container))
var/datum/component/material_container/M = C
if(!M.last_insert_success)
return
var/sheet_material = materials.get_item_material_amount(O)
if(!sheet_material)
return
if(!materials.has_space(sheet_material))
to_chat(user, "<span class='warning'>The [src.name]'s material bin is full! Please remove material before adding more.</span>")
return 1
var/obj/item/stack/sheet/stack = O
var/amount = round(input("How many sheets do you want to add?") as num)//No decimals
if(!in_range(src, stack) || !user.Adjacent(src))
return
var/amount_inserted = materials.insert_stack(O,amount)
if(!amount_inserted)
return 1
var/lit = M.last_inserted_type
var/stack_name
if(ispath(lit, /obj/item/ore/bluespace_crystal))
stack_name = "bluespace"
use_power(MINERAL_MATERIAL_AMOUNT / 10)
else
var/stack_name = stack.name
busy = TRUE
use_power(max(1000, (MINERAL_MATERIAL_AMOUNT*amount_inserted/10)))
to_chat(user, "<span class='notice'>You add [amount_inserted] sheets to the [src.name].</span>")
add_overlay("protolathe_[stack_name]")
sleep(10)
cut_overlay("protolathe_[stack_name]")
busy = FALSE
updateUsrDialog()
else if(istype(O, /obj/item/ore/bluespace_crystal)) //Bluespace crystals can be either a stack or an item
. = 1
if(!is_insertion_ready(user))
return
var/bs_material = materials.get_item_material_amount(O)
if(!bs_material)
return
if(!materials.has_space(bs_material))
to_chat(user, "<span class='warning'>The [src.name]'s material bin is full! Please remove material before adding more.</span>")
return 1
materials.insert_item(O)
busy = TRUE
use_power(MINERAL_MATERIAL_AMOUNT/10)
to_chat(user, "<span class='notice'>You add [O] to the [src.name].</span>")
qdel(O)
add_overlay("protolathe_bluespace")
sleep(10)
cut_overlay("protolathe_bluespace")
busy = FALSE
updateUsrDialog()
else if(user.a_intent != INTENT_HARM)
to_chat(user, "<span class='warning'>You cannot insert this item into the [name]!</span>")
return 1
else
return 0
var/obj/item/stack/S = lit
stack_name = initial(S.name)
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)
+34 -17
View File
@@ -169,6 +169,15 @@ won't update every console in existence) but it's more of a hassle to do. Also,
if(href_list["menu"]) //Switches menu screens. Converts a sent text string into a number. Saves a LOT of code.
var/temp_screen = text2num(href_list["menu"])
screen = temp_screen
var/datum/component/material_container/linked_materials
if(linked_lathe)
linked_materials = linked_lathe.GetComponent(/datum/component/material_container)
var/datum/component/material_container/imprinter_materials
if(linked_imprinter)
imprinter_materials = linked_imprinter.GetComponent(/datum/component/material_container)
if(href_list["category"])
selected_category = href_list["category"]
@@ -315,7 +324,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
if(linked_lathe) //Also sends salvaged materials to a linked protolathe, if any.
for(var/material in linked_destroy.loaded_item.materials)
linked_lathe.materials.insert_amount(min((linked_lathe.materials.max_amount - linked_lathe.materials.total_amount), (linked_destroy.loaded_item.materials[material]*(linked_destroy.decon_mod/10))), material)
linked_materials.insert_amount(min((linked_materials.max_amount - linked_materials.total_amount), (linked_destroy.loaded_item.materials[material]*(linked_destroy.decon_mod/10))), material)
SSblackbox.add_details("item_deconstructed","[linked_destroy.loaded_item.type]")
linked_destroy.loaded_item = null
for(var/obj/I in linked_destroy.contents)
@@ -421,7 +430,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
for(var/MAT in being_built.materials)
efficient_mats[MAT] = being_built.materials[MAT]*coeff
if(!linked_lathe.materials.has_materials(efficient_mats, amount))
if(!linked_materials.has_materials(efficient_mats, amount))
linked_lathe.say("Not enough materials to complete prototype.")
enough_materials = 0
g2g = 0
@@ -433,7 +442,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
g2g = 0
if(enough_materials)
linked_lathe.materials.use_amount(efficient_mats, amount)
linked_materials.use_amount(efficient_mats, amount)
for(var/R in being_built.reagents_list)
linked_lathe.reagents.remove_reagent(R, being_built.reagents_list[R]*coeff)
@@ -497,7 +506,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
for(var/MAT in being_built.materials)
efficient_mats[MAT] = being_built.materials[MAT]/coeff
if(!linked_imprinter.materials.has_materials(efficient_mats))
if(!imprinter_materials.has_materials(efficient_mats))
linked_imprinter.say("Not enough materials to complete prototype.")
enough_materials = 0
g2g = 0
@@ -509,7 +518,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
g2g = 0
if(enough_materials)
linked_imprinter.materials.use_amount(efficient_mats)
imprinter_materials.use_amount(efficient_mats)
for(var/R in being_built.reagents_list)
linked_imprinter.reagents.remove_reagent(R, being_built.reagents_list[R]/coeff)
@@ -536,7 +545,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
linked_lathe.reagents.clear_reagents()
else if(href_list["ejectsheet"] && linked_lathe) //Causes the protolathe to eject a sheet of material
linked_lathe.materials.retrieve_sheets(text2num(href_list["eject_amt"]), href_list["ejectsheet"])
linked_materials.retrieve_sheets(text2num(href_list["eject_amt"]), href_list["ejectsheet"])
//Circuit Imprinter Materials
else if(href_list["disposeI"] && linked_imprinter) //Causes the circuit imprinter to dispose of a single reagent (all of it)
@@ -546,7 +555,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
linked_imprinter.reagents.clear_reagents()
else if(href_list["imprinter_ejectsheet"] && linked_imprinter) //Causes the imprinter to eject a sheet of material
linked_imprinter.materials.retrieve_sheets(text2num(href_list["eject_amt"]), href_list["imprinter_ejectsheet"])
imprinter_materials.retrieve_sheets(text2num(href_list["eject_amt"]), href_list["imprinter_ejectsheet"])
else if(href_list["find_device"]) //The R&D console looks for devices nearby to link up with.
@@ -634,6 +643,14 @@ won't update every console in existence) but it's more of a hassle to do. Also,
if(linked_imprinter == null)
screen = 4.0
var/datum/component/material_container/linked_materials
if(linked_lathe)
linked_materials = linked_lathe.GetComponent(/datum/component/material_container)
var/datum/component/material_container/imprinter_materials
if(linked_imprinter)
imprinter_materials = linked_imprinter.GetComponent(/datum/component/material_container)
switch(screen)
//////////////////////R&D CONSOLE SCREENS//////////////////
@@ -823,7 +840,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
dat += "<A href='?src=\ref[src];menu=3.2'>Material Storage</A>"
dat += "<A href='?src=\ref[src];menu=3.3'>Chemical Storage</A><div class='statusDisplay'>"
dat += "<h3>Protolathe Menu:</h3><BR>"
dat += "<B>Material Amount:</B> [linked_lathe.materials.total_amount] / [linked_lathe.materials.max_amount]<BR>"
dat += "<B>Material Amount:</B> [linked_materials.total_amount] / [linked_materials.max_amount]<BR>"
dat += "<B>Chemical Volume:</B> [linked_lathe.reagents.total_volume] / [linked_lathe.reagents.maximum_volume]<BR>"
dat += "<form name='search' action='?src=\ref[src]'>\
@@ -841,7 +858,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
dat += "<A href='?src=\ref[src];menu=1.0'>Main Menu</A>"
dat += "<A href='?src=\ref[src];menu=3.1'>Protolathe Menu</A>"
dat += "<div class='statusDisplay'><h3>Browsing [selected_category]:</h3><BR>"
dat += "<B>Material Amount:</B> [linked_lathe.materials.total_amount] / [linked_lathe.materials.max_amount]<BR>"
dat += "<B>Material Amount:</B> [linked_materials.total_amount] / [linked_materials.max_amount]<BR>"
dat += "<B>Chemical Volume:</B> [linked_lathe.reagents.total_volume] / [linked_lathe.reagents.maximum_volume]<HR>"
var/coeff = linked_lathe.efficiency_coeff
@@ -879,7 +896,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
dat += "<A href='?src=\ref[src];menu=1.0'>Main Menu</A>"
dat += "<A href='?src=\ref[src];menu=3.1'>Protolathe Menu</A>"
dat += "<div class='statusDisplay'><h3>Search results:</h3><BR>"
dat += "<B>Material Amount:</B> [linked_lathe.materials.total_amount] / [linked_lathe.materials.max_amount]<BR>"
dat += "<B>Material Amount:</B> [linked_materials.total_amount] / [linked_materials.max_amount]<BR>"
dat += "<B>Chemical Volume:</B> [linked_lathe.reagents.total_volume] / [linked_lathe.reagents.maximum_volume]<HR>"
var/coeff = linked_lathe.efficiency_coeff
@@ -916,8 +933,8 @@ won't update every console in existence) but it's more of a hassle to do. Also,
if(!linked_lathe)
dat += "ERROR: Protolathe connection failed."
else
for(var/mat_id in linked_lathe.materials.materials)
var/datum/material/M = linked_lathe.materials.materials[mat_id]
for(var/mat_id in linked_materials.materials)
var/datum/material/M = linked_materials.materials[mat_id]
dat += "* [M.amount] of [M.name]: "
if(M.amount >= MINERAL_MATERIAL_AMOUNT) dat += "<A href='?src=\ref[src];ejectsheet=[M.id];eject_amt=1'>Eject</A> "
if(M.amount >= MINERAL_MATERIAL_AMOUNT*5) dat += "<A href='?src=\ref[src];ejectsheet=[M.id];eject_amt=5'>5x</A> "
@@ -944,7 +961,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
dat += "<A href='?src=\ref[src];menu=4.3'>Material Storage</A>"
dat += "<A href='?src=\ref[src];menu=4.2'>Chemical Storage</A><div class='statusDisplay'>"
dat += "<h3>Circuit Imprinter Menu:</h3><BR>"
dat += "Material Amount: [linked_imprinter.materials.total_amount]<BR>"
dat += "Material Amount: [imprinter_materials.total_amount]<BR>"
dat += "Chemical Volume: [linked_imprinter.reagents.total_volume]<HR>"
dat += "<form name='search' action='?src=\ref[src]'>\
@@ -961,7 +978,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
dat += "<A href='?src=\ref[src];menu=1.0'>Main Menu</A>"
dat += "<A href='?src=\ref[src];menu=4.1'>Circuit Imprinter Menu</A>"
dat += "<div class='statusDisplay'><h3>Browsing [selected_category]:</h3><BR>"
dat += "Material Amount: [linked_imprinter.materials.total_amount]<BR>"
dat += "Material Amount: [imprinter_materials.total_amount]<BR>"
dat += "Chemical Volume: [linked_imprinter.reagents.total_volume]<HR>"
var/coeff = linked_imprinter.efficiency_coeff
@@ -991,7 +1008,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
dat += "<A href='?src=\ref[src];menu=1.0'>Main Menu</A>"
dat += "<A href='?src=\ref[src];menu=4.1'>Circuit Imprinter Menu</A>"
dat += "<div class='statusDisplay'><h3>Search results:</h3><BR>"
dat += "Material Amount: [linked_imprinter.materials.total_amount]<BR>"
dat += "Material Amount: [imprinter_materials.total_amount]<BR>"
dat += "Chemical Volume: [linked_imprinter.reagents.total_volume]<HR>"
var/coeff = linked_imprinter.efficiency_coeff
@@ -1028,8 +1045,8 @@ won't update every console in existence) but it's more of a hassle to do. Also,
if(!linked_imprinter)
dat += "ERROR: Protolathe connection failed."
else
for(var/mat_id in linked_imprinter.materials.materials)
var/datum/material/M = linked_imprinter.materials.materials[mat_id]
for(var/mat_id in imprinter_materials.materials)
var/datum/material/M = imprinter_materials.materials[mat_id]
dat += "* [M.amount] of [M.name]: "
if(M.amount >= MINERAL_MATERIAL_AMOUNT) dat += "<A href='?src=\ref[src];imprinter_ejectsheet=[M.id];eject_amt=1'>Eject</A> "
if(M.amount >= MINERAL_MATERIAL_AMOUNT*5) dat += "<A href='?src=\ref[src];imprinter_ejectsheet=[M.id];eject_amt=5'>5x</A> "