First iteration of constructable transit tubes

This commit is contained in:
tkdrg
2014-10-04 21:18:41 -03:00
parent 2c727f04b1
commit d0ce2a848d
7 changed files with 330 additions and 54 deletions
@@ -40,6 +40,20 @@
return
//pod insertion
/obj/structure/transit_tube/station/MouseDrop_T(obj/structure/c_transit_tube_pod/R as obj, mob/user as mob)
if(!usr.canmove || usr.stat || usr.restrained())
return
if (!istype(R) || get_dist(user, src) > 1 || get_dist(src,R) > 1)
return
var/obj/structure/transit_tube_pod/T = new/obj/structure/transit_tube_pod(src)
R.transfer_fingerprints_to(T)
T.add_fingerprint(usr)
T.loc = src.loc
T.dir = turn(src.dir, -90)
user.visible_message("<span class='notice'>[user] inserts the [R].</span>", "<span class='notice'>You insert the [R].</span>")
qdel(R)
/obj/structure/transit_tube/station/attack_hand(mob/user as mob)
if(!pod_moving)
@@ -76,6 +90,17 @@
src.Bumped(GM)
qdel(G)
break
if(istype(W, /obj/item/weapon/crowbar))
for(var/obj/structure/transit_tube_pod/pod in loc)
if(pod.contents)
user << "<span class='notice'>Empty the pod first.</span>"
return
user.visible_message("<span class='notice'>[user] removes the [pod].</span>", "<span class='notice'>You remove the [pod].</span>")
var/obj/structure/c_transit_tube_pod/R = new/obj/structure/c_transit_tube_pod(src.loc)
pod.transfer_fingerprints_to(R)
R.add_fingerprint(user)
qdel(pod)
..(W, user)
/obj/structure/transit_tube/station/proc/open_animation()
if(icon_state == "closed")
@@ -1,4 +1,3 @@
// Basic transit tubes. Straight pieces, curved sections,
// and basic splits/joins (no routing logic).
// Mappers: you can use "Generate Instances from Icon-states"
@@ -48,6 +47,30 @@ obj/structure/transit_tube/ex_act(severity)
if(tube_dirs == null)
init_dirs()
/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 << "<span class='notice'>Remove the pod first.</span>"
return
user.visible_message("<span class='warning'>[user] starts to deattach the [src]!</span>", "<span class='notice'>You start deattaching the [name]...</span>")
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
if(do_after(user, 80))
user << "<span class='notice'>You deattach the [name]!</span>"
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)
// Called to check if a pod should stop upon entering this tube.
/obj/structure/transit_tube/proc/should_stop_pod(pod, from_dir)
@@ -258,53 +281,3 @@ obj/structure/transit_tube/ex_act(severity)
direction_table[text] = directions
return directions
// A copy of text2dir, extended to accept one and two letter
// directions, and to clearly return 0 otherwise.
/obj/structure/transit_tube/proc/text2dir_extended(direction)
switch(uppertext(direction))
if("NORTH", "N")
return 1
if("SOUTH", "S")
return 2
if("EAST", "E")
return 4
if("WEST", "W")
return 8
if("NORTHEAST", "NE")
return 5
if("NORTHWEST", "NW")
return 9
if("SOUTHEAST", "SE")
return 6
if("SOUTHWEST", "SW")
return 10
else
return 0
// A copy of dir2text, which returns the short one or two letter
// directions used in tube icon states.
/obj/structure/transit_tube/proc/dir2text_short(direction)
switch(direction)
if(1)
return "N"
if(2)
return "S"
if(4)
return "E"
if(8)
return "W"
if(5)
return "NE"
if(6)
return "SE"
if(9)
return "NW"
if(10)
return "SW"
else
return
@@ -0,0 +1,132 @@
// transit tube construction
//TODO: dispenser, restrict flip/rotate, testing
// normal transit tubes
/obj/structure/c_transit_tube
name = "unattached transit tube"
icon = 'icons/obj/pipes/transit_tube.dmi'
icon_state = "E-W" //icon_state decides which tube will be built
density = 0
layer = 3.1 //same as the built tube
anchored = 0.0
//wrapper for turn that changes the transit tube formatted icon_state instead of the dir
/obj/structure/c_transit_tube/proc/tube_turn(var/angle)
var/list/badtubes = list("W-E", "W-E-Pass", "S-N", "S-N-Pass", "SW-NE", "SE-NW")
var/list/split_text = text2list(icon_state, "-")
for(var/i=1; i<=split_text.len; i++)
var/curdir = text2dir_extended(split_text[i]) //0 if not a valid direction (e.g. Pass, Block)
if(curdir)
split_text[i] = dir2text_short(turn(curdir, angle))
var/newdir = list2text(split_text, "-")
if(badtubes.Find(newdir))
split_text.Swap(1,2)
newdir = list2text(split_text, "-")
icon_state = newdir
// 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)
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 category = "Object"
set src in view(1)
if(usr.stat)
return
tube_turn(180)
/obj/structure/c_transit_tube/proc/buildtube()
var/obj/structure/transit_tube/R = new/obj/structure/transit_tube(src.loc)
R.icon_state = src.icon_state
R.init_dirs()
R.generate_automatic_corners(R.tube_dirs)
return R
/obj/structure/c_transit_tube/attackby(var/obj/item/I, var/mob/user)
if(istype(I, /obj/item/weapon/wrench))
user << "<span class='notice'>You start attaching the [name]...</span>"
src.add_fingerprint(user)
if(do_after(user, 40))
if(!src) return
user << "<span class='notice'>You attach the [name]!</span>"
var/obj/structure/transit_tube/R = src.buildtube()
src.transfer_fingerprints_to(R)
qdel(src)
return
// transit tube station
/obj/structure/c_transit_tube/station
name = "unattached through station"
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)
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/buildtube()
var/obj/structure/transit_tube/station/R = new/obj/structure/transit_tube/station(src.loc)
R.dir = src.dir
R.init_dirs()
return R
// reverser station, used for the terminus
/obj/structure/c_transit_tube/station/reverse
name = "unattached terminus station"
/obj/structure/c_transit_tube/station/reverse/buildtube()
var/obj/structure/transit_tube/station/reverse/R = new/obj/structure/transit_tube/station/reverse(src.loc)
R.dir = src.dir
return R
// block, used after the terminus of a transit tube station, decorative only
// code-wise they're normal tubes but they're ~speshul~ because they care about the dir instead of the icon_state
// in that sense they're the same as stations and can reuse their flip and rotate verbs
/obj/structure/c_transit_tube/station/block
name = "unattached tube blocker"
icon = 'icons/obj/pipes/transit_tube.dmi'
icon_state = "Block"
/obj/structure/c_transit_tube/station/block/buildtube()
var/obj/structure/transit_tube/R = new/obj/structure/transit_tube(src.loc)
R.icon_state = src.icon_state
R.dir = src.dir
R.init_dirs()
return R
//transit tube pod
//see station.dm for the logic
/obj/structure/c_transit_tube_pod
name = "unattached transit tube pod"
icon = 'icons/obj/pipes/transit_tube_pod.dmi'
icon_state = "pod"
anchored = 0.0
density = 0
@@ -25,6 +25,23 @@
..()
/obj/structure/transit_tube_pod/attackby(var/obj/item/I, var/mob/user)
if(istype(I, /obj/item/weapon/crowbar))
if(!moving)
for(var/obj/structure/transit_tube/station/T in loc)
return
if(src.contents)
user.visible_message("<span class='notice'>[user] empties the [src].</span>", "<span class='notice'>You empty the [src].</span>")
for(var/atom/movable/M in src.contents)
M.loc = src.loc
return
else
user << "<span class='notice'>You free the [src].</span>"
var/obj/structure/c_transit_tube_pod/R = new/obj/structure/c_transit_tube_pod(src.loc)
src.transfer_fingerprints_to(R)
R.add_fingerprint(user)
qdel(src)
/obj/structure/transit_tube_pod/proc/follow_tube(var/reverse_launch)
if(moving)
return