mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-24 17:11:40 +00:00
-Added a solar pack crate to order. -Machines that have a use_power of 0 will no longer be turned off due to lack of power in the area. -Fixed a bug with the solar computer not reconnecting to the powernet when dismantled and remantled. -Increased the cap of crates to 30. -Some performance tweaks. -Some standardization. -All objects of type /obj/machinery/power will try to disconnect from the powernet before deleting, this will help reduce the node list size. -Added a heat_proof variable for doors. It will effect glass airlocks and it'll determine whether they can block heat or not. Research glass airlocks will always have it enabled. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5344 316c924e-a436-60f5-8080-3fe189b3f50e
85 lines
1.8 KiB
Plaintext
85 lines
1.8 KiB
Plaintext
/datum/sun
|
|
var/angle
|
|
var/dx
|
|
var/dy
|
|
var/counter = 50 // to make the vars update during 1st call
|
|
var/rate
|
|
|
|
/datum/sun/New()
|
|
rate = rand(75,125)/100 // 75% - 125% of standard rotation
|
|
if(prob(50))
|
|
rate = -rate
|
|
|
|
// calculate the sun's position given the time of day
|
|
|
|
/datum/sun/proc/calc_position()
|
|
|
|
counter++
|
|
if(counter<50) // count 50 pticks (50 seconds, roughly - about a 5deg change)
|
|
return
|
|
counter = 0
|
|
|
|
angle = ((rate*world.realtime/100)%360 + 360)%360 // gives about a 60 minute rotation time
|
|
// now 45 - 75 minutes, depending on rate
|
|
// now calculate and cache the (dx,dy) increments for line drawing
|
|
|
|
var/s = sin(angle)
|
|
var/c = cos(angle)
|
|
|
|
if(c == 0)
|
|
|
|
dx = 0
|
|
dy = s
|
|
|
|
else if( abs(s) < abs(c))
|
|
|
|
dx = s / abs(c)
|
|
dy = c / abs(c)
|
|
|
|
else
|
|
dx = s/abs(s)
|
|
dy = c / abs(s)
|
|
|
|
|
|
for(var/M in machines)
|
|
|
|
// Solar Tracker
|
|
if(istype(M, /obj/machinery/power/tracker))
|
|
var/obj/machinery/power/tracker/T = M
|
|
T.set_angle(angle)
|
|
|
|
// Solar Panel
|
|
else if(istype(M, /obj/machinery/power/solar))
|
|
var/obj/machinery/power/solar/S = M
|
|
if(S.control)
|
|
occlusion(S)
|
|
|
|
|
|
|
|
// for a solar panel, trace towards sun to see if we're in shadow
|
|
|
|
/datum/sun/proc/occlusion(var/obj/machinery/power/solar/S)
|
|
|
|
var/ax = S.x // start at the solar panel
|
|
var/ay = S.y
|
|
|
|
for(var/i = 1 to 20) // 20 steps is enough
|
|
ax += dx // do step
|
|
ay += dy
|
|
|
|
var/turf/T = locate( round(ax,0.5),round(ay,0.5),S.z)
|
|
|
|
if(T.x == 1 || T.x==world.maxx || T.y==1 || T.y==world.maxy) // not obscured if we reach the edge
|
|
break
|
|
|
|
if(T.density) // if we hit a solid turf, panel is obscured
|
|
S.obscured = 1
|
|
return
|
|
|
|
S.obscured = 0 // if hit the edge or stepped 20 times, not obscured
|
|
S.update_solar_exposure()
|
|
|
|
|
|
|
|
|