Fixes wires breaking on shuttle movement/rotation

This commit is contained in:
c0
2017-04-21 11:20:00 +03:00
parent 7db57a9f25
commit 3b0b963609
4 changed files with 77 additions and 16 deletions
@@ -409,13 +409,13 @@
NC.cableColor("red")
NC.d1 = 0
NC.d2 = fdirn
NC.updateicon()
NC.update_icon()
var/datum/powernet/PN
if(last_piece && last_piece.d2 != chassis.dir)
last_piece.d1 = min(last_piece.d2, chassis.dir)
last_piece.d2 = max(last_piece.d2, chassis.dir)
last_piece.updateicon()
last_piece.update_icon()
PN = last_piece.powernet
if(!PN)
+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...
+4 -9
View File
@@ -1,3 +1,7 @@
// Called before shuttle starts moving atoms.
/atom/movable/proc/beforeShuttleMove(turf/T1, rotation)
return
// Called when shuttle attempts to move an atom.
/atom/movable/proc/onShuttleMove(turf/T1, rotation)
if(rotation)
@@ -18,15 +22,6 @@
. = ..()
#define DIR_CHECK_TURF_AREA(X) (get_area(get_ranged_target_turf(src, X, 1)) != A)
/obj/structure/cable/onShuttleMove()
. = ..()
var/A = get_area(src)
//cut cables on the edge
if(DIR_CHECK_TURF_AREA(NORTH) || DIR_CHECK_TURF_AREA(SOUTH) || DIR_CHECK_TURF_AREA(EAST) || DIR_CHECK_TURF_AREA(WEST))
cut_cable_from_powernet()
#undef DIR_CHECK_TURF_AREA
/atom/movable/light/onShuttleMove()
return 0
+13
View File
@@ -481,6 +481,19 @@
//move or squish anything in the way ship at destination
roadkill(L0, L1, S1.dir)
for(var/i in 1 to L0.len)
var/turf/T0 = L0[i]
if(!T0)
continue
var/turf/T1 = L1[i]
if(!T1)
continue
if(T0.type == T0.baseturf)
continue
for(var/atom/movable/AM in T0)
AM.beforeShuttleMove(T1, rotation)
var/list/moved_atoms = list()
for(var/i in 1 to L0.len)