From 4ef2e494a137edf19131904342bcff2f27b035c4 Mon Sep 17 00:00:00 2001 From: tkdrg Date: Sun, 5 Oct 2014 14:09:10 -0300 Subject: [PATCH] Changes flip/rotation, better diagonal handling --- code/game/machinery/pipe/pipe_dispenser.dm | 32 +++++------ .../structures/transit_tubes/station.dm | 2 + .../structures/transit_tubes/transit_tube.dm | 53 +++++++++++-------- .../transit_tube_construction.dm | 50 ++++++++--------- 4 files changed, 70 insertions(+), 67 deletions(-) diff --git a/code/game/machinery/pipe/pipe_dispenser.dm b/code/game/machinery/pipe/pipe_dispenser.dm index 80547e27ee0..ee7ad2dd4d3 100644 --- a/code/game/machinery/pipe/pipe_dispenser.dm +++ b/code/game/machinery/pipe/pipe_dispenser.dm @@ -215,16 +215,14 @@ Nah var/dat = {"Transit Tubes:
Straight Tube
Straight Tube with Crossing
-Clockwise Curved Tube
-Counterclockwise Curved Tube
-Diagonal Tube
-Clockwise Junction
-Counterclockwise Junction
+Curved Tube
+Diagonal Tube
+Junction
Station Equipment:
-Through Tube Station
-Terminus Tube Station
-Tube Blocker
-Transit Tube Pod
+Through Tube Station
+Terminus Tube Station
+Tube Blocker
+Transit Tube Pod
"} user << browse("[src][dat]", "window=pipedispenser") @@ -239,7 +237,7 @@ Nah if(!wait) if(href_list["tube"]) var/tube_type = text2num(href_list["tube"]) - if(tube_type <= 6) + if(tube_type <= 4) var/obj/structure/c_transit_tube/C = new/obj/structure/c_transit_tube(src.loc) switch(tube_type) if(0) @@ -249,26 +247,22 @@ Nah if(2) C.icon_state = "S-NE" if(3) - C.icon_state = "S-NW" - if(4) C.icon_state = "NE-SW" - if(5) + if(4) C.icon_state = "W-NE-SE" - if(6) - C.icon_state = "S-NE-NW" C.add_fingerprint(usr) else switch(tube_type) - if(7) + if(5) var/obj/structure/c_transit_tube/station/C = new/obj/structure/c_transit_tube/station(src.loc) C.add_fingerprint(usr) - if(8) + if(6) var/obj/structure/c_transit_tube/station/reverse/C = new/obj/structure/c_transit_tube/station/reverse(src.loc) C.add_fingerprint(usr) - if(9) + if(7) var/obj/structure/c_transit_tube/station/block/C = new/obj/structure/c_transit_tube/station/block(src.loc) C.add_fingerprint(usr) - if(10) + if(8) var/obj/structure/c_transit_tube_pod/C = new/obj/structure/c_transit_tube_pod(src.loc) C.add_fingerprint(usr) wait = 1 diff --git a/code/game/objects/structures/transit_tubes/station.dm b/code/game/objects/structures/transit_tubes/station.dm index ce38f66f96a..315c5f0cd4d 100644 --- a/code/game/objects/structures/transit_tubes/station.dm +++ b/code/game/objects/structures/transit_tubes/station.dm @@ -8,6 +8,7 @@ icon_state = "closed" exit_delay = 2 enter_delay = 3 + tube_construction = /obj/structure/c_transit_tube/station var/pod_moving = 0 var/automatic_launch_time = 100 var/cooldown_delay = 200 @@ -27,6 +28,7 @@ // Stations which will send the tube in the opposite direction after their stop. /obj/structure/transit_tube/station/reverse + tube_construction = /obj/structure/c_transit_tube/station/reverse reverse_launch = 1 /obj/structure/transit_tube/station/should_stop_pod(pod, from_dir) diff --git a/code/game/objects/structures/transit_tubes/transit_tube.dm b/code/game/objects/structures/transit_tubes/transit_tube.dm index 0cefb94ffd9..152820d77dc 100644 --- a/code/game/objects/structures/transit_tubes/transit_tube.dm +++ b/code/game/objects/structures/transit_tubes/transit_tube.dm @@ -8,6 +8,7 @@ density = 1 layer = 3.1 anchored = 1.0 + var/tube_construction = /obj/structure/c_transit_tube var/list/tube_dirs = null var/exit_delay = 2 var/enter_delay = 1 @@ -49,28 +50,35 @@ obj/structure/transit_tube/ex_act(severity) /obj/structure/transit_tube/attackby(obj/item/W, mob/user) if(istype(W, /obj/item/weapon/wrench)) - for(var/obj/structure/transit_tube_pod/pod in loc) - user << "Remove the pod first." - return - user.visible_message("[user] starts to deattach the [src]!", "You start deattaching the [name]...") - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - if(do_after(user, 35)) - user << "You deattach the [name]!" - if(copytext(icon_state, 1, 3) != "D-") - if(istype(src, /obj/structure/transit_tube/station/reverse)) - var/obj/structure/R = new/obj/structure/c_transit_tube/station/reverse(src.loc) - src.transfer_fingerprints_to(R) - R.add_fingerprint(user) - else if(istype(src, /obj/structure/transit_tube/station)) - var/obj/structure/R = new/obj/structure/c_transit_tube/station(src.loc) - src.transfer_fingerprints_to(R) - R.add_fingerprint(user) - else - var/obj/structure/R = new/obj/structure/c_transit_tube(src.loc) - R.icon_state = src.icon_state - src.transfer_fingerprints_to(R) - R.add_fingerprint(user) - qdel(src) + if(copytext(icon_state, 1, 3) != "D-") //decorative diagonals cannot be unwrenched directly + for(var/obj/structure/transit_tube_pod/pod in loc) + user << "Remove the pod first." + return + user.visible_message("[user] starts to deattach the [src]!", "You start deattaching the [name]...") + playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) + if(do_after(user, 35)) + user << "You deattach the [name]!" + var/obj/structure/R = new tube_construction(src.loc) + R.icon_state = src.icon_state + src.transfer_fingerprints_to(R) + R.add_fingerprint(user) + src.destroy_diagonals() + qdel(src) + +//destroys disconnected decorative diagonals +/obj/structure/transit_tube/proc/destroy_diagonals() + for(var/obj/structure/transit_tube/D in orange(1, src)) + if(copytext(D.icon_state, 1, 3) == "D-") //is diagonal + var/my_dir = text2dir_extended(copytext(D.icon_state, 3, 5)) + var/is_connecting = 0 + for(var/obj/structure/transit_tube/N in orange(1,D)) + if( (( get_dir(D,N) == turn(my_dir, -45) && D.has_exit(turn(my_dir, 90)) ) || \ + ( get_dir(D,N) == turn(my_dir, 45) && D.has_exit(turn(my_dir, -90))) ) && \ + D != src ) + is_connecting = 1 + break + if(!is_connecting) + qdel(D) // Called to check if a pod should stop upon entering this tube. /obj/structure/transit_tube/proc/should_stop_pod(pod, from_dir) @@ -80,7 +88,6 @@ obj/structure/transit_tube/ex_act(severity) /obj/structure/transit_tube/proc/pod_stopped(pod, from_dir) return - // Returns a /list of directions this tube section can connect to. // Tubes that have some sort of logic or changing direction might // override it with additional logic. diff --git a/code/game/objects/structures/transit_tubes/transit_tube_construction.dm b/code/game/objects/structures/transit_tubes/transit_tube_construction.dm index 52bd7bde5ec..5806f16e349 100644 --- a/code/game/objects/structures/transit_tubes/transit_tube_construction.dm +++ b/code/game/objects/structures/transit_tubes/transit_tube_construction.dm @@ -23,28 +23,42 @@ newdir = list2text(split_text, "-") icon_state = newdir -// disposals-style "flip" and rotate verbs +/obj/structure/c_transit_tube/proc/tube_flip() + var/list/split_text = text2list(icon_state, "-") + //skip straight pipes + if(length(split_text[2]) < 2) + return + //for junctions, just swap the diagonals with each other + if(split_text.len == 3 && split_text[3] != "Pass") + split_text.Swap(2,3) + //for curves, swap the diagonal direction that is not in the same axis as the cardinal direction + else + if(split_text[1] == "N" || split_text[1] == "S") + split_text[2] = copytext(split_text[2],1,2) + ((copytext(split_text[2],2,3) == "E") ? "W" : "E") + else + split_text[2] = ((copytext(split_text[2],1,2) == "N") ? "S" : "N") + copytext(split_text[2],2,3) + icon_state = list2text(split_text, "-") + +// disposals-style flip and rotate verbs /obj/structure/c_transit_tube/verb/rotate() set name = "Rotate Tube" set category = "Object" set src in view(1) - if(usr.stat) + if(usr.canUseTopic()) return tube_turn(-90) -//not a real flip because it won't mirror junction pipe exits -//yes i am autistic /obj/structure/c_transit_tube/verb/flip() - set name = "Rotate Tube Twice" + set name = "Flip" set category = "Object" set src in view(1) - if(usr.stat) + if(usr.canUseTopic()) return - tube_turn(180) + tube_flip() /obj/structure/c_transit_tube/proc/buildtube() var/obj/structure/transit_tube/R = new/obj/structure/transit_tube(src.loc) @@ -71,25 +85,11 @@ icon = 'icons/obj/pipes/transit_tube_station.dmi' icon_state = "closed" -/obj/structure/c_transit_tube/station/rotate() - set name = "Rotate Tube" - set category = "Object" - set src in view(1) +/obj/structure/c_transit_tube/station/tube_turn(var/angle) + src.dir = turn(src.dir, angle) - if(usr.stat) - return - - src.dir = turn(src.dir, -90) - -/obj/structure/c_transit_tube/station/flip() - set name = "Rotate Tube Twice" - set category = "Object" - set src in view(1) - - if(usr.stat) - return - - src.dir = turn(src.dir, 180) +/obj/structure/c_transit_tube/station/tube_flip() + src.tube_turn(180) /obj/structure/c_transit_tube/station/buildtube() var/obj/structure/transit_tube/station/R = new/obj/structure/transit_tube/station(src.loc)