Files
Paradise/code/controllers/Processes/sun.dm
Krausus 61edb3eb95 Further process tweaks
- Integrates Volundr's btime library and associated process scheduler
changes.
- btime is implemented separately from the process scheduler, as precise
time measurement is also useful elsewhere.
- `TimeOfHour` is no longer internally throttled; throttling is instead
done by `SCHECK`.
- If btime's `gettime` cannot be called at world startup, an error will
be output and the world will stop.
- Retains the change to schedule processes according to game time,
rather than real time.
- Removes the (now unused) update queue files.
- Removes the process scheduler testing files.
- These are standalone tests for the process scheduler, completely
unrelated to its use in the full codebase. We never used them.
- Moves the process scheduler defines into __DEFINES.
- Makes the lighting process run once before the round starts.
- Renames `scheck` to `sleepCheck`, to ensure any code that tries to use
`scheck` will fail to compile.
- Adds `SCHECK` and `SCHECK_EVERY` macros that skip calling `sleepCheck`
entirely until a specified number of `SCHECK`s (50 by default) have been
called.
- Makes most processes iterate using their `last_object` variable,
allowing hang recovery to show the type that caused the hang.
- Makes processes output an error when they filter out a type they
refuse to process.
- Rolls the recently-added alarm subsystem into the alarm process.
- Removes the now unused subsystems code.
2015-08-08 09:07:26 -04:00

61 lines
1.8 KiB
Plaintext

var/global/datum/controller/process/sun/sun
/datum/controller/process/sun
var/angle
var/dx
var/dy
var/rate
var/list/solars = list() // for debugging purposes, references solars list at the constructor
/datum/controller/process/sun/setup()
name = "sun"
schedule_interval = 600 // every 60 seconds
sun = src
angle = rand (0,360) // the station position to the sun is randomised at round start
rate = rand(50,200)/100 // 50% - 200% of standard rotation
if(prob(50)) // same chance to rotate clockwise than counter-clockwise
rate = -rate
/datum/controller/process/sun/doWork()
calc_position()
update_solar_machinery()
// calculate the sun's position given the time of day
// at the standard rate (100%) the angle is increase/decreased by 6 degrees every minute.
// a full rotation thus take a game hour in that case
/datum/controller/process/sun/proc/calc_position()
angle = (360 + angle + rate * 6) % 360 // increase/decrease the angle to the sun, adjusted by the rate
// now calculate and cache the (dx,dy) increments for line drawing
var/s = sin(angle)
var/c = cos(angle)
// Either "abs(s) < abs(c)" or "abs(s) >= abs(c)"
// In both cases, the greater is greater than 0, so, no "if 0" check is needed for the divisions
if(abs(s) < abs(c))
dx = s / abs(c)
dy = c / abs(c)
else
dx = s / abs(s)
dy = c / abs(s)
//now tell the solar control computers to update their status and linked devices
/datum/controller/process/sun/proc/update_solar_machinery()
for(last_object in solars)
var/obj/machinery/power/solar_control/SC = last_object
if(istype(SC) && isnull(SC.gcDestroyed))
if(!SC.powernet)
solars -= SC
continue
try
SC.update()
catch(var/exception/e)
catchException(e, SC)
SCHECK
else
catchBadType(SC)
solars -= SC