Machinery Component Initialization Refactor (#3258)

Machinery objects' component_parts list is now automatically populated with the types in the component_types list. Types can have an associated number which is interpreted as an instruction to spawn that number of that type. This eliminates a few Initialize() procs, and simplifies others.
Example:

component_types = list(
    /obj/foo/bar,
    /obj/baz = 2
)
Other changes:

Cable coils will now no longer force a stack size of 30 when created without their stack size passed as a parameter - this fixes anonymous types not working correctly with cable coils.
This commit is contained in:
Lohikar
2017-08-09 12:33:14 -05:00
committed by Erki
parent 5b97803904
commit c3c31c85ea
26 changed files with 223 additions and 262 deletions

View File

@@ -20,17 +20,17 @@
var/set_temperature = T20C // Thermostat
var/cooling = 0
component_types = list(
/obj/item/weapon/circuitboard/unary_atmos/cooler,
/obj/item/weapon/stock_parts/matter_bin,
/obj/item/weapon/stock_parts/capacitor = 2,
/obj/item/weapon/stock_parts/manipulator,
/obj/item/stack/cable_coil{amount = 2}
)
/obj/machinery/atmospherics/unary/freezer/New()
..()
initialize_directions = dir
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/unary_atmos/cooler(src)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/capacitor(src)
component_parts += new /obj/item/weapon/stock_parts/capacitor(src)
component_parts += new /obj/item/weapon/stock_parts/manipulator(src)
component_parts += new /obj/item/stack/cable_coil(src, 2)
RefreshParts()
/obj/machinery/atmospherics/unary/freezer/atmos_init()
if(node)

View File

@@ -20,19 +20,17 @@
var/set_temperature = T20C //thermostat
var/heating = 0 //mainly for icon updates
component_types = list(
/obj/item/weapon/circuitboard/unary_atmos/heater,
/obj/item/weapon/stock_parts/matter_bin,
/obj/item/weapon/stock_parts/capacitor = 2,
/obj/item/stack/cable_coil{amount = 5}
)
/obj/machinery/atmospherics/unary/heater/New()
..()
initialize_directions = dir
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/unary_atmos/heater(src)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/capacitor(src)
component_parts += new /obj/item/weapon/stock_parts/capacitor(src)
component_parts += new /obj/item/stack/cable_coil(src, 5)
RefreshParts()
/obj/machinery/atmospherics/unary/heater/atmos_init()
if(node)
return