mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 07:38:05 +01:00
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:
@@ -380,38 +380,3 @@
|
||||
|
||||
return new /datum/projectile_data(src_x, src_y, time, distance, power_x, power_y, dest_x, dest_y)
|
||||
|
||||
/proc/getRotationFromDirs(dir1, dir2)
|
||||
return getDegreesFromDir(dir2)-getDegreesFromDir(dir1)
|
||||
|
||||
/proc/getDirFromRotation(rotation, olddir)
|
||||
return getDirFromDegrees(rotation+getDegreesFromDir(olddir))
|
||||
|
||||
/proc/getDirFromDegrees(degrees)
|
||||
if (degrees < 0)
|
||||
degrees += 360
|
||||
if (degrees >= 360)
|
||||
degrees %= 360
|
||||
if (degrees == 360)
|
||||
degrees = 0
|
||||
switch(degrees)
|
||||
if (0)
|
||||
return NORTH
|
||||
if (90)
|
||||
return EAST
|
||||
if (180)
|
||||
return SOUTH
|
||||
if (270)
|
||||
return WEST
|
||||
|
||||
|
||||
/proc/getDegreesFromDir(dir)
|
||||
switch(dir)
|
||||
if (NORTH)
|
||||
return 0
|
||||
if (EAST)
|
||||
return 90
|
||||
if (SOUTH)
|
||||
return 180
|
||||
if (WEST)
|
||||
return 270
|
||||
return 0
|
||||
@@ -62,10 +62,15 @@
|
||||
T.color = color
|
||||
if(T.dir != dir)
|
||||
T.dir = dir
|
||||
T.transform = transform
|
||||
return T
|
||||
|
||||
/turf/simulated/wall/shuttle/copyTurf(turf/T)
|
||||
. = ..()
|
||||
T.transform = transform
|
||||
|
||||
//why don't shuttle walls habe smoothwall? now i gotta do rotation the dirty way
|
||||
/turf/simulated/wall/shuttle/shuttleRotate(rotation)
|
||||
var/matrix/M = matrix(transform)
|
||||
var/matrix/M = transform
|
||||
M.Turn(rotation)
|
||||
transform = M
|
||||
@@ -967,4 +967,4 @@ var/list/slot_equipment_priority = list( \
|
||||
|
||||
//override to avoid rotating pixel_xy on mobs
|
||||
/mob/shuttleRotate(rotation)
|
||||
dir = getDirFromRotation(rotation, dir)
|
||||
dir = angle2dir(rotation+dir2angle(dir))
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user