Fixes bugs with shuttles breaking pipes, wires and disposals

This commit is contained in:
CitadelStationBot
2017-04-24 17:43:37 -05:00
parent a6f6317b51
commit 3afe339198
9 changed files with 166 additions and 47 deletions
+58 -5
View File
@@ -108,9 +108,9 @@ By design, d1 is the smallest direction and d2 is the highest
if(level == 1 && isturf(loc))
invisibility = i ? INVISIBILITY_MAXIMUM : 0
updateicon()
update_icon()
/obj/structure/cable/proc/updateicon()
/obj/structure/cable/update_icon()
if(invisibility)
icon_state = "[d1]-[d2]-f"
else
@@ -429,6 +429,59 @@ By design, d1 is the smallest direction and d2 is the highest
if(!P.connect_to_network()) //can't find a node cable on a the turf to connect to
P.disconnect_from_network() //remove from current network
// Ugly procs that ensure proper separation and reconnection of wires on shuttle movement/rotation
/obj/structure/cable/beforeShuttleMove(turf/T1, rotation)
var/on_edge = FALSE
var/A = get_area(src)
for(var/D in GLOB.alldirs)
if(A != get_area(get_step(src, D)))
on_edge = TRUE
break
if(on_edge && powernet)
var/tmp_loc = loc
cut_cable_from_powernet()
loc = tmp_loc
/obj/structure/cable/afterShuttleMove()
var/on_edge = FALSE
var/A = get_area(src)
for(var/D in GLOB.alldirs)
if(A != get_area(get_step(src, D)))
on_edge = TRUE
break
if(on_edge)
var/datum/powernet/PN = new()
PN.add_cable(src)
mergeConnectedNetworks(d1) //merge the powernet with adjacents powernets
mergeConnectedNetworks(d2)
mergeConnectedNetworksOnTurf() //merge the powernet with on turf powernets
if(d1 & (d1 - 1))// if the cable is layed diagonally, check the others 2 possible directions
mergeDiagonalsNetworks(d1)
if(d2 & (d2 - 1))
mergeDiagonalsNetworks(d2)
/obj/structure/cable/shuttleRotate(rotation)
//..() is not called because wires are not supposed to have a non-default direction
//Rotate connections
if(d1)
d1 = angle2dir(rotation+dir2angle(d1))
if(d2)
d2 = angle2dir(rotation+dir2angle(d2))
//d1 should be less than d2 for cable icons to work
if(d1 > d2)
var/temp = d1
d1 = d2
d2 = temp
update_icon()
///////////////////////////////////////////////
// The cable coil object, used for laying cable
///////////////////////////////////////////////
@@ -584,7 +637,7 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
C.d1 = 0 //it's a O-X node cable
C.d2 = dirn
C.add_fingerprint(user)
C.updateicon()
C.update_icon()
//create a new powernet with the cable, if needed it will be merged later
var/datum/powernet/PN = new()
@@ -650,7 +703,7 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
NC.d1 = 0
NC.d2 = fdirn
NC.add_fingerprint()
NC.updateicon()
NC.update_icon()
//create a new powernet with the cable, if needed it will be merged later
var/datum/powernet/newPN = new()
@@ -699,7 +752,7 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
C.update_stored(2, item_color)
C.add_fingerprint()
C.updateicon()
C.update_icon()
C.mergeConnectedNetworks(C.d1) //merge the powernets...