diff --git a/code/__defines/_planes+layers.dm b/code/__defines/_planes+layers.dm index 551e94183c1..c2dec3a247c 100644 --- a/code/__defines/_planes+layers.dm +++ b/code/__defines/_planes+layers.dm @@ -122,9 +122,21 @@ What is the naming convention for planes or layers? #define PLANE_ADMIN1 3 //Purely for shenanigans (below lighting) #define PLANE_PLANETLIGHTING 4 //Lighting on planets + #define PLANE_LIGHTING 5 //Where the lighting (and darkness) lives -#define PLANE_LIGHTING_ABOVE 6 //For glowy eyes etc. that shouldn't be affected by darkness -#define PLANE_RUNECHAT 7 + #define LIGHTING_RENDER_TARGET "LIGHT_PLANE" + +#define PLANE_O_LIGHTING_VISUAL 6 //For masking the lighting plane + #define O_LIGHTING_VISUAL_RENDER_TARGET "O_LIGHT_VISUAL_PLANE" + +#define PLANE_LIGHTING_ABOVE 7 //For glowy eyes etc. that shouldn't be affected by darkness + #define LIGHTING_ABOVE_RENDER_TARGET "LIGHTING_ABOVE_PLANE" + +#define PLANE_EMISSIVE 8 //Glowing lights in otherwise dark areas using overlays/sprites + #define EMISSIVE_RENDER_TARGET "*EMISSIVE_PLANE" + #define EMISSIVE_LAYER_UNBLOCKABLE 9999 + +#define PLANE_RUNECHAT 9 #define PLANE_GHOSTS 10 //Spooooooooky ghooooooosts #define PLANE_AI_EYE 11 //The AI eye lives here diff --git a/code/__defines/color.dm b/code/__defines/color.dm index c3db40eefb3..af112ef4d63 100644 --- a/code/__defines/color.dm +++ b/code/__defines/color.dm @@ -92,6 +92,7 @@ #define COLOR_LIGHT_VIOLET "#e7bfff" #define COLOR_SAN_MARINO_BLUE "#4b75ab" #define COLOR_OLIVE "#52613b" //VOREStation Addition +#define COLOR_HALF_TRANSPARENT_BLACK "#0000007A" #define PIPE_COLOR_GREY "#808080" #define PIPE_COLOR_RED "#ff0000" @@ -171,4 +172,40 @@ #define COLOR_WEBHOOK_DEFAULT 0x8bbbd5 // "#8bbbd5" #define COLOR_WEBHOOK_GOOD 0x2ECC71 // "#2ECC71" #define COLOR_WEBHOOK_POOR 0xE67E22 // "#E67E22" -#define COLOR_WEBHOOK_BAD 0xE74C3C // "#E74C3C" \ No newline at end of file +#define COLOR_WEBHOOK_BAD 0xE74C3C // "#E74C3C" + +//Some defines to generalise colours used in lighting. +//Important note on colors. Colors can end up significantly different from the basic html picture, especially when saturated +#define LIGHT_COLOR_RED "#FA8282" //Warm but extremely diluted red. rgb(250, 130, 130) +#define LIGHT_COLOR_GREEN "#64C864" //Bright but quickly dissipating neon green. rgb(100, 200, 100) +#define LIGHT_COLOR_BLUE "#6496FA" //Cold, diluted blue. rgb(100, 150, 250) + +#define LIGHT_COLOR_BLUEGREEN "#7DE1AF" //Light blueish green. rgb(125, 225, 175) +#define LIGHT_COLOR_CYAN "#7DE1E1" //Diluted cyan. rgb(125, 225, 225) +#define LIGHT_COLOR_LIGHT_CYAN "#40CEFF" //More-saturated cyan. rgb(64, 206, 255) +#define LIGHT_COLOR_DARK_BLUE "#6496FA" //Saturated blue. rgb(51, 117, 248) +#define LIGHT_COLOR_PINK "#E17DE1" //Diluted, mid-warmth pink. rgb(225, 125, 225) +#define LIGHT_COLOR_YELLOW "#E1E17D" //Dimmed yellow, leaning kaki. rgb(225, 225, 125) +#define LIGHT_COLOR_BROWN "#966432" //Clear brown, mostly dim. rgb(150, 100, 50) +#define LIGHT_COLOR_ORANGE "#FA9632" //Mostly pure orange. rgb(250, 150, 50) +#define LIGHT_COLOR_PURPLE "#952CF4" //Light Purple. rgb(149, 44, 244) +#define LIGHT_COLOR_LAVENDER "#9B51FF" //Less-saturated light purple. rgb(155, 81, 255) + +//These ones aren't a direct colour like the ones above, because nothing would fit +#define LIGHT_COLOR_FIRE "#FAA019" //Warm orange color, leaning strongly towards yellow. rgb(250, 160, 25) +#define LIGHT_COLOR_LAVA "#C48A18" //Very warm yellow, leaning slightly towards orange. rgb(196, 138, 24) +#define LIGHT_COLOR_FLARE "#FA644B" //Bright, non-saturated red. Leaning slightly towards pink for visibility. rgb(250, 100, 75) +#define LIGHT_COLOR_SLIME_LAMP "#AFC84B" //Weird color, between yellow and green, very slimy. rgb(175, 200, 75) +#define LIGHT_COLOR_TUNGSTEN "#FAE1AF" //Extremely diluted yellow, close to skin color (for some reason). rgb(250, 225, 175) +#define LIGHT_COLOR_HALOGEN "#F0FAFA" //Barely visible cyan-ish hue, as the doctor prescribed. rgb(240, 250, 250) + +//Lighting values used by the station lights +#define LIGHT_COLOR_FLUORESCENT_TUBE "#E0EFFF" +#define LIGHT_COLOR_FLUORESCENT_FLASHLIGHT "#CDDDFF" +#define LIGHT_COLOR_INCANDESCENT_TUBE "#fffed9" +#define LIGHT_COLOR_INCANDESCENT_BULB "#ffe7ce" +#define LIGHT_COLOR_INCANDESCENT_FLASHLIGHT "#FFCC66" +#define LIGHT_COLOR_NIGHTSHIFT "#EFCC86" + +//Fake ambient occlusion filter +#define AMBIENT_OCCLUSION filter(type="drop_shadow", x=0, y=-2, size=4, offset=3, color="#04080F80") diff --git a/code/__defines/dcs/flags.dm b/code/__defines/dcs/flags.dm index 128c9f19387..84d332bd567 100644 --- a/code/__defines/dcs/flags.dm +++ b/code/__defines/dcs/flags.dm @@ -15,7 +15,10 @@ * Only elements created with the same arguments given after `id_arg_index` share an element instance * The arguments are the same when the text and number values are the same and all other values have the same ref */ -#define ELEMENT_BESPOKE (1 << 1) +#define ELEMENT_BESPOKE (1 << 1) +/// Causes all detach arguments to be passed to detach instead of only being used to identify the element +/// When this is used your Detach proc should have the same signature as your Attach proc +#define ELEMENT_COMPLEX_DETACH (1 << 2) // How multiple components of the exact same type are handled in the same datum /// old component is deleted (default) diff --git a/code/__defines/dcs/signals.dm b/code/__defines/dcs/signals.dm index c6edaa80e4a..a4b1a26b33e 100644 --- a/code/__defines/dcs/signals.dm +++ b/code/__defines/dcs/signals.dm @@ -162,6 +162,8 @@ #define COMSIG_ATOM_ORBIT_BEGIN "atom_orbit_begin" ///called when an atom stops orbiting another atom: (atom) #define COMSIG_ATOM_ORBIT_STOP "atom_orbit_stop" +///from base of atom/set_opacity(): (new_opacity) +#define COMSIG_ATOM_SET_OPACITY "atom_set_opacity" ///////////////// ///from base of atom/attack_ghost(): (mob/dead/observer/ghost) #define COMSIG_ATOM_ATTACK_GHOST "atom_attack_ghost" @@ -737,4 +739,40 @@ #define COMSIG_TRIGGERED_ALARM "ssalarm_triggered" #define COMSIG_CANCELLED_ALARM "ssalarm_cancelled" -#define COMSIG_REAGENTS_CRAFTING_PING "reagents_crafting_ping" \ No newline at end of file +#define COMSIG_REAGENTS_CRAFTING_PING "reagents_crafting_ping" + +// Lighting: +///from base of [atom/proc/set_light]: (l_range, l_power, l_color, l_on) +#define COMSIG_ATOM_SET_LIGHT "atom_set_light" + /// Blocks [/atom/proc/set_light], [/atom/proc/set_light_power], [/atom/proc/set_light_range], [/atom/proc/set_light_color], [/atom/proc/set_light_on], and [/atom/proc/set_light_flags]. + #define COMPONENT_BLOCK_LIGHT_UPDATE (1<<0) +///Called right before the atom changes the value of light_power to a different one, from base [atom/proc/set_light_power]: (new_power) +#define COMSIG_ATOM_SET_LIGHT_POWER "atom_set_light_power" +///Called right after the atom changes the value of light_power to a different one, from base of [/atom/proc/set_light_power]: (old_power) +#define COMSIG_ATOM_UPDATE_LIGHT_POWER "atom_update_light_power" +///Called right before the atom changes the value of light_range to a different one, from base [atom/proc/set_light_range]: (new_range) +#define COMSIG_ATOM_SET_LIGHT_RANGE "atom_set_light_range" +///Called right after the atom changes the value of light_range to a different one, from base of [/atom/proc/set_light_range]: (old_range) +#define COMSIG_ATOM_UPDATE_LIGHT_RANGE "atom_update_light_range" +///Called right before the atom changes the value of light_color to a different one, from base [atom/proc/set_light_color]: (new_color) +#define COMSIG_ATOM_SET_LIGHT_COLOR "atom_set_light_color" +///Called right after the atom changes the value of light_color to a different one, from base of [/atom/proc/set_light_color]: (old_color) +#define COMSIG_ATOM_UPDATE_LIGHT_COLOR "atom_update_light_color" +///Called right before the atom changes the value of light_on to a different one, from base [atom/proc/set_light_on]: (new_value) +#define COMSIG_ATOM_SET_LIGHT_ON "atom_set_light_on" +///Called right after the atom changes the value of light_on to a different one, from base of [/atom/proc/set_light_on]: (old_value) +#define COMSIG_ATOM_UPDATE_LIGHT_ON "atom_update_light_on" +///Called right before the atom changes the value of light_flags to a different one, from base [atom/proc/set_light_flags]: (new_flags) +#define COMSIG_ATOM_SET_LIGHT_FLAGS "atom_set_light_flags" +///Called right after the atom changes the value of light_flags to a different one, from base of [/atom/proc/set_light_flags]: (old_flags) +#define COMSIG_ATOM_UPDATE_LIGHT_FLAGS "atom_update_light_flags" + +// /datum/element/light_eater +///from base of [/datum/element/light_eater/proc/table_buffet]: (list/light_queue, datum/light_eater) +#define COMSIG_LIGHT_EATER_QUEUE "light_eater_queue" +///from base of [/datum/element/light_eater/proc/devour]: (datum/light_eater) +#define COMSIG_LIGHT_EATER_ACT "light_eater_act" + ///Prevents the default light eater behavior from running in case of immunity or custom behavior + #define COMPONENT_BLOCK_LIGHT_EATER (1<<0) +///from base of [/datum/element/light_eater/proc/devour]: (atom/eaten_light) +#define COMSIG_LIGHT_EATER_DEVOUR "light_eater_devour" diff --git a/code/__defines/flags.dm b/code/__defines/flags.dm index 2ff8f44dbab..aa2db4bb1b4 100644 --- a/code/__defines/flags.dm +++ b/code/__defines/flags.dm @@ -13,6 +13,12 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768)) +/* Directions */ +///All the cardinal direction bitflags. +#define ALL_CARDINALS (NORTH|SOUTH|EAST|WEST) +///All the dirs except UP and DOWN +#define ALL_FLAT_DIRS (NORTH|SOUTH|EAST|WEST|NORTHWEST|SOUTHWEST|NORTHEAST|SOUTHEAST) + // datum_flags #define DF_VAR_EDITED (1<<0) #define DF_ISPROCESSING (1<<1) diff --git a/code/__defines/lighting.dm b/code/__defines/lighting.dm index 999bb7473ad..bf854548760 100644 --- a/code/__defines/lighting.dm +++ b/code/__defines/lighting.dm @@ -1,88 +1,119 @@ -#define FOR_DVIEW(type, range, center, invis_flags) \ - dview_mob.loc = center; \ - dview_mob.see_invisible = invis_flags; \ - for(type in view(range, dview_mob)) +///Object doesn't use any of the light systems. Should be changed to add a light source to the object. +#define NO_LIGHT_SUPPORT 0 +///Light made with the lighting datums, applying a matrix. +#define STATIC_LIGHT 1 +///Light made by masking the lighting darkness plane. +#define MOVABLE_LIGHT 2 +///Light made by masking the lighting darkness plane, and is directional. +#define MOVABLE_LIGHT_DIRECTIONAL 3 -#define END_FOR_DVIEW dview_mob.loc = null +///Is a movable light source attached to another movable (its loc), meaning that the lighting component should go one level deeper. +#define LIGHT_ATTACHED (1<<0) -#define LIGHTING_FALLOFF 1 // type of falloff to use for lighting; 1 for circular, 2 for square -#define LIGHTING_LAMBERTIAN 0 // use lambertian shading for light sources -#define LIGHTING_HEIGHT 1 // height off the ground of light sources on the pseudo-z-axis, you should probably leave this alone +//Bay lighting engine shit, not in /code/modules/lighting because BYOND is being shit about it +/// frequency, in 1/10ths of a second, of the lighting process +#define LIGHTING_INTERVAL 5 -#define LIGHTING_ICON 'icons/effects/lighting_overlay.dmi' // icon used for lighting shading effects -#define LIGHTING_ICON_STATE_DARK "soft_dark" // Change between "soft_dark" and "dark" to swap soft darkvision +#define MINIMUM_USEFUL_LIGHT_RANGE 1.4 -#define LIGHTING_ROUND_VALUE (1 / 64) // Value used to round lumcounts, values smaller than 1/69 don't matter (if they do, thanks sinking points), greater values will make lighting less precise, but in turn increase performance, VERY SLIGHTLY. +/// type of falloff to use for lighting; 1 for circular, 2 for square +#define LIGHTING_FALLOFF 1 +/// use lambertian shading for light sources +#define LIGHTING_LAMBERTIAN 0 +/// height off the ground of light sources on the pseudo-z-axis, you should probably leave this alone +#define LIGHTING_HEIGHT 1 +/// Value used to round lumcounts, values smaller than 1/129 don't matter (if they do, thanks sinking points), greater values will make lighting less precise, but in turn increase performance, VERY SLIGHTLY. +#define LIGHTING_ROUND_VALUE (1 / 64) -#define LIGHTING_SOFT_THRESHOLD 0.05 // If the max of the lighting lumcounts of each spectrum drops below this, disable luminosity on the lighting overlays. This also should be the transparancy of the "soft_dark" icon state. +/// icon used for lighting shading effects +#define LIGHTING_ICON 'icons/effects/lighting_object.dmi' -#define LIGHTING_MULT_FACTOR 0.5 +/// If the max of the lighting lumcounts of each spectrum drops below this, disable luminosity on the lighting objects. +/// Set to zero to disable soft lighting. Luminosity changes then work if it's lit at all. +#define LIGHTING_SOFT_THRESHOLD 0 -// If I were you I'd leave this alone. +/// If I were you I'd leave this alone. #define LIGHTING_BASE_MATRIX \ list \ ( \ - LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, 0, \ - LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, 0, \ - LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, 0, \ - LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, LIGHTING_SOFT_THRESHOLD, 0, \ + 1, 1, 1, 0, \ + 1, 1, 1, 0, \ + 1, 1, 1, 0, \ + 1, 1, 1, 0, \ 0, 0, 0, 1 \ ) \ -// Helpers so we can (more easily) control the colour matrices. -#define CL_MATRIX_RR 1 -#define CL_MATRIX_RG 2 -#define CL_MATRIX_RB 3 -#define CL_MATRIX_RA 4 -#define CL_MATRIX_GR 5 -#define CL_MATRIX_GG 6 -#define CL_MATRIX_GB 7 -#define CL_MATRIX_GA 8 -#define CL_MATRIX_BR 9 -#define CL_MATRIX_BG 10 -#define CL_MATRIX_BB 11 -#define CL_MATRIX_BA 12 -#define CL_MATRIX_AR 13 -#define CL_MATRIX_AG 14 -#define CL_MATRIX_AB 15 -#define CL_MATRIX_AA 16 -#define CL_MATRIX_CR 17 -#define CL_MATRIX_CG 18 -#define CL_MATRIX_CB 19 -#define CL_MATRIX_CA 20 +///How many tiles standard fires glow. +#define LIGHT_RANGE_FIRE 3 -//Some defines to generalise colours used in lighting. -//Important note on colors. Colors can end up significantly different from the basic html picture, especially when saturated -#define LIGHT_COLOR_RED "#FA8282" //Warm but extremely diluted red. rgb(250, 130, 130) -#define LIGHT_COLOR_GREEN "#64C864" //Bright but quickly dissipating neon green. rgb(100, 200, 100) -#define LIGHT_COLOR_BLUE "#6496FA" //Cold, diluted blue. rgb(100, 150, 250) +#define LIGHTING_PLANE_ALPHA_VISIBLE 255 +#define LIGHTING_PLANE_ALPHA_NV_TRAIT 245 +#define LIGHTING_PLANE_ALPHA_MOSTLY_VISIBLE 192 +/// For lighting alpha, small amounts lead to big changes. even at 128 its hard to figure out what is dark and what is light, at 64 you almost can't even tell. +#define LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE 128 +#define LIGHTING_PLANE_ALPHA_INVISIBLE 0 -#define LIGHT_COLOR_BLUEGREEN "#7DE1AF" //Light blueish green. rgb(125, 225, 175) -#define LIGHT_COLOR_CYAN "#7DE1E1" //Diluted cyan. rgb(125, 225, 225) -#define LIGHT_COLOR_LIGHT_CYAN "#40CEFF" //More-saturated cyan. rgb(64, 206, 255) -#define LIGHT_COLOR_DARK_BLUE "#6496FA" //Saturated blue. rgb(51, 117, 248) -#define LIGHT_COLOR_PINK "#E17DE1" //Diluted, mid-warmth pink. rgb(225, 125, 225) -#define LIGHT_COLOR_YELLOW "#E1E17D" //Dimmed yellow, leaning kaki. rgb(225, 225, 125) -#define LIGHT_COLOR_BROWN "#966432" //Clear brown, mostly dim. rgb(150, 100, 50) -#define LIGHT_COLOR_ORANGE "#FA9632" //Mostly pure orange. rgb(250, 150, 50) -#define LIGHT_COLOR_PURPLE "#952CF4" //Light Purple. rgb(149, 44, 244) -#define LIGHT_COLOR_LAVENDER "#9B51FF" //Less-saturated light purple. rgb(155, 81, 255) +//lighting area defines +/// dynamic lighting disabled (area stays at full brightness) +#define DYNAMIC_LIGHTING_DISABLED 0 +/// dynamic lighting enabled +#define DYNAMIC_LIGHTING_ENABLED 1 +/// dynamic lighting enabled even if the area doesn't require power +#define DYNAMIC_LIGHTING_FORCED 2 +/// dynamic lighting enabled only if starlight is. +#define DYNAMIC_LIGHTING_IFSTARLIGHT 3 +#define IS_DYNAMIC_LIGHTING(A) A.dynamic_lighting -//These ones aren't a direct colour like the ones above, because nothing would fit -#define LIGHT_COLOR_FIRE "#FAA019" //Warm orange color, leaning strongly towards yellow. rgb(250, 160, 25) -#define LIGHT_COLOR_LAVA "#C48A18" //Very warm yellow, leaning slightly towards orange. rgb(196, 138, 24) -#define LIGHT_COLOR_FLARE "#FA644B" //Bright, non-saturated red. Leaning slightly towards pink for visibility. rgb(250, 100, 75) -#define LIGHT_COLOR_SLIME_LAMP "#AFC84B" //Weird color, between yellow and green, very slimy. rgb(175, 200, 75) -#define LIGHT_COLOR_TUNGSTEN "#FAE1AF" //Extremely diluted yellow, close to skin color (for some reason). rgb(250, 225, 175) -#define LIGHT_COLOR_HALOGEN "#F0FAFA" //Barely visible cyan-ish hue, as the doctor prescribed. rgb(240, 250, 250) -//Lighting values used by the station lights -#define LIGHT_COLOR_FLUORESCENT_TUBE "#E0EFFF" -#define LIGHT_COLOR_FLUORESCENT_FLASHLIGHT "#CDDDFF" -#define LIGHT_COLOR_INCANDESCENT_TUBE "#FFFEB8" -#define LIGHT_COLOR_INCANDESCENT_BULB "#FFDDBB" -#define LIGHT_COLOR_INCANDESCENT_FLASHLIGHT "#FFCC66" -#define LIGHT_COLOR_NIGHTSHIFT "#EFCC86" +//code assumes higher numbers override lower numbers. +#define LIGHTING_NO_UPDATE 0 +#define LIGHTING_VIS_UPDATE 1 +#define LIGHTING_CHECK_UPDATE 2 +#define LIGHTING_FORCE_UPDATE 3 -//Fake ambient occlusion filter -#define AMBIENT_OCCLUSION filter(type="drop_shadow", x=0, y=-1, size=2, offset=2, color="#04080F55") //VOREStation Edit for prettier visuals. +#define FLASH_LIGHT_DURATION 2 +#define FLASH_LIGHT_POWER 3 +#define FLASH_LIGHT_RANGE 3.8 + +// Emissive blocking. +/// Uses vis_overlays to leverage caching so that very few new items need to be made for the overlay. For anything that doesn't change outline or opaque area much or at all. +#define EMISSIVE_BLOCK_GENERIC 1 +/// Uses a dedicated render_target object to copy the entire appearance in real time to the blocking layer. For things that can change in appearance a lot from the base state, like humans. +#define EMISSIVE_BLOCK_UNIQUE 2 + +/// The color matrix applied to all emissive overlays. Should be solely dependent on alpha and not have RGB overlap with [EM_BLOCK_COLOR]. +#define EMISSIVE_COLOR list(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1, 1,1,1,0) +/// A globaly cached version of [EMISSIVE_COLOR] for quick access. +GLOBAL_LIST_INIT(emissive_color, EMISSIVE_COLOR) +/// The color matrix applied to all emissive blockers. Should be solely dependent on alpha and not have RGB overlap with [EMISSIVE_COLOR]. +#define EM_BLOCK_COLOR list(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1, 0,0,0,0) +/// A globaly cached version of [EM_BLOCK_COLOR] for quick access. +GLOBAL_LIST_INIT(em_block_color, EM_BLOCK_COLOR) +/// The color matrix used to mask out emissive blockers on the emissive plane. Alpha should default to zero, be solely dependent on the RGB value of [EMISSIVE_COLOR], and be independant of the RGB value of [EM_BLOCK_COLOR]. +#define EM_MASK_MATRIX list(0,0,0,1/3, 0,0,0,1/3, 0,0,0,1/3, 0,0,0,0, 1,1,1,0) +/// A globaly cached version of [EM_MASK_MATRIX] for quick access. +GLOBAL_LIST_INIT(em_mask_matrix, EM_MASK_MATRIX) + +/// Returns the red part of a #RRGGBB hex sequence as number +#define GETREDPART(hexa) hex2num(copytext(hexa, 2, 4)) + +/// Returns the green part of a #RRGGBB hex sequence as number +#define GETGREENPART(hexa) hex2num(copytext(hexa, 4, 6)) + +/// Returns the blue part of a #RRGGBB hex sequence as number +#define GETBLUEPART(hexa) hex2num(copytext(hexa, 6, 8)) + +/// Parse the hexadecimal color into lumcounts of each perspective. +#define PARSE_LIGHT_COLOR(source) \ +do { \ + if (source.light_color != COLOR_WHITE) { \ + var/__light_color = source.light_color; \ + source.lum_r = GETREDPART(__light_color) / 255; \ + source.lum_g = GETGREENPART(__light_color) / 255; \ + source.lum_b = GETBLUEPART(__light_color) / 255; \ + } else { \ + source.lum_r = 1; \ + source.lum_g = 1; \ + source.lum_b = 1; \ + }; \ +} while (FALSE) diff --git a/code/__defines/misc.dm b/code/__defines/misc.dm index 824155f93eb..b853f4e9b55 100644 --- a/code/__defines/misc.dm +++ b/code/__defines/misc.dm @@ -20,6 +20,7 @@ #define SEE_INVISIBLE_MINIMUM 5 #define INVISIBILITY_MAXIMUM 100 +#define INVISIBILITY_ABSTRACT 101 //only used for abstract objects, things that are not really there. // Pseudo-Invis, like Ninja, Ling, Etc. #define EFFECTIVE_INVIS 50 // Below this, can't be examined, may as well be invisible to the game diff --git a/code/__defines/mobs.dm b/code/__defines/mobs.dm index 7513ab3c006..b70001cbd61 100644 --- a/code/__defines/mobs.dm +++ b/code/__defines/mobs.dm @@ -377,37 +377,40 @@ //Vision flags, for dealing with plane visibility #define VIS_FULLBRIGHT 1 #define VIS_LIGHTING 2 -#define VIS_GHOSTS 3 -#define VIS_AI_EYE 4 +#define VIS_O_LIGHT 3 +#define VIS_EMISSIVE 4 -#define VIS_CH_STATUS 5 -#define VIS_CH_HEALTH 6 -#define VIS_CH_LIFE 7 -#define VIS_CH_ID 8 -#define VIS_CH_WANTED 9 -#define VIS_CH_IMPLOYAL 10 -#define VIS_CH_IMPTRACK 11 -#define VIS_CH_IMPCHEM 12 -#define VIS_CH_SPECIAL 13 -#define VIS_CH_STATUS_OOC 14 +#define VIS_GHOSTS 5 +#define VIS_AI_EYE 6 -#define VIS_ADMIN1 15 -#define VIS_ADMIN2 16 -#define VIS_ADMIN3 17 +#define VIS_CH_STATUS 7 +#define VIS_CH_HEALTH 8 +#define VIS_CH_LIFE 9 +#define VIS_CH_ID 10 +#define VIS_CH_WANTED 11 +#define VIS_CH_IMPLOYAL 12 +#define VIS_CH_IMPTRACK 13 +#define VIS_CH_IMPCHEM 14 +#define VIS_CH_SPECIAL 15 +#define VIS_CH_STATUS_OOC 16 -#define VIS_MESONS 18 +#define VIS_ADMIN1 17 +#define VIS_ADMIN2 18 +#define VIS_ADMIN3 19 -#define VIS_TURFS 19 -#define VIS_OBJS 20 -#define VIS_MOBS 21 +#define VIS_MESONS 20 -#define VIS_BUILDMODE 22 +#define VIS_TURFS 21 +#define VIS_OBJS 22 +#define VIS_MOBS 23 -#define VIS_CLOAKED 23 +#define VIS_BUILDMODE 24 -#define VIS_STATUS 24 +#define VIS_CLOAKED 25 -#define VIS_COUNT 24 //Must be highest number from above. +#define VIS_STATUS 26 + +#define VIS_COUNT 26 //Must be highest number from above. //Some mob icon layering defines #define BODY_LAYER -100 diff --git a/code/__defines/subsystems.dm b/code/__defines/subsystems.dm index 0847e447dbb..687b6870261 100644 --- a/code/__defines/subsystems.dm +++ b/code/__defines/subsystems.dm @@ -56,13 +56,13 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G #define INIT_ORDER_SQLITE 40 #define INIT_ORDER_MEDIA_TRACKS 38 // Gotta get that lobby music up, yo #define INIT_ORDER_CHEMISTRY 35 +#define INIT_ORDER_VIS 32 #define INIT_ORDER_SKYBOX 30 #define INIT_ORDER_MAPPING 25 #define INIT_ORDER_SOUNDS 23 #define INIT_ORDER_INSTRUMENTS 22 #define INIT_ORDER_DECALS 20 #define INIT_ORDER_PLANTS 19 // Must initialize before atoms. -#define INIT_ORDER_PLANETS 18 #define INIT_ORDER_JOB 17 #define INIT_ORDER_ALARM 16 // Must initialize before atoms. #define INIT_ORDER_TRANSCORE 15 // VOREStation Edit @@ -73,6 +73,7 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G #define INIT_ORDER_DEFAULT 0 #define INIT_ORDER_LIGHTING 0 #define INIT_ORDER_AIR -1 +#define INIT_ORDER_PLANETS -2 #define INIT_ORDER_ASSETS -3 #define INIT_ORDER_HOLOMAPS -5 #define INIT_ORDER_NIGHTSHIFT -6 @@ -94,6 +95,7 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G #define FIRE_PRIORITY_SUPPLY 5 #define FIRE_PRIORITY_NIGHTSHIFT 5 #define FIRE_PRIORITY_PLANTS 5 +#define FIRE_PRIORITY_VIS 5 #define FIRE_PRIORITY_ORBIT 7 #define FIRE_PRIORITY_VOTE 8 #define FIRE_PRIORITY_INSTRUMENTS 9 diff --git a/code/__defines/turfs.dm b/code/__defines/turfs.dm index 64593f6e114..770d58573f8 100644 --- a/code/__defines/turfs.dm +++ b/code/__defines/turfs.dm @@ -17,4 +17,6 @@ #define SMOOTH_GREYLIST 4 // Use a whitelist and a blacklist at the same time. atom smoothing only #define isCardinal(x) (x == NORTH || x == SOUTH || x == EAST || x == WEST) -#define isDiagonal(x) (x == NORTHEAST || x == SOUTHEAST || x == NORTHWEST || x == SOUTHWEST) \ No newline at end of file +#define isDiagonal(x) (x == NORTHEAST || x == SOUTHEAST || x == NORTHWEST || x == SOUTHWEST) + +#define IS_OPAQUE_TURF(turf) (turf.directional_opacity == ALL_CARDINALS) diff --git a/code/_helpers/lighting.dm b/code/_helpers/lighting.dm new file mode 100644 index 00000000000..7cfd434e699 --- /dev/null +++ b/code/_helpers/lighting.dm @@ -0,0 +1,10 @@ +/// Produces a mutable appearance glued to the [EMISSIVE_PLANE] dyed to be the [EMISSIVE_COLOR]. +/proc/emissive_appearance(icon, icon_state = "", layer = FLOAT_LAYER, alpha = 255, appearance_flags = NONE) + var/mutable_appearance/appearance = mutable_appearance(icon, icon_state, layer, PLANE_EMISSIVE, alpha, appearance_flags) + appearance.color = GLOB.emissive_color + return appearance + +/proc/em_block_image_generic(var/image/I) + var/mutable_appearance/em_overlay = mutable_appearance(I.icon, I.icon_state, plane = PLANE_EMISSIVE, alpha = I.alpha, appearance_flags = KEEP_APART) + em_overlay.color = GLOB.em_block_color + return em_overlay diff --git a/code/_helpers/sorts/comparators.dm b/code/_helpers/sorts/comparators.dm index de64ad26f7a..b1980d6da14 100644 --- a/code/_helpers/sorts/comparators.dm +++ b/code/_helpers/sorts/comparators.dm @@ -88,3 +88,6 @@ /proc/cmp_media_track_asc(datum/track/A, datum/track/B) var/genre_sort = sorttext(B.genre || "Uncategorized", A.genre || "Uncategorized") return genre_sort || sorttext(B.title, A.title) + +/proc/cmp_filter_data_priority(list/A, list/B) + return A["priority"] - B["priority"] diff --git a/code/_helpers/visual_filters.dm b/code/_helpers/visual_filters.dm index 6cafa5a04d2..96f68710000 100644 --- a/code/_helpers/visual_filters.dm +++ b/code/_helpers/visual_filters.dm @@ -1,20 +1,306 @@ -// These involve BYOND's built in filters that do visual effects, and not stuff that distinguishes between things. +#define ICON_NOT_SET "Not Set" +//This is stored as a nested list instead of datums or whatever because it json encodes nicely for usage in tgui +GLOBAL_LIST_INIT(master_filter_info, list( + "alpha" = list( + "defaults" = list( + "x" = 0, + "y" = 0, + "icon" = ICON_NOT_SET, + "render_source" = "", + "flags" = 0 + ), + "flags" = list( + "MASK_INVERSE" = MASK_INVERSE, + "MASK_SWAP" = MASK_SWAP + ) + ), + "angular_blur" = list( + "defaults" = list( + "x" = 0, + "y" = 0, + "size" = 1 + ) + ), + /* Not supported because making a proper matrix editor on the frontend would be a huge dick pain. + Uncomment if you ever implement it + "color" = list( + "defaults" = list( + "color" = matrix(), + "space" = FILTER_COLOR_RGB + ) + ), + */ + "displace" = list( + "defaults" = list( + "x" = 0, + "y" = 0, + "size" = null, + "icon" = ICON_NOT_SET, + "render_source" = "" + ) + ), + "drop_shadow" = list( + "defaults" = list( + "x" = 1, + "y" = -1, + "size" = 1, + "offset" = 0, + "color" = COLOR_HALF_TRANSPARENT_BLACK + ) + ), + "blur" = list( + "defaults" = list( + "size" = 1 + ) + ), + "layer" = list( + "defaults" = list( + "x" = 0, + "y" = 0, + "icon" = ICON_NOT_SET, + "render_source" = "", + "flags" = FILTER_OVERLAY, + "color" = "", + "transform" = null, + "blend_mode" = BLEND_DEFAULT + ) + ), + "motion_blur" = list( + "defaults" = list( + "x" = 0, + "y" = 0 + ) + ), + "outline" = list( + "defaults" = list( + "size" = 0, + "color" = COLOR_BLACK, + "flags" = NONE + ), + "flags" = list( + "OUTLINE_SHARP" = OUTLINE_SHARP, + "OUTLINE_SQUARE" = OUTLINE_SQUARE + ) + ), + "radial_blur" = list( + "defaults" = list( + "x" = 0, + "y" = 0, + "size" = 0.01 + ) + ), + "rays" = list( + "defaults" = list( + "x" = 0, + "y" = 0, + "size" = 16, + "color" = COLOR_WHITE, + "offset" = 0, + "density" = 10, + "threshold" = 0.5, + "factor" = 0, + "flags" = FILTER_OVERLAY | FILTER_UNDERLAY + ), + "flags" = list( + "FILTER_OVERLAY" = FILTER_OVERLAY, + "FILTER_UNDERLAY" = FILTER_UNDERLAY + ) + ), + "ripple" = list( + "defaults" = list( + "x" = 0, + "y" = 0, + "size" = 1, + "repeat" = 2, + "radius" = 0, + "falloff" = 1, + "flags" = NONE + ), + "flags" = list( + "WAVE_BOUNDED" = WAVE_BOUNDED + ) + ), + "wave" = list( + "defaults" = list( + "x" = 0, + "y" = 0, + "size" = 1, + "offset" = 0, + "flags" = NONE + ), + "flags" = list( + "WAVE_SIDEWAYS" = WAVE_SIDEWAYS, + "WAVE_BOUNDED" = WAVE_BOUNDED + ) + ) +)) -// All of this ported from TG. -/atom/movable - var/list/filter_data // For handling persistent filters +#undef ICON_NOT_SET -/proc/cmp_filter_data_priority(list/A, list/B) - return A["priority"] - B["priority"] +//Helpers to generate lists for filter helpers +//This is the only practical way of writing these that actually produces sane lists +/proc/alpha_mask_filter(x, y, icon/icon, render_source, flags) + . = list("type" = "alpha") + if(!isnull(x)) + .["x"] = x + if(!isnull(y)) + .["y"] = y + if(!isnull(icon)) + .["icon"] = icon + if(!isnull(render_source)) + .["render_source"] = render_source + if(!isnull(flags)) + .["flags"] = flags -/atom/movable/proc/add_filter(filter_name, priority, list/params) +/proc/angular_blur_filter(x, y, size) + . = list("type" = "angular_blur") + if(!isnull(x)) + .["x"] = x + if(!isnull(y)) + .["y"] = y + if(!isnull(size)) + .["size"] = size + +/proc/color_matrix_filter(matrix/in_matrix, space) + . = list("type" = "color") + .["color"] = in_matrix + if(!isnull(space)) + .["space"] = space + +/proc/displacement_map_filter(icon, render_source, x, y, size = 32) + . = list("type" = "displace") + if(!isnull(icon)) + .["icon"] = icon + if(!isnull(render_source)) + .["render_source"] = render_source + if(!isnull(x)) + .["x"] = x + if(!isnull(y)) + .["y"] = y + if(!isnull(size)) + .["size"] = size + +/proc/drop_shadow_filter(x, y, size, offset, color) + . = list("type" = "drop_shadow") + if(!isnull(x)) + .["x"] = x + if(!isnull(y)) + .["y"] = y + if(!isnull(size)) + .["size"] = size + if(!isnull(offset)) + .["offset"] = offset + if(!isnull(color)) + .["color"] = color + +/proc/gauss_blur_filter(size) + . = list("type" = "blur") + if(!isnull(size)) + .["size"] = size + +/proc/layering_filter(icon, render_source, x, y, flags, color, transform, blend_mode) + . = list("type" = "layer") + if(!isnull(icon)) + .["icon"] = icon + if(!isnull(render_source)) + .["render_source"] = render_source + if(!isnull(x)) + .["x"] = x + if(!isnull(y)) + .["y"] = y + if(!isnull(color)) + .["color"] = color + if(!isnull(flags)) + .["flags"] = flags + if(!isnull(transform)) + .["transform"] = transform + if(!isnull(blend_mode)) + .["blend_mode"] = blend_mode + +/proc/motion_blur_filter(x, y) + . = list("type" = "motion_blur") + if(!isnull(x)) + .["x"] = x + if(!isnull(y)) + .["y"] = y + +/proc/outline_filter(size, color, flags) + . = list("type" = "outline") + if(!isnull(size)) + .["size"] = size + if(!isnull(color)) + .["color"] = color + if(!isnull(flags)) + .["flags"] = flags + +/proc/radial_blur_filter(size, x, y) + . = list("type" = "radial_blur") + if(!isnull(size)) + .["size"] = size + if(!isnull(x)) + .["x"] = x + if(!isnull(y)) + .["y"] = y + +/proc/rays_filter(size, color, offset, density, threshold, factor, x, y, flags) + . = list("type" = "rays") + if(!isnull(size)) + .["size"] = size + if(!isnull(color)) + .["color"] = color + if(!isnull(offset)) + .["offset"] = offset + if(!isnull(density)) + .["density"] = density + if(!isnull(threshold)) + .["threshold"] = threshold + if(!isnull(factor)) + .["factor"] = factor + if(!isnull(x)) + .["x"] = x + if(!isnull(y)) + .["y"] = y + if(!isnull(flags)) + .["flags"] = flags + +/proc/ripple_filter(radius, size, falloff, repeat, x, y, flags) + . = list("type" = "ripple") + if(!isnull(radius)) + .["radius"] = radius + if(!isnull(size)) + .["size"] = size + if(!isnull(falloff)) + .["falloff"] = falloff + if(!isnull(repeat)) + .["repeat"] = repeat + if(!isnull(flags)) + .["flags"] = flags + if(!isnull(x)) + .["x"] = x + if(!isnull(y)) + .["y"] = y + +/proc/wave_filter(x, y, size, offset, flags) + . = list("type" = "wave") + if(!isnull(size)) + .["size"] = size + if(!isnull(x)) + .["x"] = x + if(!isnull(y)) + .["y"] = y + if(!isnull(offset)) + .["offset"] = offset + if(!isnull(flags)) + .["flags"] = flags + +/atom/proc/add_filter(name,priority,list/params) LAZYINITLIST(filter_data) var/list/p = params.Copy() p["priority"] = priority - filter_data[filter_name] = p + filter_data[name] = p update_filters() -/atom/movable/proc/update_filters() +/atom/proc/update_filters() filters = null filter_data = sortTim(filter_data, /proc/cmp_filter_data_priority, TRUE) for(var/f in filter_data) @@ -22,15 +308,77 @@ var/list/arguments = data.Copy() arguments -= "priority" filters += filter(arglist(arguments)) + UNSETEMPTY(filter_data) -/atom/movable/proc/get_filter(filter_name) - if(filter_data && filter_data[filter_name]) - return filters[filter_data.Find(filter_name)] +/atom/proc/transition_filter(name, time, list/new_params, easing, loop) + var/filter = get_filter(name) + if(!filter) + return -// Polaris Extensions -/atom/movable/proc/remove_filter(filter_name) - var/thing = get_filter(filter_name) - if(thing) - LAZYREMOVE(filter_data, filter_name) - filters -= thing - update_filters() \ No newline at end of file + var/list/old_filter_data = filter_data[name] + + var/list/params = old_filter_data.Copy() + for(var/thing in new_params) + params[thing] = new_params[thing] + + animate(filter, new_params, time = time, easing = easing, loop = loop) + for(var/param in params) + filter_data[name][param] = params[param] + +/atom/proc/change_filter_priority(name, new_priority) + if(!filter_data || !filter_data[name]) + return + + filter_data[name]["priority"] = new_priority + update_filters() + +/obj/item/update_filters() + . = ..() + /* Will port this from TG + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() + */ + +/atom/proc/get_filter(name) + if(filter_data && filter_data[name]) + return filters[filter_data.Find(name)] + +/atom/proc/remove_filter(name_or_names) + if(!filter_data) + return + + var/list/names = islist(name_or_names) ? name_or_names : list(name_or_names) + + for(var/name in names) + if(filter_data[name]) + filter_data -= name + update_filters() + +/atom/proc/clear_filters() + filter_data = null + filters = null + +/proc/apply_wibbly_filters(atom/in_atom, length) + for(var/i in 1 to 7) + //This is a very baffling and strange way of doing this but I am just preserving old functionality + var/X + var/Y + var/rsq + do + X = 60*rand() - 30 + Y = 60*rand() - 30 + rsq = X*X + Y*Y + while(rsq<100 || rsq>900) // Yeah let's just loop infinitely due to bad luck what's the worst that could happen? + var/random_roll = rand() + in_atom.add_filter("wibbly-[i]", 5, wave_filter(x = X, y = Y, size = rand() * 2.5 + 0.5, offset = random_roll)) + var/filter = in_atom.get_filter("wibbly-[i]") + animate(filter, offset = random_roll, time = 0, loop = -1, flags = ANIMATION_PARALLEL) + animate(offset = random_roll - 1, time = rand() * 20 + 10) + +/proc/remove_wibbly_filters(atom/in_atom) + var/filter + for(var/i in 1 to 7) + filter = in_atom.get_filter("wibbly-[i]") + animate(filter) + in_atom.remove_filter("wibbly-[i]") diff --git a/code/_onclick/hud/fullscreen.dm b/code/_onclick/hud/fullscreen.dm index ddd7ac5dcc6..38646ccbc33 100644 --- a/code/_onclick/hud/fullscreen.dm +++ b/code/_onclick/hud/fullscreen.dm @@ -5,25 +5,22 @@ condition ? overlay_fullscreen(screen_name, screen_type, arg) : clear_fullscreen(screen_name) /mob/proc/overlay_fullscreen(category, type, severity) - var/obj/screen/fullscreen/screen = screens[category] + var/obj/screen/fullscreen/screen = screens[category] + if (!screen || screen.type != type) + // needs to be recreated + clear_fullscreen(category, FALSE) + screens[category] = screen = new type() + else if ((!severity || severity == screen.severity) && (!client || screen.screen_loc != "CENTER-7,CENTER-7" || screen.view == client.view)) + // doesn't need to be updated + return screen - if(screen) - if(screen.type != type) - clear_fullscreen(category, FALSE) - screen = null - else if(!severity || severity == screen.severity) - return screen + screen.icon_state = "[initial(screen.icon_state)][severity]" + screen.severity = severity + if (client && screen.should_show_to(src)) + screen.update_for_view(client.view) + client.screen += screen - if(!screen) - screen = new type() - - screen.icon_state = "[initial(screen.icon_state)][severity]" - screen.severity = severity - - screens[category] = screen - if(client && stat != DEAD) - client.screen += screen - return screen + return screen /mob/proc/clear_fullscreen(category, animated = 10) var/obj/screen/fullscreen/screen = screens[category] @@ -64,13 +61,26 @@ screen_loc = "CENTER-7,CENTER-7" layer = FULLSCREEN_LAYER plane = PLANE_FULLSCREEN - mouse_opacity = 0 + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + var/view = 7 var/severity = 0 + var/show_when_dead = FALSE /obj/screen/fullscreen/Destroy() severity = 0 return ..() +/obj/screen/fullscreen/proc/update_for_view(client_view) + if (screen_loc == "CENTER-7,CENTER-7" && view != client_view) + var/list/actualview = getviewsize(client_view) + view = client_view + transform = matrix(actualview[1]/15, 0, 0, 0, actualview[2]/15, 0) + +/obj/screen/fullscreen/proc/should_show_to(mob/mymob) + if(!show_when_dead && mymob.stat == DEAD) + return FALSE + return TRUE + /obj/screen/fullscreen/brute icon_state = "brutedamageoverlay" layer = DAMAGE_LAYER @@ -123,3 +133,21 @@ /obj/screen/fullscreen/fishbed icon_state = "fishbed" + +/obj/screen/fullscreen/lighting_backdrop + icon = 'icons/mob/screen_gen.dmi' + icon_state = "flash" + transform = matrix(200, 0, 0, 0, 200, 0) + plane = PLANE_LIGHTING + blend_mode = BLEND_OVERLAY + show_when_dead = TRUE + +//Provides darkness to the back of the lighting plane +/obj/screen/fullscreen/lighting_backdrop/lit + invisibility = INVISIBILITY_LIGHTING + layer = BACKGROUND_LAYER+21 + color = "#000" + +//Provides whiteness in case you don't see lights so everything is still visible +/obj/screen/fullscreen/lighting_backdrop/unlit + layer = BACKGROUND_LAYER+20 diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 257760845e6..06b51def249 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -630,6 +630,13 @@ return ..() // Background 'floor' +/obj/screen/setup_preview/pm_helper + icon = null + icon_state = null + appearance_flags = PLANE_MASTER + plane = PLANE_EMISSIVE + alpha = 0 + /obj/screen/setup_preview/bg mouse_over_pointer = MOUSE_HAND_POINTER diff --git a/code/controllers/subsystems/lighting.dm b/code/controllers/subsystems/lighting.dm index 5c7b15d8985..f851e3edf2d 100644 --- a/code/controllers/subsystems/lighting.dm +++ b/code/controllers/subsystems/lighting.dm @@ -1,171 +1,91 @@ -/* -** Lighting Subsystem - Process the lighting! Do it! -*/ - -#define SSLIGHTING_STAGE_LIGHTS 1 -#define SSLIGHTING_STAGE_CORNERS 2 -#define SSLIGHTING_STAGE_OVERLAYS 3 -#define SSLIGHTING_STAGE_DONE 4 -// This subsystem's fire() method also gets called once during Master.Initialize(). -// During this fire we need to use CHECK_TICK to sleep and continue, but in all other fires we need to use MC_CHECK_TICK to pause and return. -// This leads us to a rather annoying little tidbit of code that I have stuffed into this macro so I don't have to see it. -#define DUAL_TICK_CHECK if (init_tick_checks) { CHECK_TICK; } else if (MC_TICK_CHECK) { return; } - -// Globals -/var/lighting_overlays_initialised = FALSE -/var/list/lighting_update_lights = list() // List of lighting sources queued for update. -/var/list/lighting_update_corners = list() // List of lighting corners queued for update. -/var/list/lighting_update_overlays = list() // List of lighting overlays queued for update. - SUBSYSTEM_DEF(lighting) name = "Lighting" - wait = 2 // Ticks, not deciseconds + wait = 2 init_order = INIT_ORDER_LIGHTING flags = SS_TICKER + var/static/list/sources_queue = list() // List of lighting sources queued for update. + var/static/list/corners_queue = list() // List of lighting corners queued for update. + var/static/list/objects_queue = list() // List of lighting objects queued for update. - var/list/currentrun = list() - var/stage = null - - var/cost_lights = 0 - var/cost_corners = 0 - var/cost_overlays = 0 - -/datum/controller/subsystem/lighting/Initialize(timeofday) - if(!lighting_overlays_initialised) - // TODO - TG initializes starlight here. - create_all_lighting_overlays() - lighting_overlays_initialised = TRUE - - // Pre-process lighting once before the round starts. - internal_process_lights(FALSE, TRUE) - internal_process_corners(FALSE, TRUE) - internal_process_overlays(FALSE, TRUE) +/datum/controller/subsystem/lighting/stat_entry(msg) + msg = "L:[length(sources_queue)]|C:[length(corners_queue)]|O:[length(objects_queue)]" return ..() -/datum/controller/subsystem/lighting/fire(resumed = FALSE) - var/timer - if(!resumed) - // Santity checks to make sure we don't somehow have items left over from last cycle - // Or somehow didn't finish all the steps from last cycle - if(LAZYLEN(currentrun) || stage) - log_and_message_admins("SSlighting: Was told to start a new run, but the previous run wasn't finished! currentrun.len=[currentrun.len], stage=[stage]") - resumed = TRUE - else - stage = SSLIGHTING_STAGE_LIGHTS // Start with Step 1 of course - if(stage == SSLIGHTING_STAGE_LIGHTS) - timer = TICK_USAGE - internal_process_lights(resumed) - cost_lights = MC_AVERAGE(cost_lights, TICK_DELTA_TO_MS(TICK_USAGE - timer)) - if(state != SS_RUNNING) - return - resumed = 0 - stage = SSLIGHTING_STAGE_CORNERS +/datum/controller/subsystem/lighting/Initialize(timeofday) + if(!subsystem_initialized) + if (config.starlight) + for(var/area/A in world) + if (A.dynamic_lighting == DYNAMIC_LIGHTING_IFSTARLIGHT) + A.luminosity = 0 - if(stage == SSLIGHTING_STAGE_CORNERS) - timer = TICK_USAGE - internal_process_corners(resumed) - cost_corners = MC_AVERAGE(cost_corners, TICK_DELTA_TO_MS(TICK_USAGE - timer)) - if(state != SS_RUNNING) - return - resumed = 0 - stage = SSLIGHTING_STAGE_OVERLAYS + subsystem_initialized = TRUE + create_all_lighting_objects() - if(stage == SSLIGHTING_STAGE_OVERLAYS) - timer = TICK_USAGE - internal_process_overlays(resumed) - cost_overlays = MC_AVERAGE(cost_overlays, TICK_DELTA_TO_MS(TICK_USAGE - timer)) - if(state != SS_RUNNING) - return - resumed = 0 - stage = SSLIGHTING_STAGE_DONE + fire(FALSE, TRUE) - // Okay, we're done! Woo! Got thru a whole air_master cycle! - if(LAZYLEN(currentrun) || stage != SSLIGHTING_STAGE_DONE) - log_and_message_admins("SSlighting: Was not able to complete a full lighting cycle despite reaching the end of fire(). This shouldn't happen.") - else - currentrun = null - stage = null + return ..() -/datum/controller/subsystem/lighting/proc/internal_process_lights(resumed = FALSE, init_tick_checks = FALSE) - if (!resumed) - // We swap out the lists so any additions to the global list during a pause don't make things wierd. - src.currentrun = global.lighting_update_lights - global.lighting_update_lights = list() +/datum/controller/subsystem/lighting/fire(resumed, init_tick_checks) + MC_SPLIT_TICK_INIT(3) + if(!init_tick_checks) + MC_SPLIT_TICK + var/list/queue = sources_queue + var/i = 0 + for (i in 1 to length(queue)) + var/datum/light_source/L = queue[i] - //cache for sanic speed (lists are references anyways) - var/list/currentrun = src.currentrun - while(currentrun.len) - var/datum/light_source/L = currentrun[currentrun.len] - currentrun.len-- + L.update_corners() - if(!L) continue - if(L.check() || L.destroyed || L.force_update) - L.remove_lum() - if(!L.destroyed) - L.apply_lum() + L.needs_update = LIGHTING_NO_UPDATE - else if(L.vis_update) //We smartly update only tiles that became (in) visible to use. - L.smart_vis_update() + if(init_tick_checks) + CHECK_TICK + else if (MC_TICK_CHECK) + break + if (i) + queue.Cut(1, i+1) + i = 0 - L.vis_update = FALSE - L.force_update = FALSE - L.needs_update = FALSE + if(!init_tick_checks) + MC_SPLIT_TICK - DUAL_TICK_CHECK + queue = corners_queue + for (i in 1 to length(queue)) + var/datum/lighting_corner/C = queue[i] -/datum/controller/subsystem/lighting/proc/internal_process_corners(resumed = FALSE, init_tick_checks = FALSE) - if (!resumed) - // We swap out the lists so any additions to the global list during a pause don't make things wierd. - src.currentrun = global.lighting_update_corners - global.lighting_update_corners = list() + C.needs_update = FALSE //update_objects() can call qdel if the corner is storing no data + C.update_objects() + + if(init_tick_checks) + CHECK_TICK + else if (MC_TICK_CHECK) + break + if (i) + queue.Cut(1, i+1) + i = 0 - //cache for sanic speed (lists are references anyways) - var/list/currentrun = src.currentrun - while(currentrun.len) - var/datum/lighting_corner/C = currentrun[currentrun.len] - currentrun.len-- - if(!C) continue - C.update_overlays() - C.needs_update = FALSE + if(!init_tick_checks) + MC_SPLIT_TICK - DUAL_TICK_CHECK + queue = objects_queue + for (i in 1 to length(queue)) + var/datum/lighting_object/O = queue[i] -/datum/controller/subsystem/lighting/proc/internal_process_overlays(resumed = FALSE, init_tick_checks = FALSE) - if (!resumed) - // We swap out the lists so any additions to the global list during a pause don't make things wierd. - src.currentrun = global.lighting_update_overlays - global.lighting_update_overlays = list() + if (QDELETED(O)) + continue - //cache for sanic speed (lists are references anyways) - var/list/currentrun = src.currentrun - while(currentrun.len) - var/atom/movable/lighting_overlay/O = currentrun[currentrun.len] - currentrun.len-- - - if(!O) continue - O.update_overlay() + O.update() O.needs_update = FALSE + if(init_tick_checks) + CHECK_TICK + else if (MC_TICK_CHECK) + break + if (i) + queue.Cut(1, i+1) - DUAL_TICK_CHECK -/datum/controller/subsystem/lighting/stat_entry(msg_prefix) - var/list/msg = list(msg_prefix) - msg += "T:{" - msg += "S [total_lighting_sources] | " - msg += "C [total_lighting_corners] | " - msg += "O [total_lighting_overlays]" - msg += "}" - msg += "C:{" - msg += "S [round(cost_lights, 1)] | " - msg += "C [round(cost_corners, 1)] | " - msg += "O [round(cost_overlays, 1)]" - msg += "}" - ..(msg.Join()) - -#undef DUAL_TICK_CHECK -#undef SSLIGHTING_STAGE_LIGHTS -#undef SSLIGHTING_STAGE_CORNERS -#undef SSLIGHTING_STAGE_OVERLAYS -#undef SSLIGHTING_STAGE_STATS \ No newline at end of file +/datum/controller/subsystem/lighting/Recover() + subsystem_initialized = SSlighting.subsystem_initialized + ..() diff --git a/code/controllers/subsystems/overlays.dm b/code/controllers/subsystems/overlays.dm index 77c9d3ab94a..16662cc042e 100644 --- a/code/controllers/subsystems/overlays.dm +++ b/code/controllers/subsystems/overlays.dm @@ -224,6 +224,32 @@ var/global/image/appearance_bro = new() // Temporarily super-global because of B else if(cut_old) cut_overlays() +/** + * Returns a list of overlays that the target atom has + * + * @param priority If true, returns priority overlays as well + * @param special If true, returns special overlays like emissives and em_blockers + */ +/proc/get_overlays(atom/other, priority, special) + var/list/including = list() + if(!other) + return including + + for(var/image/I as anything in other.our_overlays) + if(!special && I.plane > 0) + continue + including += I + + if(!priority) + return including + + for(var/image/I as anything in other.priority_overlays) + if(!special && I.plane > 0) + continue + including += I + + return including + #undef NOT_QUEUED_ALREADY #undef QUEUE_FOR_COMPILE diff --git a/code/controllers/subsystems/planets.dm b/code/controllers/subsystems/planets.dm index d1c2de2410c..d468fa9ae57 100644 --- a/code/controllers/subsystems/planets.dm +++ b/code/controllers/subsystems/planets.dm @@ -14,6 +14,9 @@ SUBSYSTEM_DEF(planets) var/static/list/needs_sun_update = list() var/static/list/needs_temp_update = list() + var/static/list/queued_turfs = list() + var/static/accepting_turfs = FALSE + /datum/controller/subsystem/planets/Initialize(timeofday) admin_notice("Initializing planetary weather.", R_DEBUG) createPlanets() @@ -31,11 +34,23 @@ SUBSYSTEM_DEF(planets) admin_notice("Z[Z] is shared by more than one planet!", R_DEBUG) continue z_to_planet[Z] = NP + accepting_turfs = TRUE + while(queued_turfs.len) + addTurf(queued_turfs[queued_turfs.len]) + queued_turfs.len-- + CHECK_TICK + /* Seems to cause active edges, SOMEHOW. IT'S LIGHT AAAA. + for(var/datum/planet/P as anything in planets) + updateSunlight(P) + */ // DO NOT CALL THIS DIRECTLY UNLESS IT'S IN INITIALIZE, // USE turf/simulated/proc/make_indoors() and // tyrf/simulated/proc/make_outdoors() /datum/controller/subsystem/planets/proc/addTurf(var/turf/T) + if(!accepting_turfs) + queued_turfs |= T + return if(z_to_planet.len >= T.z && z_to_planet[T.z]) var/datum/planet/P = z_to_planet[T.z] if(!istype(P)) @@ -44,9 +59,8 @@ SUBSYSTEM_DEF(planets) P.planet_walls += T else if(istype(T, /turf/simulated) && T.outdoors) P.planet_floors += T - T.vis_contents |= P.weather_holder.visuals - T.vis_contents |= P.weather_holder.special_visuals - + P.weather_holder.apply_to_turf(T) + P.sun_holder.apply_to_turf(T) /datum/controller/subsystem/planets/proc/removeTurf(var/turf/T,var/is_edge) if(z_to_planet.len >= T.z) @@ -57,8 +71,8 @@ SUBSYSTEM_DEF(planets) P.planet_walls -= T else P.planet_floors -= T - T.vis_contents -= P.weather_holder.visuals - T.vis_contents -= P.weather_holder.special_visuals + P.weather_holder.remove_from_turf(T) + P.sun_holder.remove_from_turf(T) /datum/controller/subsystem/planets/fire(resumed = 0) @@ -102,39 +116,11 @@ SUBSYSTEM_DEF(planets) return /datum/controller/subsystem/planets/proc/updateSunlight(var/datum/planet/P) - // Remove old value from corners - var/list/sunlit_corners = P.sunlit_corners - var/old_lum_r = -P.sun["lum_r"] - var/old_lum_g = -P.sun["lum_g"] - var/old_lum_b = -P.sun["lum_b"] - if(old_lum_r || old_lum_g || old_lum_b) - for(var/C in sunlit_corners) - var/datum/lighting_corner/LC = C - LC.update_lumcount(old_lum_r, old_lum_g, old_lum_b) - CHECK_TICK - sunlit_corners.Cut() - - // Calculate new values to apply var/new_brightness = P.sun["brightness"] + P.sun_holder.update_brightness(new_brightness) + var/new_color = P.sun["color"] - var/lum_r = new_brightness * GetRedPart (new_color) / 255 - var/lum_g = new_brightness * GetGreenPart(new_color) / 255 - var/lum_b = new_brightness * GetBluePart (new_color) / 255 - var/static/update_gen = -1 // Used to prevent double-processing corners. Otherwise would happen when looping over adjacent turfs. - for(var/turf/simulated/T as anything in P.planet_floors) - if(!T.lighting_corners_initialised) - T.generate_missing_corners() - for(var/C in T.get_corners()) - var/datum/lighting_corner/LC = C - if(LC.update_gen != update_gen && LC.active) - sunlit_corners += LC - LC.update_gen = update_gen - LC.update_lumcount(lum_r, lum_g, lum_b) - CHECK_TICK - update_gen-- - P.sun["lum_r"] = lum_r - P.sun["lum_g"] = lum_g - P.sun["lum_b"] = lum_b + P.sun_holder.update_color(new_color) /datum/controller/subsystem/planets/proc/updateTemp(var/datum/planet/P) //Set new temperatures diff --git a/code/controllers/verbs.dm b/code/controllers/verbs.dm index 58a66923c42..4a9c3b48a7c 100644 --- a/code/controllers/verbs.dm +++ b/code/controllers/verbs.dm @@ -4,6 +4,7 @@ // Clickable stat() button. /obj/effect/statclick name = "Initializing..." + blocks_emissive = FALSE var/target /obj/effect/statclick/New(loc, text, target) //Don't port this to Initialize it's too critical diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index c4ee090ce85..c5bd07cdcbd 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -188,7 +188,11 @@ var/list/sig_types = islist(sig_type_or_types) ? sig_type_or_types : list(sig_type_or_types) for(var/sig_type in sig_types) if(!override && procs[target][sig_type]) - stack_trace("[sig_type] overridden. Use override = TRUE to suppress this warning") + var/trace_msg = "[sig_type] overridden. Use override = TRUE to suppress this warning." + if(isatom(target)) + var/atom/A = target + trace_msg += " [A.x],[A.y],[A.z]" + stack_trace(trace_msg) procs[target][sig_type] = proctype diff --git a/code/datums/components/overlay_lighting.dm b/code/datums/components/overlay_lighting.dm new file mode 100644 index 00000000000..cfc0f1e921e --- /dev/null +++ b/code/datums/components/overlay_lighting.dm @@ -0,0 +1,511 @@ +///For switchable lights, is it on and currently emitting light? +#define LIGHTING_ON (1<<0) +///Is the parent attached to something else, its loc? Then we need to keep an eye of this. +#define LIGHTING_ATTACHED (1<<1) + +#define GET_PARENT (parent_attached_to || parent) + +#define GET_LIGHT_SOURCE (directional_atom || current_holder) + +#define SHORT_CAST 2 + +/** + * Movable atom overlay-based lighting component. + * + * * Component works by applying a visual object to the parent target. + * + * * The component tracks the parent's loc to determine the current_holder. + * * The current_holder is either the parent or its loc, whichever is on a turf. If none, then the current_holder is null and the light is not visible. + * + * * Lighting works at its base by applying a dark overlay and "cutting" said darkness with light, adding (possibly colored) transparency. + * * This component uses the visible_mask visual object to apply said light mask on the darkness. + * + * * The main limitation of this system is that it uses a limited number of pre-baked geometrical shapes, but for most uses it does the job. + * + * * Another limitation is for big lights: you only see the light if you see the object emiting it. + * * For small objects this is good (you can't see them behind a wall), but for big ones this quickly becomes prety clumsy. +*/ +/datum/component/overlay_lighting + ///How far the light reaches, float. + var/range = 1 + ///Ceiling of range, integer without decimal entries. + var/lumcount_range = 0 + ///How much this light affects the dynamic_lumcount of turfs. + var/lum_power = 0.5 + ///Transparency value. + var/set_alpha = 0 + ///For light sources that can be turned on and off. + var/overlay_lighting_flags = NONE + + ///Cache of the possible light overlays, according to size. + var/static/list/light_overlays = list( + "32" = 'icons/effects/light_overlays/light_32.dmi', + "64" = 'icons/effects/light_overlays/light_64.dmi', + "96" = 'icons/effects/light_overlays/light_96.dmi', + "128" = 'icons/effects/light_overlays/light_128.dmi', + "160" = 'icons/effects/light_overlays/light_160.dmi', + "192" = 'icons/effects/light_overlays/light_192.dmi', + "224" = 'icons/effects/light_overlays/light_224.dmi', + "256" = 'icons/effects/light_overlays/light_256.dmi', + "288" = 'icons/effects/light_overlays/light_288.dmi', + "320" = 'icons/effects/light_overlays/light_320.dmi', + "352" = 'icons/effects/light_overlays/light_352.dmi', + ) + + ///Overlay effect to cut into the darkness and provide light. + var/obj/effect/overlay/light_visible/visible_mask + ///Lazy list to track the turfs being affected by our light, to determine their visibility. + var/list/turf/affected_turfs + ///Movable atom currently holding the light. Parent might be a flashlight, for example, but that might be held by a mob or something else. + var/atom/movable/current_holder + ///Movable atom the parent is attached to. For example, a flashlight into a helmet or gun. We'll need to track the thing the parent is attached to as if it were the parent itself. + var/atom/movable/parent_attached_to + ///Whether we're a directional light + var/directional + ///Abstractional atom for directional light, we move this around to make the directional effect + var/obj/effect/abstract/directional_lighting/directional_atom + ///A cone overlay for directional light, it's alpha and color are dependant on the light + var/obj/effect/overlay/light_cone/cone + ///Current tracked direction for the directional cast behaviour + var/current_direction + ///Cast range for the directional cast (how far away the atom is moved) + var/cast_range = 2 + ///Cone offset X hint from atom, used when facing south, inverted when facing north + var/cone_hint_x + ///Cone offset Y hint from atom, when facing east/west, ignored for north/south (uses 16 in those cases) + var/cone_hint_y + + +/datum/component/overlay_lighting/Initialize(_range, _power, _color, starts_on, is_directional) + if(!ismovable(parent)) + return COMPONENT_INCOMPATIBLE + + var/atom/movable/movable_parent = parent + if(movable_parent.light_system != MOVABLE_LIGHT && movable_parent.light_system != MOVABLE_LIGHT_DIRECTIONAL) + stack_trace("[type] added to [parent], with [movable_parent.light_system] value for the light_system var. Use [MOVABLE_LIGHT] or [MOVABLE_LIGHT_DIRECTIONAL] instead.") + return COMPONENT_INCOMPATIBLE + + . = ..() + + visible_mask = new() + if(is_directional) + directional = TRUE + directional_atom = new() + cone = new() + cone_hint_x = movable_parent.light_cone_x_offset + cone_hint_y = movable_parent.light_cone_y_offset + cone.transform = cone.transform.Translate(-32, -32) + set_direction(movable_parent.dir) + if(!isnull(_range)) + movable_parent.set_light_range(_range) + set_range(parent, movable_parent.light_range) + if(!isnull(_power)) + movable_parent.set_light_power(_power) + set_power(parent, movable_parent.light_power) + if(!isnull(_color)) + movable_parent.set_light_color(_color) + set_color(parent, movable_parent.light_color) + if(!isnull(starts_on)) + movable_parent.set_light_on(starts_on) + + +/datum/component/overlay_lighting/RegisterWithParent() + . = ..() + if(directional) + RegisterSignal(parent, COMSIG_ATOM_DIR_CHANGE, .proc/on_parent_dir_change) + RegisterSignal(parent, COMSIG_MOVABLE_MOVED, .proc/on_parent_moved) + RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_RANGE, .proc/set_range) + RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_POWER, .proc/set_power) + RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_COLOR, .proc/set_color) + RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_ON, .proc/on_toggle) + RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_FLAGS, .proc/on_light_flags_change) + RegisterSignal(parent, COMSIG_ATOM_USED_IN_CRAFT, .proc/on_parent_crafted) + RegisterSignal(parent, COMSIG_LIGHT_EATER_QUEUE, .proc/on_light_eater) + var/atom/movable/movable_parent = parent + if(movable_parent.light_flags & LIGHT_ATTACHED) + overlay_lighting_flags |= LIGHTING_ATTACHED + set_parent_attached_to(ismovable(movable_parent.loc) ? movable_parent.loc : null) + check_holder() + if(movable_parent.light_on) + turn_on() + + +/datum/component/overlay_lighting/UnregisterFromParent() + overlay_lighting_flags &= ~LIGHTING_ATTACHED + set_parent_attached_to(null) + set_holder(null) + clean_old_turfs() + UnregisterSignal(parent, list( + COMSIG_MOVABLE_MOVED, + COMSIG_ATOM_UPDATE_LIGHT_RANGE, + COMSIG_ATOM_UPDATE_LIGHT_POWER, + COMSIG_ATOM_UPDATE_LIGHT_COLOR, + COMSIG_ATOM_UPDATE_LIGHT_ON, + COMSIG_ATOM_UPDATE_LIGHT_FLAGS, + COMSIG_ATOM_USED_IN_CRAFT, + COMSIG_LIGHT_EATER_QUEUE, + )) + if(directional) + UnregisterSignal(parent, COMSIG_ATOM_DIR_CHANGE) + if(overlay_lighting_flags & LIGHTING_ON) + turn_off() + return ..() + + +/datum/component/overlay_lighting/Destroy() + set_parent_attached_to(null) + set_holder(null) + clean_old_turfs() + QDEL_NULL(visible_mask) + if(directional) + QDEL_NULL(directional_atom) + QDEL_NULL(cone) + return ..() + + +///Clears the affected_turfs lazylist, removing from its contents the effects of being near the light. +/datum/component/overlay_lighting/proc/clean_old_turfs() + for(var/t in affected_turfs) + var/turf/lit_turf = t + lit_turf.dynamic_lumcount -= lum_power + affected_turfs = null + + +///Populates the affected_turfs lazylist, adding to its contents the effects of being near the light. +/datum/component/overlay_lighting/proc/get_new_turfs() + if(!current_holder) + return + var/atom/movable/light_source = GET_LIGHT_SOURCE + for(var/turf/lit_turf in view(lumcount_range, get_turf(light_source))) + lit_turf.dynamic_lumcount += lum_power + LAZYADD(affected_turfs, lit_turf) + + +///Clears the old affected turfs and populates the new ones. +/datum/component/overlay_lighting/proc/make_luminosity_update() + clean_old_turfs() + if(!isturf(current_holder?.loc)) + return + if(directional) + cast_directional_light() + get_new_turfs() + + +///Adds the luminosity and source for the afected movable atoms to keep track of their visibility. +/datum/component/overlay_lighting/proc/add_dynamic_lumi() + var/atom/movable/light_source = GET_LIGHT_SOURCE + LAZYSET(light_source.affected_dynamic_lights, src, lumcount_range + 1) + light_source.vis_contents += visible_mask + light_source.update_dynamic_luminosity() + if(directional) + current_holder.vis_contents += cone + +///Removes the luminosity and source for the afected movable atoms to keep track of their visibility. +/datum/component/overlay_lighting/proc/remove_dynamic_lumi() + var/atom/movable/light_source = GET_LIGHT_SOURCE + LAZYREMOVE(light_source.affected_dynamic_lights, src) + light_source.vis_contents -= visible_mask + light_source.update_dynamic_luminosity() + if(directional) + current_holder.vis_contents -= cone + directional_atom.moveToNullspace() + +///Called to change the value of parent_attached_to. +/datum/component/overlay_lighting/proc/set_parent_attached_to(atom/movable/new_parent_attached_to) + if(new_parent_attached_to == parent_attached_to) + return + + . = parent_attached_to + parent_attached_to = new_parent_attached_to + if(.) + var/atom/movable/old_parent_attached_to = . + UnregisterSignal(old_parent_attached_to, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE)) + if(old_parent_attached_to == current_holder) + RegisterSignal(old_parent_attached_to, COMSIG_PARENT_QDELETING, .proc/on_holder_qdel) + RegisterSignal(old_parent_attached_to, COMSIG_MOVABLE_MOVED, .proc/on_holder_moved) + RegisterSignal(old_parent_attached_to, COMSIG_LIGHT_EATER_QUEUE, .proc/on_light_eater) + if(parent_attached_to) + if(parent_attached_to == current_holder) + UnregisterSignal(current_holder, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE)) + RegisterSignal(parent_attached_to, COMSIG_PARENT_QDELETING, .proc/on_parent_attached_to_qdel) + RegisterSignal(parent_attached_to, COMSIG_MOVABLE_MOVED, .proc/on_parent_attached_to_moved) + RegisterSignal(parent_attached_to, COMSIG_LIGHT_EATER_QUEUE, .proc/on_light_eater) + check_holder() + + +///Called to change the value of current_holder. +/datum/component/overlay_lighting/proc/set_holder(atom/movable/new_holder) + if(new_holder == current_holder) + return + if(current_holder) + if(current_holder != parent && current_holder != parent_attached_to) + UnregisterSignal(current_holder, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE)) + if(directional) + UnregisterSignal(current_holder, COMSIG_ATOM_DIR_CHANGE) + if(overlay_lighting_flags & LIGHTING_ON) + remove_dynamic_lumi() + current_holder = new_holder + if(new_holder == null) + clean_old_turfs() + return + if(new_holder != parent && new_holder != parent_attached_to) + RegisterSignal(new_holder, COMSIG_PARENT_QDELETING, .proc/on_holder_qdel) + RegisterSignal(new_holder, COMSIG_MOVABLE_MOVED, .proc/on_holder_moved) + RegisterSignal(new_holder, COMSIG_LIGHT_EATER_QUEUE, .proc/on_light_eater) + if(directional) + RegisterSignal(new_holder, COMSIG_ATOM_DIR_CHANGE, .proc/on_holder_dir_change) + if(overlay_lighting_flags & LIGHTING_ON) + make_luminosity_update() + add_dynamic_lumi() + + +///Used to determine the new valid current_holder from the parent's loc. +/datum/component/overlay_lighting/proc/check_holder() + var/atom/movable/movable_parent = GET_PARENT + if(isturf(movable_parent.loc)) + set_holder(movable_parent) + return + var/atom/inside = movable_parent.loc //Parent's loc + if(isnull(inside)) + set_holder(null) + return + if(isturf(inside.loc)) + set_holder(inside) + return + set_holder(null) + + +///Called when the current_holder is qdeleted, to remove the light effect. +/datum/component/overlay_lighting/proc/on_holder_qdel(atom/movable/source, force) + SIGNAL_HANDLER + UnregisterSignal(current_holder, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED)) + if(directional) + UnregisterSignal(current_holder, COMSIG_ATOM_DIR_CHANGE) + set_holder(null) + + +///Called when current_holder changes loc. +/datum/component/overlay_lighting/proc/on_holder_moved(atom/movable/source, OldLoc, Dir, Forced) + SIGNAL_HANDLER + if(!(overlay_lighting_flags & LIGHTING_ON)) + return + make_luminosity_update() + + +///Called when parent changes loc. +/datum/component/overlay_lighting/proc/on_parent_moved(atom/movable/source, OldLoc, Dir, Forced) + SIGNAL_HANDLER + var/atom/movable/movable_parent = parent + if(overlay_lighting_flags & LIGHTING_ATTACHED) + set_parent_attached_to(ismovable(movable_parent.loc) ? movable_parent.loc : null) + check_holder() + if(!(overlay_lighting_flags & LIGHTING_ON) || !current_holder) + return + make_luminosity_update() + + +///Called when the current_holder is qdeleted, to remove the light effect. +/datum/component/overlay_lighting/proc/on_parent_attached_to_qdel(atom/movable/source, force) + SIGNAL_HANDLER + UnregisterSignal(parent_attached_to, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED)) + if(directional) + UnregisterSignal(parent_attached_to, COMSIG_ATOM_DIR_CHANGE) + if(parent_attached_to == current_holder) + set_holder(null) + set_parent_attached_to(null) + + +///Called when parent_attached_to changes loc. +/datum/component/overlay_lighting/proc/on_parent_attached_to_moved(atom/movable/source, OldLoc, Dir, Forced) + SIGNAL_HANDLER + check_holder() + if(!(overlay_lighting_flags & LIGHTING_ON) || !current_holder) + return + make_luminosity_update() + + +///Changes the range which the light reaches. 0 means no light, 6 is the maximum value. +/datum/component/overlay_lighting/proc/set_range(atom/source, old_range) + SIGNAL_HANDLER + var/new_range = source.light_range + if(range == new_range) + return + if(range == 0) + turn_off() + range = clamp(CEILING(new_range, 0.5), 1, 6) + var/pixel_bounds = ((range - 1) * 64) + 32 + lumcount_range = CEILING(range, 1) + visible_mask.icon = light_overlays["[pixel_bounds]"] + if(pixel_bounds == 32) + visible_mask.transform = null + return + var/offset = (pixel_bounds - 32) * 0.5 + var/matrix/transform = new + transform.Translate(-offset, -offset) + visible_mask.transform = transform + if(directional) + cast_range = clamp(round(new_range * 0.5), 1, 3) + if(overlay_lighting_flags & LIGHTING_ON) + make_luminosity_update() + + +///Changes the intensity/brightness of the light by altering the visual object's alpha. +/datum/component/overlay_lighting/proc/set_power(atom/source, old_power) + SIGNAL_HANDLER + var/new_power = source.light_power + set_lum_power(new_power >= 0 ? 0.5 : -0.5) + set_alpha = min(230, (abs(new_power) * 120) + 30) + visible_mask.alpha = set_alpha + if(directional) + cone.alpha = min(200, (abs(new_power) * 90)+20) + + +///Changes the light's color, pretty straightforward. +/datum/component/overlay_lighting/proc/set_color(atom/source, old_color) + SIGNAL_HANDLER + var/new_color = source.light_color + visible_mask.color = new_color + if(directional) + cone.color = new_color + + +///Toggles the light on and off. +/datum/component/overlay_lighting/proc/on_toggle(atom/source, old_value) + SIGNAL_HANDLER + var/new_value = source.light_on + if(new_value) //Truthy value input, turn on. + turn_on() + return + turn_off() //Falsey value, turn off. + + +///Triggered right after the parent light flags change. +/datum/component/overlay_lighting/proc/on_light_flags_change(atom/source, old_flags) + SIGNAL_HANDLER + var/new_flags = source.light_flags + var/atom/movable/movable_parent = parent + if(!((new_flags ^ old_flags) & LIGHT_ATTACHED)) + return + + if(new_flags & LIGHT_ATTACHED) // Gained the [LIGHT_ATTACHED] property + overlay_lighting_flags |= LIGHTING_ATTACHED + if(ismovable(movable_parent.loc)) + set_parent_attached_to(movable_parent.loc) + else // Lost the [LIGHT_ATTACHED] property + overlay_lighting_flags &= ~LIGHTING_ATTACHED + set_parent_attached_to(null) + + +///Toggles the light on. +/datum/component/overlay_lighting/proc/turn_on() + if(overlay_lighting_flags & LIGHTING_ON) + return + if(current_holder) + if(directional) + cast_directional_light() + add_dynamic_lumi() + overlay_lighting_flags |= LIGHTING_ON + get_new_turfs() + + +///Toggles the light off. +/datum/component/overlay_lighting/proc/turn_off() + if(!(overlay_lighting_flags & LIGHTING_ON)) + return + if(current_holder) + remove_dynamic_lumi() + overlay_lighting_flags &= ~LIGHTING_ON + clean_old_turfs() + + +///Here we append the behavior associated to changing lum_power. +/datum/component/overlay_lighting/proc/set_lum_power(new_lum_power) + if(lum_power == new_lum_power) + return + . = lum_power + lum_power = new_lum_power + var/difference = . - lum_power + for(var/t in affected_turfs) + var/turf/lit_turf = t + lit_turf.dynamic_lumcount -= difference + +///Here we append the behavior associated to changing lum_power. +/datum/component/overlay_lighting/proc/cast_directional_light() + var/final_distance = cast_range + //Lower the distance by 1 if we're not looking at a cardinal direction, and we're not a short cast + if(final_distance > SHORT_CAST && !(ALL_CARDINALS & current_direction)) + final_distance -= 1 + var/turf/scanning = get_turf(current_holder) + for(var/i in 1 to final_distance) + var/turf/next_turf = get_step(scanning, current_direction) + if(isnull(next_turf) || IS_OPAQUE_TURF(next_turf)) + break + scanning = next_turf + directional_atom.forceMove(scanning) + +///Called when current_holder changes loc. +/datum/component/overlay_lighting/proc/on_holder_dir_change(atom/movable/source, olddir, newdir) + SIGNAL_HANDLER + set_direction(newdir) + +///Called when parent changes loc. +/datum/component/overlay_lighting/proc/on_parent_dir_change(atom/movable/source, olddir, newdir) + SIGNAL_HANDLER + set_direction(newdir) + +///Sets a new direction for the directional cast, then updates luminosity +/datum/component/overlay_lighting/proc/set_direction(newdir) + if(!newdir) + return + if(current_direction == newdir) + return + current_direction = newdir + cone.set_dir(newdir) + + if(newdir & NORTH) + cone.pixel_y = 16 + else if(newdir & SOUTH) + cone.pixel_y = -16 + else + if(!isnull(cone_hint_y)) + cone.pixel_y = cone_hint_y + else + cone.pixel_y = 0 + + if(newdir & EAST) + cone.pixel_x = 16 + else if(newdir & WEST) + cone.pixel_x = -16 + else + if(!isnull(cone_hint_x)) + if(newdir & NORTH) + cone.pixel_x = -1*cone_hint_x + else + cone.pixel_x = cone_hint_x + else + cone.pixel_x = 0 + + if(overlay_lighting_flags & LIGHTING_ON) + make_luminosity_update() + +/datum/component/overlay_lighting/proc/on_parent_crafted(datum/source, atom/movable/new_craft) + SIGNAL_HANDLER + + if(!istype(new_craft)) + return + + UnregisterSignal(parent, COMSIG_ATOM_USED_IN_CRAFT) + RegisterSignal(new_craft, COMSIG_ATOM_USED_IN_CRAFT, .proc/on_parent_crafted) + set_parent_attached_to(new_craft) + +/// Handles putting the source for overlay lights into the light eater queue since we aren't tracked by [/atom/var/light_sources] +/datum/component/overlay_lighting/proc/on_light_eater(datum/source, list/light_queue, datum/light_eater) + SIGNAL_HANDLER + light_queue[parent] = TRUE + return NONE + +#undef LIGHTING_ON +#undef LIGHTING_ATTACHED +#undef GET_PARENT +#undef GET_LIGHT_SOURCE +#undef SHORT_CAST diff --git a/code/datums/elements/_element.dm b/code/datums/elements/_element.dm index 46a295f90be..30bd98a3268 100644 --- a/code/datums/elements/_element.dm +++ b/code/datums/elements/_element.dm @@ -1,9 +1,9 @@ /** - * A holder for simple behaviour that can be attached to many different types - * - * Only one element of each type is instanced during game init. - * Otherwise acts basically like a lightweight component. - */ + * A holder for simple behaviour that can be attached to many different types + * + * Only one element of each type is instanced during game init. + * Otherwise acts basically like a lightweight component. + */ /datum/element /// Option flags for element behaviour var/element_flags = NONE @@ -18,17 +18,23 @@ /// Activates the functionality defined by the element on the given target datum /datum/element/proc/Attach(datum/target) - SHOULD_CALL_PARENT(1) + SHOULD_CALL_PARENT(TRUE) if(type == /datum/element) return ELEMENT_INCOMPATIBLE SEND_SIGNAL(target, COMSIG_ELEMENT_ATTACH, src) if(element_flags & ELEMENT_DETACH) - RegisterSignal(target, COMSIG_PARENT_QDELETING, .proc/Detach, override = TRUE) + RegisterSignal(target, COMSIG_PARENT_QDELETING, .proc/OnTargetDelete, override = TRUE) + +/datum/element/proc/OnTargetDelete(datum/source, force) + SIGNAL_HANDLER + Detach(source) /// Deactivates the functionality defines by the element on the given datum -/datum/element/proc/Detach(datum/source, force) +/datum/element/proc/Detach(datum/source, ...) + SIGNAL_HANDLER + SEND_SIGNAL(source, COMSIG_ELEMENT_DETACH, src) - SHOULD_CALL_PARENT(1) + SHOULD_CALL_PARENT(TRUE) UnregisterSignal(source, COMSIG_PARENT_QDELETING) /datum/element/Destroy(force) @@ -41,15 +47,21 @@ /// Finds the singleton for the element type given and attaches it to src /datum/proc/_AddElement(list/arguments) + if(QDELING(src)) + CRASH("We just tried to add an element to a qdeleted datum, something is fucked") var/datum/element/ele = SSdcs.GetElement(arguments) arguments[1] = src if(ele.Attach(arglist(arguments)) == ELEMENT_INCOMPATIBLE) CRASH("Incompatible [arguments[1]] assigned to a [type]! args: [json_encode(args)]") /** - * Finds the singleton for the element type given and detaches it from src - * You only need additional arguments beyond the type if you're using [ELEMENT_BESPOKE] - */ + * Finds the singleton for the element type given and detaches it from src + * You only need additional arguments beyond the type if you're using [ELEMENT_BESPOKE] + */ /datum/proc/_RemoveElement(list/arguments) var/datum/element/ele = SSdcs.GetElement(arguments) - ele.Detach(src) + if(ele.element_flags & ELEMENT_COMPLEX_DETACH) + arguments[1] = src + ele.Detach(arglist(arguments)) + else + ele.Detach(src) diff --git a/code/datums/elements/light_blocking.dm b/code/datums/elements/light_blocking.dm new file mode 100644 index 00000000000..86aac9f0758 --- /dev/null +++ b/code/datums/elements/light_blocking.dm @@ -0,0 +1,36 @@ +/** + * Attached to movable atoms with opacity. Listens to them move and updates their old and new turf loc's opacity accordingly. + */ +/datum/element/light_blocking + element_flags = ELEMENT_DETACH + + +/datum/element/light_blocking/Attach(datum/target) + . = ..() + if(!ismovable(target)) + return ELEMENT_INCOMPATIBLE + RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/on_target_move) + var/atom/movable/movable_target = target + if(isturf(movable_target.loc)) + var/turf/turf_loc = movable_target.loc + turf_loc.add_opacity_source(target) + + +/datum/element/light_blocking/Detach(atom/movable/target) + . = ..() + UnregisterSignal(target, list(COMSIG_MOVABLE_MOVED)) + var/atom/movable/movable_target = target + if(isturf(movable_target.loc)) + var/turf/turf_loc = movable_target.loc + turf_loc.remove_opacity_source(target) + + +///Updates old and new turf loc opacities. +/datum/element/light_blocking/proc/on_target_move(atom/movable/source, atom/OldLoc, Dir, Forced = FALSE) + SIGNAL_HANDLER + if(isturf(OldLoc)) + var/turf/old_turf = OldLoc + old_turf.remove_opacity_source(source) + if(isturf(source.loc)) + var/turf/new_turf = source.loc + new_turf.add_opacity_source(source) diff --git a/code/datums/mutable_appearance.dm b/code/datums/mutable_appearance.dm index 16d10ae0356..56faf42469f 100644 --- a/code/datums/mutable_appearance.dm +++ b/code/datums/mutable_appearance.dm @@ -10,10 +10,13 @@ plane = FLOAT_PLANE // No clue why this is 0 by default yet images are on FLOAT_PLANE // And yes this does have to be in the constructor, BYOND ignores it if you set it as a normal var -// Helper similar to image() -/proc/mutable_appearance(icon, icon_state = "", layer = FLOAT_LAYER) +/// Helper similar to image() +/proc/mutable_appearance(icon, icon_state = "", layer = FLOAT_LAYER, plane = FLOAT_PLANE, alpha = 255, appearance_flags = NONE) var/mutable_appearance/MA = new() MA.icon = icon MA.icon_state = icon_state MA.layer = layer - return MA \ No newline at end of file + MA.plane = plane + MA.alpha = alpha + MA.appearance_flags |= appearance_flags + return MA diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 9c46ab200e7..90d43a7c36c 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -80,7 +80,7 @@ A.contents.Add(T) if(old_area) // Handle dynamic lighting update if - if(T.dynamic_lighting && old_area.dynamic_lighting != A.dynamic_lighting) + if(SSlighting.subsystem_initialized && T.dynamic_lighting && old_area.dynamic_lighting != A.dynamic_lighting) if(A.dynamic_lighting) T.lighting_build_overlay() else diff --git a/code/game/atoms.dm b/code/game/atoms.dm index daf2596ced3..186a156ba52 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -26,9 +26,16 @@ ///Chemistry. // Overlays - var/list/our_overlays //our local copy of (non-priority) overlays without byond magic. Use procs in SSoverlays to manipulate - var/list/priority_overlays //overlays that should remain on top and not normally removed when using cut_overlay functions, like c4. + ///Our local copy of (non-priority) overlays without byond magic. Use procs in SSoverlays to manipulate + var/list/our_overlays + ///Overlays that should remain on top and not normally removed when using cut_overlay functions, like c4. + var/list/priority_overlays + ///vis overlays managed by SSvis_overlays to automaticaly turn them like other overlays + var/list/managed_vis_overlays + ///Our local copy of filter data so we can add/remove it + var/list/filter_data + //Detective Work, used for the duplicate data points kept in the scanners var/list/original_atom // Track if we are already had initialize() called to prevent double-initialization. @@ -82,6 +89,13 @@ initialized = TRUE return INITIALIZE_HINT_NORMAL +/atom/Destroy() + if(reagents) + QDEL_NULL(reagents) + if(light) + QDEL_NULL(light) + return ..() + // Called after all object's normal initialize() if initialize() returns INITIALIZE_HINT_LATELOAD /atom/proc/LateInitialize() return diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 645194543fb..2d82dc60711 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -30,6 +30,27 @@ var/cloaked = FALSE //If we're cloaked or not var/image/cloaked_selfimage //The image we use for our client to let them see where we are +/atom/movable/Initialize(mapload) + . = ..() + switch(blocks_emissive) + if(EMISSIVE_BLOCK_GENERIC) + var/mutable_appearance/gen_emissive_blocker = mutable_appearance(icon, icon_state, plane = PLANE_EMISSIVE, alpha = src.alpha) + gen_emissive_blocker.color = GLOB.em_block_color + gen_emissive_blocker.dir = dir + gen_emissive_blocker.appearance_flags |= appearance_flags + add_overlay(list(gen_emissive_blocker), TRUE) + if(EMISSIVE_BLOCK_UNIQUE) + render_target = ref(src) + em_block = new(src, render_target) + add_overlay(list(em_block), TRUE) + if(opacity) + AddElement(/datum/element/light_blocking) + switch(light_system) + if(MOVABLE_LIGHT) + AddComponent(/datum/component/overlay_lighting, starts_on = light_on) + if(MOVABLE_LIGHT_DIRECTIONAL) + AddComponent(/datum/component/overlay_lighting, is_directional = TRUE, starts_on = light_on) + /atom/movable/Destroy() . = ..() if(reagents) @@ -37,30 +58,19 @@ reagents = null for(var/atom/movable/AM in contents) qdel(AM) - var/turf/un_opaque - if(opacity && isturf(loc)) - un_opaque = loc + + if(opacity) + RemoveElement(/datum/element/light_blocking) moveToNullspace() - if(un_opaque) - un_opaque.recalc_atom_opacity() - if (pulledby) - if (pulledby.pulling == src) - pulledby.pulling = null - pulledby = null + + if(pulledby) + pulledby.stop_pulling() + + if(orbiting) + stop_orbit() QDEL_NULL(riding_datum) //VOREStation Add - -/atom/movable/vv_get_dropdown() - . = ..() - VV_DROPDOWN_OPTION("move_atom", "Move To Coordinate") - -/atom/vv_do_topic(list/href_list) - . = ..() - IF_VV_OPTION("move_atom") - usr.client.cmd_admin_move_atom(src) - href_list["datumrefresh"] = "\ref[src]" - /atom/movable/vv_edit_var(var_name, var_value) if(var_name in GLOB.VVpixelmovement) //Pixel movement is not yet implemented, changing this will break everything irreversibly. return FALSE @@ -211,12 +221,15 @@ //Called after a successful Move(). By this point, we've already moved /atom/movable/proc/Moved(atom/old_loc, direction, forced = FALSE, movetime) + SEND_SIGNAL(src, COMSIG_MOVABLE_MOVED, old_loc, direction, forced, movetime) // Handle any buckled mobs on this movable if(has_buckled_mobs()) handle_buckled_mob_movement(old_loc, direction, movetime) if(riding_datum) riding_datum.handle_vehicle_layer() riding_datum.handle_vehicle_offsets() + for (var/datum/light_source/light as anything in light_sources) // Cycle through the light sources on this atom and tell them to update. + light.source_atom.update_light() return TRUE /atom/movable/set_dir(newdir) diff --git a/code/game/gamemodes/endgame/supermatter_cascade/universe.dm b/code/game/gamemodes/endgame/supermatter_cascade/universe.dm index 310a7a9ae70..280d2ed6bd5 100644 --- a/code/game/gamemodes/endgame/supermatter_cascade/universe.dm +++ b/code/game/gamemodes/endgame/supermatter_cascade/universe.dm @@ -91,6 +91,8 @@ The access requirements on the Asteroid Shuttles' consoles have now been revoked A.updateicon() /datum/universal_state/supermatter_cascade/OverlayAndAmbientSet() + return + /* TODO spawn(0) for(var/datum/lighting_corner/L in world) if(L.z in using_map.admin_levels) @@ -100,7 +102,7 @@ The access requirements on the Asteroid Shuttles' consoles have now been revoked for(var/turf/space/T in world) OnTurfChange(T) - + */ /datum/universal_state/supermatter_cascade/proc/MiscSet() for (var/obj/machinery/firealarm/alm in machines) if (!(alm.stat & BROKEN)) diff --git a/code/game/machinery/computer/computer.dm b/code/game/machinery/computer/computer.dm index 9b230cc3d2e..110b70ab8c4 100644 --- a/code/game/machinery/computer/computer.dm +++ b/code/game/machinery/computer/computer.dm @@ -7,6 +7,7 @@ use_power = USE_POWER_IDLE idle_power_usage = 300 active_power_usage = 300 + blocks_emissive = FALSE var/processing = 0 var/icon_keyboard = "generic_key" @@ -62,29 +63,32 @@ /obj/machinery/computer/update_icon() cut_overlays() - // No power - if(stat & NOPOWER) - set_light(0) - if(icon_keyboard) - add_overlay("[icon_keyboard]_off") - playsound(src, 'sound/machines/terminal_off.ogg', 50, 1) - // Yes power - else - if(icon_keyboard) - add_overlay(icon_keyboard) - set_light(light_range_on, light_power_on) - playsound(src, 'sound/machines/terminal_on.ogg', 50, 1) + + . = list() - // Broken - if(stat & BROKEN) - add_overlay("[icon_state]_broken") - // Not broken - else - add_overlay(icon_screen) + if(icon_keyboard) + if(stat & NOPOWER) + playsound(src, 'sound/machines/terminal_off.ogg', 50, 1) + return add_overlay("[icon_keyboard]_off") + . += icon_keyboard + + // This whole block lets screens ignore lighting and be visible even in the darkest room + var/overlay_state = icon_screen + if(stat & BROKEN) + overlay_state = "[icon_state]_broken" + . += mutable_appearance(icon, overlay_state) + . += emissive_appearance(icon, overlay_state) + playsound(src, 'sound/machines/terminal_on.ogg', 50, 1) + + add_overlay(.) /obj/machinery/computer/power_change() ..() update_icon() + if(stat & NOPOWER) + set_light(0) + else + set_light(light_range_on, light_power_on) /obj/machinery/computer/proc/set_broken() stat |= BROKEN diff --git a/code/game/machinery/doors/blast_door.dm b/code/game/machinery/doors/blast_door.dm index 6834bc550c1..18322bf3085 100644 --- a/code/game/machinery/doors/blast_door.dm +++ b/code/game/machinery/doors/blast_door.dm @@ -388,26 +388,19 @@ obj/machinery/door/blast/gate/open . = ..() apply_opacity_to_my_turfs(opacity) -/obj/machinery/door/blast/multi_tile/open() - if((. = ..())) - apply_opacity_to_my_turfs(opacity) +/obj/machinery/door/blast/multi_tile/set_opacity() + . = ..() + apply_opacity_to_my_turfs(opacity) -/obj/machinery/door/blast/multi_tile/close() - if((. = ..())) - apply_opacity_to_my_turfs(opacity) - -/obj/machinery/door/blast/multi_tile/Destroy() - apply_opacity_to_my_turfs(0) - return ..() - -//Multi-tile poddoors don't turn invisible automatically, so we change the opacity of the turfs below instead one by one. /obj/machinery/door/blast/multi_tile/proc/apply_opacity_to_my_turfs(new_opacity) for(var/turf/T in locs) - T.opacity = new_opacity - T.has_opaque_atom = new_opacity - T.reconsider_lights() + T.set_opacity(new_opacity) update_nearby_tiles() +/obj/machinery/door/blast/multi_tile/Destroy() + UnregisterSignal(src, COMSIG_MOVABLE_MOVED) + return ..() + /obj/machinery/door/blast/multi_tile icon_state_open = "open" icon_state_opening = "opening" diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index fc03dcb8d28..616205563de 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -11,6 +11,7 @@ density = 1 can_atmos_pass = ATMOS_PASS_PROC layer = DOOR_OPEN_LAYER + blocks_emissive = EMISSIVE_BLOCK_UNIQUE var/open_layer = DOOR_OPEN_LAYER var/closed_layer = DOOR_CLOSED_LAYER diff --git a/code/game/machinery/doors/multi_tile.dm b/code/game/machinery/doors/multi_tile.dm index ec5acbea73c..23b71bdb0f1 100644 --- a/code/game/machinery/doors/multi_tile.dm +++ b/code/game/machinery/doors/multi_tile.dm @@ -7,41 +7,25 @@ open_sound_powered = 'sound/machines/door/WideOpen.ogg' close_sound_powered = 'sound/machines/door/WideClose.ogg' -/obj/machinery/door/airlock/multi_tile/New() - ..() +/obj/machinery/door/airlock/multi_tile/Initialize(mapload) + . = ..() SetBounds() - if(opacity) - create_fillers() + RegisterSignal(src, COMSIG_MOVABLE_MOVED, .proc/SetBounds) + apply_opacity_to_my_turfs(opacity) + +/obj/machinery/door/airlock/multi_tile/set_opacity() + . = ..() + apply_opacity_to_my_turfs(opacity) + +/obj/machinery/door/airlock/multi_tile/proc/apply_opacity_to_my_turfs(new_opacity) + for(var/turf/T in locs) + T.set_opacity(new_opacity) + update_nearby_tiles() /obj/machinery/door/airlock/multi_tile/Destroy() - QDEL_NULL(filler1) - QDEL_NULL(filler2) + UnregisterSignal(src, COMSIG_MOVABLE_MOVED) return ..() -/obj/machinery/door/airlock/multi_tile/Moved(atom/old_loc, direction, forced = FALSE) - . = ..() - SetBounds() - -/obj/machinery/door/airlock/multi_tile/open() - . = ..() - - if(filler1) - filler1.set_opacity(opacity) - if(filler2) - filler2.set_opacity(opacity) - - return . - -/obj/machinery/door/airlock/multi_tile/close() - . = ..() - - if(filler1) - filler1.set_opacity(opacity) - if(filler2) - filler2.set_opacity(opacity) - - return . - /obj/machinery/door/airlock/multi_tile/proc/SetBounds() if(dir in list(EAST, WEST)) bound_width = width * world.icon_size @@ -50,18 +34,6 @@ bound_width = world.icon_size bound_height = width * world.icon_size -/obj/machinery/door/airlock/multi_tile/proc/create_fillers() - if(src.dir > 3) - filler1 = new/obj/machinery/filler_object (src.loc) - filler2 = new/obj/machinery/filler_object (get_step(src,EAST)) - else - filler1 = new/obj/machinery/filler_object (src.loc) - filler2 = new/obj/machinery/filler_object (get_step(src,NORTH)) - filler1.density = 0 - filler2.density = 0 - filler1.set_opacity(opacity) - filler2.set_opacity(opacity) - /obj/machinery/door/airlock/multi_tile/glass name = "Glass Airlock" icon = 'icons/obj/doors/Door2x1glass.dmi' @@ -74,12 +46,6 @@ icon = 'icons/obj/doors/Door2x1metal.dmi' assembly_type = /obj/structure/door_assembly/multi_tile -/obj/machinery/filler_object - name = "" - icon = 'icons/obj/doors/rapid_pdoor.dmi' - icon_state = "" - density = 0 - /obj/machinery/door/airlock/multi_tile/metal/mait icon = 'icons/obj/doors/Door2x1_Maint.dmi' //req_one_access = list(access_maint_tunnels) //VOREStaiton Edit - Maintenance is open access diff --git a/code/game/machinery/fire_alarm.dm b/code/game/machinery/fire_alarm.dm index 315d470432a..a1a22b80c89 100644 --- a/code/game/machinery/fire_alarm.dm +++ b/code/game/machinery/fire_alarm.dm @@ -5,8 +5,9 @@ FIRE ALARM name = "fire alarm" desc = "\"Pull this in case of emergency\". Thus, keep pulling it forever." icon = 'icons/obj/monitors.dmi' - icon_state = "fire0" + icon_state = "fire" layer = ABOVE_WINDOW_LAYER + blocks_emissive = FALSE var/detecting = 1.0 var/working = 1.0 var/time = 10.0 @@ -45,24 +46,36 @@ FIRE ALARM if(stat & BROKEN) icon_state = "firex" set_light(0) + return else if(stat & NOPOWER) icon_state = "firep" set_light(0) + return + + var/fire_state + + . = list() + icon_state = "fire" + if(!detecting) + fire_state = "fire1" + set_light(l_range = 4, l_power = 0.9, l_color = "#ff0000") else - if(!detecting) - icon_state = "fire1" - set_light(l_range = 4, l_power = 0.9, l_color = "#ff0000") - else - icon_state = "fire0" - switch(seclevel) - if("green") set_light(l_range = 2, l_power = 0.25, l_color = "#00ff00") - if("yellow") set_light(l_range = 2, l_power = 0.25, l_color = "#ffff00") - if("violet") set_light(l_range = 2, l_power = 0.25, l_color = "#9933ff") - if("orange") set_light(l_range = 2, l_power = 0.25, l_color = "#ff9900") - if("blue") set_light(l_range = 2, l_power = 0.25, l_color = "#1024A9") - if("red") set_light(l_range = 4, l_power = 0.9, l_color = "#ff0000") - if("delta") set_light(l_range = 4, l_power = 0.9, l_color = "#FF6633") - add_overlay("overlay_[seclevel]") + fire_state = "fire0" + switch(seclevel) + if("green") set_light(l_range = 2, l_power = 0.25, l_color = "#00ff00") + if("yellow") set_light(l_range = 2, l_power = 0.25, l_color = "#ffff00") + if("violet") set_light(l_range = 2, l_power = 0.25, l_color = "#9933ff") + if("orange") set_light(l_range = 2, l_power = 0.25, l_color = "#ff9900") + if("blue") set_light(l_range = 2, l_power = 0.25, l_color = "#1024A9") + if("red") set_light(l_range = 4, l_power = 0.9, l_color = "#ff0000") + if("delta") set_light(l_range = 4, l_power = 0.9, l_color = "#FF6633") + + . += mutable_appearance(icon, fire_state) + . += emissive_appearance(icon, fire_state) + . += mutable_appearance(icon, "overlay_[seclevel]") + . += emissive_appearance(icon, "overlay_[seclevel]") + + add_overlay(.) /obj/machinery/firealarm/fire_act(datum/gas_mixture/air, temperature, volume) if(detecting) diff --git a/code/game/machinery/lightswitch.dm b/code/game/machinery/lightswitch.dm index c078b854d0c..89bd996dea9 100644 --- a/code/game/machinery/lightswitch.dm +++ b/code/game/machinery/lightswitch.dm @@ -11,6 +11,7 @@ use_power = USE_POWER_IDLE idle_power_usage = 10 power_channel = LIGHT + blocks_emissive = FALSE var/on = 1 var/area/area = null var/otherarea = null @@ -36,19 +37,18 @@ return ..() /obj/machinery/light_switch/proc/updateicon() - if(!overlay) - overlay = image(icon, "light1-overlay") - overlay.plane = PLANE_LIGHTING_ABOVE - - overlays.Cut() + cut_overlays() if(stat & NOPOWER) icon_state = "light-p" set_light(0) else icon_state = "light[on]" - overlay.icon_state = "light[on]-overlay" - overlays += overlay set_light(2, 0.1, on ? "#82FF4C" : "#F86060") + . = list() + . += emissive_appearance(icon, "light[on]-overlay") + + return add_overlay(.) + /obj/machinery/light_switch/examine(mob/user) . = ..() diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 47d26c7ab1c..1900811c8a2 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -114,6 +114,8 @@ Class Procs: var/speed_process = FALSE //If false, SSmachines. If true, SSfastprocess. + blocks_emissive = EMISSIVE_BLOCK_GENERIC + /obj/machinery/New(l, d=0) ..(l) if(d) diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index d4068974ae3..6af917ad035 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -45,6 +45,7 @@ active_power_usage = 300 //when active, this turret takes up constant 300 Equipment power power_channel = EQUIP //drains power from the EQUIPMENT channel req_one_access = list(access_security, access_heads) + blocks_emissive = EMISSIVE_BLOCK_UNIQUE var/raised = FALSE //if the turret cover is "open" and the turret is raised var/raising= FALSE //if the turret is currently opening or closing its cover diff --git a/code/game/objects/effects/effect_system.dm b/code/game/objects/effects/effect_system.dm index 7033648deaa..151cf5b47c6 100644 --- a/code/game/objects/effects/effect_system.dm +++ b/code/game/objects/effects/effect_system.dm @@ -12,6 +12,7 @@ would spawn and follow the beaker, even if it is carried or thrown. mouse_opacity = 0 unacidable = 1//So effect are not targeted by alien acid. pass_flags = PASSTABLE | PASSGRILLE + blocks_emissive = EMISSIVE_BLOCK_GENERIC /datum/effect/effect/system var/number = 3 diff --git a/code/game/objects/effects/misc.dm b/code/game/objects/effects/misc.dm index 5958f79d002..e9f2438027e 100644 --- a/code/game/objects/effects/misc.dm +++ b/code/game/objects/effects/misc.dm @@ -61,4 +61,41 @@ /obj/effect/temporary_effect/lightning_strike/Initialize() icon_state += "[rand(1,2)]" // To have two variants of lightning sprites. animate(src, alpha = 0, time = time_to_die - 1) - . = ..() \ No newline at end of file + . = ..() + +/obj/effect/dummy/lighting_obj + name = "lighting fx obj" + desc = "Tell a coder if you're seeing this." + icon_state = "nothing" + light_system = MOVABLE_LIGHT + light_range = MINIMUM_USEFUL_LIGHT_RANGE + light_color = COLOR_WHITE + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + light_on = TRUE + +/obj/effect/dummy/lighting_obj/Initialize(mapload, _range, _power, _color, _duration) + . = ..() + if(!isnull(_range)) + set_light_range(_range) + if(!isnull(_power)) + set_light_power(_power) + if(!isnull(_color)) + set_light_color(_color) + if(_duration) + QDEL_IN(src, _duration) + +/obj/effect/dummy/lighting_obj/moblight + name = "mob lighting fx" + +/obj/effect/dummy/lighting_obj/moblight/Initialize(mapload, _color, _range, _power, _duration) + . = ..() + if(!ismob(loc)) + return INITIALIZE_HINT_QDEL + +/obj/effect/dummy/lighting_obj/moblight/fire + name = "fire" + light_color = LIGHT_COLOR_FIRE + light_range = LIGHT_RANGE_FIRE + +/obj/effect/abstract/directional_lighting + mouse_opacity = MOUSE_OPACITY_TRANSPARENT diff --git a/code/game/objects/effects/overlays.dm b/code/game/objects/effects/overlays.dm index 6c8a04143b0..5ed1ccc66c1 100644 --- a/code/game/objects/effects/overlays.dm +++ b/code/game/objects/effects/overlays.dm @@ -109,3 +109,45 @@ plane = PLANE_LIGHTING_ABOVE pixel_x = -32 pixel_y = -32 + +/obj/effect/overlay/vis + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + anchored = TRUE + vis_flags = VIS_INHERIT_DIR + ///When detected to be unused it gets set to world.time, after a while it gets removed + var/unused = 0 + ///overlays which go unused for this amount of time get cleaned up + var/cache_expiration = 2 MINUTES + +/* +/obj/effect/overlay/atmos_excited + name = "excited group" + icon = null + icon_state = null + anchored = TRUE // should only appear in vis_contents, but to be safe + appearance_flags = RESET_TRANSFORM | TILE_BOUND + invisibility = INVISIBILITY_ABSTRACT + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + + plane = ATMOS_GROUP_PLANE +*/ + +/obj/effect/overlay/light_visible + name = "" + icon = 'icons/effects/light_overlays/light_32.dmi' + icon_state = "light" + plane = PLANE_O_LIGHTING_VISUAL + appearance_flags = RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + alpha = 0 + vis_flags = NONE + +/obj/effect/overlay/light_cone + name = "" + icon = 'icons/effects/light_overlays/light_cone.dmi' + icon_state = "light" + plane = PLANE_O_LIGHTING_VISUAL + appearance_flags = RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + vis_flags = NONE + alpha = 110 diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 5e109aafc9e..7bbffecbe8a 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -2,6 +2,7 @@ name = "item" icon = 'icons/obj/items.dmi' w_class = ITEMSIZE_NORMAL + blocks_emissive = EMISSIVE_BLOCK_GENERIC var/image/blood_overlay = null //this saves our blood splatter overlay, which will be processed not to go over the edges of the sprite var/randpixel = 6 @@ -632,7 +633,7 @@ var/list/global/slot_flags_enumeration = list( //Make the blood_overlay have the proper color then apply it. blood_overlay.color = blood_color - overlays += blood_overlay + add_overlay(blood_overlay) //if this blood isn't already in the list, add it if(istype(M)) @@ -824,6 +825,9 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out. if(!inhands) apply_blood(standing) //Some items show blood when bloodied apply_accessories(standing) //Some items sport accessories like webbing + + //Apply overlays to our...overlay + apply_overlays(standing) //Return our icon return standing @@ -905,6 +909,15 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out. /obj/item/proc/apply_accessories(var/image/standing) return standing +/obj/item/proc/apply_overlays(var/image/standing) + if(!blocks_emissive) + return standing + + var/mutable_appearance/blocker_overlay = mutable_appearance(standing.icon, standing.icon_state, plane = PLANE_EMISSIVE, appearance_flags = KEEP_APART) + blocker_overlay.color = GLOB.em_block_color + standing.add_overlay(blocker_overlay) + return standing + /obj/item/MouseEntered(location,control,params) . = ..() if(usr.is_preference_enabled(/datum/client_preference/inv_tooltips) && ((src in usr) || isstorage(loc))) // If in inventory or in storage we're looking at diff --git a/code/game/objects/items/devices/flashlight.dm b/code/game/objects/items/devices/flashlight.dm index 3dafea4ac78..62d1b4b9341 100644 --- a/code/game/objects/items/devices/flashlight.dm +++ b/code/game/objects/items/devices/flashlight.dm @@ -7,15 +7,18 @@ slot_flags = SLOT_BELT matter = list(DEFAULT_WALL_MATERIAL = 50,"glass" = 20) action_button_name = "Toggle Flashlight" + + light_system = MOVABLE_LIGHT_DIRECTIONAL + light_range = 4 //luminosity when on + light_power = 0.8 //lighting power when on + light_color = "#FFFFFF" //LIGHT_COLOR_INCANDESCENT_FLASHLIGHT //lighting colour when on + light_cone_y_offset = -7 + var/on = 0 - var/brightness_on = 4 //luminosity when on - var/flashlight_power = 0.8 //lighting power when on - var/flashlight_colour = LIGHT_COLOR_INCANDESCENT_FLASHLIGHT //lighting colour when on + var/obj/item/weapon/cell/cell var/cell_type = /obj/item/weapon/cell/device - var/list/brightness_levels - var/brightness_level = "medium" - var/power_usage + var/power_usage = 1 var/power_use = 1 /obj/item/device/flashlight/Initialize() @@ -23,12 +26,8 @@ if(power_use && cell_type) cell = new cell_type(src) - brightness_levels = list("low" = 0.25, "medium" = 0.5, "high" = 1) - power_usage = brightness_levels[brightness_level] - else - verbs -= /obj/item/device/flashlight/verb/toggle - - update_icon() + + update_brightness() /obj/item/device/flashlight/Destroy() STOP_PROCESSING(SSobj, src) @@ -38,63 +37,40 @@ /obj/item/device/flashlight/get_cell() return cell -/obj/item/device/flashlight/verb/toggle() - set name = "Toggle Flashlight Brightness" - set category = "Object" - set src in usr - set_brightness(usr) - -/obj/item/device/flashlight/proc/set_brightness(mob/user as mob) - var/choice = input("Choose a brightness level.") as null|anything in brightness_levels - if(choice) - brightness_level = choice - power_usage = brightness_levels[choice] - to_chat(user, "You set the brightness level on \the [src] to [brightness_level].") - update_icon() - /obj/item/device/flashlight/process() if(!on || !cell) return PROCESS_KILL - if(brightness_level && power_usage) + if(power_usage) if(cell.use(power_usage) != power_usage) // we weren't able to use our full power_usage amount! visible_message("\The [src] flickers before going dull.") - set_light(0) - playsound(src, 'sound/effects/sparks3.ogg', 10, 1, -3) //Small cue that your light went dull in your pocket. + playsound(src, 'sound/effects/sparks3.ogg', 10, 1, -3) //Small cue that your light went dull in your pocket. //VOREStation Edit on = 0 - update_icon() + update_brightness() return PROCESS_KILL -/obj/item/device/flashlight/update_icon() +/obj/item/device/flashlight/proc/update_brightness() if(on) icon_state = "[initial(icon_state)]-on" - - if(brightness_level == "low") - set_light(brightness_on/2, flashlight_power*0.75, flashlight_colour) - else if(brightness_level == "high") - set_light(brightness_on*1.5, flashlight_power*1.1, flashlight_colour) - else - set_light(brightness_on, flashlight_power, flashlight_colour) - else - icon_state = "[initial(icon_state)]" - set_light(0) + icon_state = initial(icon_state) + set_light_on(on) + if(light_system == STATIC_LIGHT) + update_light() /obj/item/device/flashlight/examine(mob/user) . = ..() - if(power_use && brightness_level) - . += "\The [src] is set to [brightness_level]." - if(cell) - . += "\The [src] has a \the [cell] attached." + if(power_use && cell) + . += "\The [src] has a \the [cell] attached." - if(cell.charge <= cell.maxcharge*0.25) - . += "It appears to have a low amount of power remaining." - else if(cell.charge > cell.maxcharge*0.25 && cell.charge <= cell.maxcharge*0.5) - . += "It appears to have an average amount of power remaining." - else if(cell.charge > cell.maxcharge*0.5 && cell.charge <= cell.maxcharge*0.75) - . += "It appears to have an above average amount of power remaining." - else if(cell.charge > cell.maxcharge*0.75 && cell.charge <= cell.maxcharge) - . += "It appears to have a high amount of power remaining." + if(cell.charge <= cell.maxcharge*0.25) + . += "It appears to have a low amount of power remaining." + else if(cell.charge > cell.maxcharge*0.25 && cell.charge <= cell.maxcharge*0.5) + . += "It appears to have an average amount of power remaining." + else if(cell.charge > cell.maxcharge*0.5 && cell.charge <= cell.maxcharge*0.75) + . += "It appears to have an above average amount of power remaining." + else if(cell.charge > cell.maxcharge*0.75 && cell.charge <= cell.maxcharge) + . += "It appears to have a high amount of power remaining." /obj/item/device/flashlight/attack_self(mob/user) if(power_use) @@ -109,8 +85,8 @@ START_PROCESSING(SSobj, src) else if(power_use) STOP_PROCESSING(SSobj, src) - playsound(src, 'sound/weapons/empty.ogg', 15, 1, -3) - update_icon() + playsound(src, 'sound/weapons/empty.ogg', 15, 1, -3) // VOREStation Edit + update_brightness() user.update_action_buttons() return 1 @@ -177,7 +153,7 @@ to_chat(user, "You remove the cell from the [src].") playsound(src, 'sound/machines/button.ogg', 30, 1, 0) on = 0 - update_icon() + update_brightness() return ..() else @@ -225,7 +201,7 @@ cell = W to_chat(user, "You install a cell in \the [src].") playsound(src, 'sound/machines/button.ogg', 30, 1, 0) - update_icon() + update_brightness() else to_chat(user, "\The [src] already has a cell.") else @@ -242,7 +218,7 @@ drop_sound = 'sound/items/drop/accessory.ogg' pickup_sound = 'sound/items/pickup/accessory.ogg' slot_flags = SLOT_EARS - brightness_on = 2 + light_range = 2 w_class = ITEMSIZE_TINY power_use = 0 @@ -270,7 +246,7 @@ name = "maglight" desc = "A very, very heavy duty flashlight." icon_state = "maglight" - flashlight_colour = LIGHT_COLOR_FLUORESCENT_FLASHLIGHT + light_color = LIGHT_COLOR_FLUORESCENT_FLASHLIGHT force = 10 slot_flags = SLOT_BELT w_class = ITEMSIZE_SMALL @@ -283,7 +259,7 @@ desc = "A miniature lamp, that might be used by small robots." icon_state = "penlight" item_state = null - brightness_on = 2 + light_range = 2 w_class = ITEMSIZE_TINY power_use = 0 @@ -294,10 +270,11 @@ icon_state = "lamp" force = 10 center_of_mass = list("x" = 13,"y" = 11) - brightness_on = 10 + light_range = 5 w_class = ITEMSIZE_LARGE power_use = 0 on = 1 + light_system = STATIC_LIGHT // green-shaded desk lamp @@ -305,8 +282,7 @@ desc = "A classic green-shaded desk lamp." icon_state = "lampgreen" center_of_mass = list("x" = 15,"y" = 11) - brightness_on = 5 - flashlight_colour = "#FFC58F" + light_color = "#FFC58F" /obj/item/device/flashlight/lamp/verb/toggle_light() set name = "Toggle light" @@ -322,9 +298,9 @@ name = "flare" desc = "A red standard-issue flare. There are instructions on the side reading 'pull cord, make light'." w_class = ITEMSIZE_SMALL - brightness_on = 8 // Pretty bright. - flashlight_power = 0.8 - flashlight_colour = LIGHT_COLOR_FLARE + light_range = 8 // Pretty bright. + light_power = 0.8 + light_color = LIGHT_COLOR_FLARE icon_state = "flare" item_state = "flare" action_button_name = null //just pull it manually, neckbeard. @@ -334,6 +310,7 @@ power_use = 0 drop_sound = 'sound/items/drop/gloves.ogg' pickup_sound = 'sound/items/pickup/gloves.ogg' + light_system = MOVABLE_LIGHT /obj/item/device/flashlight/flare/New() fuel = rand(800, 1000) // Sorry for changing this so much but I keep under-estimating how long X number of ticks last in seconds. @@ -354,7 +331,7 @@ on = 0 src.force = initial(src.force) src.damtype = initial(src.damtype) - update_icon() + update_brightness() /obj/item/device/flashlight/flare/attack_self(mob/user) @@ -375,7 +352,7 @@ /obj/item/device/flashlight/flare/proc/ignite() //Used for flare launchers. on = !on - update_icon() + update_brightness() force = on_damage damtype = "fire" START_PROCESSING(SSobj, src) @@ -387,9 +364,10 @@ name = "green glowstick" desc = "A green military-grade glowstick." w_class = ITEMSIZE_SMALL - brightness_on = 4 - flashlight_power = 0.9 - flashlight_colour = "#49F37C" + light_system = MOVABLE_LIGHT + light_range = 4 + light_power = 0.9 + light_color = "#49F37C" icon_state = "glowstick" item_state = "glowstick" var/fuel = 0 @@ -409,7 +387,7 @@ /obj/item/device/flashlight/glowstick/proc/turn_off() on = 0 - update_icon() + update_brightness() /obj/item/device/flashlight/glowstick/attack_self(mob/user) @@ -427,28 +405,28 @@ /obj/item/device/flashlight/glowstick/red name = "red glowstick" desc = "A red military-grade glowstick." - flashlight_colour = "#FC0F29" + light_color = "#FC0F29" icon_state = "glowstick_red" item_state = "glowstick_red" /obj/item/device/flashlight/glowstick/blue name = "blue glowstick" desc = "A blue military-grade glowstick." - flashlight_colour = "#599DFF" + light_color = "#599DFF" icon_state = "glowstick_blue" item_state = "glowstick_blue" /obj/item/device/flashlight/glowstick/orange name = "orange glowstick" desc = "A orange military-grade glowstick." - flashlight_colour = "#FA7C0B" + light_color = "#FA7C0B" icon_state = "glowstick_orange" item_state = "glowstick_orange" /obj/item/device/flashlight/glowstick/yellow name = "yellow glowstick" desc = "A yellow military-grade glowstick." - flashlight_colour = "#FEF923" + light_color = "#FEF923" icon_state = "glowstick_yellow" item_state = "glowstick_yellow" @@ -460,17 +438,17 @@ icon = 'icons/obj/lighting.dmi' icon_state = "floor1" //not a slime extract sprite but... something close enough! item_state = "slime" - flashlight_colour = "#FFF423" + light_color = "#FFF423" w_class = ITEMSIZE_TINY - brightness_on = 6 + light_range = 6 on = 1 //Bio-luminesence has one setting, on. power_use = 0 /obj/item/device/flashlight/slime/New() ..() - set_light(brightness_on, flashlight_power, flashlight_colour) + set_light(light_range, light_power, light_color) -/obj/item/device/flashlight/slime/update_icon() +/obj/item/device/flashlight/slime/update_brightness() return /obj/item/device/flashlight/slime/attack_self(mob/user) diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm index f81419be75e..87332c776f0 100644 --- a/code/game/objects/structures.dm +++ b/code/game/objects/structures.dm @@ -1,6 +1,7 @@ /obj/structure icon = 'icons/obj/structures.dmi' w_class = ITEMSIZE_NO_CONTAINER + blocks_emissive = EMISSIVE_BLOCK_GENERIC var/climbable var/climb_delay = 3.5 SECONDS diff --git a/code/game/objects/structures/crates_lockers/__closets.dm b/code/game/objects/structures/crates_lockers/__closets.dm index 85e45314de4..4af69175fd8 100644 --- a/code/game/objects/structures/crates_lockers/__closets.dm +++ b/code/game/objects/structures/crates_lockers/__closets.dm @@ -7,6 +7,7 @@ density = 1 w_class = ITEMSIZE_HUGE layer = UNDER_JUNK_LAYER + blocks_emissive = EMISSIVE_BLOCK_UNIQUE var/opened = 0 var/sealed = 0 diff --git a/code/game/objects/structures/crates_lockers/closets/statue.dm b/code/game/objects/structures/crates_lockers/closets/statue.dm index 2ea6372aef3..dc6e92355d7 100644 --- a/code/game/objects/structures/crates_lockers/closets/statue.dm +++ b/code/game/objects/structures/crates_lockers/closets/statue.dm @@ -6,6 +6,7 @@ density = 1 anchored = 1 health = 0 //destroying the statue kills the mob within + blocks_emissive = EMISSIVE_BLOCK_UNIQUE var/intialTox = 0 //these are here to keep the mob from taking damage from things that logically wouldn't affect a rock var/intialFire = 0 //it's a little sloppy I know but it was this or the GODMODE flag. Lesser of two evils. var/intialBrute = 0 @@ -43,7 +44,7 @@ qdel(src) return - START_PROCESSING(SSobj, src) + START_PROCESSING(SSobj, src) ..() /obj/structure/closet/statue/process() diff --git a/code/game/objects/structures/fitness.dm b/code/game/objects/structures/fitness.dm index 729e578ba58..f41fbfa8cf8 100644 --- a/code/game/objects/structures/fitness.dm +++ b/code/game/objects/structures/fitness.dm @@ -29,6 +29,7 @@ name = "weightlifting machine" desc = "A machine used to lift weights." icon_state = "weightlifter" + blocks_emissive = EMISSIVE_BLOCK_UNIQUE var/weight = 1 var/list/qualifiers = list("with ease", "without any trouble", "with great effort") diff --git a/code/game/objects/structures/flora/trees.dm b/code/game/objects/structures/flora/trees.dm index 8eefe0c3134..2ced6ba550c 100644 --- a/code/game/objects/structures/flora/trees.dm +++ b/code/game/objects/structures/flora/trees.dm @@ -265,6 +265,7 @@ icon = 'icons/obj/flora/deadtrees.dmi' icon_state = "tree_sif" base_state = "tree_sif" + blocks_emissive = FALSE product = /obj/item/stack/material/log/sif catalogue_data = list(/datum/category_item/catalogue/flora/sif_tree) randomize_size = TRUE @@ -289,7 +290,10 @@ update_icon() /obj/structure/flora/tree/sif/update_icon() - set_light(5 - light_shift, 1, "#33ccff") // 5 variants, missing bulbs. 5th has no bulbs, so no glow. - var/image/glow = image(icon = icon, icon_state = "[base_state][light_shift]_glow") - glow.plane = PLANE_LIGHTING_ABOVE - overlays = list(glow) + cut_overlays() + var/bulbs = (5 - light_shift) + if(bulbs > 0) + set_light(bulbs, 1, "#33ccff") // 5 variants, missing bulbs. 5th has no bulbs, so no glow. + add_overlay(mutable_appearance(icon, "[base_state][bulbs]_glow")) + add_overlay(emissive_appearance(icon, "[base_state][bulbs]_glow")) + \ No newline at end of file diff --git a/code/game/objects/structures/simple_doors.dm b/code/game/objects/structures/simple_doors.dm index 19ae278730d..6fe2aa384ad 100644 --- a/code/game/objects/structures/simple_doors.dm +++ b/code/game/objects/structures/simple_doors.dm @@ -12,7 +12,7 @@ var/isSwitchingStates = 0 var/hardness = 1 var/oreAmount = 7 - + /obj/structure/simple_door/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume) TemperatureAct(exposed_temperature) @@ -20,13 +20,22 @@ hardness -= material.combustion_effect(get_turf(src),temperature, 0.3) CheckHardness() -/obj/structure/simple_door/New(var/newloc, var/material_name) - ..() +/obj/structure/simple_door/Initialize(mapload, var/material_name) + . = ..() + set_material(material_name) + if(!material) + return INITIALIZE_HINT_QDEL + +/obj/structure/simple_door/Destroy() + STOP_PROCESSING(SSobj, src) + update_nearby_tiles() + return ..() + +/obj/structure/simple_door/proc/set_material(var/material_name) if(!material_name) material_name = DEFAULT_WALL_MATERIAL material = get_material_by_name(material_name) if(!material) - qdel(src) return hardness = max(1,round(material.integrity/10)) icon_state = material.door_icon_base @@ -40,11 +49,6 @@ START_PROCESSING(SSobj, src) update_nearby_tiles(need_rebuild=1) -/obj/structure/simple_door/Destroy() - STOP_PROCESSING(SSobj, src) - update_nearby_tiles() - return ..() - /obj/structure/simple_door/get_material() return material @@ -198,38 +202,38 @@ return SSradiation.radiate(src, round(material.radioactivity/3)) -/obj/structure/simple_door/iron/New(var/newloc,var/material_name) - ..(newloc, "iron") +/obj/structure/simple_door/iron/Initialize(mapload,var/material_name) + ..(mapload, material_name || "iron") -/obj/structure/simple_door/silver/New(var/newloc,var/material_name) - ..(newloc, "silver") +/obj/structure/simple_door/silver/Initialize(mapload,var/material_name) + ..(mapload, material_name || "silver") -/obj/structure/simple_door/gold/New(var/newloc,var/material_name) - ..(newloc, "gold") +/obj/structure/simple_door/gold/Initialize(mapload,var/material_name) + ..(mapload, material_name || "gold") -/obj/structure/simple_door/uranium/New(var/newloc,var/material_name) - ..(newloc, "uranium") +/obj/structure/simple_door/uranium/Initialize(mapload,var/material_name) + ..(mapload, material_name || "uranium") -/obj/structure/simple_door/sandstone/New(var/newloc,var/material_name) - ..(newloc, "sandstone") +/obj/structure/simple_door/sandstone/Initialize(mapload,var/material_name) + ..(mapload, material_name || "sandstone") -/obj/structure/simple_door/phoron/New(var/newloc,var/material_name) - ..(newloc, "phoron") +/obj/structure/simple_door/phoron/Initialize(mapload,var/material_name) + ..(mapload, material_name || "phoron") -/obj/structure/simple_door/diamond/New(var/newloc,var/material_name) - ..(newloc, "diamond") +/obj/structure/simple_door/diamond/Initialize(mapload,var/material_name) + ..(mapload, material_name || "diamond") -/obj/structure/simple_door/wood/New(var/newloc,var/material_name) - ..(newloc, MAT_WOOD) +/obj/structure/simple_door/wood/Initialize(mapload,var/material_name) + ..(mapload, material_name || MAT_WOOD) -/obj/structure/simple_door/sifwood/New(var/newloc,var/material_name) - ..(newloc, MAT_SIFWOOD) +/obj/structure/simple_door/sifwood/Initialize(mapload,var/material_name) + ..(mapload, material_name || MAT_SIFWOOD) -/obj/structure/simple_door/resin/New(var/newloc,var/material_name) - ..(newloc, "resin") +/obj/structure/simple_door/resin/Initialize(mapload,var/material_name) + ..(mapload, material_name || "resin") -/obj/structure/simple_door/cult/New(var/newloc,var/material_name) - ..(newloc, "cult") +/obj/structure/simple_door/cult/Initialize(mapload,var/material_name) + ..(mapload, material_name || "cult") /obj/structure/simple_door/cult/TryToSwitchState(atom/user) if(isliving(user)) diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index b0670868861..2ae7c7adfcc 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -424,7 +424,7 @@ return fulltile /obj/structure/window/is_between_turfs(var/turf/origin, var/turf/target) - if(fulltile) + if(is_fulltile()) return TRUE return ..() @@ -458,6 +458,8 @@ icon_state = "[basestate]" return + else + flags = 0 // Removes ON_BORDER and OPPOSITE_OPACITY var/list/dirs = list() if(anchored) for(var/obj/structure/window/W in orange(src,1)) @@ -503,6 +505,7 @@ icon_state = "window-full" maxhealth = 24 fulltile = TRUE + flags = 0 /obj/structure/window/phoronbasic name = "phoron window" @@ -520,6 +523,7 @@ icon_state = "phoronwindow-full" maxhealth = 80 fulltile = TRUE + flags = 0 /obj/structure/window/phoronreinforced name = "reinforced borosilicate window" @@ -538,6 +542,7 @@ icon_state = "phoronrwindow-full" maxhealth = 160 fulltile = TRUE + flags = 0 /obj/structure/window/reinforced name = "reinforced window" @@ -555,6 +560,7 @@ icon_state = "rwindow-full" maxhealth = 80 fulltile = TRUE + flags = 0 /obj/structure/window/reinforced/tinted name = "tinted window" @@ -592,6 +598,7 @@ icon_state = "rwindow-full" maxhealth = 80 fulltile = TRUE + flags = 0 /obj/structure/window/reinforced/polarized/attackby(obj/item/W as obj, mob/user as mob) if(istype(W, /obj/item/device/multitool) && !anchored) // Only allow programming if unanchored! @@ -617,8 +624,8 @@ else animate(src, color="#222222", time=5) set_opacity(1) - - + var/turf/T = get_turf(src) + T.recalculate_directional_opacity() /obj/machinery/button/windowtint name = "window tint control" diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 9cacb36eaf4..db8947b0563 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -41,7 +41,9 @@ //Lighting related luminosity = !(dynamic_lighting) - has_opaque_atom |= (opacity) + + if(opacity) + directional_opacity = ALL_CARDINALS //Pathfinding related if(movement_cost && pathweight == 1) // This updates pathweight automatically. diff --git a/code/game/turfs/turf_changing.dm b/code/game/turfs/turf_changing.dm index b3988f3f77a..efbea4ffb37 100644 --- a/code/game/turfs/turf_changing.dm +++ b/code/game/turfs/turf_changing.dm @@ -32,11 +32,13 @@ N = /turf/simulated/open var/obj/fire/old_fire = fire - var/old_opacity = opacity var/old_dynamic_lighting = dynamic_lighting - var/old_affecting_lights = affecting_lights - var/old_lighting_overlay = lighting_overlay - var/old_corners = corners + var/old_lighting_object = lighting_object + var/old_lighting_corner_NE = lighting_corner_NE + var/old_lighting_corner_SE = lighting_corner_SE + var/old_lighting_corner_SW = lighting_corner_SW + var/old_lighting_corner_NW = lighting_corner_NW + var/old_directional_opacity = directional_opacity var/old_outdoors = outdoors var/old_dangerous_objects = dangerous_objects @@ -94,21 +96,29 @@ W.post_change() . = W - recalc_atom_opacity() - dangerous_objects = old_dangerous_objects - if(lighting_overlays_initialised) - lighting_overlay = old_lighting_overlay - affecting_lights = old_affecting_lights - corners = old_corners - if((old_opacity != opacity) || (dynamic_lighting != old_dynamic_lighting)) - reconsider_lights() - if(dynamic_lighting != old_dynamic_lighting) - if(dynamic_lighting) + lighting_corner_NE = old_lighting_corner_NE + lighting_corner_SE = old_lighting_corner_SE + lighting_corner_SW = old_lighting_corner_SW + lighting_corner_NW = old_lighting_corner_NW + + if(SSlighting.subsystem_initialized) + lighting_object = old_lighting_object + + directional_opacity = old_directional_opacity + recalculate_directional_opacity() + + if (dynamic_lighting != old_dynamic_lighting) + if (IS_DYNAMIC_LIGHTING(src)) lighting_build_overlay() else lighting_clear_overlay() + else if(lighting_object && !lighting_object.needs_update) + lighting_object.update() + + for(var/turf/space/space_tile in RANGE_TURFS(1, src)) + space_tile.update_starlight() if(preserve_outdoors) outdoors = old_outdoors diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index a98e0898510..3d31c9e08fb 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -86,7 +86,8 @@ datum/preferences "2" = "character_preview_map:2,5", "4" = "character_preview_map:2,3", "8" = "character_preview_map:2,1", - "BG" = "character_preview_map:1,1 to 3,8" + "BG" = "character_preview_map:1,1 to 3,8", + "PMH" = "character_preview_map:2,7" ) //Jobs, uses bitflags @@ -270,6 +271,13 @@ datum/preferences if(!client) return + var/obj/screen/setup_preview/pm_helper/PMH = LAZYACCESS(char_render_holders, "PMH") + if(!PMH) + PMH = new + LAZYSET(char_render_holders, "PMH", PMH) + client.screen |= PMH + PMH.screen_loc = preview_screen_locs["PMH"] + var/obj/screen/setup_preview/bg/BG = LAZYACCESS(char_render_holders, "BG") if(!BG) BG = new diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 8c54e2ff551..c57c261322a 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -463,10 +463,10 @@ w_class = ITEMSIZE_SMALL blood_sprite_state = "helmetblood" + light_system = MOVABLE_LIGHT_DIRECTIONAL + light_cone_y_offset = 11 + var/light_overlay = "helmet_light" - var/light_applied - var/brightness_on - var/on = 0 var/image/helmet_light sprite_sheets = list( @@ -477,23 +477,21 @@ pickup_sound = 'sound/items/pickup/hat.ogg' /obj/item/clothing/head/attack_self(mob/user) - if(brightness_on) + if(light_range) if(!isturf(user.loc)) - to_chat(user, "You cannot turn the light on while in this [user.loc]") + to_chat(user, "You cannot toggle the light while in this [user.loc]") return - on = !on - to_chat(user, "You [on ? "enable" : "disable"] the helmet light.") update_flashlight(user) + to_chat(user, "You [light_on ? "enable" : "disable"] the helmet light.") else return ..(user) /obj/item/clothing/head/proc/update_flashlight(var/mob/user = null) - if(on && !light_applied) - set_light(brightness_on) - light_applied = 1 - else if(!on && light_applied) - set_light(0) - light_applied = 0 + set_light_on(!light_on) + + if(light_system == STATIC_LIGHT) + update_light() + update_icon(user) user.update_action_buttons() @@ -537,7 +535,7 @@ if(ishuman(user)) H = user - if(on) + if(light_on) // Generate object icon. if(!light_overlay_cache["[light_overlay]_icon"]) light_overlay_cache["[light_overlay]_icon"] = image(icon = 'icons/obj/light_overlays.dmi', icon_state = "[light_overlay]") diff --git a/code/modules/clothing/clothing_icons.dm b/code/modules/clothing/clothing_icons.dm index 2adfbfa0b98..1762d092017 100644 --- a/code/modules/clothing/clothing_icons.dm +++ b/code/modules/clothing/clothing_icons.dm @@ -19,7 +19,7 @@ //HELMET: May have a lighting overlay /obj/item/clothing/head/make_worn_icon(var/body_type,var/slot_name,var/inhands,var/default_icon,var/default_layer = 0,var/icon/clip_mask = null) var/image/standing = ..() - if(on && slot_name == slot_head_str) + if(light_on && slot_name == slot_head_str) var/cache_key = "[light_overlay][LAZYACCESS(sprite_sheets,body_type) ? "_[body_type]" : ""]" if(standing && light_overlay_cache[cache_key]) standing.add_overlay(light_overlay_cache[cache_key]) diff --git a/code/modules/clothing/head/hardhat.dm b/code/modules/clothing/head/hardhat.dm index f974c321c06..47a5b89f1aa 100644 --- a/code/modules/clothing/head/hardhat.dm +++ b/code/modules/clothing/head/hardhat.dm @@ -2,7 +2,8 @@ name = "hard hat" desc = "A piece of headgear used in dangerous working conditions to protect the head. Comes with a built-in flashlight." icon_state = "hardhat0_yellow" - brightness_on = 4 //luminosity when on + light_range = 4 //luminosity when on + light_cone_y_offset = 14 light_overlay = "hardhat_light" armor = list(melee = 30, bullet = 5, laser = 20,energy = 10, bomb = 20, bio = 10, rad = 20) flags_inv = 0 diff --git a/code/modules/clothing/head/helmet.dm b/code/modules/clothing/head/helmet.dm index 8cf8a6292e7..cf0527c6a6c 100644 --- a/code/modules/clothing/head/helmet.dm +++ b/code/modules/clothing/head/helmet.dm @@ -111,7 +111,7 @@ icon_state = "flexitac" armor = list(melee = 40, bullet = 40, laser = 60, energy = 35, bomb = 30, bio = 0, rad = 0) siemens_coefficient = 0.6 - brightness_on = 6 + light_range = 6 light_overlay = "helmet_light_dual_green" action_button_name = "Toggle Head-light" min_cold_protection_temperature = T0C - 20 diff --git a/code/modules/clothing/head/misc_special.dm b/code/modules/clothing/head/misc_special.dm index 6ef9ee2be6b..dbb5f6d9398 100644 --- a/code/modules/clothing/head/misc_special.dm +++ b/code/modules/clothing/head/misc_special.dm @@ -167,7 +167,7 @@ icon_state = "hardhat0_pumpkin"//Could stand to be renamed flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|BLOCKHAIR body_parts_covered = HEAD|FACE|EYES - brightness_on = 2 + light_range = 2 light_overlay = "jackolantern" w_class = ITEMSIZE_NORMAL drop_sound = 'sound/items/drop/herb.ogg' diff --git a/code/modules/clothing/spacesuits/rig/rig_pieces.dm b/code/modules/clothing/spacesuits/rig/rig_pieces.dm index cc76771d459..3c1843698c0 100644 --- a/code/modules/clothing/spacesuits/rig/rig_pieces.dm +++ b/code/modules/clothing/spacesuits/rig/rig_pieces.dm @@ -9,7 +9,7 @@ body_parts_covered = HEAD|FACE|EYES heat_protection = HEAD|FACE|EYES cold_protection = HEAD|FACE|EYES - brightness_on = 4 + light_range = 4 sprite_sheets = list( SPECIES_TAJ = 'icons/mob/species/tajaran/helmet.dmi', SPECIES_SKRELL = 'icons/mob/species/skrell/helmet.dmi', diff --git a/code/modules/clothing/spacesuits/spacesuits.dm b/code/modules/clothing/spacesuits/spacesuits.dm index 162b097aa71..4cd8ade06e2 100644 --- a/code/modules/clothing/spacesuits/spacesuits.dm +++ b/code/modules/clothing/spacesuits/spacesuits.dm @@ -29,8 +29,7 @@ action_button_name = "Toggle Helmet Light" light_overlay = "helmet_light" - brightness_on = 4 - on = 0 + light_range = 4 /obj/item/clothing/head/helmet/space/Initialize() . = ..() diff --git a/code/modules/clothing/spacesuits/void/void.dm b/code/modules/clothing/spacesuits/void/void.dm index 3a92bd2be10..926365c5c1b 100644 --- a/code/modules/clothing/spacesuits/void/void.dm +++ b/code/modules/clothing/spacesuits/void/void.dm @@ -120,7 +120,6 @@ to_chat(M, "Your suit's cooling unit deploys.") cooler.canremove = 0 - /obj/item/clothing/suit/space/void/dropped() ..() @@ -150,6 +149,22 @@ cooler.canremove = 1 cooler.forceMove(src) +/obj/item/clothing/suit/space/void/proc/attach_helmet(var/obj/item/clothing/head/helmet/space/void/helm) + if(!istype(helm) || helmet) + return + + helm.forceMove(src) + helm.set_light_flags(helm.light_flags | LIGHT_ATTACHED) + helmet = helm + +/obj/item/clothing/suit/space/void/proc/remove_helmet() + if(!helmet) + return + + helmet.forceMove(get_turf(src)) + helmet.set_light_flags(helmet.light_flags & ~LIGHT_ATTACHED) + helmet = null + /obj/item/clothing/suit/space/void/verb/toggle_helmet() set name = "Toggle Helmet" @@ -243,9 +258,8 @@ src.cooler = null else if(choice == helmet) to_chat(user, "You detach \the [helmet] from \the [src]'s helmet mount.") - helmet.forceMove(get_turf(src)) + remove_helmet() playsound(src, W.usesound, 50, 1) - src.helmet = null else if(choice == boots) to_chat(user, "You detach \the [boots] from \the [src]'s boot mounts.") boots.forceMove(get_turf(src)) @@ -260,8 +274,7 @@ else to_chat(user, "You attach \the [W] to \the [src]'s helmet mount.") user.drop_item() - W.forceMove(src) - src.helmet = W + attach_helmet(W) return else if(istype(W,/obj/item/clothing/shoes/magboots)) if(boots) diff --git a/code/modules/lighting/emissive_blocker.dm b/code/modules/lighting/emissive_blocker.dm new file mode 100644 index 00000000000..690b9b52163 --- /dev/null +++ b/code/modules/lighting/emissive_blocker.dm @@ -0,0 +1,46 @@ +/** + * Internal atom that copies an appearance on to the blocker plane + * + * Copies an appearance vis render_target and render_source on to the emissive blocking plane. + * This means that the atom in question will block any emissive sprites. + * This should only be used internally. If you are directly creating more of these, you're + * almost guaranteed to be doing something wrong. + */ +/atom/movable/emissive_blocker + name = "emissive blocker" + plane = PLANE_EMISSIVE + layer = FLOAT_LAYER + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + //Why? + //render_targets copy the transform of the target as well, but vis_contents also applies the transform + //to what's in it. Applying RESET_TRANSFORM here makes vis_contents not apply the transform. + //Since only render_target handles transform we don't get any applied transform "stacking" + appearance_flags = RESET_TRANSFORM + +/atom/movable/emissive_blocker/Initialize(mapload, source) + . = ..() + verbs.Cut() //Cargo culting from lighting object, this maybe affects memory usage? + + render_source = source + color = GLOB.em_block_color + + +/atom/movable/emissive_blocker/ex_act(severity) + return FALSE + +/atom/movable/emissive_blocker/singularity_act() + return + +/atom/movable/emissive_blocker/singularity_pull() + return + +/atom/movable/emissive_blocker/blob_act() + return + +/atom/movable/emissive_blocker/onTransitZ() + return + +//Prevents people from moving these after creation, because they shouldn't be. +/atom/movable/emissive_blocker/forceMove(atom/destination, no_tp=FALSE, harderforce = FALSE) + if(harderforce) + return ..() diff --git a/code/modules/lighting/lighting_atom.dm b/code/modules/lighting/lighting_atom.dm index 39894b13947..0d91198f440 100644 --- a/code/modules/lighting/lighting_atom.dm +++ b/code/modules/lighting/lighting_atom.dm @@ -1,110 +1,218 @@ /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 + ///Light systems, both shouldn't be active at the same time. + var/light_system = STATIC_LIGHT + ///Range of the light in tiles. Zero means no light. + var/light_range = 0 + ///Intensity of the light. The stronger, the less shadows you will see on the lit area. + var/light_power = 1 + ///Hexadecimal RGB string representing the colour of the light. White by default. + var/light_color = COLOR_WHITE + ///Boolean variable for toggleable lights. Has no effect without the proper light_system, light_range and light_power values. + var/light_on = FALSE + ///Bitflags to determine lighting-related atom properties. + var/light_flags = NONE + ///Our light source. Don't fuck with this directly unless you have a good reason! + var/tmp/datum/light_source/light + ///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. + var/tmp/list/light_sources - var/datum/light_source/light - var/list/light_sources +/atom/movable + ///Hint for directional light cone positioning. X is relevant when facing north/south (this setting is for south and inverted for north) + var/light_cone_x_offset // When facing south, inverted when facing north + ///Hint for directional light cone positioning. Y is relevant when facing east/west (same value used for both east and west) + var/light_cone_y_offset // When facing east/west, ignored for north/south (uses 16 in those cases) + ///Highest-intensity light affecting us, which determines our visibility. + var/affecting_dynamic_lumi = 0 + ///Lazylist to keep track on the sources of illumination. + var/list/affected_dynamic_lights + ///Either FALSE, [EMISSIVE_BLOCK_GENERIC], or [EMISSIVE_BLOCK_UNIQUE] + var/blocks_emissive = FALSE + ///Internal holder for emissive blocker object, do not use directly use blocks_emissive + var/atom/movable/emissive_blocker/em_block -// Nonsensical value for l_color default, so we can detect if it gets set to null. +// 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(l_range, l_power, l_color = NONSENSICAL_VALUE) - . = 0 //make it less costly if nothing's changed +/atom/proc/set_light(l_range, l_power, l_color = NONSENSICAL_VALUE, l_on) + 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(SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT, l_range, l_power, l_color, l_on) & COMPONENT_BLOCK_LIGHT_UPDATE) + return + + // Legacy behavior helper + if(l_range == 0) + l_on = FALSE + else if(l_range > 0) + l_on = TRUE + + var/needs_update = FALSE + if(!isnull(l_power) && l_power != light_power) + if(!isnull(set_light_power(l_power))) + needs_update = TRUE + + if(!isnull(l_range) && l_range != light_range) + if(!isnull(set_light_range(l_range))) + needs_update = TRUE - if(l_power != null && l_power != light_power) - light_power = l_power - . = 1 - if(l_range != null && l_range != light_range) - light_range = l_range - . = 1 if(l_color != NONSENSICAL_VALUE && l_color != light_color) - light_color = l_color - . = 1 + if(!isnull(set_light_color(l_color))) + needs_update = TRUE - if(.) update_light() + if(!isnull(l_on) && l_on != light_on) + if(!isnull(set_light_on(l_on))) + needs_update = TRUE + + if(needs_update) + 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) - if(light) - light.destroy() - light = null + if(light_system != STATIC_LIGHT) + CRASH("update_light() for [src] with following light_system value: [light_system]") + + if (!light_power || !light_range || !light_on) // We won't emit light anyways, destroy the light source. + QDEL_NULL(light) else - if(!istype(loc, /atom/movable)) + if (!ismovable(loc)) // We choose what atom should be the top atom of the light here. . = src else . = loc - if(light) + if (light) // Update the light or create it if it does not exist. light.update(.) else - light = new /datum/light_source(src, .) + light = new/datum/light_source(src, .) -/atom/New() - . = ..() - - if(light_power && light_range) - update_light() - - if(opacity && isturf(loc)) - var/turf/T = loc - T.has_opaque_atom = TRUE // No need to recalculate it in this case, it's guranteed to be on afterwards anyways. - -/atom/Destroy() - if(light) - light.destroy() - light = null - return ..() - -/atom/movable/Destroy() - var/turf/T = loc - if(opacity && istype(T)) - T.reconsider_lights() - return ..() - -/atom/movable/Moved(atom/old_loc, direction, forced = FALSE) - . = ..() - - for(var/datum/light_source/L in light_sources) - L.source_atom.update_light() - - var/turf/new_turf = loc - var/turf/old_turf = old_loc - if(istype(old_turf) && opacity) - old_turf.reconsider_lights() - - if(istype(new_turf) && opacity) - new_turf.reconsider_lights() +/** + * Updates the atom's opacity value. + * + * This exists to act as a hook for associated behavior. + * It notifies (potentially) affected light sources so they can update (if needed). + */ /atom/proc/set_opacity(new_opacity) if(new_opacity == opacity) return - + SEND_SIGNAL(src, COMSIG_ATOM_SET_OPACITY, new_opacity) + . = opacity opacity = new_opacity - var/turf/T = isturf(src) ? src : loc - if(!isturf(T)) + + +/atom/movable/set_opacity(new_opacity) + . = ..() + if(isnull(.) || !isturf(loc)) return - if(new_opacity == TRUE) - T.has_opaque_atom = TRUE - T.reconsider_lights() + if(opacity) + AddElement(/datum/element/light_blocking) 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() + RemoveElement(/datum/element/light_blocking) -/obj/item/equipped() - . = ..() - update_light() -/obj/item/pickup() +/turf/set_opacity(new_opacity) . = ..() - update_light() + if(isnull(.)) + return + recalculate_directional_opacity() -/obj/item/dropped() - . = ..() - update_light() +/atom/proc/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION) + return + + +/turf/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION) + if(!_duration) + stack_trace("Lighting FX obj created on a turf without a duration") + new /obj/effect/dummy/lighting_obj (src, _range, _power, _color, _duration) + + +/obj/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION) + if(!_duration) + stack_trace("Lighting FX obj created on a obj without a duration") + new /obj/effect/dummy/lighting_obj (get_turf(src), _range, _power, _color, _duration) + + +/mob/living/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION) + mob_light(_range, _power, _color, _duration) + + +/mob/living/proc/mob_light(_range, _power, _color, _duration) + var/obj/effect/dummy/lighting_obj/moblight/mob_light_obj = new (src, _range, _power, _color, _duration) + return mob_light_obj + +/// Setter for the light power of this atom. +/atom/proc/set_light_power(new_power) + if(new_power == light_power) + return + if(SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT_POWER, new_power) & COMPONENT_BLOCK_LIGHT_UPDATE) + return + . = light_power + light_power = new_power + SEND_SIGNAL(src, COMSIG_ATOM_UPDATE_LIGHT_POWER, .) + +/// Setter for the light range of this atom. +/atom/proc/set_light_range(new_range) + if(new_range == light_range) + return + if(SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT_RANGE, new_range) & COMPONENT_BLOCK_LIGHT_UPDATE) + return + . = light_range + light_range = new_range + SEND_SIGNAL(src, COMSIG_ATOM_UPDATE_LIGHT_RANGE, .) + +/// Setter for the light color of this atom. +/atom/proc/set_light_color(new_color) + if(new_color == light_color) + return + if(SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT_COLOR, new_color) & COMPONENT_BLOCK_LIGHT_UPDATE) + return + . = light_color + light_color = new_color + SEND_SIGNAL(src, COMSIG_ATOM_UPDATE_LIGHT_COLOR, .) + +/// Setter for whether or not this atom's light is on. +/atom/proc/set_light_on(new_value) + if(new_value == light_on) + return + if(SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT_ON, new_value) & COMPONENT_BLOCK_LIGHT_UPDATE) + return + . = light_on + light_on = new_value + SEND_SIGNAL(src, COMSIG_ATOM_UPDATE_LIGHT_ON, .) + +/// Setter for the light flags of this atom. +/atom/proc/set_light_flags(new_value) + if(new_value == light_flags) + return + if(SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT_FLAGS, new_value) & COMPONENT_BLOCK_LIGHT_UPDATE) + return + . = light_flags + light_flags = new_value + SEND_SIGNAL(src, COMSIG_ATOM_UPDATE_LIGHT_FLAGS, .) + +///Keeps track of the sources of dynamic luminosity and updates our visibility with the highest. +/atom/movable/proc/update_dynamic_luminosity() + var/highest = 0 + for(var/i in affected_dynamic_lights) + if(affected_dynamic_lights[i] <= highest) + continue + highest = affected_dynamic_lights[i] + if(highest == affecting_dynamic_lumi) + return + luminosity -= affecting_dynamic_lumi + affecting_dynamic_lumi = highest + luminosity += affecting_dynamic_lumi + + +///Helper to change several lighting overlay settings. +/atom/movable/proc/set_light_range_power_color(range, power, color) + set_light_range(range) + set_light_power(power) + set_light_color(color) diff --git a/code/modules/lighting/lighting_corner.dm b/code/modules/lighting/lighting_corner.dm index 30230a69e04..e02e04b0f7c 100644 --- a/code/modules/lighting/lighting_corner.dm +++ b/code/modules/lighting/lighting_corner.dm @@ -1,41 +1,37 @@ -/var/total_lighting_corners = 0 -/var/datum/lighting_corner/dummy/dummy_lighting_corner = new -// Because we can control each corner of every lighting overlay. +// Because we can control each corner of every lighting object. // And corners get shared between multiple turfs (unless you're on the corners of the map, then 1 corner doesn't). // For the record: these should never ever ever be deleted, even if the turf doesn't have dynamic lighting. -// This list is what the code that assigns corners listens to, the order in this list is the order in which corners are added to the /turf/corners list. -/var/list/LIGHTING_CORNER_DIAGONAL = list(NORTHEAST, SOUTHEAST, SOUTHWEST, NORTHWEST) - /datum/lighting_corner - var/list/turf/masters = list() - var/list/datum/light_source/affecting = list() // Light sources affecting us. - var/active = FALSE // TRUE if one of our masters has dynamic lighting. + var/list/datum/light_source/affecting // Light sources affecting us. - var/x = 0 - var/y = 0 - var/z = 0 + var/x = 0 + var/y = 0 + var/turf/master_NE + var/turf/master_SE + var/turf/master_SW + var/turf/master_NW + + //"raw" color values, changed by update_lumcount() var/lum_r = 0 var/lum_g = 0 var/lum_b = 0 + //true color values, guaranteed to be between 0 and 1 + var/cache_r = LIGHTING_SOFT_THRESHOLD + var/cache_g = LIGHTING_SOFT_THRESHOLD + var/cache_b = LIGHTING_SOFT_THRESHOLD + + ///the maximum of lum_r, lum_g, and lum_b. if this is > 1 then the three cached color values are divided by this + var/largest_color_luminosity = 0 + + ///whether we are to be added to SSlighting's corners_queue list for an update var/needs_update = FALSE - var/cache_r = LIGHTING_SOFT_THRESHOLD - var/cache_g = LIGHTING_SOFT_THRESHOLD - var/cache_b = LIGHTING_SOFT_THRESHOLD - var/cache_mx = 0 - - var/update_gen = 0 - -/datum/lighting_corner/New(var/turf/new_turf, var/diagonal) +/datum/lighting_corner/New(turf/new_turf, diagonal) . = ..() - - total_lighting_corners++ - - masters[new_turf] = turn(diagonal, 180) - z = new_turf.z + save_master(new_turf, turn(diagonal, 180)) var/vertical = diagonal & ~(diagonal - 1) // The horizontal directions (4 and 8) are bigger than the vertical ones (1 and 2), so we can reliably say the lsb is the horizontal direction. var/horizontal = diagonal & ~vertical // Now that we know the horizontal one we can get the vertical one. @@ -46,69 +42,75 @@ // My initial plan was to make this loop through a list of all the dirs (horizontal, vertical, diagonal). // Issue being that the only way I could think of doing it was very messy, slow and honestly overengineered. // So we'll have this hardcode instead. - var/turf/T - var/i + var/turf/new_master_turf // Diagonal one is easy. - T = get_step(new_turf, diagonal) - if (T) // In case we're on the map's border. - if (!T.corners) - T.corners = list(null, null, null, null) - - masters[T] = diagonal - i = LIGHTING_CORNER_DIAGONAL.Find(turn(diagonal, 180)) - T.corners[i] = src + new_master_turf = get_step(new_turf, diagonal) + if (new_master_turf) // In case we're on the map's border. + save_master(new_master_turf, diagonal) // Now the horizontal one. - T = get_step(new_turf, horizontal) - if (T) // Ditto. - if (!T.corners) - T.corners = list(null, null, null, null) - - masters[T] = ((T.x > x) ? EAST : WEST) | ((T.y > y) ? NORTH : SOUTH) // Get the dir based on coordinates. - i = LIGHTING_CORNER_DIAGONAL.Find(turn(masters[T], 180)) - T.corners[i] = src + new_master_turf = get_step(new_turf, horizontal) + if (new_master_turf) // Ditto. + save_master(new_master_turf, ((new_master_turf.x > x) ? EAST : WEST) | ((new_master_turf.y > y) ? NORTH : SOUTH)) // Get the dir based on coordinates. // And finally the vertical one. - T = get_step(new_turf, vertical) - if (T) - if (!T.corners) - T.corners = list(null, null, null, null) + new_master_turf = get_step(new_turf, vertical) + if (new_master_turf) + save_master(new_master_turf, ((new_master_turf.x > x) ? EAST : WEST) | ((new_master_turf.y > y) ? NORTH : SOUTH)) // Get the dir based on coordinates. - masters[T] = ((T.x > x) ? EAST : WEST) | ((T.y > y) ? NORTH : SOUTH) // Get the dir based on coordinates. - i = LIGHTING_CORNER_DIAGONAL.Find(turn(masters[T], 180)) - T.corners[i] = src +/datum/lighting_corner/proc/save_master(turf/master, dir) + switch (dir) + if (NORTHEAST) + master_NE = master + master.lighting_corner_SW = src + if (SOUTHEAST) + master_SE = master + master.lighting_corner_NW = src + if (SOUTHWEST) + master_SW = master + master.lighting_corner_NE = src + if (NORTHWEST) + master_NW = master + master.lighting_corner_SE = src - update_active() +/datum/lighting_corner/proc/self_destruct_if_idle() + if (!LAZYLEN(affecting)) + qdel(src, force = TRUE) -/datum/lighting_corner/proc/update_active() - active = FALSE - for (var/turf/T in masters) - if (T.lighting_overlay) - active = TRUE +/datum/lighting_corner/proc/vis_update() + for (var/datum/light_source/light_source as anything in affecting) + light_source.vis_update() + +/datum/lighting_corner/proc/full_update() + for (var/datum/light_source/light_source as anything in affecting) + light_source.recalc_corner(src) // God that was a mess, now to do the rest of the corner code! Hooray! -/datum/lighting_corner/proc/update_lumcount(var/delta_r, var/delta_g, var/delta_b) +/datum/lighting_corner/proc/update_lumcount(delta_r, delta_g, delta_b) + if (!(delta_r || delta_g || delta_b)) // 0 is falsey ok + return + lum_r += delta_r lum_g += delta_g lum_b += delta_b if (!needs_update) needs_update = TRUE - lighting_update_corners += src + SSlighting.corners_queue += src -/datum/lighting_corner/proc/update_overlays() - // Cache these values a head of time so 4 individual lighting overlays don't all calculate them individually. - var/lum_r = src.lum_r > 0 ? LIGHTING_MULT_FACTOR * sqrt(src.lum_r) : src.lum_r - var/lum_g = src.lum_g > 0 ? LIGHTING_MULT_FACTOR * sqrt(src.lum_g) : src.lum_g - var/lum_b = src.lum_b > 0 ? LIGHTING_MULT_FACTOR * sqrt(src.lum_b) : src.lum_b - var/mx = max(lum_r, lum_g, lum_b) // Scale it so 1 is the strongest lum, if it is above 1. +/datum/lighting_corner/proc/update_objects() + // Cache these values ahead of time so 4 individual lighting objects don't all calculate them individually. + var/lum_r = src.lum_r + var/lum_g = src.lum_g + var/lum_b = src.lum_b + var/largest_color_luminosity = max(lum_r, lum_g, lum_b) // Scale it so one of them is the strongest lum, if it is above 1. . = 1 // factor - if (mx > 1) - . = 1 / mx + if (largest_color_luminosity > 1) + . = 1 / largest_color_luminosity #if LIGHTING_SOFT_THRESHOLD != 0 - else if (mx < LIGHTING_SOFT_THRESHOLD) + else if (largest_color_luminosity < LIGHTING_SOFT_THRESHOLD) . = 0 // 0 means soft lighting. cache_r = round(lum_r * ., LIGHTING_ROUND_VALUE) || LIGHTING_SOFT_THRESHOLD @@ -119,21 +121,56 @@ cache_g = round(lum_g * ., LIGHTING_ROUND_VALUE) cache_b = round(lum_b * ., LIGHTING_ROUND_VALUE) #endif - cache_mx = round(mx, LIGHTING_ROUND_VALUE) - for (var/TT in masters) - var/turf/T = TT - if (T.lighting_overlay) - if (!T.lighting_overlay.needs_update) - T.lighting_overlay.needs_update = TRUE - lighting_update_overlays += T.lighting_overlay + src.largest_color_luminosity = round(largest_color_luminosity, LIGHTING_ROUND_VALUE) + + var/datum/lighting_object/lighting_object = master_NE?.lighting_object + if (lighting_object && !lighting_object.needs_update) + lighting_object.needs_update = TRUE + SSlighting.objects_queue += lighting_object + + lighting_object = master_SE?.lighting_object + if (lighting_object && !lighting_object.needs_update) + lighting_object.needs_update = TRUE + SSlighting.objects_queue += lighting_object + + lighting_object = master_SW?.lighting_object + if (lighting_object && !lighting_object.needs_update) + lighting_object.needs_update = TRUE + SSlighting.objects_queue += lighting_object + + lighting_object = master_NW?.lighting_object + if (lighting_object && !lighting_object.needs_update) + lighting_object.needs_update = TRUE + SSlighting.objects_queue += lighting_object + + self_destruct_if_idle() /datum/lighting_corner/dummy/New() return -/datum/lighting_corner/Destroy(var/force) +/datum/lighting_corner/Destroy(force) if (!force) return QDEL_HINT_LETMELIVE - crash_with("Who decided to force qdel() a lighting corner? Why did you do this?") + + for (var/datum/light_source/light_source as anything in affecting) + LAZYREMOVE(light_source.effect_str, src) + affecting = null + + if (master_NE) + master_NE.lighting_corner_SW = null + master_NE.lighting_corners_initialised = FALSE + if (master_SE) + master_SE.lighting_corner_NW = null + master_SE.lighting_corners_initialised = FALSE + if (master_SW) + master_SW.lighting_corner_NE = null + master_SW.lighting_corners_initialised = FALSE + if (master_NW) + master_NW.lighting_corner_SE = null + master_NW.lighting_corners_initialised = FALSE + if(needs_update) + SSlighting.corners_queue -= src + return ..() diff --git a/code/modules/lighting/lighting_fake_sun_vr.dm b/code/modules/lighting/lighting_fake_sun_vr.dm index 898532d8c22..9eb76e7f52b 100644 --- a/code/modules/lighting/lighting_fake_sun_vr.dm +++ b/code/modules/lighting/lighting_fake_sun_vr.dm @@ -3,6 +3,7 @@ desc = "Deletes itself, but first updates all the lighting on outdoor turfs." icon = 'icons/effects/effects_vr.dmi' icon_state = "fakesun" + var/datum/light_source/sun/fake_sun var/list/possible_light_setups = list( list( @@ -66,28 +67,31 @@ /obj/effect/fake_sun/LateInitialize() . = ..() + var/list/choice = pick(possible_light_setups) + if(choice["brightness"] <= LIGHTING_SOFT_THRESHOLD) // dark! + return - var/list/our_choice = pick(possible_light_setups) + fake_sun = new + fake_sun.light_color = choice["color"] + fake_sun.light_power = choice["brightness"] + + var/list/zees = GetConnectedZlevels() + var/min = z + var/max = z + for(var/zee in zees) + if(zee < min) + min = z + if(zee > max) + max = z + + var/list/all_turfs = block(locate(1, 1, min), locate(world.maxx, world.maxy, max)) + var/list/turfs_to_use = list() + for(var/turf/T as anything in all_turfs) + if(T.outdoors) + turfs_to_use += T - // Calculate new values to apply - var/new_brightness = our_choice["brightness"] - var/new_color = our_choice["color"] - var/lum_r = new_brightness * GetRedPart (new_color) / 255 - var/lum_g = new_brightness * GetGreenPart(new_color) / 255 - var/lum_b = new_brightness * GetBluePart (new_color) / 255 - var/static/update_gen = -1 // Used to prevent double-processing corners. Otherwise would happen when looping over adjacent turfs. - - var/list/turfs = block(locate(1,1,z),locate(world.maxx,world.maxy,z)) - - for(var/turf/simulated/T as anything in turfs) - if(!T.lighting_overlay) - T.lighting_build_overlay() - if(!T.outdoors) - continue - for(var/C in T.get_corners()) - var/datum/lighting_corner/LC = C - if(LC.update_gen != update_gen && LC.active) - LC.update_gen = update_gen - LC.update_lumcount(lum_r, lum_g, lum_b) - update_gen-- - qdel(src) \ No newline at end of file + if(!turfs_to_use.len) + warning("Fake sun placed on a level where it can't find any outdoor turfs to color at [x],[y],[z].") + return + + fake_sun.update_corners(turfs_to_use) diff --git a/code/modules/lighting/lighting_overlay.dm b/code/modules/lighting/lighting_overlay.dm index eb5097cf5b2..abf3c39ba6a 100644 --- a/code/modules/lighting/lighting_overlay.dm +++ b/code/modules/lighting/lighting_overlay.dm @@ -1,51 +1,51 @@ -/var/total_lighting_overlays = 0 -/atom/movable/lighting_overlay - name = "" - mouse_opacity = 0 - simulated = 0 - anchored = 1 - icon = LIGHTING_ICON - plane = PLANE_LIGHTING - //invisibility = INVISIBILITY_LIGHTING - color = LIGHTING_BASE_MATRIX - icon_state = "light1" - //auto_init = 0 // doesn't need special init - blend_mode = BLEND_OVERLAY - - var/lum_r = 0 - var/lum_g = 0 - var/lum_b = 0 +/datum/lighting_object + ///the underlay we are currently applying to our turf to apply light + var/mutable_appearance/current_underlay + ///whether we are already in the SSlighting.objects_queue list var/needs_update = FALSE -/atom/movable/lighting_overlay/Initialize() - // doesn't need special init - initialized = TRUE - return INITIALIZE_HINT_NORMAL + ///the turf that our light is applied to + var/turf/affected_turf -/atom/movable/lighting_overlay/New(var/atom/loc, var/no_update = FALSE) - . = ..() - verbs.Cut() - total_lighting_overlays++ - - var/turf/T = loc //If this runtimes atleast we'll know what's creating overlays outside of turfs. - T.lighting_overlay = src - T.luminosity = 0 - if(no_update) +/datum/lighting_object/New(turf/source) + if(!SSlighting.subsystem_initialized) + stack_trace("lighting_object created before SSlighting up!") return - update_overlay() - -/atom/movable/lighting_overlay/proc/update_overlay() - set waitfor = FALSE - var/turf/T = loc - - if(!istype(T)) - if(loc) - log_debug("A lighting overlay realised its loc was NOT a turf (actual loc: [loc][loc ? ", " + loc.type : "null"]) in update_overlay() and got qdel'ed!") - else - log_debug("A lighting overlay realised it was in nullspace in update_overlay() and got pooled!") + if(!isturf(source)) qdel(src, force=TRUE) + stack_trace("a lighting object was assigned to [source], a non turf! ") return + . = ..() + + current_underlay = mutable_appearance(LIGHTING_ICON, "transparent", source.z, PLANE_LIGHTING, 255, RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM) + + affected_turf = source + if (affected_turf.lighting_object) + qdel(affected_turf.lighting_object, force = TRUE) + stack_trace("a lighting object was assigned to a turf that already had a lighting object!") + + affected_turf.lighting_object = src + affected_turf.luminosity = 0 + + for(var/turf/space/space_tile in RANGE_TURFS(1, affected_turf)) + space_tile.update_starlight() + + needs_update = TRUE + SSlighting.objects_queue += src + +/datum/lighting_object/Destroy(force) + if (!force) + return QDEL_HINT_LETMELIVE + SSlighting.objects_queue -= src + if (isturf(affected_turf)) + affected_turf.lighting_object = null + affected_turf.luminosity = 1 + affected_turf.underlays -= current_underlay + affected_turf = null + return ..() + +/datum/lighting_object/proc/update() // To the future coder who sees this and thinks // "Why didn't he just use a loop?" @@ -55,50 +55,54 @@ // Oh it's also shorter line wise. // Including with these comments. - // See LIGHTING_CORNER_DIAGONAL in lighting_corner.dm for why these values are what they are. - // No I seriously cannot think of a more efficient method, fuck off Comic. + var/static/datum/lighting_corner/dummy/dummy_lighting_corner = new - var/datum/lighting_corner/cr = LAZYACCESS(T.corners,3) || dummy_lighting_corner - var/datum/lighting_corner/cg = LAZYACCESS(T.corners,2) || dummy_lighting_corner - var/datum/lighting_corner/cb = LAZYACCESS(T.corners,4) || dummy_lighting_corner - var/datum/lighting_corner/ca = LAZYACCESS(T.corners,1) || dummy_lighting_corner + var/datum/lighting_corner/red_corner = affected_turf.lighting_corner_SW || dummy_lighting_corner + var/datum/lighting_corner/green_corner = affected_turf.lighting_corner_SE || dummy_lighting_corner + var/datum/lighting_corner/blue_corner = affected_turf.lighting_corner_NW || dummy_lighting_corner + var/datum/lighting_corner/alpha_corner = affected_turf.lighting_corner_NE || dummy_lighting_corner - var/max = max(cr.cache_mx, cg.cache_mx, cb.cache_mx, ca.cache_mx) + var/max = max(red_corner.largest_color_luminosity, green_corner.largest_color_luminosity, blue_corner.largest_color_luminosity, alpha_corner.largest_color_luminosity) - var/rr = cr.cache_r - var/rg = cr.cache_g - var/rb = cr.cache_b + var/rr = red_corner.cache_r + var/rg = red_corner.cache_g + var/rb = red_corner.cache_b - var/gr = cg.cache_r - var/gg = cg.cache_g - var/gb = cg.cache_b + var/gr = green_corner.cache_r + var/gg = green_corner.cache_g + var/gb = green_corner.cache_b - var/br = cb.cache_r - var/bg = cb.cache_g - var/bb = cb.cache_b + var/br = blue_corner.cache_r + var/bg = blue_corner.cache_g + var/bb = blue_corner.cache_b - var/ar = ca.cache_r - var/ag = ca.cache_g - var/ab = ca.cache_b + var/ar = alpha_corner.cache_r + var/ag = alpha_corner.cache_g + var/ab = alpha_corner.cache_b #if LIGHTING_SOFT_THRESHOLD != 0 var/set_luminosity = max > LIGHTING_SOFT_THRESHOLD #else - // Because of floating points, it won't even be a flat 0. + // Because of floating pointsâ„¢?, it won't even be a flat 0. // This number is mostly arbitrary. var/set_luminosity = max > 1e-6 #endif if((rr & gr & br & ar) && (rg + gg + bg + ag + rb + gb + bb + ab == 8)) - //anything that passes the first case is very likely to pass the second, and addition is a little faster in this case - icon_state = "transparent" - color = null + //anything that passes the first case is very likely to pass the second, and addition is a little faster in this case + affected_turf.underlays -= current_underlay + current_underlay.icon_state = "transparent" + current_underlay.color = null + affected_turf.underlays += current_underlay else if(!set_luminosity) - icon_state = LIGHTING_ICON_STATE_DARK - color = null + affected_turf.underlays -= current_underlay + current_underlay.icon_state = "dark" + current_underlay.color = null + affected_turf.underlays += current_underlay else - icon_state = null - color = list( + affected_turf.underlays -= current_underlay + current_underlay.icon_state = "gradient" + current_underlay.color = list( rr, rg, rb, 00, gr, gg, gb, 00, br, bg, bb, 00, @@ -106,38 +110,12 @@ 00, 00, 00, 01 ) - luminosity = set_luminosity + affected_turf.underlays += current_underlay -// Variety of overrides so the overlays don't get affected by weird things. -/atom/movable/lighting_overlay/ex_act() - return + affected_turf.luminosity = set_luminosity -/atom/movable/lighting_overlay/singularity_act() - return +/datum/lighting_object/proc/removefromturf() + affected_turf.underlays -= current_underlay -/atom/movable/lighting_overlay/singularity_pull() - return - -/atom/movable/lighting_overlay/forceMove() - return 0 //should never move - -/atom/movable/lighting_overlay/Move() - return 0 - -/atom/movable/lighting_overlay/throw_at() - return 0 - -/atom/movable/lighting_overlay/Destroy(var/force) - if (force) - total_lighting_overlays-- - global.lighting_update_overlays -= src - LAZYREMOVE(SSlighting.currentrun, src) - - var/turf/T = loc - if(istype(T)) - T.lighting_overlay = null - T.luminosity = 1 - - return ..() - else - return QDEL_HINT_LETMELIVE +/datum/lighting_object/proc/addtoturf() + affected_turf.underlays += current_underlay diff --git a/code/modules/lighting/lighting_setup.dm b/code/modules/lighting/lighting_setup.dm index ad014b013d3..b6473f36ddf 100644 --- a/code/modules/lighting/lighting_setup.dm +++ b/code/modules/lighting/lighting_setup.dm @@ -1,24 +1,6 @@ // Create lighting overlays on all turfs with dynamic lighting in areas with dynamic lighting. -/proc/create_all_lighting_overlays() - for(var/area/A in world) - if(!A.dynamic_lighting) - continue - for(var/turf/T in A) - if(!T.dynamic_lighting) - continue - new /atom/movable/lighting_overlay(T, TRUE) - CHECK_TICK +/proc/create_all_lighting_objects() + var/list/all_turfs = block(locate(1,1,1), locate(world.maxx, world.maxy, world.maxz)) + for(var/turf/T as anything in all_turfs) + T.lighting_build_overlay() CHECK_TICK - -/proc/create_lighting_overlays_zlevel(var/zlevel) - ASSERT(zlevel) - - for(var/turf/T in block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel))) - if(!T.dynamic_lighting) - continue - - var/area/A = T.loc - if(!A.dynamic_lighting) - continue - - new /atom/movable/lighting_overlay(T, TRUE) \ No newline at end of file diff --git a/code/modules/lighting/lighting_source.dm b/code/modules/lighting/lighting_source.dm index 451b8273c84..4f863bf34ae 100644 --- a/code/modules/lighting/lighting_source.dm +++ b/code/modules/lighting/lighting_source.dm @@ -1,15 +1,22 @@ -/var/total_lighting_sources = 0 // This is where the fun begins. // These are the main datums that emit light. /datum/light_source - var/atom/top_atom // The atom we're emitting light from(for example a mob if we're from a flashlight that's being held). - var/atom/source_atom // The atom that we belong to. + ///The atom we're emitting light from (for example a mob if we're from a flashlight that's being held). + var/atom/top_atom + ///The atom that we belong to. + var/atom/source_atom - var/turf/source_turf // The turf under the above. - var/light_power // Intensity of the emitter light. - var/light_range // The range of the emitted light. - var/light_color // The colour of the light, string, decomposed by parse_light_color() + ///The turf under the source atom. + var/turf/source_turf + ///The turf the top_atom appears to over. + var/turf/pixel_turf + ///Intensity of the emitter light. + var/light_power + /// The range of the emitted light. + var/light_range + /// The colour of the light, string, decomposed by parse_light_color() + var/light_color // Variables for keeping track of the colour. var/lum_r @@ -21,142 +28,83 @@ var/tmp/applied_lum_g var/tmp/applied_lum_b - var/list/datum/lighting_corner/effect_str // List used to store how much we're affecting corners. - var/list/turf/affecting_turfs + /// List used to store how much we're affecting corners. + var/list/datum/lighting_corner/effect_str - var/applied = FALSE // Whether we have applied our light yet or not. + /// Whether we have applied our light yet or not. + var/applied = FALSE - var/vis_update // Whether we should smartly recalculate visibility. and then only update tiles that became(in)visible to us. - var/needs_update // Whether we are queued for an update. - var/destroyed // Whether we are destroyed and need to stop emitting light. - var/force_update + /// whether we are to be added to SSlighting's sources_queue list for an update + var/needs_update = LIGHTING_NO_UPDATE -/datum/light_source/New(var/atom/owner, var/atom/top) - total_lighting_sources++ + +/datum/light_source/New(atom/owner, atom/top) source_atom = owner // Set our new owner. - if(!source_atom.light_sources) - source_atom.light_sources = list() - - source_atom.light_sources += src // Add us to the lights of our owner. + LAZYADD(source_atom.light_sources, src) top_atom = top - if(top_atom != source_atom) - if(!top.light_sources) - top.light_sources = list() - - top_atom.light_sources += src + if (top_atom != source_atom) + LAZYADD(top_atom.light_sources, src) source_turf = top_atom + pixel_turf = get_turf_pixel(top_atom) || source_turf + light_power = source_atom.light_power light_range = source_atom.light_range light_color = source_atom.light_color - parse_light_color() - - effect_str = list() - affecting_turfs = list() + PARSE_LIGHT_COLOR(src) update() +/datum/light_source/Destroy(force) + remove_lum() + if (source_atom) + LAZYREMOVE(source_atom.light_sources, src) + + if (top_atom) + LAZYREMOVE(top_atom.light_sources, src) + + if (needs_update) + SSlighting.sources_queue -= src + + top_atom = null + source_atom = null + source_turf = null + pixel_turf = null return ..() -// Kill ourselves. -/datum/light_source/proc/destroy() - total_lighting_sources-- - destroyed = TRUE - force_update() - if(source_atom) - if(!source_atom.light_sources) - log_runtime(EXCEPTION("Atom [source_atom] was a light source, but lacked a light source list!\n"), source_atom) - else - source_atom.light_sources -= src +// Yes this doesn't align correctly on anything other than 4 width tabs. +// If you want it to go switch everybody to elastic tab stops. +// Actually that'd be great if you could! +#define EFFECT_UPDATE(level) \ + if (needs_update == LIGHTING_NO_UPDATE) \ + SSlighting.sources_queue += src; \ + if (needs_update < level) \ + needs_update = level; \ - if(top_atom) - top_atom.light_sources -= src - -// Call it dirty, I don't care. -// This is here so there's no performance loss on non-instant updates from the fact that the engine can also do instant updates. -// If you're wondering what's with the "BYOND" argument: BYOND won't let me have a() macro that has no arguments :|. -#define effect_update(BYOND) \ - if(!needs_update) \ - { \ - lighting_update_lights += src; \ - needs_update = TRUE; \ - } // This proc will cause the light source to update the top atom, and add itself to the update queue. -/datum/light_source/proc/update(var/atom/new_top_atom) +/datum/light_source/proc/update(atom/new_top_atom) // This top atom is different. - if(new_top_atom && new_top_atom != top_atom) - if(top_atom != source_atom) // Remove ourselves from the light sources of that top atom. - top_atom.light_sources -= src + if (new_top_atom && new_top_atom != top_atom) + if(top_atom != source_atom && top_atom.light_sources) // Remove ourselves from the light sources of that top atom. + LAZYREMOVE(top_atom.light_sources, src) top_atom = new_top_atom - if(top_atom != source_atom) - if(!top_atom.light_sources) - top_atom.light_sources = list() + if (top_atom != source_atom) + LAZYADD(top_atom.light_sources, src) // Add ourselves to the light sources of our new top atom. - top_atom.light_sources += src // Add ourselves to the light sources of our new top atom. - - effect_update(null) + EFFECT_UPDATE(LIGHTING_CHECK_UPDATE) // Will force an update without checking if it's actually needed. /datum/light_source/proc/force_update() - force_update = 1 - - effect_update(null) + EFFECT_UPDATE(LIGHTING_FORCE_UPDATE) // Will cause the light source to recalculate turfs that were removed or added to visibility only. /datum/light_source/proc/vis_update() - vis_update = 1 - - effect_update(null) - -// Will check if we actually need to update, and update any variables that may need to be updated. -/datum/light_source/proc/check() - if(!source_atom || !light_range || !light_power) - destroy() - return 1 - - if(!top_atom) - top_atom = source_atom - . = 1 - - if(isturf(top_atom)) - if(source_turf != top_atom) - source_turf = top_atom - . = 1 - else if(top_atom.loc != source_turf) - source_turf = top_atom.loc - . = 1 - - if(source_atom.light_power != light_power) - light_power = source_atom.light_power - . = 1 - - if(source_atom.light_range != light_range) - light_range = source_atom.light_range - . = 1 - - if(light_range && light_power && !applied) - . = 1 - - if(source_atom.light_color != light_color) - light_color = source_atom.light_color - parse_light_color() - . = 1 - -// Decompile the hexadecimal colour into lumcounts of each perspective. -/datum/light_source/proc/parse_light_color() - if(light_color) - lum_r = GetRedPart (light_color) / 255 - lum_g = GetGreenPart(light_color) / 255 - lum_b = GetBluePart (light_color) / 255 - else - lum_r = 1 - lum_g = 1 - lum_b = 1 + EFFECT_UPDATE(LIGHTING_VIS_UPDATE) // Macro that applies light to a new corner. // It is a macro in the interest of speed, yet not having to copy paste it. @@ -164,127 +112,264 @@ // As such this all gets counted as a single line. // The braces and semicolons are there to be able to do this on a single line. -#define APPLY_CORNER(C) \ - . = LUM_FALLOFF(C, source_turf); \ - \ - . *= light_power; \ - \ - effect_str[C] = .; \ - \ - C.update_lumcount \ - ( \ - . * applied_lum_r, \ - . * applied_lum_g, \ - . * applied_lum_b \ +// /tg/ falloff alg +#define LUM_FALLOFF(C, T) (1 - CLAMP01(sqrt((C.x - T.x) ** 2 + (C.y - T.y) ** 2 + LIGHTING_HEIGHT) / max(1, light_range))) + +// Bay/Polaris falloff alg +//#define LUM_FALLOFF(C, T)(1 - CLAMP01(((C.x - T.x) ** 2 +(C.y - T.y) ** 2 + LIGHTING_HEIGHT) ** 0.6 / max(1, light_range))) + +#define APPLY_CORNER(C) \ + . = LUM_FALLOFF(C, pixel_turf); \ + . *= light_power; \ + var/OLD = effect_str[C]; \ + \ + C.update_lumcount \ + ( \ + (. * lum_r) - (OLD * applied_lum_r), \ + (. * lum_g) - (OLD * applied_lum_g), \ + (. * lum_b) - (OLD * applied_lum_b) \ + ); \ + +#define REMOVE_CORNER(C) \ + . = -effect_str[C]; \ + C.update_lumcount \ + ( \ + . * applied_lum_r, \ + . * applied_lum_g, \ + . * applied_lum_b \ ); -// I don't need to explain what this does, do I? -#define REMOVE_CORNER(C) \ - . = -effect_str[C]; \ - C.update_lumcount \ - ( \ - . * applied_lum_r, \ - . * applied_lum_g, \ - . * applied_lum_b \ - ); +#define APPLY_CORNER_SIMPLE(C) \ + . = light_power; \ + var/OLD = effect_str[C]; \ + \ + C.update_lumcount \ + ( \ + (. * lum_r) - (OLD * applied_lum_r), \ + (. * lum_g) - (OLD * applied_lum_g), \ + (. * lum_b) - (OLD * applied_lum_b) \ + ); \ -// This is the define used to calculate falloff. -#define LUM_FALLOFF(C, T)(1 - CLAMP01(((C.x - T.x) ** 2 +(C.y - T.y) ** 2 + LIGHTING_HEIGHT) ** 0.6 / max(1, light_range))) -/datum/light_source/proc/apply_lum() - var/static/update_gen = 1 - applied = 1 +/datum/light_source/proc/remove_lum() + applied = FALSE + for (var/datum/lighting_corner/corner as anything in effect_str) + REMOVE_CORNER(corner) + LAZYREMOVE(corner.affecting, src) + + effect_str = null + +/datum/light_source/proc/recalc_corner(datum/lighting_corner/corner) + LAZYINITLIST(effect_str) + if (effect_str[corner]) // Already have one. + REMOVE_CORNER(corner) + effect_str[corner] = 0 + + APPLY_CORNER(corner) + effect_str[corner] = . + +/datum/light_source/proc/get_turfs_in_range() + return view(CEILING(light_range, 1), source_turf) + +/datum/light_source/proc/update_corners() + var/update = FALSE + var/atom/source_atom = src.source_atom + + if (QDELETED(source_atom)) + qdel(src) + return + + if (source_atom.light_power != light_power) + light_power = source_atom.light_power + update = TRUE + + if (source_atom.light_range != light_range) + light_range = source_atom.light_range + update = TRUE + + if (!top_atom) + top_atom = source_atom + update = TRUE + + if (!light_range || !light_power) + qdel(src) + return + + if (isturf(top_atom)) + if (source_turf != top_atom) + source_turf = top_atom + pixel_turf = source_turf + update = TRUE + else if (top_atom.loc != source_turf) + source_turf = top_atom.loc + pixel_turf = get_turf_pixel(top_atom) + update = TRUE + else + var/pixel_loc = get_turf_pixel(top_atom) + if (pixel_loc != pixel_turf) + pixel_turf = pixel_loc + update = TRUE + + if (!isturf(source_turf)) + if (applied) + remove_lum() + return + + if (light_range && light_power && !applied) + update = TRUE + + if (source_atom.light_color != light_color) + light_color = source_atom.light_color + PARSE_LIGHT_COLOR(src) + update = TRUE + + else if (applied_lum_r != lum_r || applied_lum_g != lum_g || applied_lum_b != lum_b) + update = TRUE + + if (update) + needs_update = LIGHTING_CHECK_UPDATE + applied = TRUE + else if (needs_update == LIGHTING_CHECK_UPDATE) + return //nothing's changed + + var/list/datum/lighting_corner/corners = list() + var/list/turf/turfs = list() + + if (source_turf) + var/oldlum = source_turf.luminosity + source_turf.luminosity = CEILING(light_range, 1) + for(var/turf/T in get_turfs_in_range()) + if(!IS_OPAQUE_TURF(T)) + if (!T.lighting_corners_initialised) + T.generate_missing_corners() + corners[T.lighting_corner_NE] = 0 + corners[T.lighting_corner_SE] = 0 + corners[T.lighting_corner_SW] = 0 + corners[T.lighting_corner_NW] = 0 + turfs += T + source_turf.luminosity = oldlum + + var/list/datum/lighting_corner/new_corners = (corners - effect_str) + LAZYINITLIST(effect_str) + if (needs_update == LIGHTING_VIS_UPDATE) + for (var/datum/lighting_corner/corner as anything in new_corners) + APPLY_CORNER(corner) + if (. != 0) + LAZYADD(corner.affecting, src) + effect_str[corner] = . + else + for (var/datum/lighting_corner/corner as anything in new_corners) + APPLY_CORNER(corner) + if (. != 0) + LAZYADD(corner.affecting, src) + effect_str[corner] = . + + for (var/datum/lighting_corner/corner as anything in corners - new_corners) // Existing corners + APPLY_CORNER(corner) + if (. != 0) + effect_str[corner] = . + else + LAZYREMOVE(corner.affecting, src) + effect_str -= corner + + var/list/datum/lighting_corner/gone_corners = effect_str - corners + for (var/datum/lighting_corner/corner as anything in gone_corners) + REMOVE_CORNER(corner) + LAZYREMOVE(corner.affecting, src) + effect_str -= gone_corners - // Keep track of the last applied lum values so that the lighting can be reversed applied_lum_r = lum_r applied_lum_g = lum_g applied_lum_b = lum_b - FOR_DVIEW(var/turf/T, light_range, source_turf, INVISIBILITY_LIGHTING) - if(!T.lighting_corners_initialised) - T.generate_missing_corners() + UNSETEMPTY(effect_str) - for(var/datum/lighting_corner/C in T.get_corners()) - if(C.update_gen == update_gen) - continue +// For planets and fake suns +/datum/light_source/sun + light_range = 1 + light_color = "#FFFFFF" + light_power = 2 + var/applied_power = 2 - C.update_gen = update_gen - C.affecting += src +/datum/light_source/sun/New() + return - if(!C.active) - effect_str[C] = 0 - continue +/datum/light_source/sun/force_update() + return - APPLY_CORNER(C) +/datum/light_source/sun/vis_update() + return - if(!T.affecting_lights) - T.affecting_lights = list() +/datum/light_source/sun/update_corners(var/list/turfs_to_update) + if(!LAZYLEN(turfs_to_update)) + stack_trace("Planet sun tried to update with no turfs given") + return - T.affecting_lights += src - affecting_turfs += T + // Update lum_r/g/b from our light_color + PARSE_LIGHT_COLOR(src) + + // Noop update + if(lum_r == applied_lum_r && lum_g == applied_lum_g && lum_b == applied_lum_b && light_power == applied_power) + return + + // No reason to unapply on the first run or if previous run was 0 power + if(applied) + remove_lum() - update_gen++ + // Entirely dark, just stop now that we've remove_lum()'d + if(!light_power) + applied = FALSE + return -/datum/light_source/proc/remove_lum() - applied = FALSE + LAZYINITLIST(effect_str) - for(var/turf/T in affecting_turfs) - if(!T.affecting_lights) - T.affecting_lights = list() - else - T.affecting_lights -= src - - affecting_turfs.Cut() - - for(var/datum/lighting_corner/C in effect_str) - REMOVE_CORNER(C) - - C.affecting -= src - - effect_str.Cut() - -/datum/light_source/proc/recalc_corner(var/datum/lighting_corner/C) - if(effect_str.Find(C)) // Already have one. - REMOVE_CORNER(C) - - APPLY_CORNER(C) - -/datum/light_source/proc/smart_vis_update() var/list/datum/lighting_corner/corners = list() - var/list/turf/turfs = list() - FOR_DVIEW(var/turf/T, light_range, source_turf, 0) - if(!T.lighting_corners_initialised) - T.generate_missing_corners() - corners |= T.get_corners() - turfs += T + for(var/turf/T as anything in turfs_to_update) + if(!IS_OPAQUE_TURF(T)) + if(!T.lighting_corners_initialised) + T.generate_missing_corners() + + var/datum/lighting_corner/LC = T.lighting_corner_NE + if(!corners[LC]) + corners[LC] = 1 + APPLY_CORNER_SIMPLE(LC) + LAZYADD(LC.affecting, src) + effect_str[LC] = . + + LC = T.lighting_corner_SE + if(!corners[LC]) + corners[LC] = 1 + APPLY_CORNER_SIMPLE(LC) + LAZYADD(LC.affecting, src) + effect_str[LC] = . + + LC = T.lighting_corner_NW + if(!corners[LC]) + corners[LC] = 1 + APPLY_CORNER_SIMPLE(LC) + LAZYADD(LC.affecting, src) + effect_str[LC] = . + + LC = T.lighting_corner_SW + if(!corners[LC]) + corners[LC] = 1 + APPLY_CORNER_SIMPLE(LC) + LAZYADD(LC.affecting, src) + effect_str[LC] = . - var/list/L = turfs - affecting_turfs // New turfs, add us to the affecting lights of them. - affecting_turfs += L - for(var/turf/T in L) - if(!T.affecting_lights) - T.affecting_lights = list(src) - else - T.affecting_lights += src + CHECK_TICK - L = affecting_turfs - turfs // Now-gone turfs, remove us from the affecting lights. - affecting_turfs -= L - for(var/turf/T in L) - T.affecting_lights -= src + applied_lum_r = lum_r + applied_lum_g = lum_g + applied_lum_b = lum_b + applied_power = light_power + applied = TRUE // remove_lum() now necessary in the future - for(var/datum/lighting_corner/C in corners - effect_str) // New corners - C.affecting += src - if(!C.active) - effect_str[C] = 0 - continue + UNSETEMPTY(effect_str) - APPLY_CORNER(C) - - for(var/datum/lighting_corner/C in effect_str - corners) // Old, now gone, corners. - REMOVE_CORNER(C) - C.affecting -= src - effect_str -= C - -#undef effect_update +#undef EFFECT_UPDATE #undef LUM_FALLOFF #undef REMOVE_CORNER #undef APPLY_CORNER +#undef REMOVE_CORNER_SIMPLE +#undef APPLY_CORNER_SIMPLE \ No newline at end of file diff --git a/code/modules/lighting/lighting_turf.dm b/code/modules/lighting/lighting_turf.dm index b8a29fc43a1..59732b5d60e 100644 --- a/code/modules/lighting/lighting_turf.dm +++ b/code/modules/lighting/lighting_turf.dm @@ -1,96 +1,142 @@ /turf - var/dynamic_lighting = TRUE // Does the turf use dynamic lighting? - luminosity = 1 + ///Lumcount added by sources other than lighting datum objects, such as the overlay lighting component. + var/dynamic_lumcount = 0 + + var/dynamic_lighting = TRUE var/tmp/lighting_corners_initialised = FALSE - var/tmp/list/datum/light_source/affecting_lights // List of light sources affecting this turf. - var/tmp/atom/movable/lighting_overlay/lighting_overlay // Our lighting overlay. - var/tmp/list/datum/lighting_corner/corners - var/tmp/has_opaque_atom = FALSE // Not to be confused with opacity, this will be TRUE if there's any opaque atom on the tile. + ///Our lighting object. + var/tmp/datum/lighting_object/lighting_object + ///Lighting Corner datums. + var/tmp/datum/lighting_corner/lighting_corner_NE + var/tmp/datum/lighting_corner/lighting_corner_SE + var/tmp/datum/lighting_corner/lighting_corner_SW + var/tmp/datum/lighting_corner/lighting_corner_NW + + ///Which directions does this turf block the vision of, taking into account both the turf's opacity and the movable opacity_sources. + var/directional_opacity = NONE + ///Lazylist of movable atoms providing opacity sources. + var/list/atom/movable/opacity_sources // Causes any affecting light sources to be queued for a visibility update, for example a door got opened. /turf/proc/reconsider_lights() - for(var/datum/light_source/L in affecting_lights) - L.vis_update() + lighting_corner_NE?.vis_update() + lighting_corner_SE?.vis_update() + lighting_corner_SW?.vis_update() + lighting_corner_NW?.vis_update() /turf/proc/lighting_clear_overlay() - if(lighting_overlay) - qdel(lighting_overlay, force = TRUE) + if(lighting_object) + qdel(lighting_object, force=TRUE) - for(var/datum/lighting_corner/C in corners) - C.update_active() - -// Builds a lighting overlay for us, but only if our area is dynamic. +// Builds a lighting object for us, but only if our area is dynamic. /turf/proc/lighting_build_overlay() - if(lighting_overlay) + if(!has_dynamic_lighting()) return - var/area/A = loc - if(A.dynamic_lighting && dynamic_lighting) - if(!lighting_corners_initialised) - generate_missing_corners() - - new /atom/movable/lighting_overlay(src) - - for(var/datum/lighting_corner/C in corners) - if(!C.active) // We would activate the corner, calculate the lighting for it. - for(var/L in C.affecting) - var/datum/light_source/S = L - S.recalc_corner(C) - - C.active = TRUE + lighting_clear_overlay() + new/datum/lighting_object(src) // Used to get a scaled lumcount. -/turf/proc/get_lumcount(var/minlum = 0, var/maxlum = 1) - if(!lighting_overlay) +/turf/proc/get_lumcount(minlum = 0, maxlum = 1) + if (!lighting_object) return 1 var/totallums = 0 - for(var/datum/lighting_corner/L in corners) - totallums += max(L.lum_r, L.lum_g, L.lum_b) + var/datum/lighting_corner/L + L = lighting_corner_NE + if (L) + totallums += L.lum_r + L.lum_b + L.lum_g + L = lighting_corner_SE + if (L) + totallums += L.lum_r + L.lum_b + L.lum_g + L = lighting_corner_SW + if (L) + totallums += L.lum_r + L.lum_b + L.lum_g + L = lighting_corner_NW + if (L) + totallums += L.lum_r + L.lum_b + L.lum_g - totallums /= 4 // 4 corners, max channel selected, return the average - totallums =(totallums - minlum) /(maxlum - minlum) + totallums /= 12 // 4 corners, each with 3 channels, get the average. + + totallums = (totallums - minlum) / (maxlum - minlum) + + totallums += dynamic_lumcount return CLAMP01(totallums) -// Can't think of a good name, this proc will recalculate the has_opaque_atom variable. -/turf/proc/recalc_atom_opacity() - has_opaque_atom = FALSE - for(var/atom/A in src.contents + src) // Loop through every movable atom on our tile PLUS ourselves (we matter too...) - if(A.opacity) - has_opaque_atom = TRUE +// Returns a boolean whether the turf is on soft lighting. +// Soft lighting being the threshold at which point the overlay considers +// itself as too dark to allow sight and see_in_dark becomes useful. +// So basically if this returns true the tile is unlit black. +/turf/proc/is_softly_lit() + if (!lighting_object) + return FALSE -// If an opaque movable atom moves around we need to potentially update visibility. -/turf/Entered(var/atom/movable/Obj, var/atom/OldLoc) - . = ..() + return !(luminosity || dynamic_lumcount) - if(Obj && Obj.opacity) - has_opaque_atom = TRUE // Make sure to do this before reconsider_lights(), incase we're on instant updates. Guaranteed to be on in this case. - reconsider_lights() -/turf/Exited(var/atom/movable/Obj, var/atom/newloc) - . = ..() +///Proc to add movable sources of opacity on the turf and let it handle lighting code. +/turf/proc/add_opacity_source(atom/movable/new_source) + LAZYADD(opacity_sources, new_source) + if(opacity) + return + recalculate_directional_opacity() - if(Obj && Obj.opacity) - recalc_atom_opacity() // Make sure to do this before reconsider_lights(), incase we're on instant updates. - reconsider_lights() -/turf/proc/get_corners() - if(has_opaque_atom) - return null // Since this proc gets used in a for loop, null won't be looped though. +///Proc to remove movable sources of opacity on the turf and let it handle lighting code. +/turf/proc/remove_opacity_source(atom/movable/old_source) + LAZYREMOVE(opacity_sources, old_source) + if(opacity) //Still opaque, no need to worry on updating. + return + recalculate_directional_opacity() - return corners + +///Calculate on which directions this turfs block view. +/turf/proc/recalculate_directional_opacity() + . = directional_opacity + if(opacity) + directional_opacity = ALL_CARDINALS + if(. != directional_opacity) + reconsider_lights() + return + directional_opacity = NONE + for(var/atom/movable/opacity_source as anything in opacity_sources) + if(opacity_source.flags & ON_BORDER) + directional_opacity |= opacity_source.dir + else //If fulltile and opaque, then the whole tile blocks view, no need to continue checking. + directional_opacity = ALL_CARDINALS + break + if(. != directional_opacity && (. == ALL_CARDINALS || directional_opacity == ALL_CARDINALS)) + reconsider_lights() //The lighting system only cares whether the tile is fully concealed from all directions or not. + + +/turf/proc/change_area(area/old_area, area/new_area) + if(SSlighting.subsystem_initialized) + if (new_area.dynamic_lighting != old_area.dynamic_lighting) + if (new_area.dynamic_lighting) + lighting_build_overlay() + else + lighting_clear_overlay() + +/turf/proc/has_dynamic_lighting() + var/area/A = loc + return (IS_DYNAMIC_LIGHTING(src) && IS_DYNAMIC_LIGHTING(A)) /turf/proc/generate_missing_corners() + + if (!lighting_corner_NE) + lighting_corner_NE = new/datum/lighting_corner(src, NORTH|EAST) + + if (!lighting_corner_SE) + lighting_corner_SE = new/datum/lighting_corner(src, SOUTH|EAST) + + if (!lighting_corner_SW) + lighting_corner_SW = new/datum/lighting_corner(src, SOUTH|WEST) + + if (!lighting_corner_NW) + lighting_corner_NW = new/datum/lighting_corner(src, NORTH|WEST) + lighting_corners_initialised = TRUE - if(!corners) - corners = list(null, null, null, null) - - for(var/i = 1 to 4) - if(corners[i]) // Already have a corner on this direction. - continue - - corners[i] = new /datum/lighting_corner(src, LIGHTING_CORNER_DIAGONAL[i]) diff --git a/code/modules/lighting/~lighting_undefs.dm b/code/modules/lighting/~lighting_undefs.dm deleted file mode 100644 index 2f863b73d5b..00000000000 --- a/code/modules/lighting/~lighting_undefs.dm +++ /dev/null @@ -1,7 +0,0 @@ -#undef LIGHTING_FALLOFF -#undef LIGHTING_LAMBERTIAN -#undef LIGHTING_HEIGHT - -#undef LIGHTING_ICON - -#undef LIGHTING_BASE_MATRIX diff --git a/code/modules/maps/tg/reader.dm b/code/modules/maps/tg/reader.dm index aa0bd51b899..542a0b9582c 100644 --- a/code/modules/maps/tg/reader.dm +++ b/code/modules/maps/tg/reader.dm @@ -159,7 +159,6 @@ GLOBAL_DATUM_INIT(_preloader, /dmm_suite/preloader, new) var/model_key = copytext(line, tpos, tpos + key_len) line_keys[++line_keys.len] = model_key #ifdef TESTING - else ++turfsSkipped #endif CHECK_TICK diff --git a/code/modules/mining/mine_items.dm b/code/modules/mining/mine_items.dm index e74c241ffb1..1d62a20a61a 100644 --- a/code/modules/mining/mine_items.dm +++ b/code/modules/mining/mine_items.dm @@ -4,7 +4,7 @@ name = "lantern" icon_state = "lantern" desc = "A mining lantern." - brightness_on = 6 // luminosity when on + light_range = 6 // luminosity when on light_color = "FF9933" // A slight yellow/orange color. /*****************************Pickaxe********************************/ diff --git a/code/modules/mining/mine_turfs.dm b/code/modules/mining/mine_turfs.dm index fd41dc7e137..6ef8200455e 100644 --- a/code/modules/mining/mine_turfs.dm +++ b/code/modules/mining/mine_turfs.dm @@ -125,7 +125,7 @@ turf/simulated/mineral/floor/light_corner /turf/simulated/mineral/proc/update_general() update_icon(1) - recalc_atom_opacity() + recalculate_directional_opacity() if(ticker && ticker.current_state == GAME_STATE_PLAYING) reconsider_lights() if(air_master) diff --git a/code/modules/mob/living/carbon/alien/alien.dm b/code/modules/mob/living/carbon/alien/alien.dm index 03a878e32d1..132be558597 100644 --- a/code/modules/mob/living/carbon/alien/alien.dm +++ b/code/modules/mob/living/carbon/alien/alien.dm @@ -7,6 +7,7 @@ health = 100 maxHealth = 100 mob_size = 4 + blocks_emissive = EMISSIVE_BLOCK_UNIQUE inventory_panel_type = null // Disable inventory diff --git a/code/modules/mob/living/carbon/carbon_defines.dm b/code/modules/mob/living/carbon/carbon_defines.dm index 07cd72fce99..a5230484ed2 100644 --- a/code/modules/mob/living/carbon/carbon_defines.dm +++ b/code/modules/mob/living/carbon/carbon_defines.dm @@ -1,5 +1,6 @@ /mob/living/carbon gender = MALE + blocks_emissive = EMISSIVE_BLOCK_UNIQUE // BLEH, this could be improved for transparent species and stuff! And blocks glowing eyes?! var/datum/species/species //Contains icon generation and language information, set during New(). var/list/stomach_contents = list() var/list/datum/disease2/disease/virus2 = list() diff --git a/code/modules/mob/living/carbon/human/human_species.dm b/code/modules/mob/living/carbon/human/human_species.dm index 90949f401f8..3c6451fc99a 100644 --- a/code/modules/mob/living/carbon/human/human_species.dm +++ b/code/modules/mob/living/carbon/human/human_species.dm @@ -2,6 +2,7 @@ real_name = "Test Dummy" status_flags = GODMODE|CANPUSH has_huds = FALSE + blocks_emissive = FALSE /mob/living/carbon/human/dummy/Initialize() . = ..() diff --git a/code/modules/mob/living/carbon/human/update_icons.dm b/code/modules/mob/living/carbon/human/update_icons.dm index b4836d168f8..143e0315eb3 100644 --- a/code/modules/mob/living/carbon/human/update_icons.dm +++ b/code/modules/mob/living/carbon/human/update_icons.dm @@ -207,7 +207,7 @@ var/global/list/damage_icon_parts = list() //see UpdateDamageIcon() else DI = damage_icon_parts[cache_index] - standing_image.overlays += DI + standing_image.add_overlay(DI) overlays_standing[DAMAGE_LAYER] = standing_image apply_layer(DAMAGE_LAYER) @@ -476,10 +476,17 @@ var/global/list/damage_icon_parts = list() //see UpdateDamageIcon() face_standing += rgb(,,,120) var/icon/ears_s = get_ears_overlay() + var/image/em_block_ears if(ears_s) face_standing.Blend(ears_s, ICON_OVERLAY) + if(ear_style?.em_block) + em_block_ears = em_block_image_generic(image(ears_s)) + + var/image/semifinal = image(face_standing, layer = BODY_LAYER+HAIR_LAYER, "pixel_y" = head_organ.head_offset) + if(em_block_ears) + semifinal.overlays += em_block_ears // Leaving this as overlays += - overlays_standing[HAIR_LAYER] = image(face_standing, layer = BODY_LAYER+HAIR_LAYER, "pixel_y" = head_organ.head_offset) + overlays_standing[HAIR_LAYER] = semifinal apply_layer(HAIR_LAYER) //return //VOREStation Edit @@ -532,6 +539,7 @@ var/global/list/damage_icon_parts = list() //see UpdateDamageIcon() else eyes_icon.Blend(rgb(128,0,0), ICON_ADD) + // Convert to emissive at some point var/image/eyes_image = image(eyes_icon) eyes_image.plane = PLANE_LIGHTING_ABOVE eyes_image.appearance_flags = appearance_flags @@ -566,7 +574,7 @@ var/global/list/damage_icon_parts = list() //see UpdateDamageIcon() for(var/mut in mutations) if(mut == LASER) - standing.overlays += "lasereyes_s" //TODO + standing.overlays += "lasereyes_s" // Leaving this as overlays += overlays_standing[MUTATIONS_LAYER] = standing apply_layer(MUTATIONS_LAYER) @@ -1067,7 +1075,7 @@ var/global/list/damage_icon_parts = list() //see UpdateDamageIcon() for(var/datum/modifier/M in modifiers) if(M.mob_overlay_state) var/image/I = image(icon = 'icons/mob/modifier_effects.dmi', icon_state = M.mob_overlay_state) - effects.overlays += I //TODO, this compositing is annoying. + effects.overlays += I // Leaving this as overlays += overlays_standing[MODIFIER_EFFECTS_LAYER] = effects @@ -1113,7 +1121,7 @@ var/global/list/damage_icon_parts = list() //see UpdateDamageIcon() for(var/obj/item/organ/external/E in organs) if(E.open) var/image/I = image(icon = 'icons/mob/surgery.dmi', icon_state = "[E.icon_name][round(E.open)]", layer = BODY_LAYER+SURGERY_LAYER) - total.overlays += I //TODO: This compositing is annoying + total.overlays += I // Leaving this as overlays += if(total.overlays.len) overlays_standing[SURGERY_LAYER] = total @@ -1127,7 +1135,9 @@ var/global/list/damage_icon_parts = list() //see UpdateDamageIcon() if(synthetic && synthetic.includes_wing && !wing_style && !wings_hidden) //VOREStation Edit var/icon/wing_s = new/icon("icon" = synthetic.icon, "icon_state" = "wing") //I dunno. If synths have some custom wing? wing_s.Blend(rgb(src.r_skin, src.g_skin, src.b_skin), species.color_mult ? ICON_MULTIPLY : ICON_ADD) - return image(wing_s) + var/image/working = image(wing_s) + working.overlays += em_block_image_generic(working) // Leaving this as overlays += + return working //If you have custom wings selected if(wing_style && !(wear_suit && wear_suit.flags_inv & HIDETAIL) && !wings_hidden) //VOREStation Edit @@ -1150,7 +1160,10 @@ var/global/list/damage_icon_parts = list() //see UpdateDamageIcon() overlay.Blend(rgb(src.r_wing3, src.g_wing3, src.b_wing3), wing_style.color_blend_mode) wing_s.Blend(overlay, ICON_OVERLAY) qdel(overlay) - return image(wing_s) + var/image/working = image(wing_s) + if(wing_style.em_block) + working.overlays += em_block_image_generic(working) // Leaving this as overlays += + return working /mob/living/carbon/human/proc/get_ears_overlay() if(ear_style && !(head && (head.flags_inv & BLOCKHEADHAIR))) @@ -1208,15 +1221,20 @@ var/global/list/damage_icon_parts = list() //see UpdateDamageIcon() tail_s.Blend(overlay, ICON_OVERLAY) qdel(overlay) + var/image/working = image(tail_s) + if(tail_style.em_block) + working.overlays += em_block_image_generic(working) // Leaving this as overlays += + if(isTaurTail(tail_style)) var/datum/sprite_accessory/tail/taur/taurtype = tail_style + working.pixel_x = -16 if(taurtype.can_ride && !riding_datum) riding_datum = new /datum/riding/taur(src) verbs |= /mob/living/carbon/human/proc/taur_mount verbs |= /mob/living/proc/toggle_rider_reins - return image(tail_s, "pixel_x" = -16) + return working else - return image(tail_s) + return working return null // TODO - Move this to where it should go ~Leshana diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index a88a434d968..90bec77cb7d 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -238,10 +238,6 @@ set_light(distance, distance * 4, l_color = "#660066") return TRUE - else if(on_fire) - set_light(min(round(fire_stacks), 3), round(fire_stacks), l_color = "#FF9933") - return TRUE - else if(glow_toggle) set_light(glow_range, glow_intensity, glow_color) diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index b6e6ffc03fd..589d9ac6a31 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -366,7 +366,7 @@ /mob/living/proc/IgniteMob() if(fire_stacks > 0 && !on_fire) on_fire = 1 - handle_light() + new/obj/effect/dummy/lighting_obj/moblight/fire(src) throw_alert("fire", /obj/screen/alert/fire) update_fire() @@ -374,7 +374,8 @@ if(on_fire) on_fire = 0 fire_stacks = 0 - handle_light() + for(var/obj/effect/dummy/lighting_obj/moblight/fire/F in src) + qdel(F) clear_alert("fire") update_fire() diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 82bc2e24989..4164b13e24b 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -12,6 +12,8 @@ mob_swap_flags = ~HEAVY mob_push_flags = ~HEAVY //trundle trundle + blocks_emissive = EMISSIVE_BLOCK_UNIQUE + var/lights_on = 0 // Is our integrated light on? var/used_power_this_tick = 0 var/sight_mode = 0 diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 90f6943a8c8..a0ca4cd4922 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -3,6 +3,7 @@ layer = MOB_LAYER plane = MOB_PLANE animate_movement = 2 + blocks_emissive = EMISSIVE_BLOCK_GENERIC var/datum/mind/mind var/stat = 0 //Whether a mob is alive or dead. TODO: Move this to living - Nodrak diff --git a/code/modules/mob/mob_planes.dm b/code/modules/mob/mob_planes.dm index 1d557e4e519..cfd4a917296 100644 --- a/code/modules/mob/mob_planes.dm +++ b/code/modules/mob/mob_planes.dm @@ -16,6 +16,8 @@ // 'Utility' planes plane_masters[VIS_FULLBRIGHT] = new /obj/screen/plane_master/fullbright //Lighting system (lighting_overlay objects) plane_masters[VIS_LIGHTING] = new /obj/screen/plane_master/lighting //Lighting system (but different!) + plane_masters[VIS_O_LIGHT] = new /obj/screen/plane_master/o_light_visual //Object lighting (using masks) + plane_masters[VIS_EMISSIVE] = new /obj/screen/plane_master/emissive //Emissive overlays plane_masters[VIS_GHOSTS] = new /obj/screen/plane_master/ghosts //Ghosts! plane_masters[VIS_AI_EYE] = new /obj/screen/plane_master{plane = PLANE_AI_EYE} //AI Eye! @@ -48,6 +50,9 @@ ..() + for(var/obj/screen/plane_master/PM as anything in plane_masters) + PM.backdrop(my_mob) + /datum/plane_holder/Destroy() my_mob = null QDEL_LIST_NULL(plane_masters) //Goodbye my children, be free @@ -106,14 +111,17 @@ for(var/SP in subplanes) alter_values(SP, values) + + + //////////////////// // The Plane Master //////////////////// /obj/screen/plane_master - screen_loc = "1,1" + screen_loc = "CENTER" plane = -100 //Dodge just in case someone instantiates one of these accidentally, don't end up on 0 with plane_master appearance_flags = PLANE_MASTER - mouse_opacity = 0 //Normally unclickable + mouse_opacity = MOUSE_OPACITY_TRANSPARENT //Normally unclickable alpha = 0 //Hidden from view var/desired_alpha = 255 //What we go to when we're enabled var/invis_toggle = FALSE @@ -122,6 +130,8 @@ /obj/screen/plane_master/New() ..(null) //Never be in anything ever. +/obj/screen/plane_master/proc/backdrop(mob/mymob) + /obj/screen/plane_master/proc/set_desired_alpha(var/new_alpha) if(new_alpha != alpha && new_alpha > 0 && new_alpha <= 255) desired_alpha = new_alpha @@ -176,6 +186,43 @@ blend_mode = BLEND_MULTIPLY alpha = 255 +/obj/screen/plane_master/lighting/backdrop(mob/mymob) + /* I'm unconvinced. + mymob.overlay_fullscreen("lighting_backdrop_lit", /obj/screen/fullscreen/lighting_backdrop/lit) + mymob.overlay_fullscreen("lighting_backdrop_unlit", /obj/screen/fullscreen/lighting_backdrop/unlit) + */ + +/*! + * This system works by exploiting BYONDs color matrix filter to use layers to handle emissive blockers. + * + * Emissive overlays are pasted with an atom color that converts them to be entirely some specific color. + * Emissive blockers are pasted with an atom color that converts them to be entirely some different color. + * Emissive overlays and emissive blockers are put onto the same plane. + * The layers for the emissive overlays and emissive blockers cause them to mask eachother similar to normal BYOND objects. + * A color matrix filter is applied to the emissive plane to mask out anything that isn't whatever the emissive color is. + * This is then used to alpha mask the lighting plane. + */ + +/obj/screen/plane_master/lighting/Initialize() + . = ..() + add_filter("emissives", 1, alpha_mask_filter(render_source = EMISSIVE_RENDER_TARGET, flags = MASK_INVERSE)) + add_filter("object_lighting", 2, alpha_mask_filter(render_source = O_LIGHTING_VISUAL_RENDER_TARGET, flags = MASK_INVERSE)) + +/obj/screen/plane_master/o_light_visual + plane = PLANE_O_LIGHTING_VISUAL + render_target = O_LIGHTING_VISUAL_RENDER_TARGET + blend_mode = BLEND_MULTIPLY + alpha = 255 + +/obj/screen/plane_master/emissive + plane = PLANE_EMISSIVE + render_target = EMISSIVE_RENDER_TARGET + alpha = 255 + +/obj/screen/plane_master/emissive/Initialize() + . = ..() + add_filter("em_block_masking", 1, color_matrix_filter(GLOB.em_mask_matrix)) + ///////////////// //Ghosts has a special alpha level /obj/screen/plane_master/ghosts diff --git a/code/modules/mob/mob_planes_vr.dm b/code/modules/mob/mob_planes_vr.dm index 5d41209b196..1c47b13e720 100644 --- a/code/modules/mob/mob_planes_vr.dm +++ b/code/modules/mob/mob_planes_vr.dm @@ -1,11 +1,12 @@ /datum/plane_holder/New(mob/this_guy) - ..() + my_mob = this_guy plane_masters[VIS_CH_STATUS_R] = new /obj/screen/plane_master{plane = PLANE_CH_STATUS_R} //Right-side status icon plane_masters[VIS_CH_HEALTH_VR] = new /obj/screen/plane_master{plane = PLANE_CH_HEALTH_VR} //Health bar but transparent at 100 plane_masters[VIS_CH_BACKUP] = new /obj/screen/plane_master{plane = PLANE_CH_BACKUP} //Backup implant status plane_masters[VIS_CH_VANTAG] = new /obj/screen/plane_master{plane = PLANE_CH_VANTAG} //Vore Antags plane_masters[VIS_AUGMENTED] = new /obj/screen/plane_master/augmented(my_mob) //Augmented reality + ..() ///////////////// //AR planemaster does some special image handling diff --git a/code/modules/mob/new_player/sprite_accessories.dm b/code/modules/mob/new_player/sprite_accessories.dm index 1a13a7ed621..1e7184f9655 100644 --- a/code/modules/mob/new_player/sprite_accessories.dm +++ b/code/modules/mob/new_player/sprite_accessories.dm @@ -39,6 +39,9 @@ // Ckey of person allowed to use this, if defined. var/list/ckeys_allowed = null + /// Should this sprite block emissives? + var/em_block = FALSE + /* //////////////////////////// / =--------------------= / @@ -1519,6 +1522,7 @@ shaved /datum/sprite_accessory/facial_hair icon = 'icons/mob/Human_face.dmi' color_blend_mode = ICON_ADD + em_block = TRUE /datum/sprite_accessory/facial_hair/shaved name = "Shaved" diff --git a/code/modules/mob/new_player/sprite_accessories_ear.dm b/code/modules/mob/new_player/sprite_accessories_ear.dm index 24e82043e41..fbf59a0fecc 100644 --- a/code/modules/mob/new_player/sprite_accessories_ear.dm +++ b/code/modules/mob/new_player/sprite_accessories_ear.dm @@ -14,6 +14,7 @@ var/extra_overlay // Icon state of an additional overlay to blend in. var/extra_overlay2 var/desc = "You should not see this..." + em_block = TRUE species_allowed = list(SPECIES_EVENT1, SPECIES_EVENT2, SPECIES_EVENT3) diff --git a/code/modules/mob/new_player/sprite_accessories_tail.dm b/code/modules/mob/new_player/sprite_accessories_tail.dm index dec95139744..f2d6fce6360 100644 --- a/code/modules/mob/new_player/sprite_accessories_tail.dm +++ b/code/modules/mob/new_player/sprite_accessories_tail.dm @@ -11,6 +11,7 @@ do_colouration = 0 //Set to 1 to enable coloration using the tail color. color_blend_mode = ICON_ADD // Only appliciable if do_coloration = 1 + em_block = TRUE var/extra_overlay // Icon state of an additional overlay to blend in. var/extra_overlay2 //Tertiary. var/show_species_tail = 0 // If false, do not render species' tail. diff --git a/code/modules/mob/new_player/sprite_accessories_taur.dm b/code/modules/mob/new_player/sprite_accessories_taur.dm index dad54ed188c..59f8f8f4d77 100644 --- a/code/modules/mob/new_player/sprite_accessories_taur.dm +++ b/code/modules/mob/new_player/sprite_accessories_taur.dm @@ -123,6 +123,7 @@ icon = 'icons/mob/human_races/sprite_accessories/taurs.dmi' do_colouration = 1 // Yes color, using tail color color_blend_mode = ICON_MULTIPLY // The sprites for taurs are designed for ICON_MULTIPLY + em_block = TRUE var/icon/suit_sprites = null //File for suit sprites, if any. var/icon/under_sprites = null diff --git a/code/modules/mob/new_player/sprite_accessories_wing.dm b/code/modules/mob/new_player/sprite_accessories_wing.dm index 486e81f4b10..85bdedd04ae 100644 --- a/code/modules/mob/new_player/sprite_accessories_wing.dm +++ b/code/modules/mob/new_player/sprite_accessories_wing.dm @@ -11,6 +11,7 @@ do_colouration = 0 //Set to 1 to enable coloration using the tail color. color_blend_mode = ICON_ADD // Only appliciable if do_coloration = 1 + em_block = TRUE var/extra_overlay // Icon state of an additional overlay to blend in. var/extra_overlay2 //Tertiary. var/clothing_can_hide = 1 // If true, clothing with HIDETAIL hides it. If the clothing is bulky enough to hide a tail, it should also hide wings. diff --git a/code/modules/modular_computers/computers/modular_computer/core.dm b/code/modules/modular_computers/computers/modular_computer/core.dm index d4b311e8e25..8639aadb63b 100644 --- a/code/modules/modular_computers/computers/modular_computer/core.dm +++ b/code/modules/modular_computers/computers/modular_computer/core.dm @@ -72,22 +72,34 @@ /obj/item/modular_computer/update_icon() icon_state = icon_state_unpowered - overlays.Cut() + cut_overlays() + + . = list() + if(bsod) - overlays += image(icon = overlay_icon, icon_state = "bsod") - return + . += mutable_appearance(overlay_icon, "bsod") + . += emissive_appearance(overlay_icon, "bsod") + return add_overlay(.) if(!enabled) if(icon_state_screensaver) - overlays += image(icon = overlay_icon, icon_state = icon_state_screensaver) + . += mutable_appearance(overlay_icon, icon_state_screensaver) + . += emissive_appearance(overlay_icon, icon_state_screensaver) set_light(0) - return + return add_overlay(.) + set_light(light_strength) + if(active_program) - overlays += image(icon = overlay_icon, icon_state = active_program.program_icon_state ? active_program.program_icon_state : icon_state_menu) + var/program_state = active_program.program_icon_state ? active_program.program_icon_state : icon_state_menu + . += mutable_appearance(overlay_icon, program_state) + . += emissive_appearance(overlay_icon, program_state) if(active_program.program_key_state) - overlays += image(icon = overlay_icon, icon_state = active_program.program_key_state) + . += mutable_appearance(overlay_icon, active_program.program_key_state) else - overlays += image(icon = overlay_icon, icon_state = icon_state_menu) + . += mutable_appearance(overlay_icon, icon_state_menu) + . += emissive_appearance(overlay_icon, icon_state_menu) + + return add_overlay(.) /obj/item/modular_computer/proc/turn_on(var/mob/user) if(bsod) diff --git a/code/modules/modular_computers/computers/modular_computer/variables.dm b/code/modules/modular_computers/computers/modular_computer/variables.dm index 373d2ad3e1f..59c45f993a2 100644 --- a/code/modules/modular_computers/computers/modular_computer/variables.dm +++ b/code/modules/modular_computers/computers/modular_computer/variables.dm @@ -24,6 +24,7 @@ // If you create a program which is limited to Laptops and Consoles you don't have to add it's icon_state overlay for Tablets too, for example. icon = null // This thing isn't meant to be used on it's own. Subtypes should supply their own icon. + blocks_emissive = FALSE var/overlay_icon = null // Icon file used for overlays icon_state = null center_of_mass = null // No pixelshifting by placing on tables, etc. diff --git a/code/modules/planet/planet.dm b/code/modules/planet/planet.dm index b069e2fddaf..293a64c9fbd 100644 --- a/code/modules/planet/planet.dm +++ b/code/modules/planet/planet.dm @@ -10,10 +10,10 @@ var/sun_last_process = null // world.time var/datum/weather_holder/weather_holder + var/datum/sun_holder/sun_holder var/sun_position = 0 // 0 means midnight, 1 means noon. - var/list/sun = list("range","brightness","color","lum_r","lum_g","lum_b") - var/list/datum/lighting_corner/sunlit_corners = list() + var/list/sun = list("range","brightness","color") var/list/expected_z_levels = list() var/turf/unsimulated/wall/planetary/planetary_wall_type = /turf/unsimulated/wall/planetary @@ -31,6 +31,7 @@ /datum/planet/New() ..() weather_holder = new(src) + sun_holder = new(src) current_time = current_time.make_random_time() if(moon_name) moon_phase = pick(list( diff --git a/code/modules/planet/sun.dm b/code/modules/planet/sun.dm new file mode 100644 index 00000000000..55f739d2178 --- /dev/null +++ b/code/modules/planet/sun.dm @@ -0,0 +1,53 @@ +/datum/sun_holder + var/atom/movable/sun_visuals/sun = new + var/datum/planet/our_planet + +/datum/sun_holder/New(var/source) + our_planet = source + +/datum/sun_holder/proc/update_color(new_color) + sun.color = new_color + +/datum/sun_holder/proc/update_brightness(new_brightness) + sun.alpha = round(CLAMP01(new_brightness)*255,1) + +/datum/sun_holder/proc/apply_to_turf(turf/T) + if(sun in T.vis_contents) + warning("Was asked to add fake sun to [T.x], [T.y], [T.z] despite already having us in it's vis contents") + return + T.vis_contents += sun + +/datum/sun_holder/proc/remove_from_turf(turf/T) + if(!(sun in T.vis_contents)) + warning("Was asked to remove fake sun from [T.x], [T.y], [T.z] despite it not having us in it's vis contents") + return + T.vis_contents -= sun + +/datum/sun_holder/proc/rainbow() + var/end = world.time + 30 SECONDS + + var/col_index = 1 + + var/list/colors = list("#ff5d5d","#ffd17b","#ffff5e","#7eff7e","#6868ff","#b753ff","#d08fff","#ffffff") + var/original_brightness = sun.alpha/255 + var/original_color = sun.color + + update_brightness(0.8) + + while(world.time < end) + update_color(colors[col_index]) + if(++col_index > colors.len) + col_index = 1 + sleep(3) + + update_brightness(original_brightness) + update_color(original_color) + +// Holds a full white icon that can be mutated to make sun on the O_LIGHTING plane +/atom/movable/sun_visuals + icon = 'icons/mob/screen_gen.dmi' + icon_state = "flash" + plane = PLANE_O_LIGHTING_VISUAL + mouse_opacity = 0 + alpha = 0 + color = "#FFFFFF" diff --git a/code/modules/planet/weather.dm b/code/modules/planet/weather.dm index c5202ab067c..48953a97f19 100644 --- a/code/modules/planet/weather.dm +++ b/code/modules/planet/weather.dm @@ -23,6 +23,20 @@ visuals = new() special_visuals = new() +/datum/weather_holder/proc/apply_to_turf(turf/T) + if(visuals in T.vis_contents) + warning("Was asked to add weather to [T.x], [T.y], [T.z] despite already having us in it's vis contents") + return + T.vis_contents += visuals + T.vis_contents += special_visuals + +/datum/weather_holder/proc/remove_from_turf(turf/T) + if(!(visuals in T.vis_contents)) + warning("Was asked to remove weather from [T.x], [T.y], [T.z] despite it not having us in it's vis contents") + return + T.vis_contents -= visuals + T.vis_contents -= special_visuals + /datum/weather_holder/proc/change_weather(var/new_weather) var/old_light_modifier = null var/datum/weather/old_weather = null diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index c576b96635f..4f7ac688d73 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -85,6 +85,7 @@ GLOBAL_LIST_EMPTY(apcs) use_power = USE_POWER_OFF clicksound = "switch" req_access = list(access_engine_equip) + blocks_emissive = FALSE var/area/area var/areastring = null var/obj/item/weapon/cell/cell @@ -128,10 +129,6 @@ GLOBAL_LIST_EMPTY(apcs) var/failure_timer = 0 var/force_update = 0 var/updating_icon = 0 - var/global/list/status_overlays_lock - var/global/list/status_overlays_charging - var/global/list/status_overlays_equipment - var/global/list/status_overlays_lighting var/global/list/status_overlays_environ var/alarms_hidden = FALSE //If power alarms from this APC are visible on consoles @@ -306,42 +303,6 @@ GLOBAL_LIST_EMPTY(apcs) // update the APC icon to show the three base states // also add overlays for indicator lights /obj/machinery/power/apc/update_icon() - if(!status_overlays) - status_overlays = 1 - status_overlays_lock = new - status_overlays_charging = new - status_overlays_equipment = new - status_overlays_lighting = new - status_overlays_environ = new - - status_overlays_lock.len = 2 - status_overlays_charging.len = 3 - status_overlays_equipment.len = 4 - status_overlays_lighting.len = 4 - status_overlays_environ.len = 4 - - status_overlays_lock[1] = image(icon, "apcox-0") // 0=blue 1=red - status_overlays_lock[2] = image(icon, "apcox-1") - - status_overlays_charging[1] = image(icon, "apco3-0") - status_overlays_charging[2] = image(icon, "apco3-1") - status_overlays_charging[3] = image(icon, "apco3-2") - - status_overlays_equipment[1] = image(icon, "apco0-0") - status_overlays_equipment[2] = image(icon, "apco0-1") - status_overlays_equipment[3] = image(icon, "apco0-2") - status_overlays_equipment[4] = image(icon, "apco0-3") - - status_overlays_lighting[1] = image(icon, "apco1-0") - status_overlays_lighting[2] = image(icon, "apco1-1") - status_overlays_lighting[3] = image(icon, "apco1-2") - status_overlays_lighting[4] = image(icon, "apco1-3") - - status_overlays_environ[1] = image(icon, "apco2-0") - status_overlays_environ[2] = image(icon, "apco2-1") - status_overlays_environ[3] = image(icon, "apco2-2") - status_overlays_environ[4] = image(icon, "apco2-3") - var/update = check_updates() //returns 0 if no need to update icons. // 1 if we need to update the icon_state // 2 if we need to update the overlays @@ -368,20 +329,25 @@ GLOBAL_LIST_EMPTY(apcs) icon_state = "apcemag" if(!(update_state & UPDATE_ALLGOOD)) - if(overlays.len) - overlays = 0 - return + cut_overlays() + return if(update & 2) - if(overlays.len) - overlays.len = 0 + cut_overlays() if(!(stat & (BROKEN|MAINT)) && update_state & UPDATE_ALLGOOD) - overlays += status_overlays_lock[locked+1] - overlays += status_overlays_charging[charging+1] + var/list/new_overlays = list() + new_overlays += mutable_appearance(icon, "apcox-[locked]") + new_overlays += emissive_appearance(icon, "apcox-[locked]") + new_overlays += mutable_appearance(icon, "apco3-[charging]") + new_overlays += emissive_appearance(icon, "apco3-[charging]") if(operating) - overlays += status_overlays_equipment[equipment+1] - overlays += status_overlays_lighting[lighting+1] - overlays += status_overlays_environ[environ+1] + new_overlays += mutable_appearance(icon, "apco0-[equipment]") + new_overlays += emissive_appearance(icon, "apco0-[equipment]") + new_overlays += mutable_appearance(icon, "apco1-[lighting]") + new_overlays += emissive_appearance(icon, "apco1-[lighting]") + new_overlays += mutable_appearance(icon, "apco2-[environ]") + new_overlays += emissive_appearance(icon, "apco2-[environ]") + add_overlay(new_overlays) if(update & 3) if(update_state & UPDATE_BLUESCREEN) diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index 67cd3bb51ab..f7350a3daa7 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -283,7 +283,7 @@ var/global/list/light_type_cache = list() plane = OBJ_PLANE layer = OBJ_LAYER desc = "A floor lamp." - light_type = /obj/item/weapon/light/bulb + light_type = /obj/item/weapon/light/bulb/large construct_type = /obj/machinery/light_construct/flamp shows_alerts = FALSE //VOREStation Edit var/lamp_shade = 1 @@ -885,20 +885,34 @@ var/global/list/light_type_cache = list() force = 2 throwforce = 5 w_class = ITEMSIZE_TINY - var/status = 0 // LIGHT_OK, LIGHT_BURNED or LIGHT_BROKEN - var/base_state - var/switchcount = 0 // number of times switched matter = list(DEFAULT_WALL_MATERIAL = 60) - var/rigged = 0 // true if rigged to explode + + ///LIGHT_OK, LIGHT_BURNED or LIGHT_BROKEN + var/status = 0 + ///Base icon_state name to append suffixes for status + var/base_state + ///Number of times switched on/off + var/switchcount = 0 + ///Is this light set to explode + var/rigged = 0 + ///The chance (prob()) that this light will be broken at roundstart var/broken_chance = 2 - var/brightness_range = 2 //how much light it gives off + ///The raidus in turfs this light will reach. It will be at it's most dim this many turfs away. + /// This is also used in power draw calculation for machinery/lights. + var/brightness_range = 8 + ///The light will fall off over more/less range based on this. The formula is complicated. var/brightness_power = 1 + ///The color of the light emitted. var/brightness_color = LIGHT_COLOR_INCANDESCENT_TUBE + ///Replaces brightness_range during nightshifts. var/nightshift_range = 8 - var/nightshift_power = 1 + ///Replaces brightness_power during nightshifts. + var/nightshift_power = 0.45 + ///Replaces brightness_color during nightshifts. var/nightshift_color = LIGHT_COLOR_NIGHTSHIFT + drop_sound = 'sound/items/drop/glass.ogg' pickup_sound = 'sound/items/pickup/glass.ogg' @@ -909,14 +923,14 @@ var/global/list/light_type_cache = list() base_state = "ltube" item_state = "c_tube" matter = list("glass" = 100) - brightness_range = 10 // luminosity when on, also used in power calculation //VOREStation Edit - brightness_power = 6 + brightness_range = 7 + brightness_power = 2 /obj/item/weapon/light/tube/large w_class = ITEMSIZE_SMALL name = "large light tube" brightness_range = 15 - brightness_power = 9 + brightness_power = 4 nightshift_range = 10 nightshift_power = 1.5 @@ -929,12 +943,21 @@ var/global/list/light_type_cache = list() item_state = "contvapour" matter = list("glass" = 100) brightness_range = 5 - brightness_power = 4 + brightness_power = 1 brightness_color = LIGHT_COLOR_INCANDESCENT_BULB nightshift_range = 3 nightshift_power = 0.5 +// For 'floor lamps' in outdoor use and such +/obj/item/weapon/light/bulb/large + name = "large light bulb" + brightness_range = 7 + brightness_power = 1.5 + + nightshift_range = 4 + nightshift_power = 0.75 + /obj/item/weapon/light/throw_impact(atom/hit_atom) ..() shatter() diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 6cd885f0c17..4a1be60a5eb 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -11,6 +11,9 @@ pass_flags = PASSTABLE mouse_opacity = 0 hitsound = 'sound/weapons/pierce.ogg' + + blocks_emissive = EMISSIVE_BLOCK_GENERIC + var/hitsound_wall = null // Played when something hits a wall, or anything else that isn't a mob. ////TG PROJECTILE SYTSEM diff --git a/icons/effects/light_overlays/light_128.dmi b/icons/effects/light_overlays/light_128.dmi new file mode 100644 index 00000000000..22dc0b01087 Binary files /dev/null and b/icons/effects/light_overlays/light_128.dmi differ diff --git a/icons/effects/light_overlays/light_160.dmi b/icons/effects/light_overlays/light_160.dmi new file mode 100644 index 00000000000..26dfa453c51 Binary files /dev/null and b/icons/effects/light_overlays/light_160.dmi differ diff --git a/icons/effects/light_overlays/light_192.dmi b/icons/effects/light_overlays/light_192.dmi new file mode 100644 index 00000000000..aca94ee0caf Binary files /dev/null and b/icons/effects/light_overlays/light_192.dmi differ diff --git a/icons/effects/light_overlays/light_224.dmi b/icons/effects/light_overlays/light_224.dmi new file mode 100644 index 00000000000..9fab531d1a6 Binary files /dev/null and b/icons/effects/light_overlays/light_224.dmi differ diff --git a/icons/effects/light_overlays/light_256.dmi b/icons/effects/light_overlays/light_256.dmi new file mode 100644 index 00000000000..701562efcd8 Binary files /dev/null and b/icons/effects/light_overlays/light_256.dmi differ diff --git a/icons/effects/light_overlays/light_288.dmi b/icons/effects/light_overlays/light_288.dmi new file mode 100644 index 00000000000..b6eac180f7a Binary files /dev/null and b/icons/effects/light_overlays/light_288.dmi differ diff --git a/icons/effects/light_overlays/light_32.dmi b/icons/effects/light_overlays/light_32.dmi new file mode 100644 index 00000000000..5269b1fba36 Binary files /dev/null and b/icons/effects/light_overlays/light_32.dmi differ diff --git a/icons/effects/light_overlays/light_320.dmi b/icons/effects/light_overlays/light_320.dmi new file mode 100644 index 00000000000..bf263c4b29b Binary files /dev/null and b/icons/effects/light_overlays/light_320.dmi differ diff --git a/icons/effects/light_overlays/light_352.dmi b/icons/effects/light_overlays/light_352.dmi new file mode 100644 index 00000000000..f895792da42 Binary files /dev/null and b/icons/effects/light_overlays/light_352.dmi differ diff --git a/icons/effects/light_overlays/light_64.dmi b/icons/effects/light_overlays/light_64.dmi new file mode 100644 index 00000000000..37fc5084abc Binary files /dev/null and b/icons/effects/light_overlays/light_64.dmi differ diff --git a/icons/effects/light_overlays/light_96.dmi b/icons/effects/light_overlays/light_96.dmi new file mode 100644 index 00000000000..b689a137016 Binary files /dev/null and b/icons/effects/light_overlays/light_96.dmi differ diff --git a/icons/effects/light_overlays/light_cone.dmi b/icons/effects/light_overlays/light_cone.dmi new file mode 100644 index 00000000000..75f322a9371 Binary files /dev/null and b/icons/effects/light_overlays/light_cone.dmi differ diff --git a/icons/effects/lighting_object.dmi b/icons/effects/lighting_object.dmi new file mode 100644 index 00000000000..4b75e0f6c9a Binary files /dev/null and b/icons/effects/lighting_object.dmi differ diff --git a/icons/effects/lighting_overlay.dmi b/icons/effects/lighting_overlay.dmi deleted file mode 100644 index 80807db1e62..00000000000 Binary files a/icons/effects/lighting_overlay.dmi and /dev/null differ diff --git a/icons/mob/screen_gen.dmi b/icons/mob/screen_gen.dmi index 75ba00f026d..00dc3f02a6f 100644 Binary files a/icons/mob/screen_gen.dmi and b/icons/mob/screen_gen.dmi differ diff --git a/icons/obj/monitors.dmi b/icons/obj/monitors.dmi index 268fa41af95..6454490dbae 100644 Binary files a/icons/obj/monitors.dmi and b/icons/obj/monitors.dmi differ diff --git a/vorestation.dme b/vorestation.dme index 4d850a9a724..1e8a6a776cb 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -132,6 +132,7 @@ #include "code\_helpers\global_lists_vr.dm" #include "code\_helpers\icons.dm" #include "code\_helpers\icons_vr.dm" +#include "code\_helpers\lighting.dm" #include "code\_helpers\logging.dm" #include "code\_helpers\logging_vr.dm" #include "code\_helpers\matrices.dm" @@ -296,6 +297,7 @@ #include "code\controllers\subsystems\time_track.dm" #include "code\controllers\subsystems\timer.dm" #include "code\controllers\subsystems\transcore_vr.dm" +#include "code\controllers\subsystems\vis_overlays.dm" #include "code\controllers\subsystems\vote.dm" #include "code\controllers\subsystems\webhooks.dm" #include "code\controllers\subsystems\xenoarch.dm" @@ -351,12 +353,14 @@ #include "code\datums\autolathe\tools_vr.dm" #include "code\datums\components\_component.dm" #include "code\datums\components\material_container.dm" +#include "code\datums\components\overlay_lighting.dm" #include "code\datums\components\resize_guard.dm" #include "code\datums\components\crafting\crafting.dm" #include "code\datums\components\crafting\crafting_external.dm" #include "code\datums\components\crafting\recipes.dm" #include "code\datums\components\crafting\tool_quality.dm" #include "code\datums\elements\_element.dm" +#include "code\datums\elements\light_blocking.dm" #include "code\datums\game_masters\_common.dm" #include "code\datums\helper_datums\construction_datum.dm" #include "code\datums\helper_datums\events.dm" @@ -2450,6 +2454,7 @@ #include "code\modules\library\hardcode_library\reference\PortedBooks.dm" #include "code\modules\library\hardcode_library\reference\Schnayy.dm" #include "code\modules\library\hardcode_library\religious\PortedBooks.dm" +#include "code\modules\lighting\emissive_blocker.dm" #include "code\modules\lighting\lighting_area.dm" #include "code\modules\lighting\lighting_atom.dm" #include "code\modules\lighting\lighting_corner.dm" @@ -3332,6 +3337,7 @@ #include "code\modules\persistence\storage\smartfridge.dm" #include "code\modules\persistence\storage\storage.dm" #include "code\modules\planet\planet.dm" +#include "code\modules\planet\sun.dm" #include "code\modules\planet\time.dm" #include "code\modules\planet\virgo3b_vr.dm" #include "code\modules\planet\virgo4_vr.dm"