diff --git a/code/controllers/Processes/air.dm b/code/controllers/Processes/air.dm deleted file mode 100644 index e7937593c19..00000000000 --- a/code/controllers/Processes/air.dm +++ /dev/null @@ -1,197 +0,0 @@ -var/kill_air = 0 - -var/global/datum/controller/process/air_system/air_master - -/datum/controller/process/air_system - var/list/excited_groups = list() - var/list/active_turfs = list() - var/list/hotspots = list() - - //Special functions lists - var/list/turf/simulated/active_super_conductivity = list() - var/list/turf/simulated/high_pressure_delta = list() - - var/current_cycle = 0 - var/failed_ticks = 0 - var/tick_progress = 0 - - // Stats - var/last_active = 0 - var/last_excited = 0 - var/last_hpd = 0 - var/last_hotspots = 0 - var/last_asc = 0 - - -/datum/controller/process/air_system/setup() - name = "air" - schedule_interval = 4 - start_delay = 4 - - var/watch = start_watch() - log_startup_progress("Processing geometry...") - setup_overlays() // Assign icons and such for gas-turf-overlays - setup_allturfs() // Get all currently active tiles that need processing each atmos tick. - log_startup_progress(" Geometry processed in [stop_watch(watch)]s.") - -/datum/controller/process/air_system/doWork() - if(kill_air) - return 1 - current_cycle++ - process_pipenets() - process_atmos_machinery() - process_active_turfs() - process_excited_groups() - process_high_pressure_delta() - process_hotspots() - process_super_conductivity() - return 1 - -/datum/controller/process/air_system/statProcess() - ..() - stat(null, "[last_active] active") - stat(null, "[last_excited] EG | [last_hpd] HPD | [last_asc] ASC | [last_hotspots] Hot") - stat(null, "[pipe_networks.len] pipe nets, [deferred_pipenet_rebuilds.len] deferred") - stat(null, "[atmos_machinery.len] atmos machines") - -DECLARE_GLOBAL_CONTROLLER(air_system, air_master) - -/datum/controller/process/air_system/proc/process_hotspots() - last_hotspots = hotspots.len - for(var/obj/effect/hotspot/H in hotspots) - H.process() - SCHECK - -/datum/controller/process/air_system/proc/process_super_conductivity() - last_asc = active_super_conductivity.len - for(var/turf/simulated/T in active_super_conductivity) - T.super_conduct() - SCHECK - -/datum/controller/process/air_system/proc/process_high_pressure_delta() - last_hpd = high_pressure_delta.len - for(var/turf/T in high_pressure_delta) - T.high_pressure_movements() - T.pressure_difference = 0 - SCHECK - high_pressure_delta.Cut() - -/datum/controller/process/air_system/proc/process_active_turfs() - last_active = active_turfs.len - for(var/turf/simulated/T in active_turfs) - T.process_cell() - SCHECK - -/datum/controller/process/air_system/proc/process_pipenets() - for(last_object in deferred_pipenet_rebuilds) - var/obj/machinery/atmospherics/M = last_object - if(istype(M) && isnull(M.gcDestroyed)) - try - M.build_network() - catch(var/exception/e) - catchException(e, M) - SCHECK - else - catchBadType(M) - deferred_pipenet_rebuilds -= M - - for(last_object in pipe_networks) - var/datum/pipeline/pipeNetwork = last_object - if(istype(pipeNetwork) && isnull(pipeNetwork.gcDestroyed)) - try - pipeNetwork.process() - catch(var/exception/e) - catchException(e, pipeNetwork) - SCHECK - else - catchBadType(pipeNetwork) - pipe_networks -= pipeNetwork - -/datum/controller/process/air_system/proc/process_atmos_machinery() - for(last_object in atmos_machinery) - var/obj/machinery/M = last_object - if(istype(M) && isnull(M.gcDestroyed)) - try - if(M.process_atmos() == PROCESS_KILL) - atmos_machinery.Remove(M) - continue - catch(var/exception/e) - catchException(e, M) - else - catchBadType(M) - atmos_machinery -= M - - SCHECK - - -/datum/controller/process/air_system/proc/remove_from_active(var/turf/simulated/T) - if(istype(T)) - T.excited = 0 - active_turfs -= T - if(T.excited_group) - T.excited_group.garbage_collect() - -/datum/controller/process/air_system/proc/add_to_active(var/turf/simulated/T, var/blockchanges = 1) - if(istype(T) && T.air) - T.excited = 1 - active_turfs |= T - if(blockchanges && T.excited_group) - T.excited_group.garbage_collect() - else - for(var/direction in cardinal) - if(!(T.atmos_adjacent_turfs & direction)) - continue - var/turf/simulated/S = get_step(T, direction) - if(istype(S)) - add_to_active(S) - -/datum/controller/process/air_system/proc/setup_allturfs(var/turfs_in = world) - for(var/turf/simulated/T in turfs_in) - T.CalculateAdjacentTurfs() - if(!T.blocks_air) - T.update_visuals() - for(var/direction in cardinal) - if(!(T.atmos_adjacent_turfs & direction)) - continue - var/turf/enemy_tile = get_step(T, direction) - if(istype(enemy_tile,/turf/simulated/)) - var/turf/simulated/enemy_simulated = enemy_tile - if(!T.air.compare(enemy_simulated.air)) - T.excited = 1 - active_turfs |= T - break - else - if(!T.air.check_turf_total(enemy_tile)) - T.excited = 1 - active_turfs |= T - -/datum/controller/process/air_system/proc/process_excited_groups() - last_excited = excited_groups.len - for(var/datum/excited_group/EG in excited_groups) - EG.breakdown_cooldown++ - if(EG.breakdown_cooldown == 10) - EG.self_breakdown() - SCHECK - return - if(EG.breakdown_cooldown > 20) - EG.dismantle() - SCHECK - -/datum/controller/process/air_system/proc/setup_overlays() - plmaster = new /obj/effect/overlay() - plmaster.icon = 'icons/effects/tile_effects.dmi' - plmaster.icon_state = "plasma" - plmaster.layer = FLY_LAYER - plmaster.mouse_opacity = 0 - - slmaster = new /obj/effect/overlay() - slmaster.icon = 'icons/effects/tile_effects.dmi' - slmaster.icon_state = "sleeping_agent" - slmaster.layer = FLY_LAYER - slmaster.mouse_opacity = 0 - - icemaster = new /obj/effect/overlay() - icemaster.icon = 'icons/turf/overlays.dmi' - icemaster.icon_state = "snowfloor" - icemaster.layer = TURF_LAYER+0.1 - icemaster.mouse_opacity = 0 diff --git a/code/controllers/Processes/spacedrift.dm b/code/controllers/Processes/spacedrift.dm deleted file mode 100644 index d799aeb99d9..00000000000 --- a/code/controllers/Processes/spacedrift.dm +++ /dev/null @@ -1,53 +0,0 @@ -var/global/datum/controller/process/spacedrift/drift_master - -/datum/controller/process/spacedrift - var/list/processing_list = list() - -/datum/controller/process/spacedrift/setup() - name = "spacedrift" - schedule_interval = 5 - start_delay = 20 - log_startup_progress("Spacedrift starting up.") - -/datum/controller/process/spacedrift/statProcess() - ..() - stat(null, "P:[processing_list.len]") - -/datum/controller/process/spacedrift/doWork() - var/list/currentrun = processing_list.Copy() - - while(currentrun.len) - var/atom/movable/AM = currentrun[currentrun.len] - currentrun.len-- - if(!AM) - processing_list -= AM - SCHECK - continue - - if(AM.inertia_next_move > world.time) - SCHECK - continue - - if(!AM.loc || AM.loc != AM.inertia_last_loc || AM.Process_Spacemove(0)) - AM.inertia_dir = 0 - - if(!AM.inertia_dir) - AM.inertia_last_loc = null - processing_list -= AM - SCHECK - continue - - var/old_dir = AM.dir - var/old_loc = AM.loc - AM.inertia_moving = TRUE - step(AM, AM.inertia_dir) - AM.inertia_moving = FALSE - AM.inertia_next_move = world.time + AM.inertia_move_delay - if(AM.loc == old_loc) - AM.inertia_dir = 0 - - AM.setDir(old_dir) - AM.inertia_last_loc = AM.loc - SCHECK - -DECLARE_GLOBAL_CONTROLLER(spacedrift, drift_master) \ No newline at end of file diff --git a/code/controllers/Processes/sun.dm b/code/controllers/Processes/sun.dm deleted file mode 100644 index bd9644b4536..00000000000 --- a/code/controllers/Processes/sun.dm +++ /dev/null @@ -1,61 +0,0 @@ -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 - log_startup_progress("Sun ticker starting up.") - - 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() - -DECLARE_GLOBAL_CONTROLLER(sun, sun) - -// 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 diff --git a/code/controllers/Processes/throwing.dm b/code/controllers/Processes/throwing.dm deleted file mode 100644 index a11c1252d35..00000000000 --- a/code/controllers/Processes/throwing.dm +++ /dev/null @@ -1,138 +0,0 @@ -#define MAX_THROWING_DIST 512 // 2 z-levels on default width -#define MAX_TICKS_TO_MAKE_UP 3 //how many missed ticks will we attempt to make up for this run. - -var/global/datum/controller/process/throwing/throw_master - -/datum/controller/process/throwing - var/list/processing_list - -/datum/controller/process/throwing/setup() - name = "throwing" - schedule_interval = 1 - start_delay = 20 - log_startup_progress("Throw ticker starting up.") - -/datum/controller/process/throwing/statProcess() - ..() - stat(null, "P:[processing_list.len]") - -/datum/controller/process/throwing/started() - ..() - if(!processing_list) - processing_list = list() - -/datum/controller/process/throwing/doWork() - for(last_object in processing_list) - var/atom/movable/AM = last_object - if(istype(AM) && isnull(AM.gcDestroyed)) - var/datum/thrownthing/TT = processing_list[AM] - if(istype(TT) && isnull(TT.gcDestroyed)) - TT.tick() - SCHECK - else - catchBadType(TT) - processing_list -= AM - AM.throwing = null - else - catchBadType(AM) - processing_list -= AM - SCHECK - -DECLARE_GLOBAL_CONTROLLER(throwing, throw_master) - -/datum/thrownthing - var/atom/movable/thrownthing - var/atom/target - var/turf/target_turf - var/init_dir - var/maxrange - var/speed - var/mob/thrower - var/diagonals_first - var/dist_travelled = 0 - var/start_time - var/dist_x - var/dist_y - var/dx - var/dy - var/pure_diagonal - var/diagonal_error - var/datum/callback/callback - -/datum/thrownthing/proc/tick() - var/atom/movable/AM = thrownthing - if(!isturf(AM.loc) || !AM.throwing) - finalize() - return - - if(dist_travelled && hitcheck()) //to catch sneaky things moving on our tile while we slept - finalize() - return - - var/atom/step - - // calculate how many tiles to move, making up for any missed ticks. - if((dist_travelled >= maxrange || AM.loc == target_turf) && has_gravity(AM, AM.loc)) - finalize() - return - - if(dist_travelled <= max(dist_x, dist_y)) //if we haven't reached the target yet we home in on it, otherwise we use the initial direction - step = get_step(AM, get_dir(AM, target_turf)) - else - step = get_step(AM, init_dir) - - if(!pure_diagonal && !diagonals_first) // not a purely diagonal trajectory and we don't want all diagonal moves to be done first - if(diagonal_error >= 0 && max(dist_x, dist_y) - dist_travelled != 1) // we do a step forward unless we're right before the target - step = get_step(AM, dx) - diagonal_error += (diagonal_error < 0) ? dist_x / 2 : -dist_y - - if(!step) // going off the edge of the map makes get_step return null, don't let things go off the edge - finalize() - return - - AM.Move(step, get_dir(AM, step)) - - if(!AM.throwing) // we hit something during our move - finalize(hit = TRUE) - return - - dist_travelled++ - - if(dist_travelled > MAX_THROWING_DIST) - finalize() - return - -/datum/thrownthing/proc/finalize(hit = FALSE) - set waitfor = 0 - throw_master.processing_list -= thrownthing - // done throwning, either because it hit something or it finished moving - thrownthing.throwing = null - if(!hit) - for(var/thing in get_turf(thrownthing)) //looking for our target on the turf we land on. - var/atom/A = thing - if(A == target) - hit = 1 - thrownthing.throw_impact(A, src) - break - if(!hit) - thrownthing.throw_impact(get_turf(thrownthing), src) // we haven't hit something yet and we still must, let's hit the ground. - thrownthing.newtonian_move(init_dir) - else - thrownthing.newtonian_move(init_dir) - if(callback) - callback.Invoke() - -/datum/thrownthing/proc/hit_atom(atom/A) - thrownthing.throw_impact(A, src) - thrownthing.newtonian_move(init_dir) - finalize(TRUE) - -/datum/thrownthing/proc/hitcheck() - for(var/thing in get_turf(thrownthing)) - var/atom/movable/AM = thing - if(AM == thrownthing) - continue - if(AM.density && !(AM.pass_flags & LETPASSTHROW) && !(AM.flags & ON_BORDER)) - thrownthing.throwing = null - thrownthing.throw_impact(AM, src) - return TRUE \ No newline at end of file diff --git a/code/controllers/subsystem/sun.dm b/code/controllers/subsystem/sun.dm new file mode 100644 index 00000000000..8e5e47e7abf --- /dev/null +++ b/code/controllers/subsystem/sun.dm @@ -0,0 +1,42 @@ +SUBSYSTEM_DEF(sun) + name = "Sun" + wait = 600 + flags = SS_NO_TICK_CHECK|SS_NO_INIT + var/angle + var/dx + var/dy + var/rate + var/list/solars = list() + +/datum/controller/subsystem/sun/PreInit() + 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/subsystem/sun/stat_entry(msg) + ..("P:[solars.len]") + +/datum/controller/subsystem/sun/fire() + 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 + for(var/obj/machinery/power/solar_control/SC in solars) + if(!SC.powernet) + solars.Remove(SC) + continue + SC.update() \ No newline at end of file diff --git a/code/controllers/verbs.dm b/code/controllers/verbs.dm index bad73292c82..b076d1915ff 100644 --- a/code/controllers/verbs.dm +++ b/code/controllers/verbs.dm @@ -49,7 +49,7 @@ debug_variables(job_master) feedback_add_details("admin_verb","DJobs") if("Sun") - debug_variables(sun) + debug_variables(SSsun) feedback_add_details("admin_verb","DSun") if("Radio") debug_variables(radio_controller) diff --git a/code/game/gamemodes/vampire/vampire.dm b/code/game/gamemodes/vampire/vampire.dm index 394f7fcc7da..781d417929f 100644 --- a/code/game/gamemodes/vampire/vampire.dm +++ b/code/game/gamemodes/vampire/vampire.dm @@ -384,8 +384,8 @@ You are weak to holy things and starlight. Don't go into space and avoid the Cha var/ay = owner.y for(var/i = 1 to 20) - ax += sun.dx - ay += sun.dy + ax += SSsun.dx + ay += SSsun.dy var/turf/T = locate(round(ax, 0.5), round(ay, 0.5), owner.z) diff --git a/code/modules/power/solar.dm b/code/modules/power/solar.dm index fa9b61c8059..a24e09f435e 100644 --- a/code/modules/power/solar.dm +++ b/code/modules/power/solar.dm @@ -111,7 +111,7 @@ return //find the smaller angle between the direction the panel is facing and the direction of the sun (the sign is not important here) - var/p_angle = min(abs(adir - sun.angle), 360 - abs(adir - sun.angle)) + var/p_angle = min(abs(adir - SSsun.angle), 360 - abs(adir - SSsun.angle)) if(p_angle > 90) // if facing more than 90deg from sun, zero output sunfrac = 0 @@ -174,8 +174,8 @@ var/ax = x // start at the solar panel var/ay = y var/turf/T = null - var/dx = sun.dx - var/dy = sun.dy + var/dx = SSsun.dx + var/dy = SSsun.dy for(var/i = 1 to 20) // 20 steps is enough ax += dx // do step @@ -309,7 +309,7 @@ if(autostart) src.search_for_connected() if(connected_tracker && track == 2) - connected_tracker.set_angle(sun.angle) + connected_tracker.set_angle(SSsun.angle) set_panels(cdir) /obj/machinery/power/solar_control/Destroy() @@ -321,13 +321,12 @@ /obj/machinery/power/solar_control/disconnect_from_network() ..() - if(sun) - sun.solars.Remove(src) + SSsun.solars.Remove(src) /obj/machinery/power/solar_control/connect_to_network() var/to_return = ..() - if(powernet && sun) //if connected and not already in solar list... - sun.solars |= src //... add it + if(powernet) //if connected and not already in solar list... + SSsun.solars |= src //... add it return to_return //search for unconnected panels and trackers in the computer powernet and connect them @@ -355,7 +354,7 @@ cdir = targetdir //...the current direction is the targetted one (and rotates panels to it) if(2) // auto-tracking if(connected_tracker) - connected_tracker.set_angle(sun.angle) + connected_tracker.set_angle(SSsun.angle) set_panels(cdir) updateDialog() @@ -479,7 +478,7 @@ track = text2num(href_list["track"]) if(track == 2) if(connected_tracker) - connected_tracker.set_angle(sun.angle) + connected_tracker.set_angle(SSsun.angle) set_panels(cdir) else if(track == 1) //begin manual tracking src.targetdir = src.cdir @@ -489,7 +488,7 @@ if(href_list["search_connected"]) search_for_connected() if(connected_tracker && track == 2) - connected_tracker.set_angle(sun.angle) + connected_tracker.set_angle(SSsun.angle) set_panels(cdir) return diff --git a/paradise.dme b/paradise.dme index 75274b9ee46..ad5b1fc15af 100644 --- a/paradise.dme +++ b/paradise.dme @@ -201,7 +201,6 @@ #include "code\controllers\Processes\npcpool.dm" #include "code\controllers\Processes\obj.dm" #include "code\controllers\Processes\shuttles.dm" -#include "code\controllers\Processes\sun.dm" #include "code\controllers\Processes\ticker.dm" #include "code\controllers\Processes\timer.dm" #include "code\controllers\Processes\weather.dm" @@ -210,6 +209,7 @@ #include "code\controllers\subsystem\air.dm" #include "code\controllers\subsystem\fires.dm" #include "code\controllers\subsystem\spacedrift.dm" +#include "code\controllers\subsystem\sun.dm" #include "code\controllers\subsystem\throwing.dm" #include "code\datums\action.dm" #include "code\datums\ai_law_sets.dm"