Port material containers to datum components (#29268)

* Ports /vg/'s component system

* Fix component signalling itself for addition

* Fix the list arrangement for removal

* Whoops

* Return the existing component if the created one was deleted

* These can't be ints

* ,

* returning TRUE from a callback will mark the event as handled

* Small refactor

* Add powered components

* R e f a c t o r

* More wip

* Fixes et al

* Pure pain

* When bae tells you she was tabs but she was actually spaces

* RReee

* Needs arglist

* Fax

* Fax

* More better

* You fail me yet again git commit

* Some kajiggering, but there we go

* No more 3rd param = variadic

* fix

* Sanity

* Whoops

* Minor thing

* Whoops

* fax

* Better describe the function, + add ..()s

* Fix

* Port to Initialize

* fuk in git
This commit is contained in:
Jordan Brown
2017-08-30 15:11:34 +02:00
committed by AnturK
parent 455cf37e52
commit 2c92735520
17 changed files with 255 additions and 348 deletions
+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()
..()