Shuttle Rotation Tweaks

This should fix shuttle walls not rotating back to their old state correctly when the shuttle docks elsewhere.
Also uses built in procs and caches the calculated rotation angle to improve shuttle docking speed by not calculating it again for every object.
This should also ensure that diagonal objects rotate correctly, rather then snapping back to a cardinal direction.
This commit is contained in:
MrStonedOne
2015-07-20 04:28:46 -07:00
parent 19ef482d87
commit 7f58d930bb
4 changed files with 19 additions and 42 deletions
+12 -5
View File
@@ -270,7 +270,7 @@
//default shuttleRotate
/atom/proc/shuttleRotate(rotation)
dir = getDirFromRotation(rotation, dir)
dir = angle2dir(rotation+dir2angle(dir))
//we need to rotate the pixel offsets too.
if (pixel_x || pixel_y)
@@ -313,6 +313,13 @@
var/list/L0 = return_ordered_turfs(x, y, z, dir, areaInstance)
var/list/L1 = return_ordered_turfs(S1.x, S1.y, S1.z, S1.dir)
var/rotation = dir2angle(S1.dir)-dir2angle(dir)
if ((rotation % 90) != 0)
rotation += (rotation % 90) //diagonal rotations not allowed, round up
rotation = SimplifyDegrees(rotation)
//remove area surrounding docking port
if(areaInstance.contents.len)
var/area/A0 = locate("[area_type]")
@@ -357,8 +364,8 @@
for(var/atom/movable/AM in T0)
if (dir != S1.dir)
AM.shuttleRotate(getRotationFromDirs(dir,S1.dir))
if (rotation)
AM.shuttleRotate(rotation)
if (istype(AM,/obj))
var/obj/O = AM
@@ -392,8 +399,8 @@
M.Weaken(3)
T0.ChangeTurf(turf_type)
if (dir != S1.dir)
T1.shuttleRotate(getRotationFromDirs(dir,S1.dir))
if (rotation)
T1.shuttleRotate(rotation)
loc = S1.loc
dir = S1.dir