Files
fulpstation/code/modules/mining/machine_processing.dm
Qustinnus b33d1c49a3 [READY] Floydmats (Datum materials) & custom toolboxes (#45118)
* Initial work

* more

* ass

* wsedfwedff

* asss

* test

* stuff

* fuck

* sss

a

* kms

* asdadwedwdfwefwef

* start

* test

* dwwdew

* ewefwfef

* Redemption machine (#8)

* Redemption machine

* Removes debug messages

* changes

* fuckmyshitup

* coin mint works with new material shenanigans (#10)

* Auto stash before merge of "materials" and "origin/materials"

* woops

* furnace (#11)

* autolathe manufacturing of toolboxes

* eggs in a basket

* some small changes

* matcolors

* documentation

* more documentation and effects

* done

* Color man bad (#12)

* fixes designs

* ass

* more fixes

* fuck me

* firestacks adder

* epic fixes

* fixes designs

* DONE DIDDILY DOO

* removes category macro

* ch-ch-ch-changes

* fixes some stuff

* Fixes display of ore values (#9)

* Redemption machine

* Removes debug messages

* Re-adds value display

* Replaces the fire stacking component with an element instead (#13)

* fixes examine

* fixes ligma bugs

* double ligma boofus

* fix

* misses some defines

* fixes ORM

* Update code/datums/components/material_container.dm

Co-Authored-By: Emmett Gaines <ninjanomnom@gmail.com>

* fixes

* Makes glass objects weaker (#14)

* Makes glass objects weaker

* uses correct proc

* fixes shit

* honk honk

* better

* oh shit oh fuck

* fixes

* fuck ORMs

* fixes the biogen

* documentation

* ass (#15)

* component

* changes

* ass

* ass

* doc

* Auto stash before merge of "materials-plasmacomponent" and "origin/materials-plasmacomponent"

* fixes rounding

* fixed
2019-07-24 11:27:01 -04:00

212 lines
6.5 KiB
Plaintext

#define SMELT_AMOUNT 10
/**********************Mineral processing unit console**************************/
/obj/machinery/mineral
var/input_dir = NORTH
var/output_dir = SOUTH
/obj/machinery/mineral/proc/unload_mineral(atom/movable/S)
S.forceMove(drop_location())
var/turf/T = get_step(src,output_dir)
if(T)
S.forceMove(T)
/obj/machinery/mineral/processing_unit_console
name = "production machine console"
icon = 'icons/obj/machines/mining_machines.dmi'
icon_state = "console"
density = TRUE
var/obj/machinery/mineral/processing_unit/machine = null
var/machinedir = EAST
speed_process = TRUE
/obj/machinery/mineral/processing_unit_console/Initialize()
. = ..()
machine = locate(/obj/machinery/mineral/processing_unit, get_step(src, machinedir))
if (machine)
machine.CONSOLE = src
else
return INITIALIZE_HINT_QDEL
/obj/machinery/mineral/processing_unit_console/ui_interact(mob/user)
. = ..()
if(!machine)
return
var/dat = machine.get_machine_data()
var/datum/browser/popup = new(user, "processing", "Smelting Console", 300, 500)
popup.set_content(dat)
popup.open()
/obj/machinery/mineral/processing_unit_console/Topic(href, href_list)
if(..())
return
usr.set_machine(src)
add_fingerprint(usr)
if(href_list["material"])
var/datum/material/new_material = locate(href_list["material"])
if(istype(new_material))
machine.selected_material = new_material
machine.selected_alloy = null
if(href_list["alloy"])
machine.selected_material = null
machine.selected_alloy = href_list["alloy"]
if(href_list["set_on"])
machine.on = (href_list["set_on"] == "on")
updateUsrDialog()
return
/obj/machinery/mineral/processing_unit_console/Destroy()
machine = null
return ..()
/**********************Mineral processing unit**************************/
/obj/machinery/mineral/processing_unit
name = "furnace"
icon = 'icons/obj/machines/mining_machines.dmi'
icon_state = "furnace"
density = TRUE
var/obj/machinery/mineral/CONSOLE = null
var/on = FALSE
var/datum/material/selected_material = null
var/selected_alloy = null
var/datum/techweb/stored_research
/obj/machinery/mineral/processing_unit/Initialize()
. = ..()
proximity_monitor = new(src, 1)
AddComponent(/datum/component/material_container, list(/datum/material/iron, /datum/material/glass, /datum/material/silver, /datum/material/gold, /datum/material/diamond, /datum/material/plasma, /datum/material/uranium, /datum/material/bananium, /datum/material/titanium, /datum/material/bluespace), INFINITY, TRUE, /obj/item/stack)
stored_research = new /datum/techweb/specialized/autounlocking/smelter
selected_material = getmaterialref(/datum/material/iron)
/obj/machinery/mineral/processing_unit/Destroy()
CONSOLE = null
QDEL_NULL(stored_research)
return ..()
/obj/machinery/mineral/processing_unit/HasProximity(atom/movable/AM)
if(istype(AM, /obj/item/stack/ore) && AM.loc == get_step(src, input_dir))
process_ore(AM)
/obj/machinery/mineral/processing_unit/proc/process_ore(obj/item/stack/ore/O)
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
var/material_amount = materials.get_item_material_amount(O)
if(!materials.has_space(material_amount))
unload_mineral(O)
else
materials.insert_item(O)
qdel(O)
if(CONSOLE)
CONSOLE.updateUsrDialog()
/obj/machinery/mineral/processing_unit/proc/get_machine_data()
var/dat = "<b>Smelter control console</b><br><br>"
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
for(var/datum/material/M in materials.materials)
var/amount = materials.materials[M]
dat += "<span class=\"res_name\">[M.name]: </span>[amount] cm&sup3;"
if (selected_material == M)
dat += " <i>Smelting</i>"
else
dat += " <A href='?src=[REF(CONSOLE)];material=[REF(M)]'><b>Not Smelting</b></A> "
dat += "<br>"
dat += "<br><br>"
dat += "<b>Smelt Alloys</b><br>"
for(var/v in stored_research.researched_designs)
var/datum/design/D = SSresearch.techweb_design_by_id(v)
dat += "<span class=\"res_name\">[D.name] "
if (selected_alloy == D.id)
dat += " <i>Smelting</i>"
else
dat += " <A href='?src=[REF(CONSOLE)];alloy=[D.id]'><b>Not Smelting</b></A> "
dat += "<br>"
dat += "<br><br>"
//On or off
dat += "Machine is currently "
if (on)
dat += "<A href='?src=[REF(CONSOLE)];set_on=off'>On</A> "
else
dat += "<A href='?src=[REF(CONSOLE)];set_on=on'>Off</A> "
return dat
/obj/machinery/mineral/processing_unit/process()
if (on)
if(selected_material)
smelt_ore()
else if(selected_alloy)
smelt_alloy()
if(CONSOLE)
CONSOLE.updateUsrDialog()
/obj/machinery/mineral/processing_unit/proc/smelt_ore()
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
var/datum/material/mat = selected_material
if(mat)
var/sheets_to_remove = (materials.materials[mat] >= (MINERAL_MATERIAL_AMOUNT * SMELT_AMOUNT) ) ? SMELT_AMOUNT : round(materials.materials[mat] / MINERAL_MATERIAL_AMOUNT)
if(!sheets_to_remove)
on = FALSE
else
var/out = get_step(src, output_dir)
materials.retrieve_sheets(sheets_to_remove, mat, out)
/obj/machinery/mineral/processing_unit/proc/smelt_alloy()
var/datum/design/alloy = stored_research.isDesignResearchedID(selected_alloy) //check if it's a valid design
if(!alloy)
on = FALSE
return
var/amount = can_smelt(alloy)
if(!amount)
on = FALSE
return
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
materials.use_materials(alloy.materials, amount)
generate_mineral(alloy.build_path)
/obj/machinery/mineral/processing_unit/proc/can_smelt(datum/design/D)
if(D.make_reagents.len)
return FALSE
var/build_amount = SMELT_AMOUNT
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
for(var/mat_cat in D.materials)
var/required_amount = D.materials[mat_cat]
var/amount = materials.materials[mat_cat]
build_amount = min(build_amount, round(amount / required_amount))
return build_amount
/obj/machinery/mineral/processing_unit/proc/generate_mineral(P)
var/O = new P(src)
unload_mineral(O)
/obj/machinery/mineral/processing_unit/on_deconstruction()
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
materials.retrieve_all()
..()
#undef SMELT_AMOUNT