This commit is contained in:
SkyMarshal
2015-08-30 14:15:20 -07:00
parent 491bb6931a
commit 772c320303
14 changed files with 258 additions and 286 deletions
+31
View File
@@ -0,0 +1,31 @@
// If you add a more comprehensive system, just untick this file.
// WARNING: Only works for up to 17 z-levels!
var/z_levels = 0 // Each bit represents a connection between adjacent levels. So the first bit means levels 1 and 2 are connected.
// If the height is more than 1, we mark all contained levels as connected.
/obj/effect/landmark/map_data/New()
for(var/i = z - 1 to height - 2)
z_levels |= 1 << i
del src
HasAbove(z)
if(z > world.maxz || z > 17 || z < 2)
return 0
return z_levels & (1 << (z - 1))
HasBelow(z)
if(z >= world.maxz || z > 16 || z < 1)
return 0
return z_levels & (1 << z)
GetAbove(var/atom/thing)
var/turf/turf = get_turf(thing)
if(!istype(turf))
return null
return HasBelow(turf.z) ? locate(turf.z, turf.y, turf.z - 1) : null
GetBelow(var/atom/thing)
var/turf/turf = get_turf(thing)
if(!istype(turf))
return null
return HasBelow(turf.z) ? locate(turf.z, turf.y, turf.z + 1) : null
+16
View File
@@ -0,0 +1,16 @@
/obj/effect/landmark/map_data
name = "Unknown"
desc = "An unknown location."
invisibility = 101
var/height = 1 ///< The number of Z-Levels in the map.
var/turf/edge_type ///< What the map edge should be formed with. (null = world.turf)
// FOR THE LOVE OF GOD USE THESE. DO NOT FUCKING SPAGHETTIFY THIS.
// Use the Has*() functions if you ONLY need to check.
// If you need to do something, use Get*().
proc/HasAbove(var/z)
proc/HasBelow(var/z)
// These give either the turf or null.
proc/GetAbove(var/turf/turf)
proc/GetBelow(var/turf/turf)
+40 -41
View File
@@ -126,11 +126,10 @@ By design, d1 is the smallest direction and d2 is the highest
return
if(istype(W, /obj/item/weapon/wirecutters))
///// Z-Level Stuff
if(src.d1 == 12 || src.d2 == 12)
if(d1 == 12 || d2 == 12)
user << "<span class='warning'>You must cut this cable from above.</span>"
return
///// Z-Level Stuff
if(breaker_box)
user << "\red This cable is connected to nearby breaker box. Use breaker box to interact with it."
return
@@ -146,16 +145,13 @@ By design, d1 is the smallest direction and d2 is the highest
for(var/mob/O in viewers(src, null))
O.show_message("<span class='warning'>[user] cuts the cable.</span>", 1)
///// Z-Level Stuff
if(src.d1 == 11 || src.d2 == 11)
var/turf/controllerlocation = locate(1, 1, z)
for(var/obj/effect/landmark/zcontroller/controller in controllerlocation)
if(controller.down)
var/turf/below = locate(src.x, src.y, controller.down_target)
for(var/obj/structure/cable/c in below)
if(c.d1 == 12 || c.d2 == 12)
qdel(c)
///// Z-Level Stuff
if(d1 == 11 || d2 == 11)
var/turf/turf = GetBelow(src)
if(turf)
for(var/obj/structure/cable/c in turf)
if(c.d1 == 12 || c.d2 == 12)
qdel(c)
investigate_log("was cut by [key_name(usr, usr.client)] in [user.loc.loc]","wires")
qdel(src)
@@ -347,19 +343,20 @@ obj/structure/cable/proc/cableColor(var/colorC)
. = list() // this will be a list of all connected power objects
var/turf/T
///// Z-Level Stuff
if (d1 == 11 || d1 == 12)
var/turf/controllerlocation = locate(1, 1, z)
for(var/obj/effect/landmark/zcontroller/controller in controllerlocation)
if(controller.up && d1 == 12)
T = locate(src.x, src.y, controller.up_target)
if(T)
. += power_list(T, src, 11, 1)
if(controller.down && d1 == 11)
T = locate(src.x, src.y, controller.down_target)
if(T)
. += power_list(T, src, 12, 1)
///// Z-Level Stuff
// Handle z-level connections.
if(d1 == 11 || d1 == 12)
// Connections below.
if(d1 == 11)
var/turf/turf = GetBelow(src)
if(turf)
. += power_list(turf, src, 12, 1)
// Connections above.
if(d1 == 12)
var/turf/turf = GetAbove(src)
if(turf)
. += power_list(turf, src, 11, 1)
//get matching cables from the first direction
else if(d1) //if not a node cable
T = get_step(src, d1)
@@ -376,19 +373,22 @@ obj/structure/cable/proc/cableColor(var/colorC)
. += power_list(loc, src, d1, powernetless_only) //get on turf matching cables
///// Z-Level Stuff
// Second direction.
// Handle z-level connections.
if(d2 == 11 || d2 == 12)
var/turf/controllerlocation = locate(1, 1, z)
for(var/obj/effect/landmark/zcontroller/controller in controllerlocation)
if(controller.up && d2 == 12)
T = locate(src.x, src.y, controller.up_target)
if(T)
. += power_list(T, src, 11, 1)
if(controller.down && d2 == 11)
T = locate(src.x, src.y, controller.down_target)
if(T)
. += power_list(T, src, 12, 1)
///// Z-Level Stuff
// Connections below.
if(d2 == 11)
var/turf/turf = GetBelow(src)
if(turf)
. += power_list(turf, src, 12, 1)
// Connections above.
if(d2 == 12)
var/turf/turf = GetAbove(src)
if(turf)
. += power_list(turf, src, 11, 1)
else
//do the same on the second direction (which can't be 0)
T = get_step(src, d2)
@@ -672,15 +672,14 @@ obj/structure/cable/proc/cableColor(var/colorC)
return
///// Z-Level Stuff
// check if the target is open space
if(istype(F, /turf/simulated/floor/open))
if(istype(F, /turf/simulated/open))
for(var/obj/structure/cable/LC in F)
if((LC.d1 == dirn && LC.d2 == 11 ) || ( LC.d2 == dirn && LC.d1 == 11))
user << "<span class='warning'>There's already a cable at that position.</span>"
return
var/turf/simulated/floor/open/temp = F
var/obj/structure/cable/C = new(F)
var/obj/structure/cable/D = new(temp.floorbelow)
var/obj/structure/cable/D = new(GetBelow(F))
C.cableColor(color)
+3 -9
View File
@@ -985,12 +985,9 @@
var/obj/structure/disposalpipe/P
if(nextdir == 12)
var/turf/controllerlocation = locate(1, 1, src.z)
for(var/obj/effect/landmark/zcontroller/controller in controllerlocation)
if(controller.up)
T = locate(src.x, src.y, controller.up_target)
T = GetAbove(src)
if(!T)
H.loc = src.loc
H.loc = loc
return
else
for(var/obj/structure/disposalpipe/down/F in T)
@@ -1038,10 +1035,7 @@
var/obj/structure/disposalpipe/P
if(nextdir == 11)
var/turf/controllerlocation = locate(1, 1, src.z)
for(var/obj/effect/landmark/zcontroller/controller in controllerlocation)
if(controller.down)
T = locate(src.x, src.y, controller.down_target)
T = GetBelow(src)
if(!T)
H.loc = src.loc
return