mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
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
163 lines
4.2 KiB
Plaintext
163 lines
4.2 KiB
Plaintext
|
|
/atom/proc/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
|
|
return null
|
|
|
|
|
|
|
|
/turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
|
|
|
|
|
|
|
|
/turf/simulated/hotspot_expose(exposed_temperature, exposed_volume, soh)
|
|
var/datum/gas_mixture/air_contents = return_air()
|
|
if(!air_contents)
|
|
return 0
|
|
if(active_hotspot)
|
|
if(soh)
|
|
if(air_contents.toxins > 0.5 && air_contents.oxygen > 0.5)
|
|
if(active_hotspot.temperature < exposed_temperature)
|
|
active_hotspot.temperature = exposed_temperature
|
|
if(active_hotspot.volume < exposed_volume)
|
|
active_hotspot.volume = exposed_volume
|
|
return 1
|
|
|
|
var/igniting = 0
|
|
|
|
if((exposed_temperature > PLASMA_MINIMUM_BURN_TEMPERATURE) && air_contents.toxins > 0.5)
|
|
igniting = 1
|
|
|
|
if(igniting)
|
|
if(air_contents.oxygen < 0.5 || air_contents.toxins < 0.5)
|
|
return 0
|
|
|
|
if(parent&&parent.group_processing)
|
|
parent.suspend_group_processing()
|
|
|
|
active_hotspot = new(src)
|
|
active_hotspot.temperature = exposed_temperature
|
|
active_hotspot.volume = exposed_volume
|
|
|
|
active_hotspot.just_spawned = (current_cycle < air_master.current_cycle)
|
|
//remove just_spawned protection if no longer processing this cell
|
|
|
|
//start processing quickly if we aren't already
|
|
reset_delay()
|
|
|
|
return igniting
|
|
|
|
|
|
//This is the icon for fire on turfs, also helps for nurturing small fires until they are full tile
|
|
/obj/effect/hotspot
|
|
anchored = 1
|
|
mouse_opacity = 0
|
|
unacidable = 1//So you can't melt fire with acid.
|
|
icon = 'icons/effects/fire.dmi'
|
|
icon_state = "1"
|
|
layer = TURF_LAYER
|
|
luminosity = 3
|
|
|
|
var/volume = 125
|
|
var/temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST
|
|
var/just_spawned = 1
|
|
var/bypassing = 0
|
|
|
|
|
|
proc/perform_exposure()
|
|
var/turf/simulated/floor/location = loc
|
|
if(!istype(location)) return 0
|
|
|
|
if(volume > CELL_VOLUME*0.95) bypassing = 1
|
|
else bypassing = 0
|
|
|
|
if(bypassing)
|
|
if(!just_spawned)
|
|
volume = location.air.fuel_burnt*FIRE_GROWTH_RATE
|
|
temperature = location.air.temperature
|
|
else
|
|
var/datum/gas_mixture/affected = location.air.remove_ratio(volume/location.air.volume)
|
|
affected.temperature = temperature
|
|
affected.react()
|
|
temperature = affected.temperature
|
|
volume = affected.fuel_burnt*FIRE_GROWTH_RATE
|
|
location.assume_air(affected)
|
|
|
|
for(var/atom/item in loc)
|
|
item.temperature_expose(null, temperature, volume)
|
|
return 0
|
|
|
|
|
|
process(turf/simulated/list/possible_spread)
|
|
if(just_spawned)
|
|
just_spawned = 0
|
|
return 0
|
|
|
|
var/turf/simulated/floor/location = loc
|
|
if(!istype(location))
|
|
del(src)
|
|
|
|
if((temperature < FIRE_MINIMUM_TEMPERATURE_TO_EXIST) || (volume <= 1))
|
|
del(src)
|
|
|
|
if(location.air.toxins < 0.5 || location.air.oxygen < 0.5)
|
|
del(src)
|
|
|
|
perform_exposure()
|
|
|
|
if(location.wet) location.wet = 0
|
|
|
|
if(bypassing)
|
|
icon_state = "3"
|
|
location.burn_tile()
|
|
|
|
//Possible spread due to radiated heat
|
|
if(location.air.temperature > FIRE_MINIMUM_TEMPERATURE_TO_SPREAD)
|
|
var/radiated_temperature = location.air.temperature*FIRE_SPREAD_RADIOSITY_SCALE
|
|
|
|
for(var/turf/simulated/possible_target in possible_spread)
|
|
if(!possible_target.active_hotspot)
|
|
possible_target.hotspot_expose(radiated_temperature, CELL_VOLUME/4)
|
|
|
|
else
|
|
if(volume > CELL_VOLUME*0.4)
|
|
icon_state = "2"
|
|
else
|
|
icon_state = "1"
|
|
|
|
if(temperature > location.max_fire_temperature_sustained)
|
|
location.max_fire_temperature_sustained = temperature
|
|
|
|
if(temperature > location.heat_capacity)
|
|
location.to_be_destroyed = 1
|
|
/*if(prob(25))
|
|
location.ReplaceWithSpace()
|
|
return 0*/
|
|
return 1
|
|
|
|
|
|
New()
|
|
..()
|
|
dir = pick(cardinal)
|
|
return
|
|
|
|
|
|
Del()
|
|
if (istype(loc, /turf/simulated))
|
|
var/turf/simulated/T = loc
|
|
loc:active_hotspot = null
|
|
|
|
if(T.to_be_destroyed)
|
|
var/chance_of_deletion
|
|
if (T.heat_capacity) //beware of division by zero
|
|
chance_of_deletion = T.max_fire_temperature_sustained / T.heat_capacity * 8 //there is no problem with prob(23456), min() was redundant --rastaf0
|
|
else
|
|
chance_of_deletion = 100
|
|
if(prob(chance_of_deletion))
|
|
T.ReplaceWithSpace()
|
|
else
|
|
T.to_be_destroyed = 0
|
|
T.max_fire_temperature_sustained = 0
|
|
|
|
loc = null
|
|
..()
|
|
return
|