Files
Yogstation/code/modules/lighting/lighting_atom.dm
Emmett Gaines 456cd10d94 Radiation rework and subsystem (#30909)
* radiation rework and subsystem

* moves a few things to initialize and adds radiation insulation

* adds a radiation contamination mechanic and makes requested changes

I'm terrified by the possibilities from this

* radiated objects give off light

and hopefuly contamination is balanced

* fixes runtimes and an mc crash kek

removed the lighting part of contaminated objects
attempted some more balancing

* Collectors output power in process() gradualy

And some more balancing tweaks

* Excludes a bunch of things from becoming radioactive

* Ready for testmerge balancing

* Inverse square law was swapped

* testmerge balancing

fixes the geiger counter
buffs collector power gen
nerfs sm radiation
slightly buffs rad insulation
nerfs rad damage (and its burn)
raised the minimum radiation

* disabling the radiation subsystem won't build up rad wave datums forever

* rewrites how mobs handle radiation

upgrades geiger counter functionality
and more balance tweaks

* cleans up stuff and removes debug message

* Slight contamination buff

* Major rad wave performance boost

Also improves rad insulation
Buffs contamination, again

* Fixes insulation runtime

More balance and performance tweaks

* fixes rad collectors not receiving power

* The final balance commit

Fixes a major bug causing radiation to underperform
More geiger counter changes that will be changed more to add sounds

* Monkey business

* Geiger counter sounds

* cleanup and move components to their own initialize

* Some code cleanup

And forgotten changes

* Cleans up some trailing returns

* Mapping changes
2017-10-13 10:22:00 -04:00

106 lines
3.1 KiB
Plaintext

#define MINIMUM_USEFUL_LIGHT_RANGE 1.4
/atom
var/light_power = 1 // Intensity of the light.
var/light_range = 0 // Range in tiles of the light.
var/light_color // Hexadecimal RGB string representing the colour of the light.
var/tmp/datum/light_source/light // Our light source. Don't fuck with this directly unless you have a good reason!
var/tmp/list/light_sources // Any light sources that are "inside" of us, for example, if src here was a mob that's carrying a flashlight, that flashlight's light source would be part of this list.
// The proc you should always use to set the light of this atom.
// Nonesensical value for l_color default, so we can detect if it gets set to null.
#define NONSENSICAL_VALUE -99999
/atom/proc/set_light(var/l_range, var/l_power, var/l_color = NONSENSICAL_VALUE)
if(l_range > 0 && l_range < MINIMUM_USEFUL_LIGHT_RANGE)
l_range = MINIMUM_USEFUL_LIGHT_RANGE //Brings the range up to 1.4, which is just barely brighter than the soft lighting that surrounds players.
if (l_power != null)
light_power = l_power
if (l_range != null)
light_range = l_range
if (l_color != NONSENSICAL_VALUE)
light_color = l_color
SendSignal(COMSIG_ATOM_SET_LIGHT, l_range, l_power, l_color)
update_light()
#undef NONSENSICAL_VALUE
// Will update the light (duh).
// Creates or destroys it if needed, makes it update values, makes sure it's got the correct source turf...
/atom/proc/update_light()
set waitfor = FALSE
if (QDELETED(src))
return
if (!light_power || !light_range) // We won't emit light anyways, destroy the light source.
QDEL_NULL(light)
else
if (!ismovableatom(loc)) // We choose what atom should be the top atom of the light here.
. = src
else
. = loc
if (light) // Update the light or create it if it does not exist.
light.update(.)
else
light = new/datum/light_source(src, .)
// If we have opacity, make sure to tell (potentially) affected light sources.
/atom/movable/Destroy()
var/turf/T = loc
. = ..()
if (opacity && istype(T))
var/old_has_opaque_atom = T.has_opaque_atom
T.recalc_atom_opacity()
if (old_has_opaque_atom != T.has_opaque_atom)
T.reconsider_lights()
// Should always be used to change the opacity of an atom.
// It notifies (potentially) affected light sources so they can update (if needed).
/atom/proc/set_opacity(var/new_opacity)
if (new_opacity == opacity)
return
opacity = new_opacity
var/turf/T = loc
if (!isturf(T))
return
if (new_opacity == TRUE)
T.has_opaque_atom = TRUE
T.reconsider_lights()
else
var/old_has_opaque_atom = T.has_opaque_atom
T.recalc_atom_opacity()
if (old_has_opaque_atom != T.has_opaque_atom)
T.reconsider_lights()
/atom/movable/Moved(atom/OldLoc, Dir)
. = ..()
var/datum/light_source/L
var/thing
for (thing in light_sources) // Cycle through the light sources on this atom and tell them to update.
L = thing
L.source_atom.update_light()
/atom/vv_edit_var(var_name, var_value)
switch (var_name)
if ("light_range")
set_light(l_range=var_value)
return
if ("light_power")
set_light(l_power=var_value)
return
if ("light_color")
set_light(l_color=var_value)
return
return ..()