mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-24 12:37:50 +01:00
New lighting, it's essentially just the old DAL system with a queue.
Comments for lighting: Like sd_DAL (what we used to use), it changes the shading overlays of areas by splitting each type of area into sub-areas by using the var/tag variable and moving turfs into the contents list of the correct sub-area. Unlike sd_DAL however it uses a queueing system. Everytime we call a change to opacity or luminosity (through SetOpacity() or SetLuminosity()) we are simply updating variables and scheduling certain lights/turfs for an update. Actual updates are handled periodically by the lighting_controller. This carries additional overheads, however it means that each thing is changed only once per lighting_controller.processing_interval ticks. Allowing for greater control over how much priority we'd like lighting updates to have. It also makes it possible for us to simply delay updates by setting lighting_controller.processing = 0 at say, the start of a large explosion, waiting for it to finish, and then turning it back on with lighting_controller.processing = 1. Unlike our old system there is a hardcoded maximum luminosity. This is to discourage coders using large luminosity values for dynamic lighting, as the cost of lighting grows rapidly at large luminosity levels (especially when changing opacity at runtime) Also, in order for the queueing system to work, each light remembers the effect it casts on each turf. This is going to have larger memory requirements than our previous system but hopefully it's worth the hassle for the greater control we gain. Besides, there are far far worse uses of needless lists in the game, it'd be worth pruning some of them to offset costs. Known Issues/TODO: admin-spawned turfs will have broken lumcounts. Not willing to fix it at this moment mob luminosity will be lower than expected when one of multiple light sources is dropped after exceeding the maximum luminosity Shuttles still do not have support for dynamic lighting (I hope to fix this at some point) No directional lighting support. Fairly easy to add this and the code is ready. When opening airlocks etc, lighting does not always update to account for the change in opacity. Explosions now cause lighting to cease processing temporarily. Moved controller datums to the code/controllers directory. I plan on standardising them. "Master","Ticker","Lighting","Air","Jobs","Sun","Radio","Supply Shuttle","Emergency Shuttle","Configuration","pAI" controller datums can be accessed via the debug controller verb (used to be the debug master controller verb) Supply shuttle now uses a controller datum. Shuttles tend to arrive up to 30 seconds late, this is not a bug. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4537 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -87,9 +87,6 @@
|
||||
//stuff in the stomach
|
||||
handle_stomach()
|
||||
|
||||
//Flashlights and such
|
||||
UpdateLuminosity()
|
||||
|
||||
//Status updates, death etc.
|
||||
handle_regular_status_updates() //TODO: optimise ~Carn
|
||||
update_canmove()
|
||||
@@ -745,13 +742,16 @@
|
||||
|
||||
if(dna && dna.mutantrace == "plant") //couldn't think of a better place to place it, since it handles nutrition -- Urist
|
||||
var/light_amount = 0 //how much light there is in the place, affects receiving nutrition and healing
|
||||
if(istype(loc,/turf)) //else, there's considered to be no light
|
||||
light_amount = min(10,loc:sd_lumcount) - 5 //hardcapped so it's not abused by having a ton of flashlights
|
||||
if(istype(loc,/turf/simulated/shuttle))//Now not only will potatomen not starve on the shuttle, they will actually be fed
|
||||
light_amount = 5
|
||||
if(nutrition < 500) //so they can't store nutrition to survive without light forever
|
||||
nutrition += light_amount
|
||||
if(light_amount > 0) //if there's enough light, heal
|
||||
if(isturf(loc)) //else, there's considered to be no light
|
||||
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
|
||||
else light_amount = 5
|
||||
nutrition += light_amount
|
||||
if(nutrition > 500)
|
||||
nutrition = 500
|
||||
if(light_amount > 2) //if there's enough light, heal
|
||||
heal_overall_damage(1,1)
|
||||
adjustToxLoss(-1)
|
||||
adjustOxyLoss(-1)
|
||||
@@ -1150,7 +1150,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.sd_lumcount)
|
||||
if(!currentTurf.lighting_lumcount)
|
||||
playsound_local(src,pick(scarySounds),50, 1, -1)
|
||||
|
||||
proc/handle_virus_updates()
|
||||
|
||||
@@ -53,9 +53,6 @@
|
||||
if(environment) // More error checking -- TLE
|
||||
handle_environment(environment)
|
||||
|
||||
//Flashlights and such
|
||||
UpdateLuminosity()
|
||||
|
||||
//Status updates, death etc.
|
||||
handle_regular_status_updates()
|
||||
update_canmove()
|
||||
|
||||
@@ -429,12 +429,13 @@
|
||||
|
||||
/mob/living/silicon/ai/reset_view(atom/A)
|
||||
if(current)
|
||||
current.sd_SetLuminosity(0)
|
||||
current.SetLuminosity(0)
|
||||
if(istype(A,/obj/machinery/camera))
|
||||
current = A
|
||||
..()
|
||||
if(istype(A,/obj/machinery/camera))
|
||||
A.sd_SetLuminosity(camera_light_on * AI_CAMERA_LUMINOSITY)
|
||||
if(camera_light_on) A.SetLuminosity(AI_CAMERA_LUMINOSITY)
|
||||
else A.SetLuminosity(0)
|
||||
|
||||
|
||||
/mob/living/silicon/ai/proc/switchCamera(var/obj/machinery/camera/C)
|
||||
@@ -641,7 +642,7 @@
|
||||
src << "Camera lights [camera_light_on ? "activated" : "deactivated"]."
|
||||
if(!camera_light_on)
|
||||
if(src.current)
|
||||
src.current.sd_SetLuminosity(0)
|
||||
src.current.SetLuminosity(0)
|
||||
else
|
||||
src.lightNearbyCamera()
|
||||
|
||||
@@ -656,16 +657,16 @@
|
||||
// I have to use range instead of view or the darkness gets in the way.
|
||||
var/camera = near_range_camera(src.eyeobj)
|
||||
if(camera && src.current != camera)
|
||||
src.current.sd_SetLuminosity(0)
|
||||
src.current.SetLuminosity(0)
|
||||
src.current = camera
|
||||
src.current.sd_SetLuminosity(lum)
|
||||
src.current.SetLuminosity(lum)
|
||||
else if(isnull(camera))
|
||||
src.current.sd_SetLuminosity(0)
|
||||
src.current.SetLuminosity(0)
|
||||
src.current = null
|
||||
camera_light_on = world.timeofday + 1 * 10 // Update the light every 2 seconds.
|
||||
else
|
||||
src.current = near_range_camera(src.eyeobj)
|
||||
if(src.current) src.current.sd_SetLuminosity(lum)
|
||||
if(src.current) src.current.SetLuminosity(lum)
|
||||
|
||||
|
||||
#undef AI_CAMERA_LUMINOSITY
|
||||
@@ -90,7 +90,7 @@
|
||||
for(var/turf/t in visRemoved)
|
||||
if(t in obscuredTurfs)
|
||||
if(!t.obscured)
|
||||
t.obscured = image('effects/cameravis.dmi', t, "black", 15)
|
||||
t.obscured = image('icons/effects/cameravis.dmi', t, "black", 15)
|
||||
|
||||
obscured += t.obscured
|
||||
for(var/mob/aiEye/m in seenby)
|
||||
@@ -129,7 +129,7 @@
|
||||
|
||||
for(var/turf/t in obscuredTurfs)
|
||||
if(!t.obscured)
|
||||
t.obscured = image('effects/cameravis.dmi', t, "black", 15)
|
||||
t.obscured = image('icons/effects/cameravis.dmi', t, "black", 15)
|
||||
obscured += t.obscured
|
||||
|
||||
#undef UPDATE_BUFFER
|
||||
@@ -62,7 +62,7 @@
|
||||
if(src.can_use())
|
||||
cameranet.addCamera(src)
|
||||
else
|
||||
src.sd_SetLuminosity(0)
|
||||
src.SetLuminosity(0)
|
||||
cameranet.removeCamera(src)
|
||||
|
||||
/obj/machinery/camera/New()
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
handle_regular_status_updates()
|
||||
|
||||
if(client)
|
||||
UpdateLuminosity()
|
||||
handle_regular_hud_updates()
|
||||
update_items()
|
||||
if (src.stat != DEAD) //still using power
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
emote_hear = list("barks", "woofs", "yaps","pants")
|
||||
emote_see = list("shakes its head", "shivers")
|
||||
desc = "It's a corgi."
|
||||
src.sd_SetLuminosity(0)
|
||||
SetLuminosity(0)
|
||||
inventory_head.loc = src.loc
|
||||
inventory_head = null
|
||||
else
|
||||
@@ -214,7 +214,7 @@
|
||||
name = "Rudolph the Red-Nosed Corgi"
|
||||
emote_hear = list("barks christmas songs", "yaps")
|
||||
desc = "He has a very shiny nose."
|
||||
src.sd_SetLuminosity(6)
|
||||
SetLuminosity(6)
|
||||
if(/obj/item/clothing/head/soft)
|
||||
name = "Corgi Tech [real_name]"
|
||||
speak = list("Needs a stamp!", "Request DENIED!", "Fill these out in triplicate!")
|
||||
|
||||
@@ -505,11 +505,6 @@ var/list/slot_equipment_priority = list( \
|
||||
// ..()
|
||||
return
|
||||
|
||||
/mob/proc/UpdateLuminosity()
|
||||
if(src.total_luminosity == src.last_luminosity) return 0//nothing to do here
|
||||
src.last_luminosity = src.total_luminosity
|
||||
sd_SetLuminosity(min(src.total_luminosity,7))//Current hardcode max at 7, should likely be a const somewhere else
|
||||
return 1
|
||||
|
||||
/mob/MouseDrop(mob/M as mob)
|
||||
..()
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
var/obj/screen/pressure = null
|
||||
var/obj/screen/damageoverlay = null
|
||||
|
||||
var/total_luminosity = 0 //This controls luminosity for mobs, when you pick up lights and such this is edited. If you want the mob to use lights it must update its lum in its life proc or such. Note clamp this value around 7 or such to prevent massive light lag.
|
||||
var/last_luminosity = 0
|
||||
|
||||
/*A bunch of this stuff really needs to go under their own defines instead of being globally attached to mob.
|
||||
A variable should only be globally attached to turfs/objects/whatever, when it is in fact needed as such.
|
||||
The current method unnecessarily clusters up the variable list, especially for humans (although rearranging won't really clean it up a lot but the difference will be noticable for other mobs).
|
||||
|
||||
Reference in New Issue
Block a user