A bunch of refactoring; RPD runtimes if a forbidden pipe is attempted to be dispensed; names loose disposals pipes

This commit is contained in:
Citinited
2018-07-16 00:23:03 +01:00
parent 2a310f3539
commit 29c6e6d69b
11 changed files with 252 additions and 270 deletions
+1 -1
View File
@@ -317,7 +317,7 @@ proc/getFilesSlow(var/client/client, var/list/files, var/register_asset = TRUE)
for(var/D in cardinal)
assets["[state]-[dir2text(D)].png"] = icon('icons/obj/pipe-item.dmi', state, D)
for(var/state in icon_states('icons/obj/pipes/disposal.dmi'))
if(!(state in list("conpipe-c", "conpipe-j1", "conpipe-s", "conpipe-t", "conpipe-y", "intake", "outlet"))) //Pipes we want sprites for
if(!(state in list("pipe-c", "pipe-j1", "pipe-s", "pipe-t", "pipe-y", "intake", "outlet"))) //Pipes we want sprites for
continue
for(var/D in cardinal)
assets["[state]-[dir2text(D)].png"] = icon('icons/obj/pipes/disposal.dmi', state, D)
+50 -67
View File
@@ -11,11 +11,9 @@
density = 0
pressure_resistance = 5*ONE_ATMOSPHERE
level = 2
var/ptype = 0
// 0=straight, 1=bent, 2=junction-j1, 3=junction-j2, 4=junction-y, 5=trunk, 6=disposal bin, 7=outlet, 8=inlet
var/ptype = PIPE_DISPOSALS_STRAIGHT //Use the defines
var/base_state
var/dpdir = 0 // directions as disposalpipe
var/base_state = "pipe-s"
/obj/structure/disposalconstruct/New(loc, pipe_type, direction)
..()
@@ -27,58 +25,43 @@
// update iconstate and dpdir due to dir and type
/obj/structure/disposalconstruct/proc/update()
base_state = get_pipe_icon(ptype)
icon_state = "con[base_state]"
var/flip = turn(dir, 180)
var/left = turn(dir, 90)
var/right = turn(dir, -90)
name = get_pipe_name(ptype, PIPETYPE_DISPOSAL)
switch(ptype)
if(0)
base_state = "pipe-s"
if(PIPE_DISPOSALS_STRAIGHT)
dpdir = dir | flip
if(1)
base_state = "pipe-c"
if(PIPE_DISPOSALS_BENT)
dpdir = dir | right
if(2)
base_state = "pipe-j1"
if(PIPE_DISPOSALS_JUNCTION_RIGHT)
dpdir = dir | right | flip
if(3)
base_state = "pipe-j2"
if(PIPE_DISPOSALS_JUNCTION_LEFT)
dpdir = dir | left | flip
if(4)
base_state = "pipe-y"
if(PIPE_DISPOSALS_Y_JUNCTION)
dpdir = dir | left | right
if(5)
base_state = "pipe-t"
if(PIPE_DISPOSALS_TRUNK)
dpdir = dir
// disposal bin has only one dir, thus we don't need to care about setting it
if(6)
if(anchored)
base_state = "disposal"
else
base_state = "condisposal"
if(7)
base_state = "outlet"
dpdir = dir
if(8)
base_state = "intake"
dpdir = dir
if(9)
base_state = "pipe-j1s"
if(PIPE_DISPOSALS_SORT_RIGHT)
dpdir = dir | right | flip
if(10)
base_state = "pipe-j2s"
if(PIPE_DISPOSALS_SORT_LEFT)
dpdir = dir | left | flip
if(ptype<6 || ptype>8)
// disposal bin has only one dir, thus we don't need to care about setting it
if(PIPE_DISPOSALS_BIN)
if(!anchored)
icon_state = "[base_state]-unanchored"
else
icon_state = base_state
if(PIPE_DISPOSALS_OUTLET)
dpdir = dir
icon_state = base_state
if(PIPE_DISPOSALS_CHUTE)
dpdir = dir
icon_state = base_state
if(!(ptype in list(PIPE_DISPOSALS_BIN, PIPE_DISPOSALS_OUTLET, PIPE_DISPOSALS_CHUTE)))
icon_state = "con[base_state]"
else
icon_state = base_state
if(invisibility) // if invisible, fade icon
icon -= rgb(0,0,0,128)
@@ -124,33 +107,33 @@
dir = turn(dir, 180)
switch(ptype)
if(2)
ptype = 3
if(3)
ptype = 2
if(9)
ptype = 10
if(10)
ptype = 9
if(PIPE_DISPOSALS_JUNCTION_RIGHT)
ptype = PIPE_DISPOSALS_JUNCTION_LEFT
if(PIPE_DISPOSALS_JUNCTION_LEFT)
ptype = PIPE_DISPOSALS_JUNCTION_RIGHT
if(PIPE_DISPOSALS_SORT_RIGHT)
ptype = PIPE_DISPOSALS_SORT_LEFT
if(PIPE_DISPOSALS_SORT_LEFT)
ptype = PIPE_DISPOSALS_SORT_RIGHT
update()
// returns the type path of disposalpipe corresponding to this item dtype
/obj/structure/disposalconstruct/proc/dpipetype()
switch(ptype)
if(0,1)
if(PIPE_DISPOSALS_STRAIGHT, PIPE_DISPOSALS_BENT)
return /obj/structure/disposalpipe/segment
if(2,3,4)
if(PIPE_DISPOSALS_JUNCTION_RIGHT, PIPE_DISPOSALS_JUNCTION_LEFT, PIPE_DISPOSALS_Y_JUNCTION)
return /obj/structure/disposalpipe/junction
if(5)
if(PIPE_DISPOSALS_TRUNK)
return /obj/structure/disposalpipe/trunk
if(6)
if(PIPE_DISPOSALS_BIN)
return /obj/machinery/disposal
if(7)
if(PIPE_DISPOSALS_OUTLET)
return /obj/structure/disposaloutlet
if(8)
if(PIPE_DISPOSALS_CHUTE)
return /obj/machinery/disposal/deliveryChute
if(9,10)
if(PIPE_DISPOSALS_SORT_RIGHT, PIPE_DISPOSALS_SORT_LEFT)
return /obj/structure/disposalpipe/sortjunction
return
@@ -165,13 +148,13 @@
var/ispipe = 0 // Indicates if we should change the level of this pipe
src.add_fingerprint(user)
switch(ptype)
if(6)
if(PIPE_DISPOSALS_BIN)
nicetype = "disposal bin"
if(7)
if(PIPE_DISPOSALS_OUTLET)
nicetype = "disposal outlet"
if(8)
if(PIPE_DISPOSALS_CHUTE)
nicetype = "delivery chute"
if(9, 10)
if(PIPE_DISPOSALS_SORT_RIGHT, PIPE_DISPOSALS_SORT_LEFT)
nicetype = "sorting pipe"
ispipe = 1
else
@@ -205,7 +188,7 @@
return
var/obj/structure/disposalpipe/CP = locate() in T
if(ptype>=6 && ptype <= 8) // Disposal or outlet
if(ptype in list(PIPE_DISPOSALS_BIN, PIPE_DISPOSALS_OUTLET, PIPE_DISPOSALS_CHUTE)) // Disposal or outlet
if(CP) // There's something there
if(!istype(CP,/obj/structure/disposalpipe/trunk))
to_chat(user, "The [nicetype] requires a trunk underneath it in order to work.")
@@ -244,22 +227,22 @@
P.update_icon()
//Needs some special treatment ;)
if(ptype==9 || ptype==10)
if(ptype == PIPE_DISPOSALS_SORT_RIGHT || ptype == PIPE_DISPOSALS_SORT_LEFT)
var/obj/structure/disposalpipe/sortjunction/SortP = P
SortP.updatedir()
else if(ptype==6) // Disposal bin
else if(ptype == PIPE_DISPOSALS_BIN) // Disposal bin
var/obj/machinery/disposal/P = new /obj/machinery/disposal(src.loc)
src.transfer_fingerprints_to(P)
P.mode = 0 // start with pump off
else if(ptype==7) // Disposal outlet
else if(ptype == PIPE_DISPOSALS_OUTLET) // Disposal outlet
var/obj/structure/disposaloutlet/P = new /obj/structure/disposaloutlet(src.loc)
src.transfer_fingerprints_to(P)
P.dir = dir
else if(ptype==8) // Disposal outlet
else if(ptype==PIPE_DISPOSALS_CHUTE) // Disposal outlet
var/obj/machinery/disposal/deliveryChute/P = new /obj/machinery/disposal/deliveryChute(src.loc)
src.transfer_fingerprints_to(P)
+10 -10
View File
@@ -97,7 +97,7 @@
to_chat(user, "You sliced the floorweld off the disposal unit.")
var/obj/structure/disposalconstruct/C = new (src.loc)
src.transfer_fingerprints_to(C)
C.ptype = 6 // 6 = disposal unit
C.ptype = PIPE_DISPOSALS_BIN
C.anchored = 1
C.density = 1
C.update()
@@ -889,21 +889,21 @@
var/obj/structure/disposalconstruct/C = new (src.loc)
switch(base_icon_state)
if("pipe-s")
C.ptype = 0
C.ptype = PIPE_DISPOSALS_STRAIGHT
if("pipe-c")
C.ptype = 1
C.ptype = PIPE_DISPOSALS_BENT
if("pipe-j1")
C.ptype = 2
C.ptype = PIPE_DISPOSALS_JUNCTION_RIGHT
if("pipe-j2")
C.ptype = 3
C.ptype = PIPE_DISPOSALS_JUNCTION_LEFT
if("pipe-y")
C.ptype = 4
C.ptype = PIPE_DISPOSALS_Y_JUNCTION
if("pipe-t")
C.ptype = 5
C.ptype = PIPE_DISPOSALS_TRUNK
if("pipe-j1s")
C.ptype = 9
C.ptype = PIPE_DISPOSALS_SORT_RIGHT
if("pipe-j2s")
C.ptype = 10
C.ptype = PIPE_DISPOSALS_SORT_LEFT
src.transfer_fingerprints_to(C)
C.dir = dir
C.density = 0
@@ -1339,7 +1339,7 @@
to_chat(user, "You sliced the floorweld off the disposal outlet.")
var/obj/structure/disposalconstruct/C = new (src.loc)
src.transfer_fingerprints_to(C)
C.ptype = 7 // 7 = outlet
C.ptype = PIPE_DISPOSALS_OUTLET
C.update()
C.anchored = 1
C.density = 1
+1 -1
View File
@@ -349,7 +349,7 @@
if(!src || !W.isOn()) return
to_chat(user, "You sliced the floorweld off the delivery chute.")
var/obj/structure/disposalconstruct/C = new (src.loc)
C.ptype = 8 // 8 = Delivery chute
C.ptype = PIPE_DISPOSALS_CHUTE
C.update()
C.anchored = 1
C.density = 1