mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 05:30:05 +01:00
[MIRROR] Color standardization, vars moved, and signals (#194)
* Color standardization, vars moved, and signals (#52574) Defined all the existing light_color values. Moved their definitions to colors.dm Made white the default color. It was so already, but that was very obscured. Moved the atom light-related variables to the atom definition. Wrapped changes to variables such as light_color into procs that report the event through signals. Moved the light_on variable to the atom level, also adding a signal for its changing, to represent toggling lights. Cleaned up a little bit of code in where new variables were defined before redefinitions. This is all atomization to reduce changes in #52413 None of this affect gameplay at all, it's all code cleaning and refactoring. There's more colors to standardize, a search for color = will find lots of targets, and I see little need to have both the LIGHT_COLOR and COLOR patterns, but I don't want to make this PR bigger than it already is. * Color standardization, vars moved, and signals Co-authored-by: Rohesie <rohesie@gmail.com>
This commit is contained in:
@@ -1,12 +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
|
||||
@@ -98,15 +90,15 @@
|
||||
return ..()
|
||||
|
||||
|
||||
/atom/proc/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = LIGHT_COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
|
||||
/atom/proc/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
|
||||
return
|
||||
|
||||
/turf/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = LIGHT_COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
|
||||
/turf/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
|
||||
if(!_duration)
|
||||
stack_trace("Lighting FX obj created on a turf without a duration")
|
||||
new /obj/effect/dummy/lighting_obj (src, _color, _range, _power, _duration)
|
||||
|
||||
/obj/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = LIGHT_COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
|
||||
/obj/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
|
||||
var/temp_color
|
||||
var/temp_power
|
||||
var/temp_range
|
||||
@@ -117,10 +109,41 @@
|
||||
set_light(_range, _power, _color)
|
||||
addtimer(CALLBACK(src, /atom/proc/set_light, _reset_lighting ? initial(light_range) : temp_range, _reset_lighting ? initial(light_power) : temp_power, _reset_lighting ? initial(light_color) : temp_color), _duration, TIMER_OVERRIDE|TIMER_UNIQUE)
|
||||
|
||||
/mob/living/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = LIGHT_COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
|
||||
/mob/living/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
|
||||
mob_light(_color, _range, _power, _duration)
|
||||
|
||||
/mob/living/proc/mob_light(_color, _range, _power, _duration)
|
||||
var/obj/effect/dummy/lighting_obj/moblight/mob_light_obj = new (src, _color, _range, _power, _duration)
|
||||
return mob_light_obj
|
||||
|
||||
|
||||
/atom/proc/set_light_range(new_range)
|
||||
if(new_range == light_range)
|
||||
return
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT_RANGE, new_range)
|
||||
. = light_range
|
||||
light_range = new_range
|
||||
|
||||
|
||||
/atom/proc/set_light_power(new_power)
|
||||
if(new_power == light_power)
|
||||
return
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT_POWER, new_power)
|
||||
. = light_power
|
||||
light_power = new_power
|
||||
|
||||
|
||||
/atom/proc/set_light_color(new_color)
|
||||
if(new_color == light_color)
|
||||
return
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT_COLOR, new_color)
|
||||
. = light_color
|
||||
light_color = new_color
|
||||
|
||||
|
||||
/atom/proc/set_light_on(new_value)
|
||||
if(new_value == light_on)
|
||||
return
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT_ON, new_value)
|
||||
. = light_on
|
||||
light_on = new_value
|
||||
|
||||
Reference in New Issue
Block a user