Merge pull request #16212 from AffectedArc07/atom-rotation

Better atom rotation
This commit is contained in:
Fox McCloud
2021-07-01 22:15:58 -04:00
committed by GitHub
10 changed files with 31 additions and 24 deletions
+11 -14
View File
@@ -31,19 +31,20 @@
return 1
/proc/Get_Angle(atom/movable/start,atom/movable/end)//For beams.
if(!start || !end) return 0
/proc/get_angle(atom/movable/start, atom/movable/end)//For beams.
if(!start || !end)
return 0
var/dy
var/dx
dy=(32*end.y+end.pixel_y)-(32*start.y+start.pixel_y)
dx=(32*end.x+end.pixel_x)-(32*start.x+start.pixel_x)
dy = (32 * end.y + end.pixel_y) - (32 * start.y + start.pixel_y)
dx = (32 * end.x + end.pixel_x) - (32 * start.x + start.pixel_x)
if(!dy)
return (dx>=0)?90:270
.=arctan(dx/dy)
if(dy<0)
.+=180
else if(dx<0)
.+=360
return (dx >= 0) ? 90 : 270
. = arctan(dx / dy)
if(dy < 0)
. += 180
else if(dx < 0)
. += 360
//Returns location. Returns null if no location was found.
/proc/get_teleport_loc(turf/location,mob/target,distance = 1, density = 0, errorx = 0, errory = 0, eoffsetx = 0, eoffsety = 0)
@@ -1246,10 +1247,6 @@ GLOBAL_LIST_INIT(wall_items, typecacheof(list(/obj/machinery/power/apc, /obj/mac
return 1
return 0
/proc/get_angle(atom/a, atom/b)
return atan2(b.y - a.y, b.x - a.x)
/proc/atan2(x, y)
if(!x && !y) return 0
return y >= 0 ? arccos(x / sqrt(x * x + y * y)) : -arccos(x / sqrt(x * x + y * y))
+1 -1
View File
@@ -58,7 +58,7 @@
return ..()
/datum/beam/proc/Draw()
var/Angle = round(Get_Angle(origin,target))
var/Angle = round(get_angle(origin, target))
var/matrix/rot_matrix = matrix()
rot_matrix.Turn(Angle)
+8
View File
@@ -1139,3 +1139,11 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
else
name = "[prefix][t]"
return t
/atom/proc/set_angle(degrees)
var/matrix/M = matrix()
M.Turn(degrees)
// If we aint 0, make it NN transform
if(degrees)
appearance_flags |= PIXEL_SCALE
transform = M
+3 -1
View File
@@ -657,6 +657,7 @@ GLOBAL_LIST_EMPTY(turret_icons)
qdel(flick_holder)
set_raised_raising(FALSE, FALSE)
set_angle(0)
update_icon()
/obj/machinery/porta_turret/on_assess_perp(mob/living/carbon/human/perp)
@@ -678,7 +679,8 @@ GLOBAL_LIST_EMPTY(turret_icons)
last_target = target
if(has_cover)
popUp() //pop the turret up if it's not already up.
setDir(get_dir(src, target)) //even if you can't shoot, follow the target
// Set angle
set_angle(get_angle(src, target))
shootAt(target)
return TRUE
@@ -189,7 +189,7 @@ Difficulty: Very Hard
var/turf/target_turf = get_turf(target)
playsound(src, 'sound/magic/clockwork/invoke_general.ogg', 200, TRUE, 2)
newtonian_move(get_dir(target_turf, src))
var/angle_to_target = Get_Angle(src, target_turf)
var/angle_to_target = get_angle(src, target_turf)
if(isnum(set_angle))
angle_to_target = set_angle
var/static/list/colossus_shotgun_shot_angles = list(12.5, 7.5, 2.5, -2.5, -7.5, -12.5)
+5 -5
View File
@@ -101,7 +101,7 @@
overlays += image('icons/obj/power.dmi', icon_state = "solar_panel-b", layer = FLY_LAYER)
else
overlays += image('icons/obj/power.dmi', icon_state = "solar_panel", layer = FLY_LAYER)
src.dir = angle2dir(adir)
set_angle(adir)
return
//calculates the fraction of the sunlight that the panel recieves
@@ -298,7 +298,7 @@
if(autostart)
search_for_connected()
if(connected_tracker && track == TRACKER_AUTO)
connected_tracker.set_angle(SSsun.angle)
connected_tracker.modify_angle(SSsun.angle)
set_panels(cdir)
/obj/machinery/power/solar_control/Destroy()
@@ -338,7 +338,7 @@
return
if(track == TRACKER_AUTO && connected_tracker) // auto-tracking
connected_tracker.set_angle(SSsun.angle)
connected_tracker.modify_angle(SSsun.angle)
set_panels(cdir)
updateDialog()
@@ -410,7 +410,7 @@
track = text2num(params["track"])
if(track == TRACKER_AUTO)
if(connected_tracker)
connected_tracker.set_angle(SSsun.angle)
connected_tracker.modify_angle(SSsun.angle)
set_panels(cdir)
else if(track == TRACKER_TIMED)
targetdir = cdir
@@ -420,7 +420,7 @@
if("refresh")
search_for_connected()
if(connected_tracker && track == TRACKER_AUTO)
connected_tracker.set_angle(SSsun.angle)
connected_tracker.modify_angle(SSsun.angle)
set_panels(cdir)
/obj/machinery/power/solar_control/attackby(obj/item/I, mob/user, params)
+1 -1
View File
@@ -50,7 +50,7 @@
update_icon()
//updates the tracker icon and the facing angle for the control computer
/obj/machinery/power/tracker/proc/set_angle(angle)
/obj/machinery/power/tracker/proc/modify_angle(angle)
sun_angle = angle
//set icon dir to show sun illumination
+1 -1
View File
@@ -239,7 +239,7 @@
if((!current || loc == current))
current = locate(clamp(x + xo, 1, world.maxx), clamp(y + yo, 1, world.maxy), z)
if(isnull(Angle))
Angle = round(Get_Angle(src, current))
Angle = round(get_angle(src, current))
if(spread)
Angle += (rand() - 0.5) * spread
var/matrix/M = new
Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 14 KiB