Added new "default_apply_parts" facility to machines to create default parts.

* Every constructable machine with a circuit board needs to create its required parts in its constructor.  These parts must be the same parts specified in the machine's circuit board, otherwise you get the wrong parts when you deconstruct.  This creates an opportunity for error which we can eliminate by reading the circuit board's part list and just adding those to the machine directly!  Plus its less tedious.
* Implemented it on the jukebox.
This commit is contained in:
Leshana
2017-02-22 17:27:24 -05:00
parent f0c30b2817
commit d7b82fc719
3 changed files with 27 additions and 5 deletions

View File

@@ -35,3 +35,22 @@
if(istype(M, build_path))
return 1
return 0
//Should be called from the constructor of any machine to automatically populate the default parts
/obj/item/weapon/circuitboard/proc/apply_default_parts(var/obj/machinery/M)
if(!istype(M))
return
if(!req_components)
return
M.component_parts = list()
for(var/comp_path in req_components)
var/comp_amt = req_components[comp_path]
if(!comp_amt)
continue
if(ispath(comp_path, /obj/item/stack))
M.component_parts += new comp_path(contain_parts ? M : null, comp_amt)
else
for(var/i in 1 to comp_amt)
M.component_parts += new comp_path(contain_parts ? M : null)
return