mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 02:34:00 +00:00
Lighting system is too buggy to continue until I know wtf is going on
This commit is contained in:
@@ -74,13 +74,11 @@
|
||||
#include "code\ATMOSPHERICS\components\unary\unary_base.dm"
|
||||
#include "code\ATMOSPHERICS\components\unary\vent_pump.dm"
|
||||
#include "code\ATMOSPHERICS\components\unary\vent_scrubber.dm"
|
||||
#include "code\controllers\_DynamicAreaLighting_TG.dm"
|
||||
#include "code\controllers\autotransfer.dm"
|
||||
#include "code\controllers\configuration.dm"
|
||||
#include "code\controllers\failsafe.dm"
|
||||
#include "code\controllers\hooks-defs.dm"
|
||||
#include "code\controllers\hooks.dm"
|
||||
#include "code\controllers\lighting_controller.dm"
|
||||
#include "code\controllers\master_controller.dm"
|
||||
#include "code\controllers\shuttle_controller.dm"
|
||||
#include "code\controllers\verbs.dm"
|
||||
@@ -1285,6 +1283,12 @@
|
||||
#include "code\WorkInProgress\explosion_particles.dm"
|
||||
#include "code\WorkInProgress\periodic_news.dm"
|
||||
#include "code\WorkInProgress\Apples\artifacts.dm"
|
||||
#include "code\WorkInProgress\Aryn\Lighting\Compatibility.dm"
|
||||
#include "code\WorkInProgress\Aryn\Lighting\Controller.dm"
|
||||
#include "code\WorkInProgress\Aryn\Lighting\Engine.dm"
|
||||
#include "code\WorkInProgress\Aryn\Lighting\Light.dm"
|
||||
#include "code\WorkInProgress\Aryn\Lighting\Lightpoint.dm"
|
||||
#include "code\WorkInProgress\Aryn\Lighting\Math.dm"
|
||||
#include "code\WorkInProgress\Cael_Aislinn\Jungle\falsewall.dm"
|
||||
#include "code\WorkInProgress\Cael_Aislinn\Jungle\jungle.dm"
|
||||
#include "code\WorkInProgress\Cael_Aislinn\Jungle\jungle_animals.dm"
|
||||
|
||||
41
code/WorkInProgress/Aryn/Lighting/Compatibility.dm
Normal file
41
code/WorkInProgress/Aryn/Lighting/Compatibility.dm
Normal file
@@ -0,0 +1,41 @@
|
||||
area/var/lighting_use_dynamic
|
||||
|
||||
turf/space/is_outside = 1
|
||||
|
||||
/datum/controller/lighting/var/processing = 1
|
||||
/datum/controller/lighting/var/iteration = 0
|
||||
|
||||
//Because so many objects jump the gun.
|
||||
proc/lighting_ready()
|
||||
return lighting_controller && lighting_controller.started
|
||||
|
||||
turf_light_data
|
||||
var/light_overlay
|
||||
var/lightNW
|
||||
var/lightSW
|
||||
var/lightNE
|
||||
var/lightSE
|
||||
var/lit_by
|
||||
|
||||
turf_light_data/proc/copy_from(turf/T)
|
||||
light_overlay = T.light_overlay
|
||||
lightNW = T.lightNW
|
||||
lightSW = T.lightSW
|
||||
lightNE = T.lightNE
|
||||
lightSE = T.lightSE
|
||||
lit_by = T.lit_by
|
||||
|
||||
turf_light_data/proc/copy_to(turf/T)
|
||||
T.light_overlay = light_overlay
|
||||
T.lightNW = lightNW
|
||||
T.lightSW = lightSW
|
||||
T.lightNE = lightNE
|
||||
T.lightSE = lightSE
|
||||
T.lit_by = lit_by
|
||||
//T.ResetValue()
|
||||
|
||||
atom/proc/SetLuminosity(n)
|
||||
n = min(n,10) //Caelcode.
|
||||
SetLight(n>>1,n)
|
||||
luminosity = n
|
||||
//else lighting_controller.initial_lights.Add(src)
|
||||
@@ -34,9 +34,11 @@ Class Procs:
|
||||
*/
|
||||
|
||||
var/datum/controller/lighting/lighting_controller
|
||||
var/list/initial_lights = list()
|
||||
|
||||
var/all_lightpoints_made = 0
|
||||
|
||||
var/list/lit_z_levels = list(1,5)
|
||||
|
||||
/datum/controller/lighting
|
||||
|
||||
var/starlight = 4
|
||||
@@ -44,6 +46,8 @@ var/all_lightpoints_made = 0
|
||||
|
||||
var/list/light_border = list()
|
||||
|
||||
var/started = 0
|
||||
|
||||
//var/icon/border = icon('Icons/Test.dmi', "border")
|
||||
|
||||
/datum/controller/lighting/New()
|
||||
@@ -51,47 +55,45 @@ var/all_lightpoints_made = 0
|
||||
|
||||
/datum/controller/lighting/proc/Initialize()
|
||||
|
||||
set background = 1
|
||||
|
||||
var/start_time = world.timeofday
|
||||
world << "<b><font color=red>Processing lights...</font></b>"
|
||||
|
||||
var/turfs_updated = 0
|
||||
sleep(1)
|
||||
|
||||
for(var/z = 1, z <= world.maxz, z++)
|
||||
var/turfs_updated = 0
|
||||
var/total_turfs = world.maxx*world.maxy*lit_z_levels.len
|
||||
|
||||
for(var/z in lit_z_levels)
|
||||
for(var/y = 0, y <= world.maxy, y++)
|
||||
for(var/x = 0, x <= world.maxx, x++)
|
||||
if(x > 0 && y > 0)
|
||||
var/turf/T = locate(x,y,z)
|
||||
if(!T.light_overlay)
|
||||
T.light_overlay = new(T)
|
||||
T.CheckForOpaqueObjects()
|
||||
|
||||
turfs_updated++
|
||||
if((turfs_updated % 5000) == 0)
|
||||
sleep(1)
|
||||
world << "<font color=red>Progress: [round((turfs_updated/total_turfs)*100, 0.01)]% ([turfs_updated]/[total_turfs])"
|
||||
|
||||
var/turf/T = locate(x,y,z)
|
||||
if(!T.light_overlay && !T.is_outside)
|
||||
T.light_overlay = new(T)
|
||||
T.ResetValue()
|
||||
if(!all_lightpoints_made) new/lightpoint(x+0.5,y+0.5,z)
|
||||
|
||||
|
||||
|
||||
//world << "[x],[y],[z]"
|
||||
|
||||
all_lightpoints_made = 1
|
||||
started = 1
|
||||
|
||||
for(var/atom/movable/M in initial_lights)
|
||||
if(!M.light)
|
||||
M.SetLight(M.luminosity,M.luminosity)
|
||||
else
|
||||
M.light.Reset()
|
||||
|
||||
StarLight(starlight)
|
||||
initial_lights = null
|
||||
for(var/turf/T)
|
||||
if(!T.is_outside) T.UpdateLight()
|
||||
|
||||
world << "<b><font color=red>Lighting initialization took [(world.timeofday-start_time)/world.fps] seconds.</font></b>"
|
||||
world << "<font color=red>Updated [turfs_updated] turfs.</font>"
|
||||
|
||||
/datum/controller/lighting/proc/StarLight(n)
|
||||
starlight = n
|
||||
for(var/turf/T in light_border)
|
||||
T.SetLight(5,n-1)
|
||||
|
||||
for(var/turf/T)
|
||||
if(T.is_outside)
|
||||
T.ResetValue()
|
||||
|
||||
FlushIconUpdates()
|
||||
|
||||
/datum/controller/lighting/proc/MarkIconUpdate(turf/T)
|
||||
if(!T.needs_light_update)
|
||||
icon_updates.Add(T)
|
||||
|
||||
@@ -65,6 +65,7 @@ atom/var/light/light
|
||||
turf/var/obj/effect/lighting_overlay/light_overlay
|
||||
|
||||
turf/var/lit_value = 0
|
||||
turf/var/max_brightness = 0
|
||||
turf/var/has_opaque = 0
|
||||
turf/var/is_outside = 0
|
||||
turf/var/is_border = 0
|
||||
@@ -78,16 +79,13 @@ turf/var/list/lit_by
|
||||
|
||||
atom/New()
|
||||
. = ..()
|
||||
if(luminosity || light)
|
||||
if(!lighting_controller)
|
||||
initial_lights.Add(src)
|
||||
if(luminosity)
|
||||
if(!light)
|
||||
SetLight(luminosity,luminosity)
|
||||
else
|
||||
if(!light)
|
||||
SetLight(luminosity,luminosity)
|
||||
else
|
||||
light.Reset()
|
||||
if(lighting_controller)
|
||||
if(opacity)
|
||||
light.Reset()
|
||||
if(opacity)
|
||||
if(lighting_ready())
|
||||
opacity = 0
|
||||
SetOpacity(1)
|
||||
|
||||
@@ -102,11 +100,18 @@ atom/movable/Move()
|
||||
lighting_controller.FlushIconUpdates()
|
||||
|
||||
atom/proc/SetLight(intensity, radius)
|
||||
if(!intensity)
|
||||
if(!light) return
|
||||
light.Off()
|
||||
light = null
|
||||
if(lighting_ready()) lighting_controller.FlushIconUpdates()
|
||||
return
|
||||
if(!light) light = new(src)
|
||||
if(light.intensity == intensity) return
|
||||
light.radius = min(radius,15)
|
||||
light.intensity = intensity
|
||||
light.Reset()
|
||||
lighting_controller.FlushIconUpdates()
|
||||
if(lighting_ready()) lighting_controller.FlushIconUpdates()
|
||||
|
||||
atom/proc/SetOpacity(o)
|
||||
if(o == opacity) return
|
||||
@@ -122,41 +127,72 @@ turf/proc/UpdateLight()
|
||||
light_overlay.icon_state = "[lightSE.max_value()][lightSW.max_value()][lightNW.max_value()][lightNE.max_value()]"
|
||||
|
||||
turf/proc/AddLight(light/light)
|
||||
if(is_outside) return
|
||||
if(has_opaque) return
|
||||
|
||||
if(!lit_by) lit_by = list()
|
||||
lit_by.Add(light)
|
||||
if(!has_opaque)
|
||||
var/brightness = light.CalculateBrightness(src)
|
||||
if(brightness > lit_value)
|
||||
|
||||
var/brightness = light.CalculateBrightness(src)
|
||||
lit_by[light] = brightness
|
||||
|
||||
if(!has_opaque && lighting_ready())
|
||||
if(brightness > max_brightness)
|
||||
lit_value = LIGHTCLAMP(brightness)
|
||||
max_brightness = brightness
|
||||
ResetCachedValues()
|
||||
for(var/turf/T in range(1,src))
|
||||
lighting_controller.MarkIconUpdate(T)
|
||||
for(var/turf/T in range(1,src))
|
||||
lighting_controller.MarkIconUpdate(T)
|
||||
|
||||
turf/proc/RemoveLight(light/light)
|
||||
lit_by.Remove(light)
|
||||
ResetValue()
|
||||
if(!lit_by.len) lit_by = null
|
||||
if(has_opaque) return
|
||||
if(lit_by)
|
||||
var/brightness = lit_by[light]
|
||||
lit_by.Remove(light)
|
||||
if(brightness == max_brightness)
|
||||
ResetValue()
|
||||
if(!lit_by.len) lit_by = null
|
||||
|
||||
turf/proc/ResetValue()
|
||||
if(is_outside)
|
||||
max_brightness = lighting_controller.starlight
|
||||
lit_value = LIGHTCLAMP(lighting_controller.starlight)
|
||||
return
|
||||
|
||||
var/old_value = lit_value
|
||||
|
||||
CheckForOpaqueObjects()
|
||||
if(has_opaque)
|
||||
lit_value = 0
|
||||
else
|
||||
var/max_brightness = (is_outside?(lighting_controller.starlight):0)
|
||||
the_part_where_I_calculate_brightness()
|
||||
|
||||
if(lighting_ready() && lit_value != old_value)
|
||||
the_part_where_I_use_range()
|
||||
|
||||
turf/proc
|
||||
the_part_where_I_calculate_brightness()
|
||||
max_brightness = 0
|
||||
for(var/light/light in lit_by)
|
||||
var/brightness = light.CalculateBrightness(src)
|
||||
var/brightness = lit_by[light]//light.CalculateBrightness(src)
|
||||
if(brightness > max_brightness)
|
||||
max_brightness = brightness
|
||||
lit_value = LIGHTCLAMP(max_brightness)
|
||||
ResetCachedValues()
|
||||
for(var/turf/T in range(1,src))
|
||||
lighting_controller.MarkIconUpdate(T)
|
||||
|
||||
the_part_where_I_use_range()
|
||||
ResetCachedValues()
|
||||
for(var/turf/T in range(1,src))
|
||||
lighting_controller.MarkIconUpdate(T)
|
||||
|
||||
turf/proc/ResetCachedValues()
|
||||
lightNE.cached_value = -1
|
||||
lightNW.cached_value = -1
|
||||
lightSE.cached_value = -1
|
||||
lightSW.cached_value = -1
|
||||
if(lightNE)
|
||||
lightNE.cached_value = -1
|
||||
if(lightNW)
|
||||
lightNW.cached_value = -1
|
||||
if(lightSE)
|
||||
lightSE.cached_value = -1
|
||||
if(lightSW)
|
||||
lightSW.cached_value = -1
|
||||
|
||||
turf/proc/CheckForOpaqueObjects()
|
||||
has_opaque = opacity
|
||||
@@ -165,12 +201,5 @@ turf/proc/CheckForOpaqueObjects()
|
||||
if(M.opacity)
|
||||
has_opaque = 1
|
||||
break
|
||||
if(is_outside)
|
||||
for(var/d = 1, d < 16, d*=2)
|
||||
var/turf/T = get_step(src,d)
|
||||
if(T && !T.is_outside)
|
||||
lighting_controller.AddBorder(src)
|
||||
return
|
||||
if(is_border) lighting_controller.RemoveBorder(src)
|
||||
|
||||
#undef LIGHTCLAMP
|
||||
@@ -37,8 +37,9 @@ light/proc/Reset()
|
||||
|
||||
if(intensity > 0)
|
||||
for(var/turf/T in view(atom,radius+1))
|
||||
T.AddLight(src)
|
||||
lit_turfs.Add(T)
|
||||
if(!T.is_outside)
|
||||
T.AddLight(src)
|
||||
lit_turfs.Add(T)
|
||||
|
||||
light/proc/Off()
|
||||
for(var/turf/T in lit_turfs)
|
||||
|
||||
@@ -108,6 +108,7 @@ Class Procs:
|
||||
|
||||
/zone/proc/rebuild()
|
||||
if(invalid) return //Short circuit for explosions where rebuild is called many times over.
|
||||
if(air_master.current_cycle == 0) return //Why would you rebuild when you're building?
|
||||
c_invalidate()
|
||||
for(var/turf/simulated/T in contents)
|
||||
//T.dbg(invalid_zone)
|
||||
|
||||
@@ -45,7 +45,8 @@ var/datum/controller/failsafe/Failsafe
|
||||
MC_defcon = 0
|
||||
MC_iteration = controller_iteration
|
||||
|
||||
if(lighting_controller.processing)
|
||||
//Lighting controller now neither processes nor iterates.
|
||||
/*if(lighting_controller.processing)
|
||||
if(lighting_iteration == lighting_controller.iteration) //master_controller hasn't finished processing in the defined interval
|
||||
switch(lighting_defcon)
|
||||
if(0 to 3)
|
||||
@@ -60,7 +61,7 @@ var/datum/controller/failsafe/Failsafe
|
||||
lighting_defcon = 0
|
||||
else
|
||||
lighting_defcon = 0
|
||||
lighting_iteration = lighting_controller.iteration
|
||||
lighting_iteration = lighting_controller.iteration*/
|
||||
else
|
||||
MC_defcon = 0
|
||||
lighting_defcon = 0
|
||||
|
||||
@@ -77,6 +77,7 @@ datum/controller/game_controller/proc/setup()
|
||||
if(ticker)
|
||||
ticker.pregame()
|
||||
|
||||
new/datum/controller/lighting()
|
||||
lighting_controller.Initialize()
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
feedback_add_details("admin_verb","RFailsafe")
|
||||
if("Lighting")
|
||||
new /datum/controller/lighting()
|
||||
lighting_controller.process()
|
||||
//lighting_controller.process()
|
||||
feedback_add_details("admin_verb","RLighting")
|
||||
if("Supply Shuttle")
|
||||
supply_shuttle.process()
|
||||
|
||||
@@ -24,20 +24,16 @@
|
||||
// lighting_state = 4
|
||||
//has_gravity = 0 // Space has gravity. Because.. because.
|
||||
|
||||
if(requires_power)
|
||||
luminosity = 0
|
||||
else
|
||||
if(!requires_power)
|
||||
power_light = 0 //rastaf0
|
||||
power_equip = 0 //rastaf0
|
||||
power_environ = 0 //rastaf0
|
||||
luminosity = 1
|
||||
lighting_use_dynamic = 0
|
||||
|
||||
..()
|
||||
|
||||
// spawn(15)
|
||||
power_change() // all machines set to current power level, also updates lighting icon
|
||||
InitializeLighting()
|
||||
|
||||
|
||||
/area/proc/poweralert(var/state, var/obj/source as obj)
|
||||
|
||||
@@ -148,7 +148,7 @@ var/global/datum/controller/gameticker/ticker
|
||||
|
||||
supply_shuttle.process() //Start the supply shuttle regenerating points -- TLE
|
||||
master_controller.process() //Start master_controller.process()
|
||||
lighting_controller.process() //Start processing DynamicAreaLighting updates
|
||||
//lighting_controller.process() //Start processing DynamicAreaLighting updates
|
||||
|
||||
for(var/obj/multiz/ladder/L in world) L.connect() //Lazy hackfix for ladders. TODO: move this to an actual controller. ~ Z
|
||||
|
||||
|
||||
@@ -133,9 +133,6 @@ move an amendment</a> to the drawing.</p>
|
||||
move_turfs_to_area(turfs, A)
|
||||
|
||||
A.always_unpowered = 0
|
||||
for(var/turf/T in A.contents)
|
||||
T.lighting_changed = 1
|
||||
lighting_controller.changed_turfs += T
|
||||
|
||||
spawn(5)
|
||||
//ma = A.master ? "[A.master]" : "(null)"
|
||||
|
||||
@@ -195,6 +195,8 @@
|
||||
if(L)
|
||||
del L
|
||||
|
||||
var/turf_light_data/old_lights = new
|
||||
|
||||
//Creates a new turf
|
||||
/turf/proc/ChangeTurf(var/turf/N)
|
||||
if (!N)
|
||||
@@ -214,10 +216,10 @@
|
||||
return W
|
||||
///// Z-Level Stuff
|
||||
|
||||
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
|
||||
|
||||
//world << "Replacing [src.type] with [N]"
|
||||
|
||||
old_lights.copy_from(src)
|
||||
|
||||
if(connections) connections.erase_all()
|
||||
|
||||
if(istype(src,/turf/simulated))
|
||||
@@ -238,10 +240,7 @@
|
||||
var/turf/simulated/W = new N( locate(src.x, src.y, src.z) )
|
||||
//W.Assimilate_Air()
|
||||
|
||||
W.lighting_lumcount += old_lumcount
|
||||
if(old_lumcount != W.lighting_lumcount)
|
||||
W.lighting_changed = 1
|
||||
lighting_controller.changed_turfs += W
|
||||
old_lights.copy_to(W)
|
||||
|
||||
if (istype(W,/turf/simulated/floor))
|
||||
W.RemoveLattice()
|
||||
@@ -259,10 +258,8 @@
|
||||
// zone.SetStatus(ZONE_ACTIVE)
|
||||
|
||||
var/turf/W = new N( locate(src.x, src.y, src.z) )
|
||||
W.lighting_lumcount += old_lumcount
|
||||
if(old_lumcount != W.lighting_lumcount)
|
||||
W.lighting_changed = 1
|
||||
lighting_controller.changed_turfs += W
|
||||
|
||||
old_lights.copy_to(W)
|
||||
|
||||
if(air_master)
|
||||
air_master.mark_for_update(src)
|
||||
|
||||
@@ -897,7 +897,7 @@
|
||||
var/turf/T = loc
|
||||
var/area/A = T.loc
|
||||
if(A)
|
||||
if(A.lighting_use_dynamic) light_amount = min(10,T.lighting_lumcount) - 5 //hardcapped so it's not abused by having a ton of flashlights
|
||||
if(A.lighting_use_dynamic) light_amount = min(10,T.lit_value) - 5 //hardcapped so it's not abused by having a ton of flashlights
|
||||
else light_amount = 5
|
||||
nutrition += light_amount
|
||||
traumatic_shock -= light_amount
|
||||
@@ -917,7 +917,7 @@
|
||||
var/turf/T = loc
|
||||
var/area/A = T.loc
|
||||
if(A)
|
||||
if(A.lighting_use_dynamic) light_amount = T.lighting_lumcount
|
||||
if(A.lighting_use_dynamic) light_amount = T.lit_value
|
||||
else light_amount = 10
|
||||
if(light_amount > 2) //if there's enough light, start dying
|
||||
take_overall_damage(1,1)
|
||||
@@ -1072,7 +1072,7 @@
|
||||
E = get_visible_implants(0)
|
||||
if(!E.len)
|
||||
embedded_flag = 0
|
||||
|
||||
|
||||
|
||||
//Eyes
|
||||
if(sdisabilities & BLIND) //disabled-blind, doesn't get better on its own
|
||||
@@ -1393,7 +1393,7 @@
|
||||
//0.1% chance of playing a scary sound to someone who's in complete darkness
|
||||
if(isturf(loc) && rand(1,1000) == 1)
|
||||
var/turf/currentTurf = loc
|
||||
if(!currentTurf.lighting_lumcount)
|
||||
if(!currentTurf.lit_value)
|
||||
playsound_local(src,pick(scarySounds),50, 1, -1)
|
||||
|
||||
proc/handle_virus_updates()
|
||||
|
||||
@@ -446,7 +446,7 @@
|
||||
var/turf/T = loc
|
||||
var/area/A = T.loc
|
||||
if(A)
|
||||
if(A.lighting_use_dynamic) light_amount = min(10,T.lighting_lumcount) - 5 //hardcapped so it's not abused by having a ton of flashlights
|
||||
if(A.lighting_use_dynamic) light_amount = min(10,T.lit_value) - 5 //hardcapped so it's not abused by having a ton of flashlights
|
||||
else light_amount = 5
|
||||
|
||||
nutrition += light_amount
|
||||
|
||||
@@ -604,8 +604,8 @@
|
||||
#define LIGHTING_POWER_FACTOR 20 //20W per unit luminosity
|
||||
|
||||
/obj/machinery/light/process()//TODO: remove/add this from machines to save on processing as needed ~Carn PRIORITY
|
||||
if(on)
|
||||
use_power(luminosity * LIGHTING_POWER_FACTOR, LIGHT)
|
||||
if(on && light)
|
||||
use_power(light.radius * LIGHTING_POWER_FACTOR, LIGHT)
|
||||
|
||||
// called when area power state changes
|
||||
/obj/machinery/light/power_change()
|
||||
|
||||
Reference in New Issue
Block a user