mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user