Files
Aurora.3/code/_helpers/matrices.dm
Lohikar 1545ba469e Orbit Fixes (#3207)
changes:

Fixed an issue where the segment count argument of orbit() was ignored, leading to the Tesla not animating as it was intended to.
Fixed an issue where /datum/event had two completely unrelated definitions (fixes #3192).
2017-08-02 19:55:53 +03:00

27 lines
878 B
Plaintext

/matrix/proc/TurnTo(old_angle, new_angle)
. = new_angle - old_angle
Turn(.) //BYOND handles cases such as -270, 360, 540 etc. DOES NOT HANDLE 180 TURNS WELL, THEY TWEEN AND LOOK LIKE SHIT
/atom/proc/SpinAnimation(speed = 10, loops = -1, clockwise = 1, segments = 3)
if(!segments)
return
var/segment = 360/segments
if(!clockwise)
segment = -segment
var/list/matrices = list()
for(var/i in 1 to segments-1)
var/matrix/M = matrix(transform)
M.Turn(segment*i)
matrices += M
var/matrix/last = matrix(transform)
matrices += last
speed /= segments
animate(src, transform = matrices[1], time = speed, loops)
for(var/i in 2 to segments) //2 because 1 is covered above
animate(transform = matrices[i], time = speed)
//doesn't have an object argument because this is "Stacking" with the animate call above
//3 billion% intentional