Adds a proc to allow any /atom/movable to smoothly orbit an /atom

This commit is contained in:
Remie Richards
2015-08-01 21:57:38 -07:00
committed by Tigercat2000
parent f3826a798f
commit 8856dfcf01
+37 -1
View File
@@ -1708,4 +1708,40 @@ var/mob/dview/dview_mob = new
see_in_dark = 1e6
/mob/dview/New() //For whatever reason, if this isn't called, then BYOND will throw a type mismatch runtime when attempting to add this to the mobs list. -Fox
/mob/dview/New() //For whatever reason, if this isn't called, then BYOND will throw a type mismatch runtime when attempting to add this to the mobs list. -Fox
//ORBITS
/atom/movable/var/atom/orbiting = null
//This is just so you can stop an orbit.
//orbit() can run without it (swap orbiting for A)
//but then you can never stop it and that's just silly.
/atom/movable/proc/orbit(atom/A, radius = 10, clockwise = 1, angle_increment = 15)
if(!istype(A))
return
orbiting = A
var/angle = 0
var/matrix/initial_transform = matrix(transform)
spawn
while(orbiting)
loc = orbiting.loc
angle += angle_increment
var/matrix/shift = matrix(initial_transform)
shift.Translate(radius,0)
if(clockwise)
shift.Turn(angle)
else
shift.Turn(-angle)
animate(src,transform = shift,2)
sleep(0.6) //the effect breaks above 0.6 delay
animate(src,transform = initial_transform,2)
/atom/movable/proc/stop_orbit()
if(orbiting)
loc = get_turf(orbiting)
orbiting = null