Implements a configurable sun for a sunlight effect using the lighting engine.
Abuses Z-lights to illuminate Zs in a semi-realistic way.

Kinda slow at setting state, but state changes shouldn't lag & are rare.

Also adds the ability to create lights that ignore visibility when calculating range, causing them to shine through objects/walls.
This commit is contained in:
Lohikar
2017-05-31 11:43:18 +03:00
committed by skull132
parent 1db5663128
commit 90b6691c8f
14 changed files with 336 additions and 66 deletions
+9
View File
@@ -276,6 +276,9 @@ var/list/gamemode_cache = list()
var/access_deny_vms = 0
var/access_warn_vms = 0
var/sun_accuracy = 8
var/sun_target_z = 7
/datum/configuration/New()
var/list/L = typesof(/datum/game_mode) - /datum/game_mode
for (var/T in L)
@@ -920,6 +923,12 @@ var/list/gamemode_cache = list()
if("use_loyalty_implants")
config.use_loyalty_implants = 1
if ("sunlight_accuracy")
config.sun_accuracy = value
if ("sunlight_z")
config.sun_target_z = value
else
log_misc("Unknown setting in configuration: '[name]'")
+5 -1
View File
@@ -5,6 +5,7 @@ var/datum/controller/subsystem/lighting/SSlighting
/datum/controller/subsystem/lighting
name = "Lighting"
wait = LIGHTING_INTERVAL
flags = SS_FIRE_IN_LOBBY
priority = SS_PRIORITY_LIGHTING
init_order = SS_INIT_LIGHTING
@@ -31,7 +32,10 @@ var/datum/controller/subsystem/lighting/SSlighting
LAZYINITLIST(lighting_overlays)
/datum/controller/subsystem/lighting/stat_entry()
..("O:[lighting_overlays.len] C:[lighting_corners.len] ITL:[round(instant_tick_limit, 0.1)]%\n\tP:{L:[light_queue.len]|C:[corner_queue.len]|O:[overlay_queue.len]}\n\tL:{L:[processed_lights]|C:[processed_corners]|O:[processed_overlays]}")
var/out = "O:[lighting_overlays.len] C:[lighting_corners.len] ITL:[round(instant_tick_limit, 0.1)]%\n"
out += "\tP:{L:[light_queue.len]|C:[corner_queue.len]|O:[overlay_queue.len]}\n"
out += "\tL:{L:[processed_lights]|C:[processed_corners]|O:[processed_overlays]}\n"
..(out)
/datum/controller/subsystem/lighting/ExplosionStart()
force_queued = TRUE
+93
View File
@@ -0,0 +1,93 @@
/var/datum/controller/subsystem/sunlight/SSsunlight
/datum/controller/subsystem/sunlight
name = "Sunlight"
flags = SS_NO_FIRE
init_order = SS_INIT_SUNLIGHT
var/list/light_points = list()
var/config.sun_target_z = 7
var/list/presets
/datum/controller/subsystem/sunlight/New()
NEW_SS_GLOBAL(SSsunlight)
/datum/controller/subsystem/sunlight/stat_entry()
..("A:[config.sun_accuracy] LP:[light_points.len] Z:[config.sun_target_z]")
/datum/controller/subsystem/sunlight/Initialize()
presets = list()
for (var/thing in subtypesof(/datum/sun_state))
presets += new thing
var/thing
var/turf/T
for (thing in block(locate(1, 1, config.sun_target_z), locate(world.maxx, world.maxy, config.sun_target_z)))
T = thing
if (!(T.x % config.sun_accuracy) && !(T.y % config.sun_accuracy))
light_points += new /atom/movable/sunobj(thing)
CHECK_TICK
log_debug("sunlight: [light_points.len] sun emitters.")
..()
/datum/controller/subsystem/sunlight/proc/set_overall_light(...)
. = 0
SSlighting.force_queued = TRUE
for (var/thing in light_points)
var/atom/movable/AM = thing
AM.set_light(arglist(args))
.++
CHECK_TICK
if (!SSlighting.force_override)
SSlighting.force_queued = FALSE
/datum/controller/subsystem/sunlight/proc/apply_sun_state(datum/sun_state/S)
log_debug("sunlight: Applying preset [S].")
set_overall_light(config.sun_accuracy * 1.2, 1, S.color)
/atom/movable/sunobj
name = "sunlight emitter"
desc = "Weren't you told to never look directly at the sun? (but seriously, you shouldn't see this)"
light_novis = TRUE
light_range = 16
simulated = FALSE
mouse_opacity = FALSE
/atom/movable/sunobj/Destroy(force = FALSE)
if (!force)
crash_with("Something attempted to delete a sunobj!")
return QDEL_HINT_LETMELIVE
SSsunlight.light_points -= src
return ..()
/atom/movable/sunobj/Initialize()
light_range = Ceiling(config.sun_accuracy * 1.2)
return ..()
/datum/sun_state
var/color = "#FFFFFF"
var/name = "INVALID"
/datum/sun_state/default
name = "Default"
/datum/sun_state/sensual
name = "Sensual"
color = LIGHT_COLOR_PINK
/datum/sun_state/red
name = "Nar-Sie"
color = "#FF0000"
/datum/sun_state/less_red
name = "Red"
color = LIGHT_COLOR_RED
/datum/sun_state/blue
name = "Blue"
color = LIGHT_COLOR_BLUE