From 82d8e6ad5ce1ce99cb9e8307fabf3d2f5d3b4367 Mon Sep 17 00:00:00 2001 From: davipatury Date: Mon, 27 Mar 2017 19:00:01 -0300 Subject: [PATCH] Machine construction. --- code/ATMOSPHERICS/atmospherics.dm | 2 +- code/game/machinery/Freezer.dm | 4 ++-- code/game/machinery/computer/computer.dm | 6 ++++++ code/game/machinery/cryo.dm | 2 +- code/game/machinery/machinery.dm | 20 +++++++++++++------- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/code/ATMOSPHERICS/atmospherics.dm b/code/ATMOSPHERICS/atmospherics.dm index b4819294256..80086cd75f9 100644 --- a/code/ATMOSPHERICS/atmospherics.dm +++ b/code/ATMOSPHERICS/atmospherics.dm @@ -217,7 +217,7 @@ Pipelines + Other Objects -> Pipe network qdel(src) -/obj/machinery/atmospherics/construction(D, P, C) +/obj/machinery/atmospherics/on_construction(D, P, C) if(C) color = C dir = D diff --git a/code/game/machinery/Freezer.dm b/code/game/machinery/Freezer.dm index 0c207c8217e..244b3b04977 100644 --- a/code/game/machinery/Freezer.dm +++ b/code/game/machinery/Freezer.dm @@ -44,7 +44,7 @@ min_temperature = max(0,T0C - (170 + (T*15))) current_heat_capacity = 1000 * ((H - 1) ** 2) -/obj/machinery/atmospherics/unary/cold_sink/freezer/construction() +/obj/machinery/atmospherics/unary/cold_sink/freezer/on_construction() ..(dir,dir) /obj/machinery/atmospherics/unary/cold_sink/freezer/attackby(obj/item/I, mob/user, params) @@ -193,7 +193,7 @@ component_parts += new /obj/item/stack/cable_coil(src, 1) RefreshParts() -/obj/machinery/atmospherics/unary/heat_reservoir/heater/construction() +/obj/machinery/atmospherics/unary/heat_reservoir/heater/on_construction() ..(dir,dir) /obj/machinery/atmospherics/unary/heat_reservoir/heater/RefreshParts() diff --git a/code/game/machinery/computer/computer.dm b/code/game/machinery/computer/computer.dm index 11778503e9d..955ed3b7e56 100644 --- a/code/game/machinery/computer/computer.dm +++ b/code/game/machinery/computer/computer.dm @@ -19,6 +19,12 @@ overlay_layer = layer ..() +/obj/machinery/computer/Destroy() + if(circuit) + qdel(circuit) + circuit = null + return ..() + /obj/machinery/computer/initialize() ..() power_change() diff --git a/code/game/machinery/cryo.dm b/code/game/machinery/cryo.dm index de5d69c2bbc..55e1e2ba5eb 100644 --- a/code/game/machinery/cryo.dm +++ b/code/game/machinery/cryo.dm @@ -52,7 +52,7 @@ component_parts += new /obj/item/stack/cable_coil(null, 1) RefreshParts() -/obj/machinery/atmospherics/unary/cryo_cell/construction() +/obj/machinery/atmospherics/unary/cryo_cell/on_construction() ..(dir,dir) /obj/machinery/atmospherics/unary/cryo_cell/RefreshParts() diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 90c4d82befe..8891625ba07 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -396,15 +396,18 @@ Class Procs: /obj/machinery/proc/default_deconstruction_crowbar(var/obj/item/weapon/crowbar/C, var/ignore_panel = 0) if(istype(C) && (panel_open || ignore_panel)) playsound(loc, C.usesound, 50, 1) - spawn_frame() - for(var/obj/item/I in component_parts) - if(I.reliability != 100 && crit_fail) - I.crit_fail = 1 - I.forceMove(loc) - qdel(src) + deconstruct() return 1 return 0 +/obj/machinery/proc/deconstruct() + on_deconstruction() + spawn_frame() + for(var/obj/item/I in component_parts) + if(I.reliability != 100 && crit_fail) + I.crit_fail = 1 + I.forceMove(loc) + qdel(src) /obj/machinery/proc/spawn_frame() var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(loc) @@ -573,7 +576,10 @@ Class Procs: return 0 //called on machinery construction (i.e from frame to machinery) but not on initialization -/obj/machinery/proc/construction() +/obj/machinery/proc/on_construction() + return + +/obj/machinery/proc/on_deconstruction() return /obj/machinery/proc/can_be_overridden()