Files
Batrachophreno 4ecb0bc21c Repath obj/machinery to obj/structure/machinery [MDB Ignore] (#22500)
Repaths obj/machinery to obj/structure/machinery. **Note for
reviewers:** the only meaningful changed code exists within
**code/game/objects/structures.dm** and
**code/game/objects/structures/_machinery.dm**, largely concerning
damage procs. With the exception of moving airlock defines to their own
file, ALL OTHER CHANGES ARE STRICTLY PATH CHANGES.

Objects, _categorically_, are largely divided between those you can hold
in your hand/inventory and those you can't. Machinery objects are
already subtypes of Structures behaviorally, this PR just makes their
pathing reflect that, and allows for future work (tool actions, more
health/destruction functionality) to be developed without unnecessary
code duplication.

I have tested this PR by loading up the Horizon and dismantling various
machines and structures with tools, shooting guns of various types
throughout the ship, and detonating a bunch of explosions throughout the
ship.
2026-05-26 19:35:48 +00:00

65 lines
1.7 KiB
Plaintext

SUBSYSTEM_DEF(sun)
name = "Sun"
flags = SS_NO_INIT | SS_POST_FIRE_TIMING | SS_BACKGROUND
wait = 1 MINUTE
priority = SS_PRIORITY_SUN
runlevels = RUNLEVELS_PLAYING
var/angle
var/dx
var/dy
var/rate
var/list/solars // for debugging purposes, references solars_list at the constructor
var/tmp/list/updating_solars
var/solar_next_update // last time the sun position was checked and adjusted
/datum/controller/subsystem/sun/PreInit()
LAZYINITLIST(solars)
rate = rand(50,200)/100 // 50% - 200% of standard rotation
if(prob(50)) // same chance to rotate clockwise than counter-clockwise
rate = -rate
solar_next_update = world.time // init the timer
angle = rand (0,360)
/datum/controller/subsystem/sun/stat_entry(msg)
msg = "A:[angle] R:[rate] S:[LAZYLEN(solars)]"
return ..()
/datum/controller/subsystem/sun/fire(resumed = 0)
if (!resumed)
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)
updating_solars = solars.Copy()
//now tell the solar control computers to update their status and linked devices
while (updating_solars.len)
var/obj/structure/machinery/power/solar_control/SC = updating_solars[updating_solars.len]
updating_solars.len--
if (QDELETED(SC) || !SC.powernet)
solars -= SC
continue
SC.update()
if (MC_TICK_CHECK)
return