Improves Machine Frame

Fixes #4942
Makes setting a build state use a proc which automatically updates the icon of the machine frame so nobody accidentally sets build state without updating the look of the machine frame.

Improves some of the machine frame's attackby code, including - and this is beautiful, a system by which it spawns every object required to build when a circuit board is attached, reads the name, then deletes it immediately.
This commit is contained in:
clusterfack
2015-06-19 01:04:49 -05:00
parent ee940b391c
commit c66085c476
7 changed files with 30 additions and 24 deletions

View File

@@ -50,8 +50,7 @@
if(C && C.amount >= 5) // Check again if(C && C.amount >= 5) // Check again
C.use(5) C.use(5)
user << "<span class='notice'>You add cables to the frame.</span>" user << "<span class='notice'>You add cables to the frame.</span>"
build_state = 2 set_build_state(2)
icon_state = "box_1"
else if(istype(P, /obj/item/stack/sheet/glass/glass)) else if(istype(P, /obj/item/stack/sheet/glass/glass))
var/obj/item/stack/sheet/glass/glass/G=P var/obj/item/stack/sheet/glass/glass/G=P
if(G.amount<1) if(G.amount<1)
@@ -61,7 +60,7 @@
user << "<span class='notice'>You add the glass to the frame.</span>" user << "<span class='notice'>You add the glass to the frame.</span>"
playsound(get_turf(src), 'sound/items/Deconstruct.ogg', 50, 1) playsound(get_turf(src), 'sound/items/Deconstruct.ogg', 50, 1)
new /obj/structure/displaycase_frame(src.loc) new /obj/structure/displaycase_frame(src.loc)
del(src) qdel(src)
return return
else else
if(istype(P, /obj/item/weapon/wrench)) if(istype(P, /obj/item/weapon/wrench))
@@ -70,7 +69,7 @@
//new /obj/item/stack/sheet/metal(src.loc, 5) //new /obj/item/stack/sheet/metal(src.loc, 5)
var/obj/item/stack/sheet/metal/M = getFromPool(/obj/item/stack/sheet/metal, src.loc) var/obj/item/stack/sheet/metal/M = getFromPool(/obj/item/stack/sheet/metal, src.loc)
M.amount = 5 M.amount = 5
del(src) qdel(src)
if(2) if(2)
if(!..()) if(!..())
if(istype(P, /obj/item/weapon/circuitboard)) if(istype(P, /obj/item/weapon/circuitboard))
@@ -80,18 +79,21 @@
user << "<span class='notice'>You add the circuit board to the frame.</span>" user << "<span class='notice'>You add the circuit board to the frame.</span>"
circuit = P circuit = P
user.drop_item(B, src) user.drop_item(B, src)
icon_state = "box_2" set_build_state(3)
build_state = 3
components = list() components = list()
req_components = circuit.req_components.Copy() req_components = circuit.req_components.Copy()
for(var/A in circuit.req_components) for(var/A in circuit.req_components)
req_components[A] = circuit.req_components[A] req_components[A] = circuit.req_components[A]
req_component_names = circuit.req_components.Copy() req_component_names = circuit.req_components.Copy()
/* Are you fucking kidding me
for(var/A in req_components) for(var/A in req_components)
var/cp = text2path(A) var/cp = text2path(A)
var/obj/ct = new cp() // have to quickly instantiate it get name var/obj/ct = new cp() // have to quickly instantiate it get name
req_component_names[A] = ct.name req_component_names[A] = ct.name
del(ct) del(ct)*/
for(var/A in req_components)
var/atom/path = text2path(A)
req_component_names[A] = initial(path.name)
if(circuit.frame_desc) if(circuit.frame_desc)
desc = circuit.frame_desc desc = circuit.frame_desc
else else
@@ -103,8 +105,7 @@
if(istype(P, /obj/item/weapon/wirecutters)) if(istype(P, /obj/item/weapon/wirecutters))
playsound(get_turf(src), 'sound/items/Wirecutter.ogg', 50, 1) playsound(get_turf(src), 'sound/items/Wirecutter.ogg', 50, 1)
user << "<span class='notice'>You remove the cables.</span>" user << "<span class='notice'>You remove the cables.</span>"
build_state = 1 set_build_state(1)
icon_state = "box_0"
var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( src.loc ) var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( src.loc )
A.amount = 5 A.amount = 5
@@ -112,7 +113,7 @@
if(!..()) if(!..())
if(istype(P, /obj/item/weapon/crowbar)) if(istype(P, /obj/item/weapon/crowbar))
playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1) playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1)
build_state = 2 set_build_state(2)
circuit.loc = src.loc circuit.loc = src.loc
circuit = null circuit = null
if(components.len == 0) if(components.len == 0)
@@ -124,7 +125,6 @@
desc = initial(desc) desc = initial(desc)
req_components = null req_components = null
components = null components = null
icon_state = "box_1"
else else
if(istype(P, /obj/item/weapon/screwdriver)) if(istype(P, /obj/item/weapon/screwdriver))
var/component_check = 1 var/component_check = 1
@@ -136,7 +136,7 @@
playsound(get_turf(src), 'sound/items/Screwdriver.ogg', 50, 1) playsound(get_turf(src), 'sound/items/Screwdriver.ogg', 50, 1)
var/obj/machinery/new_machine = new src.circuit.build_path(src.loc) var/obj/machinery/new_machine = new src.circuit.build_path(src.loc)
for(var/obj/O in new_machine.component_parts) for(var/obj/O in new_machine.component_parts)
del(O) returnToPool(O)
new_machine.component_parts = list() new_machine.component_parts = list()
for(var/obj/O in src) for(var/obj/O in src)
if(circuit.contain_parts) // things like disposal don't want their parts in them if(circuit.contain_parts) // things like disposal don't want their parts in them
@@ -149,7 +149,8 @@
else else
circuit.loc = null circuit.loc = null
new_machine.RefreshParts() new_machine.RefreshParts()
del(src) components = null
qdel(src)
else else
if(istype(P, /obj/item/weapon)||istype(P, /obj/item/stack)) if(istype(P, /obj/item/weapon)||istype(P, /obj/item/stack))
for(var/I in req_components) for(var/I in req_components)
@@ -192,6 +193,15 @@
if(P && P.loc != src && !istype(P, /obj/item/stack/cable_coil)) if(P && P.loc != src && !istype(P, /obj/item/stack/cable_coil))
user << "<span class='warning'>You cannot add that component to the machine!</span>" user << "<span class='warning'>You cannot add that component to the machine!</span>"
/obj/machinery/constructable_frame/machine_frame/proc/set_build_state(var/state)
build_state = state
switch(state)
if(1)
icon_state = "box_0"
if(2)
icon_state = "box_1"
if(3)
icon_state = "box_2"
//Machine Frame Circuit Boards //Machine Frame Circuit Boards
/*Common Parts: Parts List: Ignitor, Timer, Infra-red laser, Infra-red sensor, t_scanner, Capacitor, Valve, sensor unit, /*Common Parts: Parts List: Ignitor, Timer, Infra-red laser, Infra-red sensor, t_scanner, Capacitor, Valve, sensor unit,

View File

@@ -451,9 +451,8 @@ Class Procs:
/obj/machinery/proc/dropFrame() /obj/machinery/proc/dropFrame()
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc) var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
M.build_state = 2 M.set_build_state(2)
M.state = 1 M.state = 1
M.icon_state = "box_1"
/obj/machinery/proc/crowbarDestroy(mob/user) /obj/machinery/proc/crowbarDestroy(mob/user)
user.visible_message( "[user] begins to pry out the circuitboard from \the [src].", user.visible_message( "[user] begins to pry out the circuitboard from \the [src].",

View File

@@ -90,7 +90,7 @@
// Create a machine frame and delete the current machine // Create a machine frame and delete the current machine
var/obj/machinery/constructable_frame/machine_frame/F = new var/obj/machinery/constructable_frame/machine_frame/F = new
F.build_state = 2 F.set_build_state(2)
F.loc = src.loc F.loc = src.loc
del(src) del(src)

View File

@@ -18,7 +18,7 @@
if(istype(W, /obj/item/weapon/crowbar)) if(istype(W, /obj/item/weapon/crowbar))
var/obj/machinery/constructable_frame/machine_frame/MF = new /obj/machinery/constructable_frame/machine_frame(T) var/obj/machinery/constructable_frame/machine_frame/MF = new /obj/machinery/constructable_frame/machine_frame(T)
MF.state = 1 MF.state = 1
MF.build_state = 2 MF.set_build_state(2)
new /obj/item/stack/sheet/glass/glass(T) new /obj/item/stack/sheet/glass/glass(T)
del(src) del(src)
playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1) playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1)

View File

@@ -249,8 +249,7 @@
playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1) playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1)
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc) var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
M.state = 1 M.state = 1
M.build_state = 2 M.set_build_state(2)
M.icon_state = "box_1"
for(var/obj/I in component_parts) for(var/obj/I in component_parts)
if(I.reliability != 100 && crit_fail) if(I.reliability != 100 && crit_fail)
I.crit_fail = 1 I.crit_fail = 1

View File

@@ -331,8 +331,7 @@
if(do_after(user, src, 50)) if(do_after(user, src, 50))
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc) var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
M.state = 1 M.state = 1
M.build_state = 2 M.set_build_state(2)
M.icon_state = "box_1"
for(var/obj/I in component_parts) for(var/obj/I in component_parts)
if(I.reliability != 100 && crit_fail) if(I.reliability != 100 && crit_fail)
I.crit_fail = 1 I.crit_fail = 1

View File

@@ -113,9 +113,8 @@
I.crit_fail = 1 I.crit_fail = 1
I.loc = src.loc I.loc = src.loc
new_frame.state = 1 new_frame.state = 1
new_frame.build_state = 2 new_frame.set_build_state(2)
new_frame.icon_state = "box_1" qdel(src)
del(src)
/obj/machinery/power/port_gen/pacman2/attack_hand(mob/user as mob) /obj/machinery/power/port_gen/pacman2/attack_hand(mob/user as mob)
..() ..()