mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-13 08:03:43 +01:00
Lighting seems to be working now.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
area/var/lighting_use_dynamic
|
||||
|
||||
turf/space/is_outside = 1
|
||||
turf/simulated/shuttle/is_outside = 1
|
||||
|
||||
/datum/controller/lighting/var/processing = 1
|
||||
/datum/controller/lighting/var/iteration = 0
|
||||
@@ -36,6 +37,9 @@ turf_light_data/proc/copy_to(turf/T)
|
||||
|
||||
atom/proc/SetLuminosity(n)
|
||||
n = min(n,10) //Caelcode.
|
||||
SetLight(n>>1,n)
|
||||
if(n > 0)
|
||||
SetLight(max(1,n>>1),n)
|
||||
else
|
||||
SetLight(0,0)
|
||||
luminosity = n
|
||||
//else lighting_controller.initial_lights.Add(src)
|
||||
@@ -89,7 +89,9 @@ var/list/lit_z_levels = list(1,5)
|
||||
started = 1
|
||||
|
||||
for(var/turf/T)
|
||||
if(!T.is_outside) T.UpdateLight()
|
||||
if(!T.is_outside)
|
||||
if(!T.lit_value) T.ResetValue()
|
||||
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>"
|
||||
|
||||
@@ -77,7 +77,7 @@ turf/var/lightpoint/lightSE
|
||||
turf/var/lightpoint/lightSW
|
||||
turf/var/list/lit_by
|
||||
|
||||
atom/New()
|
||||
atom/movable/New()
|
||||
. = ..()
|
||||
if(luminosity)
|
||||
if(!light)
|
||||
@@ -97,17 +97,25 @@ atom/movable/Move()
|
||||
if(o) SetOpacity(1)
|
||||
if(light)
|
||||
light.Reset()
|
||||
lighting_controller.FlushIconUpdates()
|
||||
if(lighting_ready()) lighting_controller.FlushIconUpdates()
|
||||
|
||||
atom/proc/SetLight(intensity, radius)
|
||||
if(lights_verbose) world << "SetLight([intensity],[radius])"
|
||||
if(!intensity)
|
||||
if(!light) return
|
||||
if(!light || !light.intensity)
|
||||
if(lights_verbose) world << "Still off."
|
||||
return
|
||||
if(lights_verbose) world << "Shut off light with [light.lit_turfs.len] turfs lit."
|
||||
light.Off()
|
||||
light = null
|
||||
light.intensity = 0
|
||||
if(lighting_ready()) lighting_controller.FlushIconUpdates()
|
||||
return
|
||||
if(!light) light = new(src)
|
||||
if(light.intensity == intensity) return
|
||||
if(!light)
|
||||
if(lights_verbose) world << "New light."
|
||||
light = new(src)
|
||||
if(light.intensity == intensity)
|
||||
if(lights_verbose) world << "Same intensity."
|
||||
return
|
||||
light.radius = min(radius,15)
|
||||
light.intensity = intensity
|
||||
light.Reset()
|
||||
@@ -128,12 +136,14 @@ turf/proc/UpdateLight()
|
||||
|
||||
turf/proc/AddLight(light/light)
|
||||
if(is_outside) return
|
||||
if(has_opaque) return
|
||||
|
||||
var/brightness = light.CalculateBrightness(src)
|
||||
if(brightness <= 0) return
|
||||
|
||||
if(!lit_by) lit_by = list()
|
||||
lit_by.Add(light)
|
||||
|
||||
var/brightness = light.CalculateBrightness(src)
|
||||
|
||||
lit_by[light] = brightness
|
||||
|
||||
if(!has_opaque && lighting_ready())
|
||||
@@ -145,7 +155,6 @@ turf/proc/AddLight(light/light)
|
||||
lighting_controller.MarkIconUpdate(T)
|
||||
|
||||
turf/proc/RemoveLight(light/light)
|
||||
if(has_opaque) return
|
||||
if(lit_by)
|
||||
var/brightness = lit_by[light]
|
||||
lit_by.Remove(light)
|
||||
@@ -159,15 +168,13 @@ turf/proc/ResetValue()
|
||||
lit_value = LIGHTCLAMP(lighting_controller.starlight)
|
||||
return
|
||||
|
||||
var/old_value = lit_value
|
||||
|
||||
CheckForOpaqueObjects()
|
||||
if(has_opaque)
|
||||
lit_value = 0
|
||||
else
|
||||
the_part_where_I_calculate_brightness()
|
||||
|
||||
if(lighting_ready() && lit_value != old_value)
|
||||
if(lighting_ready())
|
||||
the_part_where_I_use_range()
|
||||
|
||||
turf/proc
|
||||
|
||||
@@ -31,19 +31,21 @@ light/New(atom/atom)
|
||||
src.atom = atom
|
||||
|
||||
light/proc/Reset()
|
||||
if(atom.lights_verbose) world << "light.Reset()"
|
||||
Off()
|
||||
|
||||
lit_turfs = list()
|
||||
|
||||
if(intensity > 0)
|
||||
for(var/turf/T in view(atom,radius+1))
|
||||
if(atom.lights_verbose) world << "Restoring light."
|
||||
for(var/turf/T in view(get_turf(atom),radius+1))
|
||||
if(!T.is_outside)
|
||||
T.AddLight(src)
|
||||
lit_turfs.Add(T)
|
||||
if(atom.lights_verbose) world << "[lit_turfs.len] turfs added."
|
||||
|
||||
light/proc/Off()
|
||||
if(atom.lights_verbose) world << "light.Off()"
|
||||
for(var/turf/T in lit_turfs)
|
||||
T.RemoveLight(src)
|
||||
lit_turfs = list()
|
||||
|
||||
light/proc/CalculateBrightness(turf/T)
|
||||
var/square = get_square_dist(atom.x,atom.y,atom.z,T.x,T.y,T.z)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
var/icon/lighting_dbg = icon('icons/Testing/Zone.dmi', "created")
|
||||
|
||||
atom/var/lights_verbose = 0
|
||||
|
||||
obj/machinery/light/verb/ShowInfluence()
|
||||
set src in world
|
||||
|
||||
lights_verbose = 1
|
||||
usr << "<b>[src]</b>"
|
||||
if(light)
|
||||
usr << "Intensity: [light.intensity]"
|
||||
usr << "Radius: [light.radius]"
|
||||
|
||||
for(var/turf/T in light.lit_turfs)
|
||||
T.overlays += lighting_dbg
|
||||
spawn(50)
|
||||
for(var/turf/T in light.lit_turfs)
|
||||
T.overlays -= lighting_dbg
|
||||
|
||||
turf/verb/ShowData()
|
||||
set src in world
|
||||
|
||||
usr << "<b>[src]</b>"
|
||||
usr << "Lit Value: [lit_value]"
|
||||
usr << "Max Brightness: [max_brightness]"
|
||||
|
||||
usr << "Lit By: "
|
||||
for(var/light/light in lit_by)
|
||||
usr << " - [light.atom] \[[lit_by[light]]\][(lit_by[light] == max_brightness ? "(MAX)" : "")]"
|
||||
light.atom.overlays += lighting_dbg
|
||||
spawn(50)
|
||||
for(var/light/light in lit_by)
|
||||
light.atom.overlays -= lighting_dbg
|
||||
Reference in New Issue
Block a user