From e1956df14979c21555a7fb3daf7df62910d4a632 Mon Sep 17 00:00:00 2001 From: "L.E.D" Date: Sun, 6 Nov 2016 09:51:16 -0500 Subject: [PATCH] Glorious /vg/ Lighting Port (#66) * fuck * [CANT WAKE UP] * AAAAAAAAAHHHHHHHHHHHH * SAAAAVE MEEEEEEEEEEEEEEEE * this is so bad how can i even call myself a coder * thanks fam * hello darkness my old friend i've come to talk with you again * ugh go away * OH * much less broken * ayy * aaaaa * OH YEAAAAAAAAHHHHHHHHHHH * aaaa * k * dfgjtxkytkjyd * debug * dangerously cheesy * mm * OH YEAAAAAAAAAAAAAAAAAAAAAAAAAA * oH YEAH * Some final touches and cleanup of the lighting port. * One more * More fixes. * varedit hack for easy modification * fixed * C O L O R * slym * fffff * oh great what the fuck is wrong now * Revert "oh great what the fuck is wrong now" This reverts commit e589ad51facb5464e107ca515317d41136dd1e5e. * fu * will it blend * aaaaaaaaaaaaaaaaaaaa * this is why im bad at porting falalalala, lala la la * k * yeh * can't forget majestic fire --- code/__DEFINES/{MC.dm => _MC.dm} | 0 code/__DEFINES/lighting.dm | 79 ++++ code/__DEFINES/misc.dm | 8 - code/__HELPERS/maths.dm | 1 + code/__HELPERS/type2type.dm | 11 + code/__HELPERS/unsorted.dm | 35 ++ code/citadel/dogborgstuff.dm | 2 +- code/controllers/subsystem.dm | 1 - code/controllers/subsystem/lighting.dm | 137 ++---- code/game/area/Space_Station_13_areas.dm | 22 +- code/game/area/areas.dm | 4 +- code/game/atoms.dm | 6 + code/game/atoms_movable.dm | 2 +- .../gamemodes/clock_cult/clock_machines.dm | 6 +- code/game/gamemodes/clock_cult/clock_mobs.dm | 4 +- .../gamemodes/clock_cult/clock_structures.dm | 4 +- code/game/gamemodes/gang/dominator.dm | 6 +- .../gamemodes/miniantags/bot_swarm/swarmer.dm | 4 +- code/game/machinery/Sleeper.dm | 5 + code/game/machinery/announcement_system.dm | 5 + code/game/machinery/autolathe.dm | 5 + code/game/machinery/camera/camera.dm | 8 +- code/game/machinery/computer/Operating.dm | 3 +- code/game/machinery/computer/aifixer.dm | 3 +- code/game/machinery/computer/arcade.dm | 2 + code/game/machinery/computer/atmos_alert.dm | 3 +- code/game/machinery/computer/atmos_control.dm | 1 + code/game/machinery/computer/camera.dm | 3 + code/game/machinery/computer/card.dm | 4 + code/game/machinery/computer/cloning.dm | 1 + .../game/machinery/computer/communications.dm | 2 + code/game/machinery/computer/computer.dm | 10 +- code/game/machinery/computer/crew.dm | 1 + code/game/machinery/computer/dna_console.dm | 1 + .../machinery/computer/gulag_teleporter.dm | 8 +- code/game/machinery/computer/medical.dm | 1 + code/game/machinery/computer/message.dm | 5 +- code/game/machinery/computer/pod.dm | 3 + code/game/machinery/computer/prisoner.dm | 3 +- code/game/machinery/computer/robot.dm | 1 + code/game/machinery/computer/security.dm | 1 + code/game/machinery/computer/station_alert.dm | 3 +- .../machinery/computer/telecrystalconsoles.dm | 1 + code/game/machinery/dna_scanner.dm | 6 +- code/game/machinery/doors/airlock.dm | 6 +- code/game/machinery/doors/door.dm | 6 +- code/game/machinery/doors/windowdoor.dm | 2 +- code/game/machinery/doppler_array.dm | 2 +- code/game/machinery/gulag_item_reclaimer.dm | 6 +- code/game/machinery/hologram.dm | 6 +- code/game/machinery/igniter.dm | 4 +- code/game/machinery/lightswitch.dm | 3 +- code/game/machinery/machinery.dm | 4 + code/game/machinery/newscaster.dm | 7 +- code/game/machinery/requests_console.dm | 11 +- code/game/machinery/slotmachine.dm | 1 + code/game/machinery/suit_storage_unit.dm | 7 +- .../telecomms/computers/logbrowser.dm | 2 + .../telecomms/computers/telemonitor.dm | 3 +- .../machinery/telecomms/machines/receiver.dm | 3 +- .../machinery/telecomms/telecomunications.dm | 5 + code/game/machinery/teleporter.dm | 1 + code/game/machinery/wishgranter.dm | 8 +- code/game/mecha/mech_bay.dm | 1 + code/game/mecha/mecha_actions.dm | 4 +- code/game/objects/effects/anomalies.dm | 2 +- code/game/objects/effects/glowshroom.dm | 2 +- code/game/objects/items/blueprints.dm | 4 +- code/game/objects/items/candle.dm | 19 +- code/game/objects/items/crayons.dm | 4 +- code/game/objects/items/devices/PDA/PDA.dm | 29 +- code/game/objects/items/devices/flashlight.dm | 52 +-- code/game/objects/items/devices/powersink.dm | 4 +- .../objects/items/weapons/cigs_lighters.dm | 29 +- .../game/objects/items/weapons/clown_items.dm | 2 +- code/game/objects/structures.dm | 2 +- code/game/objects/structures/false_walls.dm | 4 +- code/game/pooling/pool.dm | 32 ++ .../game/turfs/simulated/floor/light_floor.dm | 12 +- code/game/turfs/simulated/floor/plating.dm | 4 +- code/game/turfs/space/space.dm | 6 +- code/game/turfs/turf.dm | 3 +- code/modules/admin/admin_verbs.dm | 2 +- code/modules/admin/verbs/fps.dm | 4 +- code/modules/admin/verbs/mapping.dm | 2 +- code/modules/admin/verbs/massmodvar.dm | 14 +- code/modules/admin/verbs/modifyvariables.dm | 19 +- .../atmospherics/environmental/LINDA_fire.dm | 2 +- .../awaymissions/mission_code/Cabin.dm | 8 +- .../awaymissions/mission_code/researchbase.dm | 2 +- .../awaymissions/mission_code/snowdin.dm | 2 +- code/modules/awaymissions/signpost.dm | 2 +- code/modules/cargo/console.dm | 2 +- code/modules/clothing/head/hardhat.dm | 19 +- code/modules/clothing/head/helmet.dm | 32 +- code/modules/clothing/spacesuits/hardsuit.dm | 22 +- code/modules/events/spacevine.dm | 10 +- code/modules/holodeck/areas.dm | 4 +- code/modules/holodeck/computer.dm | 3 +- code/modules/hydroponics/biogenerator.dm | 4 + code/modules/hydroponics/grown.dm | 30 +- code/modules/hydroponics/growninedible.dm | 28 +- code/modules/hydroponics/hydroponics.dm | 8 +- code/modules/hydroponics/plant_genes.dm | 2 +- code/modules/hydroponics/seed_extractor.dm | 4 + code/modules/lighting/__lighting_docs.dm | 74 +++ code/modules/lighting/lighting_area.dm | 30 ++ code/modules/lighting/lighting_atom.dm | 105 +++++ code/modules/lighting/lighting_corner.dm | 137 ++++++ code/modules/lighting/lighting_overlay.dm | 112 +++++ code/modules/lighting/lighting_setup.dm | 17 + code/modules/lighting/lighting_source.dm | 305 +++++++++++++ code/modules/lighting/lighting_system.dm | 428 ------------------ code/modules/lighting/lighting_turf.dm | 153 +++++++ code/modules/lighting/~lighting_undefs.dm | 12 + code/modules/mining/equipment.dm | 11 +- code/modules/mining/laborcamp/laborshuttle.dm | 3 +- code/modules/mining/mine_items.dm | 3 +- code/modules/mob/living/living_defense.dm | 4 +- code/modules/mob/living/silicon/ai/ai.dm | 2 +- .../modules/mob/living/silicon/robot/robot.dm | 4 +- .../mob/living/simple_animal/bot/bot.dm | 6 +- .../mob/living/simple_animal/friendly/dog.dm | 2 +- .../friendly/drone/extra_drone_types.dm | 2 +- .../simple_animal/friendly/drone/verbs.dm | 5 +- .../living/simple_animal/guardian/guardian.dm | 4 +- .../living/simple_animal/hostile/statue.dm | 4 +- code/modules/mob/mob.dm | 14 +- code/modules/power/lighting.dm | 8 +- code/modules/power/monitor.dm | 1 + code/modules/power/power.dm | 9 + code/modules/power/solar.dm | 10 +- code/modules/projectiles/gun.dm | 25 +- code/modules/projectiles/projectile/energy.dm | 2 +- .../chemistry/machinery/chem_master.dm | 4 + .../research/xenobiology/xenobio_camera.dm | 1 + code/modules/shuttle/shuttle.dm | 4 +- code/modules/stock_market/computer.dm | 2 + config/game_options.txt | 2 +- icons/effects/lighting_overlay.png | Bin 0 -> 1542 bytes tgstation.dme | 13 +- 141 files changed, 1508 insertions(+), 958 deletions(-) rename code/__DEFINES/{MC.dm => _MC.dm} (100%) create mode 100644 code/__DEFINES/lighting.dm create mode 100644 code/modules/lighting/__lighting_docs.dm create mode 100644 code/modules/lighting/lighting_area.dm create mode 100644 code/modules/lighting/lighting_atom.dm create mode 100644 code/modules/lighting/lighting_corner.dm create mode 100644 code/modules/lighting/lighting_overlay.dm create mode 100644 code/modules/lighting/lighting_setup.dm create mode 100644 code/modules/lighting/lighting_source.dm delete mode 100644 code/modules/lighting/lighting_system.dm create mode 100644 code/modules/lighting/lighting_turf.dm create mode 100644 code/modules/lighting/~lighting_undefs.dm create mode 100644 icons/effects/lighting_overlay.png diff --git a/code/__DEFINES/MC.dm b/code/__DEFINES/_MC.dm similarity index 100% rename from code/__DEFINES/MC.dm rename to code/__DEFINES/_MC.dm diff --git a/code/__DEFINES/lighting.dm b/code/__DEFINES/lighting.dm new file mode 100644 index 0000000000..d3915d6584 --- /dev/null +++ b/code/__DEFINES/lighting.dm @@ -0,0 +1,79 @@ +#define DYNAMIC_LIGHTING_DISABLED 0 //dynamic lighting disabled (area stays at full brightness) +#define DYNAMIC_LIGHTING_ENABLED 1 //dynamic lighting enabled +#define DYNAMIC_LIGHTING_IFSTARLIGHT 2 //dynamic lighting enabled only if starlight is. +#define IS_DYNAMIC_LIGHTING(A) ( A.dynamic_lighting == DYNAMIC_LIGHTING_IFSTARLIGHT ? config.starlight : A.dynamic_lighting ) + + +//Bay lighting engine shit, not in /code/modules/lighting because BYOND is being shit about it +#define LIGHTING_INTERVAL 5 // frequency, in 1/10ths of a second, of the lighting process + +#ifndef LIGHTING_INSTANT_UPDATES +#define LIGHTING_INTERVAL 5 // Frequency, in 1/10ths of a second, of the lighting process. +#include "../controllers/subsystem/lighting.dm" +#endif + +#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 +#define LIGHTING_ROUND_VALUE 1 / 128 //Value used to round lumcounts, values smaller than 1/255 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_ICON 'icons/effects/lighting_overlay.png' // icon used for lighting shading effects + +#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. + +// 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, \ + 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 + +//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_CYAN "#7DE1E1" //Diluted cyan. rgb(125, 225, 225) +#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) + +//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_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) + +#define FOR_DVIEW(type, range, center, invis_flags) \ + dview_mob.forceMove(center); \ + dview_mob.see_invisible = invis_flags; \ + for(type in view(range, dview_mob)) diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 83c1b36b28..0d740458d1 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -307,14 +307,6 @@ var/list/bloody_footprints_cache = list() #define POLLTYPE_MULTI "MULTICHOICE" #define POLLTYPE_IRV "IRV" - - -//lighting area defines -#define DYNAMIC_LIGHTING_DISABLED 0 //dynamic lighting disabled (area stays at full brightness) -#define DYNAMIC_LIGHTING_ENABLED 1 //dynamic lighting enabled -#define DYNAMIC_LIGHTING_IFSTARLIGHT 2 //dynamic lighting enabled only if starlight is. -#define IS_DYNAMIC_LIGHTING(A) ( A.lighting_use_dynamic == DYNAMIC_LIGHTING_IFSTARLIGHT ? config.starlight : A.lighting_use_dynamic ) - //subtypesof(), typesof() without the parent path #define subtypesof(typepath) ( typesof(typepath) - typepath ) diff --git a/code/__HELPERS/maths.dm b/code/__HELPERS/maths.dm index c64350a8a6..9e34764192 100644 --- a/code/__HELPERS/maths.dm +++ b/code/__HELPERS/maths.dm @@ -21,6 +21,7 @@ var/list/sqrtTable = list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, return -round(-x / y) * y #define Clamp(CLVALUE,CLMIN,CLMAX) ( max( (CLMIN), min((CLVALUE), (CLMAX)) ) ) +#define CLAMP01(x) (Clamp(x,0,1)) // cotangent /proc/Cot(x) diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index 46f4ae0d2a..c186481cde 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -574,6 +574,17 @@ for(var/t in test_times) var/B = hex2num(copytext(A,6,0)) return R+G+B +//get just one color +/proc/GetRedPart(A) + return hex2num(copytext(A,2,4)) + +/proc/GetGreenPart(A) + return hex2num(copytext(A,4,6)) + +/proc/GetBluePart(A) + return hex2num(copytext(A,6,0)) + + //Converts a positive interger to its roman numeral equivilent. Ignores any decimals. //Numbers over 3999 will display with extra "M"s (don't tell the Romans) and can get comically long, so be careful. /proc/num2roman(A) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index d470785dad..19ff525dc8 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -359,6 +359,41 @@ Turf and target are seperate in case you want to teleport some distance from a t moblist.Add(M) return moblist +/var/mob/dview/dview_mob = new + +//Version of view() which ignores darkness, because BYOND doesn't have it (I actually suggested it but it was tagged redundant, BUT HEARERS IS A T- /rant). +/proc/dview(var/range = world.view, var/center, var/invis_flags = 0) + if(!center) + return + + dview_mob.forceMove(center) + + dview_mob.see_invisible = invis_flags + + . = view(range, dview_mob) + dview_mob.forceMove(null) + +/mob/dview + invisibility = 101 + density = 0 + see_in_dark = 1e6 + anchored = 1 + +// Finds ALL mobs on turfs in line of sight. Similar to "in dview", but catches mobs that are not on a turf (e.g. inside a locker or such). +/proc/get_all_mobs_in_dview(var/turf/T, var/range = world.view, var/list/ignore_types = list()) + . = list() + var/list/can_see = dview(range, T) + for(var/mob/M in can_see) + if(is_type_in_list(M, ignore_types)) + continue + . += M + for(var/mob/M in mob_list) //Got the ones in vision, now let's go for the ones not on a turf. + if(M.z == 0) //Mobs not on a turf will have XYZ = 0,0,0. They also won't show up in dview() so we're not checking anything twice. + if(is_type_in_list(M, ignore_types)) + continue + if(get_turf(M) in can_see) //Checking the mob's turf now, since those are it's "true" coordinates (plus dview() did pick up on turfs, so we can check using that). + . += M + //E = MC^2 /proc/convert2energy(M) var/E = M*(SPEED_OF_LIGHT_SQ) diff --git a/code/citadel/dogborgstuff.dm b/code/citadel/dogborgstuff.dm index 8fb3916132..c9a191b433 100644 --- a/code/citadel/dogborgstuff.dm +++ b/code/citadel/dogborgstuff.dm @@ -262,7 +262,7 @@ if(do_after(user, src.cleanspeed, target = target)) user << "You clean \the [target.name]." target.color = initial(target.color) - target.SetOpacity(initial(target.opacity)) + target.set_opacity(initial(target.opacity)) else user.visible_message("[user] begins to lick \the [target.name] clean...", "You begin to lick \the [target.name] clean...") if(do_after(user, src.cleanspeed, target = target)) diff --git a/code/controllers/subsystem.dm b/code/controllers/subsystem.dm index dc86c45a32..8cd011932b 100644 --- a/code/controllers/subsystem.dm +++ b/code/controllers/subsystem.dm @@ -161,4 +161,3 @@ if (edited_var == "can_fire" && can_fire) next_fire = world.time + wait ..() - diff --git a/code/controllers/subsystem/lighting.dm b/code/controllers/subsystem/lighting.dm index 388ca3e231..2eac9a1021 100644 --- a/code/controllers/subsystem/lighting.dm +++ b/code/controllers/subsystem/lighting.dm @@ -1,116 +1,65 @@ + var/datum/subsystem/lighting/SSlighting -#define SSLIGHTING_LIGHTS 1 -#define SSLIGHTING_TURFS 2 +/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. + +/var/list/lighting_update_lights_old = list() // List of lighting sources currently being updated. +/var/list/lighting_update_corners_old = list() // List of lighting corners currently being updated. +/var/list/lighting_update_overlays_old = list() // List of lighting overlays currently being updated. /datum/subsystem/lighting - name = "Lighting" + name = "lighting" init_order = 1 - wait = 1 - flags = SS_POST_FIRE_TIMING - priority = 40 + wait = 2 display_order = 5 - - var/list/changed_lights = list() //list of all datum/light_source that need updating - var/changed_lights_workload = 0 //stats on the largest number of lights (max changed_lights.len) - var/list/changed_turfs = list() //list of all turfs which may have a different light level - var/changed_turfs_workload = 0 //stats on the largest number of turfs changed (max changed_turfs.len) + priority = 40 + flags = SS_POST_FIRE_TIMING /datum/subsystem/lighting/New() NEW_SS_GLOBAL(SSlighting) return ..() - -/datum/subsystem/lighting/stat_entry() - ..("L:[round(changed_lights_workload,1)]|T:[round(changed_turfs_workload,1)]") - - -//Workhorse of lighting. It cycles through each light that needs updating. It updates their -//effects and then processes every turf in the queue, updating their lighting object's appearance -//Any light that returns 1 in check() deletes itself -//By using queues we are ensuring we don't perform more updates than are necessary -/datum/subsystem/lighting/fire(resumed = 0) - var/ticklimit = CURRENT_TICKLIMIT - //split our tick allotment in half so we don't spend it all on lightshift checks - CURRENT_TICKLIMIT = world.tick_usage + ((ticklimit-world.tick_usage)/2) - - var/list/changed_lights = src.changed_lights - if (!resumed) - changed_lights_workload = MC_AVERAGE(changed_lights_workload, changed_lights.len) - var/i = 1 - while (i <= changed_lights.len) - var/datum/light_source/LS = changed_lights[i++] - LS.check() - if (MC_TICK_CHECK) - break - if (i > 1) - changed_lights.Cut(1,i) - - CURRENT_TICKLIMIT = ticklimit - var/list/changed_turfs = src.changed_turfs - if (!resumed) - changed_turfs_workload = MC_AVERAGE(changed_turfs_workload, changed_turfs.len) - i = 1 - while (i <= changed_turfs.len) - var/turf/T = changed_turfs[i++] - if(T.lighting_changed) - T.redraw_lighting() - if (MC_TICK_CHECK) - break - if (i > 1) - changed_turfs.Cut(1,i) - -//same as above except it attempts to shift ALL turfs in the world regardless of lighting_changed status -/datum/subsystem/lighting/Initialize(timeofday) - var/list/turfs_to_init = block(locate(1, 1, 1), locate(world.maxx, world.maxy, world.maxz)) +/datum/subsystem/lighting/Initialize() if (config.starlight) for(var/area/A in world) - if (A.lighting_use_dynamic == DYNAMIC_LIGHTING_IFSTARLIGHT) + if (A.dynamic_lighting == DYNAMIC_LIGHTING_IFSTARLIGHT) A.luminosity = 0 - for(var/thing in changed_lights) - var/datum/light_source/LS = thing - LS.check() - changed_lights.Cut() + create_all_lighting_overlays() - for(var/thing in turfs_to_init) - var/turf/T = thing - T.init_lighting() - changed_turfs.Cut() +/datum/subsystem/lighting/fire() - ..() + lighting_update_lights_old = lighting_update_lights //We use a different list so any additions to the update lists during a delay from scheck() don't cause things to be cut from the list without being updated. + lighting_update_lights = list() + for(var/datum/light_source/L in lighting_update_lights_old) -//Used to strip valid information from an existing instance and transfer it to the replacement. i.e. when a crash occurs -//It works by using spawn(-1) to transfer the data, if there is a runtime the data does not get transfered but the loop -//does not crash -/datum/subsystem/lighting/Recover() - if(!istype(SSlighting.changed_turfs)) - SSlighting.changed_turfs = list() - if(!istype(SSlighting.changed_lights)) - SSlighting.changed_lights = list() + if(L.check() || L.destroyed || L.force_update) + L.remove_lum() + if(!L.destroyed) + L.apply_lum() - for(var/thing in SSlighting.changed_lights) - var/datum/light_source/LS = thing - spawn(-1) //so we don't crash the loop (inefficient) - LS.check() + else if(L.vis_update) //We smartly update only tiles that became (in) visible to use. + L.smart_vis_update() - for(var/thing in changed_turfs) - var/turf/T = thing - if(T.lighting_changed) - spawn(-1) - T.redraw_lighting() + L.vis_update = FALSE + L.force_update = FALSE + L.needs_update = FALSE - var/msg = "## DEBUG: [time2text(world.timeofday)] [name] subsystem restarted. Reports:\n" - for(var/varname in SSlighting.vars) - switch(varname) - if("tag","bestF","type","parent_type","vars") - continue - else - var/varval1 = SSlighting.vars[varname] - var/varval2 = vars[varname] - if(istype(varval1,/list)) - varval1 = "/list([length(varval1)])" - varval2 = "/list([length(varval2)])" - msg += "\t [varname] = [varval1] -> [varval2]\n" - world.log << msg + lighting_update_corners_old = lighting_update_corners //Same as above. + lighting_update_corners = list() + for(var/A in lighting_update_corners_old) + var/datum/lighting_corner/C = A + + C.update_overlays() + + C.needs_update = FALSE + + lighting_update_overlays_old = lighting_update_overlays //Same as above. + lighting_update_overlays = list() + + for(var/atom/movable/lighting_overlay/O in lighting_update_overlays_old) + O.update_overlay() + O.needs_update = 0 diff --git a/code/game/area/Space_Station_13_areas.dm b/code/game/area/Space_Station_13_areas.dm index 574749c44b..0b56781b1b 100644 --- a/code/game/area/Space_Station_13_areas.dm +++ b/code/game/area/Space_Station_13_areas.dm @@ -98,7 +98,7 @@ var/list/teleportlocs = list() icon_state = "space" requires_power = 1 always_unpowered = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_DISABLED + dynamic_lighting = DYNAMIC_LIGHTING_DISABLED power_light = 0 power_equip = 0 power_environ = 0 @@ -109,7 +109,7 @@ var/list/teleportlocs = list() /area/space/nearstation icon_state = "space_near" - lighting_use_dynamic = DYNAMIC_LIGHTING_IFSTARLIGHT + dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT //These are shuttle areas; all subtypes are only used as teleportation markers, they have no actual function beyond that. @@ -117,7 +117,7 @@ var/list/teleportlocs = list() name = "Shuttle" requires_power = 0 luminosity = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_ENABLED + dynamic_lighting = DYNAMIC_LIGHTING_ENABLED has_gravity = 1 valid_territory = 0 icon_state = "shuttle" @@ -166,7 +166,7 @@ var/list/teleportlocs = list() icon_state = "start" requires_power = 0 luminosity = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_DISABLED + dynamic_lighting = DYNAMIC_LIGHTING_DISABLED has_gravity = 1 // CENTCOM @@ -237,7 +237,7 @@ var/list/teleportlocs = list() /area/asteroid/artifactroom/New() ..() - SetDynamicLighting() + dynamic_lighting = TRUE /area/planet/clown name = "Clown Planet" @@ -656,7 +656,7 @@ var/list/teleportlocs = list() /area/solar requires_power = 0 luminosity = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_IFSTARLIGHT + dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT valid_territory = 0 /area/solar/auxport @@ -1239,25 +1239,25 @@ var/list/teleportlocs = list() name = "AI Sat Ext" icon_state = "storage" luminosity = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_IFSTARLIGHT + dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT /area/turret_protected/AIsatextFS name = "AI Sat Ext" icon_state = "storage" luminosity = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_IFSTARLIGHT + dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT /area/turret_protected/AIsatextAS name = "AI Sat Ext" icon_state = "storage" luminosity = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_IFSTARLIGHT + dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT /area/turret_protected/AIsatextAP name = "AI Sat Ext" icon_state = "storage" luminosity = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_IFSTARLIGHT + dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT /area/turret_protected/NewAIMain name = "AI Main New" @@ -1380,7 +1380,7 @@ var/list/teleportlocs = list() name = "Beach" icon_state = "away" luminosity = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_DISABLED + dynamic_lighting = DYNAMIC_LIGHTING_DISABLED requires_power = 0 has_gravity = 1 ambientsounds = list('sound/ambience/shore.ogg', 'sound/ambience/seag1.ogg','sound/ambience/seag2.ogg','sound/ambience/seag2.ogg') diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 5032ea6ec2..6a61ada3fb 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -39,8 +39,8 @@ power_equip = 1 power_environ = 1 - if (lighting_use_dynamic != DYNAMIC_LIGHTING_IFSTARLIGHT) - lighting_use_dynamic = DYNAMIC_LIGHTING_DISABLED + if (dynamic_lighting != DYNAMIC_LIGHTING_IFSTARLIGHT) + dynamic_lighting = DYNAMIC_LIGHTING_DISABLED ..() diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 4896dc1e0f..4eb9476e51 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -339,6 +339,12 @@ var/list/blood_splatter_icons = list() /atom/proc/wash_cream() return 1 +/atom/proc/change_area(var/area/oldarea, var/area/newarea) + change_area_name(oldarea.name, newarea.name) + +/atom/proc/change_area_name(var/oldname, var/newname) + name = replacetext(name,oldname,newname) + /atom/proc/get_global_map_pos() if(!islist(global_map) || isemptylist(global_map)) return var/cur_x = null diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 4f94616b11..4a5dd97ac3 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -366,4 +366,4 @@ //called when a mob resists while inside a container that is itself inside something. /atom/movable/proc/relay_container_resist(mob/living/user, obj/O) - return \ No newline at end of file + return diff --git a/code/game/gamemodes/clock_cult/clock_machines.dm b/code/game/gamemodes/clock_cult/clock_machines.dm index 8db2ed225b..6cf77b1f98 100644 --- a/code/game/gamemodes/clock_cult/clock_machines.dm +++ b/code/game/gamemodes/clock_cult/clock_machines.dm @@ -400,9 +400,9 @@ /obj/structure/clockwork/powered/interdiction_lens/toggle(fast_process, mob/living/user) ..() if(active) - SetLuminosity(4,2) + set_light(4,2) else - SetLuminosity(0) + set_light(0) /obj/structure/clockwork/powered/interdiction_lens/attack_hand(mob/living/user) if(user.canUseTopic(src, BE_CLOSE)) @@ -519,7 +519,7 @@ recharging = world.time + recharge_time flick("interdiction_lens_discharged", src) icon_state = "interdiction_lens_inactive" - SetLuminosity(2,1) + set_light(2,1) disabled = TRUE diff --git a/code/game/gamemodes/clock_cult/clock_mobs.dm b/code/game/gamemodes/clock_cult/clock_mobs.dm index f707454d5a..f691c5acd8 100644 --- a/code/game/gamemodes/clock_cult/clock_mobs.dm +++ b/code/game/gamemodes/clock_cult/clock_mobs.dm @@ -52,7 +52,7 @@ /mob/living/simple_animal/hostile/clockwork/fragment/New() ..() - SetLuminosity(2,1) + set_light(2,1) if(prob(1)) name = "anime fragment" real_name = name @@ -128,7 +128,7 @@ ..() combattimer = 0 true_name = pick(possible_true_names) - SetLuminosity(2,1) + set_light(2,1) /mob/living/simple_animal/hostile/clockwork/marauder/Life() ..() diff --git a/code/game/gamemodes/clock_cult/clock_structures.dm b/code/game/gamemodes/clock_cult/clock_structures.dm index d0627ce6ea..cd002c0d88 100644 --- a/code/game/gamemodes/clock_cult/clock_structures.dm +++ b/code/game/gamemodes/clock_cult/clock_structures.dm @@ -156,7 +156,7 @@ ..() START_PROCESSING(SSobj, src) clockwork_caches++ - SetLuminosity(2,1) + set_light(2,1) /obj/structure/clockwork/cache/Destroy() clockwork_caches-- @@ -755,7 +755,7 @@ /obj/effect/clockwork/sigil/submission/New() ..() - SetLuminosity(glow_light,glow_falloff) + set_light(glow_light,glow_falloff) /obj/effect/clockwork/sigil/submission/proc/post_channel(mob/living/L) diff --git a/code/game/gamemodes/gang/dominator.dm b/code/game/gamemodes/gang/dominator.dm index a2051d1f4b..4aea7e0485 100644 --- a/code/game/gamemodes/gang/dominator.dm +++ b/code/game/gamemodes/gang/dominator.dm @@ -19,7 +19,7 @@ /obj/machinery/dominator/New() ..() - SetLuminosity(2) + set_light(2) poi_list |= src spark_system = new spark_system.set_up(5, 1, src) @@ -113,7 +113,7 @@ gang.message_gangtools("Hostile takeover cancelled: Dominator is no longer operational.[gang.dom_attempts ? " You have [gang.dom_attempts] attempt remaining." : " The station network will have likely blocked any more attempts by us."]",1,1) - SetLuminosity(0) + set_light(0) icon_state = "dominator-broken" cut_overlays() operating = 0 @@ -201,7 +201,7 @@ countdown.text_color = gang.color_hex countdown.start() - SetLuminosity(3) + set_light(3) START_PROCESSING(SSmachine, src) gang.message_gangtools("Hostile takeover in progress: Estimated [time] minutes until victory.[gang.dom_attempts ? "" : " This is your final attempt."]") diff --git a/code/game/gamemodes/miniantags/bot_swarm/swarmer.dm b/code/game/gamemodes/miniantags/bot_swarm/swarmer.dm index 59dada4de7..531db5bb7b 100644 --- a/code/game/gamemodes/miniantags/bot_swarm/swarmer.dm +++ b/code/game/gamemodes/miniantags/bot_swarm/swarmer.dm @@ -549,9 +549,9 @@ /mob/living/simple_animal/hostile/swarmer/proc/ToggleLight() if(!luminosity) - SetLuminosity(3) + set_light(3) else - SetLuminosity(0) + set_light(0) /mob/living/simple_animal/hostile/swarmer/proc/ContactSwarmers() var/message = input(src, "Announce to other swarmers", "Swarmer contact") diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm index 7dc2a55e86..1f1cfd233f 100644 --- a/code/game/machinery/Sleeper.dm +++ b/code/game/machinery/Sleeper.dm @@ -13,6 +13,10 @@ density = FALSE anchored = TRUE state_open = TRUE + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 3 + light_color = LIGHT_COLOR_HALOGEN var/efficiency = 1 var/min_health = -25 var/list/available_chems @@ -24,6 +28,7 @@ list("omnizine") ) + /obj/machinery/sleeper/New() ..() var/obj/item/weapon/circuitboard/machine/B = new /obj/item/weapon/circuitboard/machine/sleeper(null) diff --git a/code/game/machinery/announcement_system.dm b/code/game/machinery/announcement_system.dm index 58a8729df0..61b25fc15d 100644 --- a/code/game/machinery/announcement_system.dm +++ b/code/game/machinery/announcement_system.dm @@ -9,6 +9,11 @@ var/list/announcement_systems = list() icon_state = "AAS_On" var/obj/item/device/radio/headset/radio + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 2 + light_color = LIGHT_COLOR_BLUE + verb_say = "coldly states" verb_ask = "queries" verb_exclaim = "alarms" diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index 46591a5dcd..4927bf87db 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -8,6 +8,11 @@ icon_state = "autolathe" density = 1 + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 3 + light_color = LIGHT_COLOR_CYAN + var/operating = 0 anchored = 1 var/list/L = list() diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 852bc2a070..3a40da5a68 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -83,7 +83,7 @@ network = list() cameranet.removeCamera(src) stat |= EMPED - SetLuminosity(0) + set_light(0) emped = emped+1 //Increase the number of consecutive EMP's update_icon() var/thisemp = emped //Take note of which EMP this proc is for @@ -274,7 +274,7 @@ if(can_use()) cameranet.addCamera(src) else - SetLuminosity(0) + set_light(0) cameranet.removeCamera(src) cameranet.updateChunk(x, y, z) var/change_msg = "deactivates" @@ -385,9 +385,9 @@ if(cam == src) return if(on) - src.SetLuminosity(AI_CAMERA_LUMINOSITY) + src.set_light(AI_CAMERA_LUMINOSITY) else - src.SetLuminosity(0) + src.set_light(0) /obj/machinery/camera/bullet_act(obj/item/projectile/P) . = ..() diff --git a/code/game/machinery/computer/Operating.dm b/code/game/machinery/computer/Operating.dm index cae8c26366..9929efb64f 100644 --- a/code/game/machinery/computer/Operating.dm +++ b/code/game/machinery/computer/Operating.dm @@ -6,6 +6,7 @@ circuit = /obj/item/weapon/circuitboard/computer/operating var/mob/living/carbon/human/patient = null var/obj/structure/table/optable/table = null + light_color = LIGHT_COLOR_BLUE /obj/machinery/computer/operating/New() @@ -66,4 +67,4 @@ var/datum/surgery_step/surgery_step = procedure.get_surgery_step() dat += "Next step: [capitalize(surgery_step.name)]
" dat += "" - return dat \ No newline at end of file + return dat diff --git a/code/game/machinery/computer/aifixer.dm b/code/game/machinery/computer/aifixer.dm index 107a03eaad..10221811bd 100644 --- a/code/game/machinery/computer/aifixer.dm +++ b/code/game/machinery/computer/aifixer.dm @@ -7,6 +7,7 @@ circuit = /obj/item/weapon/circuitboard/computer/aifixer icon_keyboard = "tech_key" icon_screen = "ai-fixer" + light_color = LIGHT_COLOR_PINK /obj/machinery/computer/aifixer/attackby(obj/I, mob/user, params) if(occupier && istype(I, /obj/item/weapon/screwdriver)) @@ -144,4 +145,4 @@ else if (active) user << "ERROR: Reconstruction in progress." else if (!occupier) - user << "ERROR: Unable to locate artificial intelligence." \ No newline at end of file + user << "ERROR: Unable to locate artificial intelligence." diff --git a/code/game/machinery/computer/arcade.dm b/code/game/machinery/computer/arcade.dm index 8561e0bf1b..9fd153ce2c 100644 --- a/code/game/machinery/computer/arcade.dm +++ b/code/game/machinery/computer/arcade.dm @@ -5,6 +5,8 @@ icon_keyboard = null icon_screen = "invaders" clockwork = TRUE //it'd look weird + light_color = LIGHT_COLOR_GREEN + light_range_on = 2 var/list/prizes = list( /obj/item/weapon/storage/box/snappops = 2, /obj/item/toy/talking/AI = 2, diff --git a/code/game/machinery/computer/atmos_alert.dm b/code/game/machinery/computer/atmos_alert.dm index 899f382190..c38b9d63ff 100644 --- a/code/game/machinery/computer/atmos_alert.dm +++ b/code/game/machinery/computer/atmos_alert.dm @@ -8,6 +8,7 @@ var/list/minor_alarms = list() var/receive_frequency = 1437 var/datum/radio_frequency/radio_connection + light_color = LIGHT_COLOR_CYAN /obj/machinery/computer/atmos_alert/initialize() ..() @@ -82,4 +83,4 @@ if(priority_alarms.len) add_overlay("alert:2") else if(minor_alarms.len) - add_overlay("alert:1") \ No newline at end of file + add_overlay("alert:1") diff --git a/code/game/machinery/computer/atmos_control.dm b/code/game/machinery/computer/atmos_control.dm index 83b8da0dda..7cc39f4422 100644 --- a/code/game/machinery/computer/atmos_control.dm +++ b/code/game/machinery/computer/atmos_control.dm @@ -69,6 +69,7 @@ icon_screen = "tank" icon_keyboard = "atmos_key" circuit = /obj/item/weapon/circuitboard/computer/atmos_control + light_color = LIGHT_COLOR_CYAN var/frequency = 1441 var/list/sensors = list( diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index 6c6abb2912..7b687984cc 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -8,6 +8,8 @@ var/list/network = list("SS13") var/mapping = 0//For the overview file, interesting bit of code. var/list/watchers = list() //who's using the console, associated with the camera they're on. + light_color = LIGHT_COLOR_RED + /obj/machinery/computer/security/check_eye(mob/user) if( (stat & (NOPOWER|BROKEN)) || user.incapacitated() || user.eye_blind ) @@ -147,6 +149,7 @@ density = 0 circuit = null clockwork = TRUE //it'd look very weird + use_auto_lights = 0 /obj/machinery/computer/security/telescreen/update_icon() icon_state = initial(icon_state) diff --git a/code/game/machinery/computer/card.dm b/code/game/machinery/computer/card.dm index 83c5e541c3..d26140697e 100644 --- a/code/game/machinery/computer/card.dm +++ b/code/game/machinery/computer/card.dm @@ -19,6 +19,7 @@ var/time_last_changed_position = 0 var/list/region_access = null var/list/head_subordinates = null var/target_dept = 0 //Which department this computer has access to. 0=all departments + light_color = LIGHT_COLOR_BLUE //Cooldown for closing positions in seconds //if set to -1: No cooldown... probably a bad idea @@ -505,6 +506,7 @@ var/time_last_changed_position = 0 /obj/machinery/computer/card/minor/hos target_dept = 2 icon_screen = "idhos" + light_color = LIGHT_COLOR_RED /obj/machinery/computer/card/minor/cmo target_dept = 3 @@ -513,7 +515,9 @@ var/time_last_changed_position = 0 /obj/machinery/computer/card/minor/rd target_dept = 4 icon_screen = "idrd" + light_color = LIGHT_COLOR_PINK /obj/machinery/computer/card/minor/ce target_dept = 5 icon_screen = "idce" + light_color = LIGHT_COLOR_ORANGE diff --git a/code/game/machinery/computer/cloning.dm b/code/game/machinery/computer/cloning.dm index 534729e844..b66a64c172 100644 --- a/code/game/machinery/computer/cloning.dm +++ b/code/game/machinery/computer/cloning.dm @@ -17,6 +17,7 @@ var/obj/item/weapon/disk/data/diskette = null //Mostly so the geneticist can steal everything. var/loading = 0 // Nice loading text var/autoprocess = 0 + light_color = LIGHT_COLOR_BLUE /obj/machinery/computer/cloning/New() ..() diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index 2a8f5996f4..41a0afcfde 100644 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -36,6 +36,8 @@ var/const/CALL_SHUTTLE_REASON_LENGTH = 12 var/stat_msg1 var/stat_msg2 + light_color = LIGHT_COLOR_BLUE + /obj/machinery/computer/communications/New() shuttle_caller_list += src diff --git a/code/game/machinery/computer/computer.dm b/code/game/machinery/computer/computer.dm index 5523e47e8e..fd207eedbd 100644 --- a/code/game/machinery/computer/computer.dm +++ b/code/game/machinery/computer/computer.dm @@ -15,6 +15,10 @@ var/computer_health = 25 var/clockwork = FALSE + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 3 + /obj/machinery/computer/New(location, obj/item/weapon/circuitboard/C) ..(location) if(C && istype(C)) @@ -82,15 +86,13 @@ add_overlay(icon_keyboard) if(stat & BROKEN) add_overlay("[icon_state]_broken") + set_light(l_color = LIGHT_COLOR_BLUE) else add_overlay(icon_screen) + set_light(l_color = initial(light_color)) /obj/machinery/computer/power_change() ..() - if(stat & NOPOWER) - SetLuminosity(0) - else - SetLuminosity(brightness_on) update_icon() return diff --git a/code/game/machinery/computer/crew.dm b/code/game/machinery/computer/crew.dm index 65a9260bac..4f2cdc2d44 100644 --- a/code/game/machinery/computer/crew.dm +++ b/code/game/machinery/computer/crew.dm @@ -7,6 +7,7 @@ idle_power_usage = 250 active_power_usage = 500 circuit = /obj/item/weapon/circuitboard/computer/crew + light_color = LIGHT_COLOR_BLUE /obj/machinery/computer/crew/attack_ai(mob/user) if(stat & (BROKEN|NOPOWER)) diff --git a/code/game/machinery/computer/dna_console.dm b/code/game/machinery/computer/dna_console.dm index 7df6df6336..6ece9a35ba 100644 --- a/code/game/machinery/computer/dna_console.dm +++ b/code/game/machinery/computer/dna_console.dm @@ -37,6 +37,7 @@ use_power = 1 idle_power_usage = 10 active_power_usage = 400 + light_color = LIGHT_COLOR_BLUE /obj/machinery/computer/scan_consolenew/attackby(obj/item/I, mob/user, params) if (istype(I, /obj/item/weapon/disk/data)) //INSERT SOME DISKETTES diff --git a/code/game/machinery/computer/gulag_teleporter.dm b/code/game/machinery/computer/gulag_teleporter.dm index e1ea4f9c3d..f37066dd29 100644 --- a/code/game/machinery/computer/gulag_teleporter.dm +++ b/code/game/machinery/computer/gulag_teleporter.dm @@ -12,6 +12,7 @@ var/obj/structure/gulag_beacon/beacon = null var/mob/living/carbon/human/prisoner = null var/datum/data/record/temporary_record = null + light_color = LIGHT_COLOR_RED /obj/machinery/computer/gulag_teleporter_computer/New() ..() @@ -155,10 +156,3 @@ teleporter.toggle_open() id = null temporary_record = null - - - - - - - diff --git a/code/game/machinery/computer/medical.dm b/code/game/machinery/computer/medical.dm index 5576e6ee39..e04d379189 100644 --- a/code/game/machinery/computer/medical.dm +++ b/code/game/machinery/computer/medical.dm @@ -19,6 +19,7 @@ //Sorting Variables var/sortBy = "name" var/order = 1 // -1 = Descending - 1 = Ascending + light_color = LIGHT_COLOR_BLUE /obj/machinery/computer/med_data/attackby(obj/item/O, mob/user, params) if(istype(O, /obj/item/weapon/card/id) && !scan) diff --git a/code/game/machinery/computer/message.dm b/code/game/machinery/computer/message.dm index 1484bea112..246f77dafe 100644 --- a/code/game/machinery/computer/message.dm +++ b/code/game/machinery/computer/message.dm @@ -17,7 +17,7 @@ var/noserver = "ALERT: No server detected." var/incorrectkey = "ALERT: Incorrect decryption key!" var/defaultmsg = "Welcome. Please select an option." - var/rebootmsg = "%$&(£: Critical %$$@ Error // !RestArting! - ?pLeaSe wAit!" + var/rebootmsg = "%$&(�: Critical %$$@ Error // !RestArting! - ?pLeaSe wAit!" //Computer properties var/screen = 0 // 0 = Main menu, 1 = Message Logs, 2 = Hacked screen, 3 = Custom Message var/hacking = 0 // Is it being hacked into by the AI/Cyborg @@ -29,6 +29,7 @@ var/obj/item/device/pda/customrecepient = null var/customjob = "Admin" var/custommessage = "This is a test, please ignore." + light_color = LIGHT_COLOR_GREEN /obj/machinery/computer/message_monitor/attackby(obj/item/weapon/O, mob/living/user, params) if(istype(O, /obj/item/weapon/screwdriver) && emagged) @@ -47,7 +48,7 @@ var/obj/item/weapon/paper/monitorkey/MK = new/obj/item/weapon/paper/monitorkey MK.loc = src.loc // Will help make emagging the console not so easy to get away with. - MK.info += "

£%@%(*$%&(£&?*(%&£/{}" + MK.info += "

�%@%(*$%&(�&?*(%&�/{}" var/time = 100 * length(src.linkedServer.decryptkey) addtimer(src, "UnmagConsole", time) message = rebootmsg diff --git a/code/game/machinery/computer/pod.dm b/code/game/machinery/computer/pod.dm index 427890e9c9..1f38de96ab 100644 --- a/code/game/machinery/computer/pod.dm +++ b/code/game/machinery/computer/pod.dm @@ -7,6 +7,9 @@ var/timing = 0 var/time = 30 var/range = 4 + light_color = LIGHT_COLOR_GREEN + light_power_on = 0.5 + light_range_on = 1 /obj/machinery/computer/pod/initialize() diff --git a/code/game/machinery/computer/prisoner.dm b/code/game/machinery/computer/prisoner.dm index 8a837a5af5..9d1d6f1196 100644 --- a/code/game/machinery/computer/prisoner.dm +++ b/code/game/machinery/computer/prisoner.dm @@ -12,6 +12,7 @@ var/screen = 0 // 0 - No Access Denied, 1 - Access allowed var/obj/item/weapon/card/id/prisoner/inserted_id circuit = /obj/item/weapon/circuitboard/computer/prisoner + light_color = LIGHT_COLOR_RED /obj/machinery/computer/prisoner/attack_hand(mob/user) if(..()) @@ -145,5 +146,3 @@ src.add_fingerprint(usr) src.updateUsrDialog() return - - diff --git a/code/game/machinery/computer/robot.dm b/code/game/machinery/computer/robot.dm index 129493c1f6..6cf90d9861 100644 --- a/code/game/machinery/computer/robot.dm +++ b/code/game/machinery/computer/robot.dm @@ -9,6 +9,7 @@ req_access = list(access_robotics) circuit = /obj/item/weapon/circuitboard/computer/robotics var/temp = null + light_color = LIGHT_COLOR_PINK /obj/machinery/computer/robotics/proc/can_control(mob/user, mob/living/silicon/robot/R) if(!istype(R)) diff --git a/code/game/machinery/computer/security.dm b/code/game/machinery/computer/security.dm index 5bd276d4a6..2b40a2c06e 100644 --- a/code/game/machinery/computer/security.dm +++ b/code/game/machinery/computer/security.dm @@ -22,6 +22,7 @@ //Sorting Variables var/sortBy = "name" var/order = 1 // -1 = Descending - 1 = Ascending + light_color = LIGHT_COLOR_RED /obj/machinery/computer/secure_data/attackby(obj/item/O, mob/user, params) diff --git a/code/game/machinery/computer/station_alert.dm b/code/game/machinery/computer/station_alert.dm index debb8a5f7a..c01741b91b 100644 --- a/code/game/machinery/computer/station_alert.dm +++ b/code/game/machinery/computer/station_alert.dm @@ -5,6 +5,7 @@ icon_keyboard = "atmos_key" circuit = /obj/item/weapon/circuitboard/computer/stationalert var/alarms = list("Fire" = list(), "Atmosphere" = list(), "Power" = list()) + light_color = LIGHT_COLOR_CYAN /obj/machinery/computer/station_alert/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \ datum/tgui/master_ui = null, datum/ui_state/state = default_state) @@ -80,4 +81,4 @@ if(L.len) active_alarms = TRUE if(active_alarms) - add_overlay("alert:2") \ No newline at end of file + add_overlay("alert:2") diff --git a/code/game/machinery/computer/telecrystalconsoles.dm b/code/game/machinery/computer/telecrystalconsoles.dm index af96154abf..3c95bd6861 100644 --- a/code/game/machinery/computer/telecrystalconsoles.dm +++ b/code/game/machinery/computer/telecrystalconsoles.dm @@ -9,6 +9,7 @@ var/list/possible_uplinker_IDs = list("Alfa","Bravo","Charlie","Delta","Echo","F icon_keyboard = "tcstation_key" icon_screen = "syndie" clockwork = TRUE //it'd look weird, at least if ratvar ever got there + light_color = LIGHT_COLOR_RED ///////////////////////////////////////////// /obj/machinery/computer/telecrystals/uplinker diff --git a/code/game/machinery/dna_scanner.dm b/code/game/machinery/dna_scanner.dm index 327ded8f46..03f7e55b64 100644 --- a/code/game/machinery/dna_scanner.dm +++ b/code/game/machinery/dna_scanner.dm @@ -12,6 +12,10 @@ var/damage_coeff var/scan_level var/precision_coeff + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 2 + light_color = LIGHT_COLOR_GREEN /obj/machinery/dna_scannernew/New() ..() @@ -158,4 +162,4 @@ if(..(user,1,0)) //don't set the machine, since there's no dialog return - toggle_open(user) \ No newline at end of file + toggle_open(user) diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index d5999d7de8..e38ab01154 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -1011,13 +1011,13 @@ var/list/airlock_overlays = list() return 0 operating = 1 update_icon(AIRLOCK_OPENING, 1) - src.SetOpacity(0) + src.set_opacity(0) sleep(5) src.density = 0 sleep(9) src.layer = OPEN_DOOR_LAYER update_icon(AIRLOCK_OPEN, 1) - SetOpacity(0) + set_opacity(0) operating = 0 air_update_turf(1) update_freelook_sight() @@ -1060,7 +1060,7 @@ var/list/airlock_overlays = list() sleep(9) update_icon(AIRLOCK_CLOSED, 1) if(visible && !glass) - SetOpacity(1) + set_opacity(1) operating = 0 air_update_turf(1) update_freelook_sight() diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 4e2857e76c..b13e4555ac 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -235,13 +235,13 @@ obj/machinery/door/proc/try_to_crowbar(obj/item/I, mob/user) return 0 operating = 1 do_animate("opening") - SetOpacity(0) + set_opacity(0) sleep(5) density = 0 sleep(5) layer = OPEN_DOOR_LAYER update_icon() - SetOpacity(0) + set_opacity(0) operating = 0 air_update_turf(1) update_freelook_sight() @@ -270,7 +270,7 @@ obj/machinery/door/proc/try_to_crowbar(obj/item/I, mob/user) sleep(5) update_icon() if(visible && !glass) - SetOpacity(1) + set_opacity(1) operating = 0 air_update_turf(1) update_freelook_sight() diff --git a/code/game/machinery/doors/windowdoor.dm b/code/game/machinery/doors/windowdoor.dm index 771b900d1e..1e02a1238b 100644 --- a/code/game/machinery/doors/windowdoor.dm +++ b/code/game/machinery/doors/windowdoor.dm @@ -128,7 +128,7 @@ sleep(10) src.density = 0 -// src.sd_SetOpacity(0) //TODO: why is this here? Opaque windoors? ~Carn +// src.sd_set_opacity(0) //TODO: why is this here? Opaque windoors? ~Carn air_update_turf(1) update_freelook_sight() diff --git a/code/game/machinery/doppler_array.dm b/code/game/machinery/doppler_array.dm index ea23390530..93b5502d16 100644 --- a/code/game/machinery/doppler_array.dm +++ b/code/game/machinery/doppler_array.dm @@ -108,4 +108,4 @@ var/list/doppler_arrays = list() name = "integrated tachyon-doppler module" integrated = 1 max_dist = 21 //Should detect most explosions in hearing range. - use_power = 0 \ No newline at end of file + use_power = 0 diff --git a/code/game/machinery/gulag_item_reclaimer.dm b/code/game/machinery/gulag_item_reclaimer.dm index 91d7bb1882..080f70e450 100644 --- a/code/game/machinery/gulag_item_reclaimer.dm +++ b/code/game/machinery/gulag_item_reclaimer.dm @@ -12,6 +12,10 @@ var/list/stored_items = list() var/obj/item/weapon/card/id/prisoner/inserted_id = null var/obj/machinery/gulag_teleporter/linked_teleporter = null + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 3 + light_color = LIGHT_COLOR_BLUE /obj/machinery/gulag_item_reclaimer/Destroy() for(var/i in contents) @@ -105,4 +109,4 @@ var/obj/item/W = i stored_items[user] -= W W.forceMove(get_turf(src)) - stored_items -= user \ No newline at end of file + stored_items -= user diff --git a/code/game/machinery/hologram.dm b/code/game/machinery/hologram.dm index 5b65821d77..8806c7431e 100644 --- a/code/game/machinery/hologram.dm +++ b/code/game/machinery/hologram.dm @@ -163,9 +163,9 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/ h.layer = FLY_LAYER//Above all the other objects/mobs. Or the vast majority of them. h.anchored = 1//So space wind cannot drag it. h.name = "[A.name] (Hologram)"//If someone decides to right click. - h.SetLuminosity(2) //hologram lighting + h.set_light(2) //hologram lighting masters[A] = h - SetLuminosity(2) //pad lighting + set_light(2) //pad lighting icon_state = "holopad1" A.current = src use_power += HOLOGRAM_POWER_USAGE @@ -178,7 +178,7 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/ masters -= user //Discard AI from the list of those who use holopad use_power = max(HOLOPAD_PASSIVE_POWER_USAGE, use_power - HOLOGRAM_POWER_USAGE)//Reduce power usage if (!masters.len)//If no users left - SetLuminosity(0) //pad lighting (hologram lighting will be handled automatically since its owner was deleted) + set_light(0) //pad lighting (hologram lighting will be handled automatically since its owner was deleted) icon_state = "holopad0" use_power = HOLOPAD_PASSIVE_POWER_USAGE return 1 diff --git a/code/game/machinery/igniter.dm b/code/game/machinery/igniter.dm index 4aef607a43..dcde578e4b 100644 --- a/code/game/machinery/igniter.dm +++ b/code/game/machinery/igniter.dm @@ -72,11 +72,11 @@ if ( powered() && disable == 0 ) stat &= ~NOPOWER icon_state = "[base_state]" -// src.sd_SetLuminosity(2) +// src.sd_set_light(2) else stat |= ~NOPOWER icon_state = "[base_state]-p" -// src.sd_SetLuminosity(0) +// src.sd_set_light(0) /obj/machinery/sparker/attackby(obj/item/weapon/W, mob/user, params) if (istype(W, /obj/item/weapon/screwdriver)) diff --git a/code/game/machinery/lightswitch.dm b/code/game/machinery/lightswitch.dm index 792334b434..674ad00ff3 100644 --- a/code/game/machinery/lightswitch.dm +++ b/code/game/machinery/lightswitch.dm @@ -9,7 +9,6 @@ var/on = 1 var/area/area = null var/otherarea = null - // luminosity = 1 /obj/machinery/light_switch/New() ..() @@ -73,4 +72,4 @@ ..(severity) return power_change() - ..(severity) \ No newline at end of file + ..(severity) diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 6824ebe611..6c9e33c319 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -120,6 +120,10 @@ Class Procs: var/interact_offline = 0 // Can the machine be interacted with while de-powered. var/speed_process = 0 // Process as fast as possible? + var/light_range_on = 0 + var/light_power_on = 0 + var/use_auto_lights = 0 + /obj/machinery/New() ..() machines += src diff --git a/code/game/machinery/newscaster.dm b/code/game/machinery/newscaster.dm index 359893bdbb..40a39ce2c6 100644 --- a/code/game/machinery/newscaster.dm +++ b/code/game/machinery/newscaster.dm @@ -189,7 +189,10 @@ var/list/obj/machinery/newscaster/allCasters = list() var/health = 60 var/datum/newscaster/feed_channel/viewing_channel = null var/allow_comments = 1 - luminosity = 0 + use_auto_lights = 1 + light_power_on = 0.5 + light_range_on = 1 + light_color = LIGHT_COLOR_GREEN anchored = 1 var/hitstaken = 0 //TO BE REMOVED, no longer used, the var is present in a map var edit which must be removed. @@ -1048,4 +1051,4 @@ var/list/obj/machinery/newscaster/allCasters = list() scribble = s attack_self(user) else - return ..() \ No newline at end of file + return ..() diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm index 0893d6f8f2..245970a561 100644 --- a/code/game/machinery/requests_console.dm +++ b/code/game/machinery/requests_console.dm @@ -56,7 +56,10 @@ var/list/obj/machinery/requests_console/allConsoles = list() var/priority = -1 ; //Priority of the message being sent var/obj/item/device/radio/Radio var/emergency //If an emergency has been called by this device. Acts as both a cooldown and lets the responder know where it the emergency was triggered from - luminosity = 0 + use_auto_lights = 1 + light_power_on = 0.5 + light_range_on = 1 + light_color = LIGHT_COLOR_GREEN /obj/machinery/requests_console/power_change() ..() @@ -185,7 +188,7 @@ var/list/obj/machinery/requests_console/allConsoles = list() if (Console.department == department) Console.newmessagepriority = 0 Console.update_icon() - Console.SetLuminosity(1) + Console.set_light(1) newmessagepriority = 0 update_icon() var/messageComposite = "" @@ -375,7 +378,7 @@ var/list/obj/machinery/requests_console/allConsoles = list() alert = "Message from [department][authentic]" Console.createmessage(src, alert , sending, 1, 1) screen = 6 - Console.SetLuminosity(2) + Console.set_light(2) if(radio_freq) Radio.talk_into(src,"[alert]: [message]",radio_freq) @@ -476,7 +479,7 @@ var/list/obj/machinery/requests_console/allConsoles = list() playsound(src.loc, 'sound/machines/twobeep.ogg', 50, 1) say(title) src.messages += "From: [linkedsender]
[message]" - SetLuminosity(2) + set_light(2) /obj/machinery/requests_console/attackby(obj/item/weapon/O, mob/user, params) if(istype(O, /obj/item/weapon/crowbar)) diff --git a/code/game/machinery/slotmachine.dm b/code/game/machinery/slotmachine.dm index a204918d41..b8ab9a0763 100644 --- a/code/game/machinery/slotmachine.dm +++ b/code/game/machinery/slotmachine.dm @@ -22,6 +22,7 @@ use_power = 1 idle_power_usage = 50 circuit = /obj/item/weapon/circuitboard/computer/slot_machine + light_range_on = 0 var/money = 3000 //How much money it has CONSUMED var/plays = 0 var/working = 0 diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm index 32bd100fba..297d4e9a22 100644 --- a/code/game/machinery/suit_storage_unit.dm +++ b/code/game/machinery/suit_storage_unit.dm @@ -26,6 +26,11 @@ var/uv_super = FALSE var/uv_cycles = 6 + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 3 + light_color = LIGHT_COLOR_ORANGE + /obj/machinery/suit_storage_unit/standard_unit suit_type = /obj/item/clothing/suit/space/eva helmet_type = /obj/item/clothing/head/helmet/space/eva @@ -378,4 +383,4 @@ storage.loc = loc storage = null . = TRUE - update_icon() \ No newline at end of file + update_icon() diff --git a/code/game/machinery/telecomms/computers/logbrowser.dm b/code/game/machinery/telecomms/computers/logbrowser.dm index 61598ca32b..5dea78051b 100644 --- a/code/game/machinery/telecomms/computers/logbrowser.dm +++ b/code/game/machinery/telecomms/computers/logbrowser.dm @@ -16,6 +16,8 @@ req_access = list(access_tcomsat) circuit = /obj/item/weapon/circuitboard/computer/comm_server + light_color = LIGHT_COLOR_GREEN + /obj/machinery/computer/telecomms/server/attack_hand(mob/user) if(..()) return diff --git a/code/game/machinery/telecomms/computers/telemonitor.dm b/code/game/machinery/telecomms/computers/telemonitor.dm index 0fd04b2536..7395e1e795 100644 --- a/code/game/machinery/telecomms/computers/telemonitor.dm +++ b/code/game/machinery/telecomms/computers/telemonitor.dm @@ -8,6 +8,7 @@ /obj/machinery/computer/telecomms/monitor name = "telecommunications monitoring console" icon_screen = "comm_monitor" + light_color = LIGHT_COLOR_GREEN var/screen = 0 // the screen number: var/list/machinelist = list() // the machines located by the computer @@ -124,4 +125,4 @@ /obj/machinery/computer/telecomms/monitor/attackby() . = ..() - updateUsrDialog() \ No newline at end of file + updateUsrDialog() diff --git a/code/game/machinery/telecomms/machines/receiver.dm b/code/game/machinery/telecomms/machines/receiver.dm index 319806a965..8c31abbb08 100644 --- a/code/game/machinery/telecomms/machines/receiver.dm +++ b/code/game/machinery/telecomms/machines/receiver.dm @@ -16,6 +16,7 @@ use_power = 1 idle_power_usage = 30 machinetype = 1 + light_color = LIGHT_COLOR_GREEN //heatgen = 0 /obj/machinery/telecomms/receiver/receive_signal(datum/signal/signal) @@ -96,4 +97,4 @@ /obj/machinery/telecomms/receiver/preset_left/birdstation name = "Receiver" - freq_listening = list() \ No newline at end of file + freq_listening = list() diff --git a/code/game/machinery/telecomms/telecomunications.dm b/code/game/machinery/telecomms/telecomunications.dm index dd1d5f2de4..24be233193 100644 --- a/code/game/machinery/telecomms/telecomunications.dm +++ b/code/game/machinery/telecomms/telecomunications.dm @@ -32,6 +32,11 @@ var/global/list/obj/machinery/telecomms/telecomms_list = list() var/hide = 0 // Is it a hidden machine? var/listening_level = 0 // 0 = auto set in New() - this is the z level that the machine is listening to. + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 3 + light_color = LIGHT_COLOR_BLUE + /obj/machinery/telecomms/proc/relay_information(datum/signal/signal, filter, copysig, amount = 20) // relay signal to all linked machinery that are of type [filter]. If signal has been sent [amount] times, stop sending diff --git a/code/game/machinery/teleporter.dm b/code/game/machinery/teleporter.dm index 914071708d..fd718fd54f 100644 --- a/code/game/machinery/teleporter.dm +++ b/code/game/machinery/teleporter.dm @@ -4,6 +4,7 @@ icon_screen = "teleport" icon_keyboard = "teleport_key" circuit = /obj/item/weapon/circuitboard/computer/teleporter + light_color = LIGHT_COLOR_BLUE var/obj/item/device/gps/locked = null var/regime_set = "Teleporter" var/id = null diff --git a/code/game/machinery/wishgranter.dm b/code/game/machinery/wishgranter.dm index 5123cba369..63131bb0e0 100644 --- a/code/game/machinery/wishgranter.dm +++ b/code/game/machinery/wishgranter.dm @@ -4,6 +4,11 @@ icon = 'icons/obj/device.dmi' icon_state = "syndbeacon" + use_auto_lights = 1 + light_power_on = 2 + light_range_on = 2 + light_color = LIGHT_COLOR_RED + use_power = 0 anchored = 1 density = 1 @@ -22,7 +27,6 @@ else if(is_special_character(user)) user << "Even to a heart as dark as yours, you know nothing good will come of this. Something instinctual makes you pull away." - else if (!insisting) user << "Your first touch makes the Wish Granter stir, listening to you. Are you really sure you want to do this?" insisting++ @@ -53,4 +57,4 @@ user << "You have a very bad feeling about this." - return \ No newline at end of file + return diff --git a/code/game/mecha/mech_bay.dm b/code/game/mecha/mech_bay.dm index 5f7135cdc5..095674f40e 100644 --- a/code/game/mecha/mech_bay.dm +++ b/code/game/mecha/mech_bay.dm @@ -85,6 +85,7 @@ icon_keyboard = "rd_key" circuit = /obj/item/weapon/circuitboard/computer/mech_bay_power_console var/obj/machinery/mech_bay_recharge_port/recharge_port + light_color = LIGHT_COLOR_PINK /obj/machinery/computer/mech_bay_power_console/attack_ai(mob/user) return interact(user) diff --git a/code/game/mecha/mecha_actions.dm b/code/game/mecha/mecha_actions.dm index 869801152e..40933e8115 100644 --- a/code/game/mecha/mecha_actions.dm +++ b/code/game/mecha/mecha_actions.dm @@ -106,10 +106,10 @@ return chassis.lights = !chassis.lights if(chassis.lights) - chassis.AddLuminosity(chassis.lights_power) + chassis.set_light(chassis.lights_power) button_icon_state = "mech_lights_on" else - chassis.AddLuminosity(-chassis.lights_power) + chassis.set_light(0) button_icon_state = "mech_lights_off" chassis.occupant_message("Toggled lights [chassis.lights?"on":"off"].") chassis.log_message("Toggled lights [chassis.lights?"on":"off"].") diff --git a/code/game/objects/effects/anomalies.dm b/code/game/objects/effects/anomalies.dm index e79f76f672..264cf0bb2d 100644 --- a/code/game/objects/effects/anomalies.dm +++ b/code/game/objects/effects/anomalies.dm @@ -14,7 +14,7 @@ /obj/effect/anomaly/New() ..() poi_list |= src - SetLuminosity(initial(luminosity)) + set_light(initial(luminosity)) aSignal = new(src) aSignal.code = rand(1,100) diff --git a/code/game/objects/effects/glowshroom.dm b/code/game/objects/effects/glowshroom.dm index 8f94e4f178..772268792a 100644 --- a/code/game/objects/effects/glowshroom.dm +++ b/code/game/objects/effects/glowshroom.dm @@ -34,7 +34,7 @@ obj/effect/glowshroom/glowcap /obj/effect/glowshroom/New() ..() - SetLuminosity(round(potency/10)) + set_light(round(potency/10)) setDir(CalcDir()) var/base_icon_state = initial(icon_state) if(!floor) diff --git a/code/game/objects/items/blueprints.dm b/code/game/objects/items/blueprints.dm index 56e99c069f..02bc51fdf3 100644 --- a/code/game/objects/items/blueprints.dm +++ b/code/game/objects/items/blueprints.dm @@ -213,12 +213,12 @@ turfs -= key if(A) A.contents += turfs - A.SetDynamicLighting() + A.set_dynamic_lighting() else A = new A.setup(str) A.contents += turfs - A.SetDynamicLighting() + A.set_dynamic_lighting() A.has_gravity = old_gravity interact() return 1 diff --git a/code/game/objects/items/candle.dm b/code/game/objects/items/candle.dm index 0ccd6b7831..b318f91a43 100644 --- a/code/game/objects/items/candle.dm +++ b/code/game/objects/items/candle.dm @@ -64,7 +64,7 @@ if(show_message) usr.visible_message( "[usr] lights the [name].") - SetLuminosity(CANDLE_LUMINOSITY) + set_light(CANDLE_LUMINOSITY) START_PROCESSING(SSobj, src) update_icon() @@ -89,22 +89,7 @@ "[user] snuffs [src].") lit = FALSE update_icon() - SetLuminosity(0) - user.AddLuminosity(-CANDLE_LUMINOSITY) - - -/obj/item/candle/pickup(mob/user) - ..() - if(lit) - SetLuminosity(0) - user.AddLuminosity(CANDLE_LUMINOSITY) - - -/obj/item/candle/dropped(mob/user) - ..() - if(lit) - user.AddLuminosity(-CANDLE_LUMINOSITY) - SetLuminosity(CANDLE_LUMINOSITY) + set_light(0) /obj/item/candle/is_hot() return lit * heat diff --git a/code/game/objects/items/crayons.dm b/code/game/objects/items/crayons.dm index e5be254541..c8b368ead3 100644 --- a/code/game/objects/items/crayons.dm +++ b/code/game/objects/items/crayons.dm @@ -655,9 +655,9 @@ if(actually_paints) target.color = paint_color if(color_hex2num(paint_color) < 255) - target.SetOpacity(255) + target.set_opacity(255) else - target.SetOpacity(initial(target.opacity)) + target.set_opacity(initial(target.opacity)) . = use_charges(2) var/fraction = min(1, . / reagents.maximum_volume) reagents.reaction(target, TOUCH, fraction * volume_multiplier) diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index def27bf165..c4c7fc679e 100644 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -50,27 +50,10 @@ var/global/list/obj/item/device/pda/PDAs = list() var/image/photo = null //Scanned photo - -/obj/item/device/pda/pickup(mob/user) - ..() - if(fon) - SetLuminosity(0) - user.AddLuminosity(f_lum) - -/obj/item/device/pda/dropped(mob/user) - ..() - if(fon) - user.AddLuminosity(-f_lum) - SetLuminosity(f_lum) - /obj/item/device/pda/New() ..() if(fon) - if(!isturf(loc)) - loc.AddLuminosity(f_lum) - SetLuminosity(0) - else - SetLuminosity(f_lum) + set_light(f_lum) PDAs += src if(default_cartridge) cartridge = new default_cartridge(src) @@ -343,16 +326,10 @@ var/global/list/obj/item/device/pda/PDAs = list() if("Light") if(fon) fon = 0 - if(src in U.contents) - U.AddLuminosity(-f_lum) - else - SetLuminosity(0) + set_light(0) else fon = 1 - if(src in U.contents) - U.AddLuminosity(f_lum) - else - SetLuminosity(f_lum) + set_light(f_lum) if("Medical Scan") if(scanmode == 1) scanmode = 0 diff --git a/code/game/objects/items/devices/flashlight.dm b/code/game/objects/items/devices/flashlight.dm index 28d05305bb..5985f45e65 100644 --- a/code/game/objects/items/devices/flashlight.dm +++ b/code/game/objects/items/devices/flashlight.dm @@ -14,33 +14,19 @@ /obj/item/device/flashlight/initialize() ..() - if(on) - icon_state = "[initial(icon_state)]-on" - SetLuminosity(brightness_on) - else - icon_state = initial(icon_state) - SetLuminosity(0) + update_brightness() -/obj/item/device/flashlight/proc/update_brightness(mob/user = null) +/obj/item/device/flashlight/proc/update_brightness() if(on) icon_state = "[initial(icon_state)]-on" - if(loc == user) - user.AddLuminosity(brightness_on) - else if(isturf(loc)) - SetLuminosity(brightness_on) + set_light(brightness_on) else icon_state = initial(icon_state) - if(loc == user) - user.AddLuminosity(-brightness_on) - else if(isturf(loc)) - SetLuminosity(0) + set_light(0) /obj/item/device/flashlight/attack_self(mob/user) - if(!isturf(user.loc)) - user << "You cannot turn the light on while in this [user.loc]!" //To prevent some lighting anomalities. - return 0 on = !on - update_brightness(user) + update_brightness() for(var/X in actions) var/datum/action/A = X A.UpdateButtonIcon() @@ -85,21 +71,6 @@ else return ..() - -/obj/item/device/flashlight/pickup(mob/user) - ..() - if(on) - user.AddLuminosity(brightness_on) - SetLuminosity(0) - - -/obj/item/device/flashlight/dropped(mob/user) - ..() - if(on) - user.AddLuminosity(-brightness_on) - SetLuminosity(brightness_on) - - /obj/item/device/flashlight/pen name = "penlight" desc = "A pen-sized light, used by medical staff. It can also be used to create a hologram to alert people of incoming medical assistance." @@ -193,6 +164,7 @@ obj/item/device/flashlight/lamp/bananalamp var/on_damage = 7 var/produce_heat = 1500 heat = 1000 + light_color = LIGHT_COLOR_FLARE /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. @@ -213,13 +185,9 @@ obj/item/device/flashlight/lamp/bananalamp on = 0 force = initial(src.force) damtype = initial(src.damtype) - if(ismob(loc)) - var/mob/U = loc - update_brightness(U) - else - update_brightness(null) + update_brightness() -/obj/item/device/flashlight/flare/update_brightness(mob/user = null) +/obj/item/device/flashlight/flare/update_brightness() ..() if(on) item_state = "[initial(item_state)]-on" @@ -262,6 +230,7 @@ obj/item/device/flashlight/lamp/bananalamp item_state = "lantern" desc = "A mining lantern." brightness_on = 6 // luminosity when on + light_color = LIGHT_COLOR_FIRE /obj/item/device/flashlight/slime @@ -275,9 +244,10 @@ obj/item/device/flashlight/lamp/bananalamp slot_flags = SLOT_BELT materials = list() brightness_on = 6 //luminosity when on + light_color = LIGHT_COLOR_SLIME_LAMP /obj/item/device/flashlight/emp - origin_tech = "magnets=3;syndicate=´1" + origin_tech = "magnets=3;syndicate=�1" var/emp_max_charges = 4 var/emp_cur_charges = 4 var/charge_tick = 0 diff --git a/code/game/objects/items/devices/powersink.dm b/code/game/objects/items/devices/powersink.dm index 175f6d2d4a..0f3b602995 100644 --- a/code/game/objects/items/devices/powersink.dm +++ b/code/game/objects/items/devices/powersink.dm @@ -52,7 +52,7 @@ mode = value update_icon() - SetLuminosity(0) + set_light(0) /obj/item/device/powersink/attackby(obj/item/I, mob/user, params) if(istype(I, /obj/item/weapon/screwdriver)) @@ -113,7 +113,7 @@ var/datum/powernet/PN = attached.powernet if(PN) - SetLuminosity(5) + set_light(5) // found a powernet, so drain up to max power from it diff --git a/code/game/objects/items/weapons/cigs_lighters.dm b/code/game/objects/items/weapons/cigs_lighters.dm index e0037536f5..c47fda348a 100644 --- a/code/game/objects/items/weapons/cigs_lighters.dm +++ b/code/game/objects/items/weapons/cigs_lighters.dm @@ -188,6 +188,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM hitsound = 'sound/items/welder.ogg' damtype = "fire" force = 4 + update_brightness() if(reagents.get_reagent_amount("plasma")) // the plasma explodes when exposed to fire var/datum/effect_system/reagents_explosion/e = new() e.set_up(round(reagents.get_reagent_amount("plasma") / 2.5, 1), get_turf(src), 0, 0) @@ -223,6 +224,11 @@ CIGARETTE PACKETS ARE IN FANCY.DM M.update_inv_l_hand() M.update_inv_r_hand() +/obj/item/clothing/mask/cigarette/proc/update_brightness() + if(lit) + set_light(1) + else + set_light(0) /obj/item/clothing/mask/cigarette/proc/handle_reagents() if(reagents.total_volume) @@ -245,6 +251,8 @@ CIGARETTE PACKETS ARE IN FANCY.DM smoketime-- if(smoketime < 1) new type_butt(location) + lit = 0 + update_brightness() if(ismob(loc)) M << "Your [name] goes out." M.unEquip(src, 1) //un-equip it so the overlays can update //Force the un-equip so the overlays update @@ -259,6 +267,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM user.visible_message("[user] calmly drops and treads on \the [src], putting it out instantly.") new type_butt(user.loc) new /obj/effect/decal/cleanable/ash(user.loc) + update_brightness() qdel(src) return ..() @@ -511,7 +520,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM user.apply_damage(5, BURN, hitzone) user.visible_message("After a few attempts, [user] manages to light [src] - they however burn their finger in the process.", "You burn yourself while lighting the lighter!") - user.AddLuminosity(1) + set_light(1) START_PROCESSING(SSobj, src) else lit = 0 @@ -523,7 +532,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM user.visible_message("You hear a quiet click, as [user] shuts off [src] without even looking at what they're doing. Wow.", "You quietly shut off [src] without even looking at what you're doing. Wow.") else user.visible_message("[user] quietly shuts off [src].", "You quietly shut off [src].") - user.AddLuminosity(-1) + set_light(0) STOP_PROCESSING(SSobj, src) else return ..() @@ -553,22 +562,6 @@ CIGARETTE PACKETS ARE IN FANCY.DM location.hotspot_expose(700, 5) return -/obj/item/weapon/lighter/pickup(mob/user) - ..() - if(lit) - SetLuminosity(0) - user.AddLuminosity(1) - return - - -/obj/item/weapon/lighter/dropped(mob/user) - ..() - if(lit) - if(user) - user.AddLuminosity(-1) - SetLuminosity(1) - return - /obj/item/weapon/lighter/is_hot() return lit * heat diff --git a/code/game/objects/items/weapons/clown_items.dm b/code/game/objects/items/weapons/clown_items.dm index 898cd83e66..6cbf714968 100644 --- a/code/game/objects/items/weapons/clown_items.dm +++ b/code/game/objects/items/weapons/clown_items.dm @@ -72,7 +72,7 @@ if(do_after(user, src.cleanspeed, target = target)) user << "You clean \the [target.name]." target.color = initial(target.color) - target.SetOpacity(initial(target.opacity)) + target.set_opacity(initial(target.opacity)) else user.visible_message("[user] begins to clean \the [target.name] with [src]...", "You begin to clean \the [target.name] with [src]...") if(do_after(user, src.cleanspeed, target = target)) diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm index d64ec43677..6cac7d71b8 100644 --- a/code/game/objects/structures.dm +++ b/code/game/objects/structures.dm @@ -25,7 +25,7 @@ if(ticker) cameranet.updateVisibility(src) if(opacity) - UpdateAffectingLights() + update_light() if(smooth) queue_smooth_neighbors(src) return ..() diff --git a/code/game/objects/structures/false_walls.dm b/code/game/objects/structures/false_walls.dm index 6081462ac8..1387e5877a 100644 --- a/code/game/objects/structures/false_walls.dm +++ b/code/game/objects/structures/false_walls.dm @@ -45,7 +45,7 @@ sleep(5) if(!qdeleted(src)) density = 0 - SetOpacity(0) + set_opacity(0) update_icon() else var/srcturf = get_turf(src) @@ -56,7 +56,7 @@ density = 1 sleep(5) if(!qdeleted(src)) - SetOpacity(1) + set_opacity(1) update_icon() air_update_turf(1) opening = 0 diff --git a/code/game/pooling/pool.dm b/code/game/pooling/pool.dm index ebbcebeb95..1c608fe72b 100644 --- a/code/game/pooling/pool.dm +++ b/code/game/pooling/pool.dm @@ -23,6 +23,8 @@ For almost all pooling purposes, it is better to use the QDEL hint than to pool */ +#define MAINTAINING_OBJECT_POOL_COUNT 500 + var/global/list/GlobalPool = list() //You'll be using this proc 90% of the time. @@ -133,3 +135,33 @@ var/list/pooledvariables = list() /image/ResetVars() ..() loc = null + +/proc/returnToPool(const/datum/D) + ASSERT(D) + + if(istype(D, /atom/movable) && length(GlobalPool[D.type]) > MAINTAINING_OBJECT_POOL_COUNT) + #ifdef DEBUG_DATUM_POOL + to_chat(world, text("DEBUG_DATUM_POOL: returnToPool([]) exceeds [] discarding...", D.type, MAINTAINING_OBJECT_POOL_COUNT)) + #endif + + qdel(D) + return + + if(isnull(GlobalPool[D.type])) + GlobalPool[D.type] = list() + + D.Destroy() + D.ResetVars() + + #ifdef DEBUG_DATUM_POOL + if(D in GlobalPool[D.type]) + to_chat(world, text("returnToPool has been called twice for the same datum of type [] time to panic.", D.type)) + #endif + + GlobalPool[D.type] |= D + + #ifdef DEBUG_DATUM_POOL + to_chat(world, text("DEBUG_DATUM_POOL: returnToPool([]) [] left.", D.type, length(GlobalPool[D.type]))) + #endif + +#undef MAINTAINING_OBJECT_POOL_COUNT \ No newline at end of file diff --git a/code/game/turfs/simulated/floor/light_floor.dm b/code/game/turfs/simulated/floor/light_floor.dm index 62b6437314..bf0c8230ee 100644 --- a/code/game/turfs/simulated/floor/light_floor.dm +++ b/code/game/turfs/simulated/floor/light_floor.dm @@ -24,24 +24,24 @@ switch(state) if(0) icon_state = "light_on-[coloredlights[currentcolor]]" - SetLuminosity(1) + set_light(1) if(1) var/num = pick("1","2","3","4") icon_state = "light_on_flicker[num]" - SetLuminosity(1) + set_light(1) if(2) icon_state = "light_on_broken" - SetLuminosity(1) + set_light(1) if(3) icon_state = "light_off" - SetLuminosity(0) + set_light(0) else - SetLuminosity(0) + set_light(0) icon_state = "light_off" /turf/open/floor/light/ChangeTurf(turf/T) - SetLuminosity(0) + set_light(0) ..() /turf/open/floor/light/attack_hand(mob/user) diff --git a/code/game/turfs/simulated/floor/plating.dm b/code/game/turfs/simulated/floor/plating.dm index f177df2d67..fe030c1e01 100644 --- a/code/game/turfs/simulated/floor/plating.dm +++ b/code/game/turfs/simulated/floor/plating.dm @@ -215,7 +215,9 @@ baseturf = /turf/open/floor/plating/lava //lava all the way down slowdown = 2 var/processing = 0 - luminosity = 1 + light_range = 2 + light_power = 0.75 + light_color = "#c48a18" /turf/open/floor/plating/lava/airless initial_gas_mix = "TEMP=2.7" diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm index 69db4ab9f1..22f510ca1d 100644 --- a/code/game/turfs/space/space.dm +++ b/code/game/turfs/space/space.dm @@ -14,6 +14,8 @@ var/destination_y var/global/datum/gas_mixture/space/space_gas = new + light_power = 0.25 + dynamic_lighting = DYNAMIC_LIGHTING_DISABLED /turf/open/space/New() @@ -52,9 +54,9 @@ if(istype(t, /turf/open/space)) //let's NOT update this that much pls continue - SetLuminosity(4,1) + set_light(2) return - SetLuminosity(0) + set_light(0) /turf/open/space/attack_paw(mob/user) return src.attack_hand(user) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 218d764dd0..749ff89254 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -148,6 +148,7 @@ W.AfterChange() W.blueprint_data = old_blueprint_data return W + /turf/proc/AfterChange() //called after a turf has been replaced in ChangeTurf() levelupdate() @@ -316,7 +317,7 @@ T0.ChangeTurf(turf_type) - T0.redraw_lighting() + T0.reconsider_lights() SSair.remove_from_active(T0) T0.CalculateAdjacentTurfs() SSair.add_to_active(T0,1) diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index cda2c628af..41364451e8 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -302,7 +302,7 @@ var/list/admin_verbs_hideable = list( /client/proc/count_objects_all, /client/proc/cmd_assume_direct_control, /client/proc/startSinglo, - /client/proc/fps, + /client/proc/set_fps, /client/proc/cmd_admin_grantfullaccess, /client/proc/cmd_admin_areatest, /client/proc/readmin diff --git a/code/modules/admin/verbs/fps.dm b/code/modules/admin/verbs/fps.dm index 6cb8107ba0..4e101b2d47 100644 --- a/code/modules/admin/verbs/fps.dm +++ b/code/modules/admin/verbs/fps.dm @@ -1,5 +1,5 @@ //replaces the old Ticklag verb, fps is easier to understand -/client/proc/fps() +/client/proc/set_fps() set category = "Debug" set name = "Set fps" set desc = "Sets game speed in frames-per-second. Can potentially break the game" @@ -21,4 +21,4 @@ message_admins(msg, 0) feedback_add_details("admin_verb","TICKLAG") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! - world.fps = fps \ No newline at end of file + world.fps = fps diff --git a/code/modules/admin/verbs/mapping.dm b/code/modules/admin/verbs/mapping.dm index 360ebdb37b..36b1f12b71 100644 --- a/code/modules/admin/verbs/mapping.dm +++ b/code/modules/admin/verbs/mapping.dm @@ -33,7 +33,7 @@ var/list/admin_verbs_debug_mapping = list( /client/proc/count_objects_all, /client/proc/cmd_assume_direct_control, //-errorage /client/proc/startSinglo, - /client/proc/fps, //allows you to set the ticklag. + /client/proc/set_fps, //allows you to set the ticklag. /client/proc/cmd_admin_grantfullaccess, /client/proc/cmd_admin_areatest, /client/proc/cmd_admin_rejuvenate, diff --git a/code/modules/admin/verbs/massmodvar.dm b/code/modules/admin/verbs/massmodvar.dm index be4f4e728a..b1faa1d65e 100644 --- a/code/modules/admin/verbs/massmodvar.dm +++ b/code/modules/admin/verbs/massmodvar.dm @@ -308,7 +308,7 @@ if(new_value == null) return if(variable=="luminosity") - O.SetLuminosity(new_value) + O.set_light(new_value) else O.vars[variable] = new_value @@ -317,7 +317,7 @@ for(var/mob/M in mob_list) if ( istype(M , O.type) ) if(variable=="luminosity") - M.SetLuminosity(new_value) + M.set_light(new_value) else M.vars[variable] = O.vars[variable] CHECK_TICK @@ -326,7 +326,7 @@ for(var/obj/A in world) if ( istype(A , O.type) ) if(variable=="luminosity") - A.SetLuminosity(new_value) + A.set_light(new_value) else A.vars[variable] = O.vars[variable] CHECK_TICK @@ -335,7 +335,7 @@ for(var/turf/A in world) if ( istype(A , O.type) ) if(variable=="luminosity") - A.SetLuminosity(new_value) + A.set_light(new_value) else A.vars[variable] = O.vars[variable] CHECK_TICK @@ -345,7 +345,7 @@ for(var/mob/M in mob_list) if (M.type == O.type) if(variable=="luminosity") - M.SetLuminosity(new_value) + M.set_light(new_value) else M.vars[variable] = O.vars[variable] CHECK_TICK @@ -354,7 +354,7 @@ for(var/obj/A in world) if (A.type == O.type) if(variable=="luminosity") - A.SetLuminosity(new_value) + A.set_light(new_value) else A.vars[variable] = O.vars[variable] CHECK_TICK @@ -363,7 +363,7 @@ for(var/turf/A in world) if (A.type == O.type) if(variable=="luminosity") - A.SetLuminosity(new_value) + A.set_light(new_value) else A.vars[variable] = O.vars[variable] CHECK_TICK diff --git a/code/modules/admin/verbs/modifyvariables.dm b/code/modules/admin/verbs/modifyvariables.dm index 7cbba6e126..3b44af2c76 100644 --- a/code/modules/admin/verbs/modifyvariables.dm +++ b/code/modules/admin/verbs/modifyvariables.dm @@ -607,6 +607,11 @@ var/list/VVckey_edit = list("key", "ckey") var/var_new = input("Enter new text:","Text",O.vars[variable]) as null|message if(var_new==null) return + if(variable == "light_color") + O.set_light(l_color = var_new) + else + O.vars[variable] = var_new + if(findtext(var_new,"\[")) var/process_vars = alert(usr,"\[] detected in string, process as variables?","Process Variables?","Yes","No") if(process_vars == "Yes") @@ -617,10 +622,18 @@ var/list/VVckey_edit = list("key", "ckey") O.vars[variable] = var_new if("num") - if(variable=="luminosity") + if(variable=="light_range") var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num - if(var_new == null) return - O.SetLuminosity(var_new) + if(var_new == null) + return + O.set_light(var_new) + + else if(variable=="light_power") + var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num + if(var_new == null) + return + O.set_light(l_power = var_new) + else if(variable=="stat") var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num if(var_new == null) return diff --git a/code/modules/atmospherics/environmental/LINDA_fire.dm b/code/modules/atmospherics/environmental/LINDA_fire.dm index 1c2ec88a9d..034c18ae26 100644 --- a/code/modules/atmospherics/environmental/LINDA_fire.dm +++ b/code/modules/atmospherics/environmental/LINDA_fire.dm @@ -59,6 +59,7 @@ /obj/effect/hotspot/New() ..() + set_light(3,1,LIGHT_COLOR_FIRE) SSair.hotspots += src perform_exposure() setDir(pick(cardinal)) @@ -146,7 +147,6 @@ return 1 /obj/effect/hotspot/Destroy() - SetLuminosity(0) SSair.hotspots -= src DestroyTurf() if(istype(loc, /turf)) diff --git a/code/modules/awaymissions/mission_code/Cabin.dm b/code/modules/awaymissions/mission_code/Cabin.dm index 6f5ba2a4d6..670ff0f38d 100644 --- a/code/modules/awaymissions/mission_code/Cabin.dm +++ b/code/modules/awaymissions/mission_code/Cabin.dm @@ -4,14 +4,14 @@ icon_state = "away" requires_power = 0 luminosity = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_ENABLED + dynamic_lighting = DYNAMIC_LIGHTING_ENABLED /area/awaymission/cabin name = "Cabin" icon_state = "away2" requires_power = 1 luminosity = 0 - lighting_use_dynamic = DYNAMIC_LIGHTING_ENABLED + dynamic_lighting = DYNAMIC_LIGHTING_ENABLED /area/awaymission/snowforest/lumbermill name = "Lumbermill" @@ -54,10 +54,10 @@ /obj/structure/fireplace/proc/toggleFireplace() if(active) - SetLuminosity(8) + set_light(8) icon_state = "fireplace-active" else - SetLuminosity(0) + set_light(0) icon_state = "fireplace" /obj/structure/fireplace/extinguish() diff --git a/code/modules/awaymissions/mission_code/researchbase.dm b/code/modules/awaymissions/mission_code/researchbase.dm index 0149a5cdf0..56cfb14195 100644 --- a/code/modules/awaymissions/mission_code/researchbase.dm +++ b/code/modules/awaymissions/mission_code/researchbase.dm @@ -4,7 +4,7 @@ name = "Research Outpost" icon_state = "away" luminosity = 0 - lighting_use_dynamic = DYNAMIC_LIGHTING_ENABLED + dynamic_lighting = DYNAMIC_LIGHTING_ENABLED /area/awaymission/research/interior name = "Research Inside" diff --git a/code/modules/awaymissions/mission_code/snowdin.dm b/code/modules/awaymissions/mission_code/snowdin.dm index 35dcdc3b70..af2d22731b 100644 --- a/code/modules/awaymissions/mission_code/snowdin.dm +++ b/code/modules/awaymissions/mission_code/snowdin.dm @@ -5,7 +5,7 @@ icon_state = "away" requires_power = 0 luminosity = 1 - lighting_use_dynamic = DYNAMIC_LIGHTING_ENABLED + dynamic_lighting = DYNAMIC_LIGHTING_ENABLED /area/awaymission/snowdin/post name = "Snowdin Outpost" diff --git a/code/modules/awaymissions/signpost.dm b/code/modules/awaymissions/signpost.dm index 5567f0c0cf..d496e07a6d 100644 --- a/code/modules/awaymissions/signpost.dm +++ b/code/modules/awaymissions/signpost.dm @@ -9,7 +9,7 @@ /obj/structure/signpost/New() . = ..() - SetLuminosity(2) + set_light(2) /obj/structure/signpost/attackby(obj/item/weapon/W, mob/user, params) return attack_hand(user) diff --git a/code/modules/cargo/console.dm b/code/modules/cargo/console.dm index 10ef82c119..de812a3eb1 100644 --- a/code/modules/cargo/console.dm +++ b/code/modules/cargo/console.dm @@ -8,6 +8,7 @@ var/safety_warning = "For safety reasons the automated supply shuttle \ cannot transport live organisms, classified nuclear weaponry or \ homing beacons." + light_color = LIGHT_COLOR_BROWN /obj/machinery/computer/cargo/request name = "supply request console" @@ -197,4 +198,3 @@ status_signal.data["command"] = command frequency.post_signal(src, status_signal) - diff --git a/code/modules/clothing/head/hardhat.dm b/code/modules/clothing/head/hardhat.dm index 421a77b43d..66e0473005 100644 --- a/code/modules/clothing/head/hardhat.dm +++ b/code/modules/clothing/head/hardhat.dm @@ -14,9 +14,6 @@ dog_fashion = /datum/dog_fashion/head /obj/item/clothing/head/hardhat/attack_self(mob/user) - if(!isturf(user.loc)) - user << "You cannot turn the light on while in this [user.loc]!" //To prevent some lighting anomalities. - return on = !on icon_state = "hardhat[on]_[item_color]" item_state = "hardhat[on]_[item_color]" @@ -30,23 +27,11 @@ var/datum/action/A = X A.UpdateButtonIcon() -/obj/item/clothing/head/hardhat/pickup(mob/user) - ..() - if(on) - user.AddLuminosity(brightness_on) - SetLuminosity(0) - -/obj/item/clothing/head/hardhat/dropped(mob/user) - ..() - if(on) - user.AddLuminosity(-brightness_on) - SetLuminosity(brightness_on) - /obj/item/clothing/head/hardhat/proc/turn_on(mob/user) - user.AddLuminosity(brightness_on) + set_light(brightness_on) /obj/item/clothing/head/hardhat/proc/turn_off(mob/user) - user.AddLuminosity(-brightness_on) + set_light(0) /obj/item/clothing/head/hardhat/orange icon_state = "hardhat0_orange" diff --git a/code/modules/clothing/head/helmet.dm b/code/modules/clothing/head/helmet.dm index 1b6b271f6f..8d05cc6b8f 100644 --- a/code/modules/clothing/head/helmet.dm +++ b/code/modules/clothing/head/helmet.dm @@ -247,7 +247,7 @@ return user << "You click [S] into place on [src]." if(S.on) - SetLuminosity(0) + set_light(0) F = S S.loc = src update_icon() @@ -298,37 +298,13 @@ /obj/item/clothing/head/helmet/proc/update_helmlight(mob/user = null) if(F) if(F.on) - if(loc == user) - user.AddLuminosity(F.brightness_on) - else if(isturf(loc)) - SetLuminosity(F.brightness_on) + set_light(F.brightness_on) else - if(loc == user) - user.AddLuminosity(-F.brightness_on) - else if(isturf(loc)) - SetLuminosity(0) + set_light(0) update_icon() else - if(loc == user) - user.AddLuminosity(-5) - else if(isturf(loc)) - SetLuminosity(0) + set_light(0) for(var/X in actions) var/datum/action/A = X A.UpdateButtonIcon() - -/obj/item/clothing/head/helmet/pickup(mob/user) - ..() - if(F) - if(F.on) - user.AddLuminosity(F.brightness_on) - SetLuminosity(0) - - -/obj/item/clothing/head/helmet/dropped(mob/user) - ..() - if(F) - if(F.on) - user.AddLuminosity(-F.brightness_on) - SetLuminosity(F.brightness_on) diff --git a/code/modules/clothing/spacesuits/hardsuit.dm b/code/modules/clothing/spacesuits/hardsuit.dm index 4503c214dc..36394c1924 100644 --- a/code/modules/clothing/spacesuits/hardsuit.dm +++ b/code/modules/clothing/spacesuits/hardsuit.dm @@ -14,33 +14,21 @@ /obj/item/clothing/head/helmet/space/hardsuit/attack_self(mob/user) - if(!isturf(user.loc)) - user << "You cannot turn the light on while in this [user.loc]!" //To prevent some lighting anomalities. - return on = !on icon_state = "[basestate][on]-[item_color]" user.update_inv_head() //so our mob-overlays update if(on) - user.AddLuminosity(brightness_on) + set_light(brightness_on) else - user.AddLuminosity(-brightness_on) + set_light(0) + for(var/X in actions) var/datum/action/A = X A.UpdateButtonIcon() - -/obj/item/clothing/head/helmet/space/hardsuit/pickup(mob/user) - ..() - if(on) - user.AddLuminosity(brightness_on) - SetLuminosity(0) - /obj/item/clothing/head/helmet/space/hardsuit/dropped(mob/user) ..() - if(on) - user.AddLuminosity(-brightness_on) - SetLuminosity(brightness_on) if(suit) suit.RemoveHelmet() @@ -228,7 +216,7 @@ user << "You switch your hardsuit to EVA mode, sacrificing speed for space protection." name = initial(name) desc = initial(desc) - user.AddLuminosity(brightness_on) + set_light(brightness_on) flags |= visor_flags flags_cover |= HEADCOVERSEYES | HEADCOVERSMOUTH flags_inv |= visor_flags_inv @@ -237,7 +225,7 @@ user << "You switch your hardsuit to combat mode and can now run at full speed." name += " (combat)" desc = alt_desc - user.AddLuminosity(-brightness_on) + set_light(0) flags &= ~visor_flags flags_cover &= ~(HEADCOVERSEYES | HEADCOVERSMOUTH) flags_inv &= ~visor_flags_inv diff --git a/code/modules/events/spacevine.dm b/code/modules/events/spacevine.dm index 40f290aa30..f355634ca6 100644 --- a/code/modules/events/spacevine.dm +++ b/code/modules/events/spacevine.dm @@ -110,7 +110,7 @@ for(var/obj/effect/spacevine/SV in src) qdel(SV) ..() - UpdateAffectingLights() + reconsider_lights() /datum/spacevine_mutation/space_covering/on_grow(obj/effect/spacevine/holder) if(istype(holder.loc, /turf/open/space)) @@ -144,7 +144,7 @@ /datum/spacevine_mutation/light/on_grow(obj/effect/spacevine/holder) if(holder.energy) - holder.SetLuminosity(severity, 3) + holder.set_light(severity, 3) /datum/spacevine_mutation/toxicity name = "toxic" @@ -219,7 +219,7 @@ quality = POSITIVE /datum/spacevine_mutation/transparency/on_grow(obj/effect/spacevine/holder) - holder.SetOpacity(0) + holder.set_opacity(0) holder.alpha = 125 /datum/spacevine_mutation/oxy_eater @@ -359,7 +359,7 @@ KZ.potency = min(100, master.mutativness * 10) KZ.production = (master.spread_cap / initial(master.spread_cap)) * 50 mutations = list() - SetOpacity(0) + set_opacity(0) if(has_buckled_mobs()) unbuckle_all_mobs(force=1) return ..() @@ -519,7 +519,7 @@ if(!energy) src.icon_state = pick("Med1", "Med2", "Med3") energy = 1 - SetOpacity(1) + set_opacity(1) else src.icon_state = pick("Hvy1", "Hvy2", "Hvy3") energy = 2 diff --git a/code/modules/holodeck/areas.dm b/code/modules/holodeck/areas.dm index 53f475affa..f7bac9dc9a 100644 --- a/code/modules/holodeck/areas.dm +++ b/code/modules/holodeck/areas.dm @@ -2,7 +2,7 @@ name = "Holodeck" icon_state = "Holodeck" luminosity = 1 - lighting_use_dynamic = 0 + dynamic_lighting = DYNAMIC_LIGHTING_DISABLED var/obj/machinery/computer/holodeck/linked var/restricted = 0 // if true, program goes on emag list @@ -99,4 +99,4 @@ /area/holodeck/rec_center/anthophila name = "Holodeck - Anthophila" - restricted = 1 \ No newline at end of file + restricted = 1 diff --git a/code/modules/holodeck/computer.dm b/code/modules/holodeck/computer.dm index cc50f155f0..02d6a81a9f 100644 --- a/code/modules/holodeck/computer.dm +++ b/code/modules/holodeck/computer.dm @@ -25,6 +25,7 @@ var/area/holodeck/program var/area/holodeck/last_program var/area/offline_program = /area/holodeck/rec_center/offline + light_color = LIGHT_COLOR_CYAN var/list/program_cache = list() var/list/emag_programs = list() @@ -206,4 +207,4 @@ /obj/machinery/computer/holodeck/blob_act(obj/effect/blob/B) emergency_shutdown() - ..() \ No newline at end of file + ..() diff --git a/code/modules/hydroponics/biogenerator.dm b/code/modules/hydroponics/biogenerator.dm index fb1983a417..5a64a2d086 100644 --- a/code/modules/hydroponics/biogenerator.dm +++ b/code/modules/hydroponics/biogenerator.dm @@ -7,6 +7,10 @@ anchored = 1 use_power = 1 idle_power_usage = 40 + use_auto_lights = 1 + light_power_on = 2 + light_range_on = 3 + light_color = LIGHT_COLOR_BLUE var/processing = 0 var/obj/item/weapon/reagent_containers/glass/beaker = null var/points = 0 diff --git a/code/modules/hydroponics/grown.dm b/code/modules/hydroponics/grown.dm index 8942a68eba..ad1279c858 100644 --- a/code/modules/hydroponics/grown.dm +++ b/code/modules/hydroponics/grown.dm @@ -38,6 +38,9 @@ seed.prepare_result(src) transform *= TransformUsingVariable(seed.potency, 100, 0.5) //Makes the resulting produce's sprite larger or smaller based on potency! add_juice() + var/datum/plant_gene/trait/glow/G = seed.get_gene(/datum/plant_gene/trait/glow) + if(G) + set_light(G.get_lum(seed)) @@ -134,33 +137,6 @@ T.on_cross(src, AM) ..() - -// Glow gene procs -/obj/item/weapon/reagent_containers/food/snacks/grown/Destroy() - if(seed) - var/datum/plant_gene/trait/glow/G = seed.get_gene(/datum/plant_gene/trait/glow) - if(G && ismob(loc)) - loc.AddLuminosity(-G.get_lum(seed)) - return ..() - -/obj/item/weapon/reagent_containers/food/snacks/grown/pickup(mob/user) - ..() - if(seed) - var/datum/plant_gene/trait/glow/G = seed.get_gene(/datum/plant_gene/trait/glow) - if(G) - SetLuminosity(0) - user.AddLuminosity(G.get_lum(seed)) - -/obj/item/weapon/reagent_containers/food/snacks/grown/dropped(mob/user) - ..() - if(seed) - var/datum/plant_gene/trait/glow/G = seed.get_gene(/datum/plant_gene/trait/glow) - if(G) - user.AddLuminosity(-G.get_lum(seed)) - SetLuminosity(G.get_lum(seed)) - - - // For item-containing growns such as eggy or gatfruit /obj/item/weapon/reagent_containers/food/snacks/grown/shell/attack_self(mob/user as mob) user.unEquip(src) diff --git a/code/modules/hydroponics/growninedible.dm b/code/modules/hydroponics/growninedible.dm index 17b5456e72..3514138036 100644 --- a/code/modules/hydroponics/growninedible.dm +++ b/code/modules/hydroponics/growninedible.dm @@ -30,6 +30,9 @@ seed.prepare_result(src) transform *= TransformUsingVariable(seed.potency, 100, 0.5) add_juice() + var/datum/plant_gene/trait/glow/G = seed.get_gene(/datum/plant_gene/trait/glow) + if(G) + set_light(G.get_lum(seed)) /obj/item/weapon/grown/attackby(obj/item/O, mob/user, params) @@ -53,28 +56,3 @@ for(var/datum/plant_gene/trait/T in seed.genes) T.on_cross(src, AM) ..() - - -// Glow gene procs -/obj/item/weapon/grown/Destroy() - if(seed) - var/datum/plant_gene/trait/glow/G = seed.get_gene(/datum/plant_gene/trait/glow) - if(G && ismob(loc)) - loc.AddLuminosity(-G.get_lum(seed)) - return ..() - -/obj/item/weapon/grown/pickup(mob/user) - ..() - if(seed) - var/datum/plant_gene/trait/glow/G = seed.get_gene(/datum/plant_gene/trait/glow) - if(G) - SetLuminosity(0) - user.AddLuminosity(G.get_lum(seed)) - -/obj/item/weapon/grown/dropped(mob/user) - ..() - if(seed) - var/datum/plant_gene/trait/glow/G = seed.get_gene(/datum/plant_gene/trait/glow) - if(G) - user.AddLuminosity(-G.get_lum(seed)) - SetLuminosity(G.get_lum(seed)) \ No newline at end of file diff --git a/code/modules/hydroponics/hydroponics.dm b/code/modules/hydroponics/hydroponics.dm index f456854975..6a00b9fa11 100644 --- a/code/modules/hydroponics/hydroponics.dm +++ b/code/modules/hydroponics/hydroponics.dm @@ -150,7 +150,7 @@ // Lack of light hurts non-mushrooms if(isturf(loc)) var/turf/currentTurf = loc - var/lightAmt = currentTurf.lighting_lumcount + var/lightAmt = currentTurf.get_lumcount() if(myseed.plant_type == PLANT_MUSHROOM) if(lightAmt < 2) adjustHealth(-1 / rating) @@ -259,7 +259,7 @@ color = rgb(255, 175, 0) else overlays += image('icons/obj/hydroponics/equipment.dmi', icon_state = "gaia_blessing") - SetLuminosity(3) + set_light(3) update_icon_hoses() @@ -270,9 +270,9 @@ if(!self_sustaining) if(myseed && myseed.get_gene(/datum/plant_gene/trait/glow)) var/datum/plant_gene/trait/glow/G = myseed.get_gene(/datum/plant_gene/trait/glow) - SetLuminosity(G.get_lum(myseed)) + set_light(G.get_lum(myseed)) else - SetLuminosity(0) + set_light(0) return diff --git a/code/modules/hydroponics/plant_genes.dm b/code/modules/hydroponics/plant_genes.dm index 3812bc1812..965c67d501 100644 --- a/code/modules/hydroponics/plant_genes.dm +++ b/code/modules/hydroponics/plant_genes.dm @@ -258,7 +258,7 @@ if(ismob(newloc)) G.pickup(newloc)//adjusts the lighting on the mob else - G.SetLuminosity(get_lum(G.seed)) + G.set_light(get_lum(G.seed)) /datum/plant_gene/trait/glow/berry name = "Strong Bioluminescence" diff --git a/code/modules/hydroponics/seed_extractor.dm b/code/modules/hydroponics/seed_extractor.dm index 380882f203..2579a8fd45 100644 --- a/code/modules/hydroponics/seed_extractor.dm +++ b/code/modules/hydroponics/seed_extractor.dm @@ -47,6 +47,10 @@ var/piles = list() var/max_seeds = 1000 var/seed_multiplier = 1 + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 3 + light_color = LIGHT_COLOR_BLUE /obj/machinery/seed_extractor/New() ..() diff --git a/code/modules/lighting/__lighting_docs.dm b/code/modules/lighting/__lighting_docs.dm new file mode 100644 index 0000000000..255ecc0359 --- /dev/null +++ b/code/modules/lighting/__lighting_docs.dm @@ -0,0 +1,74 @@ +/* +BS12 object based lighting system from VG, ported to TG by Unusual Crow with plenty of help from PJB. +*/ + +/* +Changes from TG DAL: + - Lighting is done using objects instead of subareas. + - Animated transitions. (newer TG DAL has this) + - Full colours with mixing. + - Support for lights on shuttles. + + - Code: + - Instead of one flat luminosity var, light is represented by 3 atom vars: + - light_range; range in tiles of the light, used for calculating falloff, + - light_power; multiplier for the brightness of lights, + - light_color; hex string representing the RGB colour of the light. + - SetLuminosity() is now set_light() and takes the three variables above. + - Variables can be left as null to not update them. + - SetOpacity() is now set_opacity(). + - Areas have luminosity set to 1 permanently, no hard-lighting. + - Objects inside other objects can have lights and they properly affect the turf. (flashlights) + - area/master and area/list/related have been eviscerated since subareas aren't needed. +*/ + +/* +Relevant vars/procs: + +global: (uh, I placed the only one in lighting_system.dm) + - var/list/all_lighting_overlays; Just a list of ALL of the lighting overlays. + +atom: (lighting_atom.dm) + - var/light_range; range in tiles of the light, used for calculating falloff + - var/light_power; multiplier for the brightness of lights + - var/light_color; hex string representing the RGB colour of the light + + - var/datum/light_source/light; light source datum for this atom, only present if light_range && light_power + - var/list/light_sources; light sources in contents that are shining through this object, including this object + + - proc/set_light(l_range, l_power, l_color): + - Sets light_range/power/color to non-null args and calls update_light() + - proc/set_opacity(new_opacity): + - Sets opacity to new_opacity. + - If opacity has changed, call turf.reconsider_lights() to fix light occlusion + - proc/update_light(): + - Updates the light var on this atom, deleting or creating as needed and calling .update() + + +turf: (lighting_turf.dm) + - var/list/affecting_lights; list of light sources that are shining onto this turf + - var/list/lighting_overlays; list of lighting overlays in the turf. (only used if higher resolutions + - var/lighting_overlay; ref to the lighting overlay (only used if resolution is 1) + + - proc/reconsider_lights(): + - Force all light sources shining onto this turf to update + + - proc/lighting_clear_overlays(): + - Delete (manual GC) all light overlays on this turf, used when changing turf to space + - proc/lighting_build_overlays(): + - Create lighting overlays for this turf + - proc/get_lumcount(var/minlum = 0, var/maxlum = 1) + - Returns a decimal according to the amount of lums on a turf's overlay (also averages them) + - With default arguments (based on the fact that 0 = pitch black and 1 = full bright), it will return .5 for a 50% lit tile. + +atom/movable/lighting_overlay: (lighting_overlay.dm) + - var/lum_r, var/lum_g, var/lum_b; lumcounts of each colour + - var/needs_update; set on update_lumcount, checked by lighting process + + - var/xoffset, var/yoffset; (only present when using sub-tile overlays) fractional offset of this overlay in the tile + + - proc/update_lumcount(delta_r, delta_g, delta_b): + - Change the lumcount vars and queue the overlay for update + - proc/update_overlay() + - Called by the lighting process to update the color of the overlay +*/ diff --git a/code/modules/lighting/lighting_area.dm b/code/modules/lighting/lighting_area.dm new file mode 100644 index 0000000000..702a6ded15 --- /dev/null +++ b/code/modules/lighting/lighting_area.dm @@ -0,0 +1,30 @@ +/area + luminosity = TRUE + var/dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + +/area/New() + . = ..() + + // Moved to the subsystem. + /* + if (dynamic_lighting) + luminosity = FALSE + */ + +/area/proc/set_dynamic_lighting(var/new_dynamic_lighting = DYNAMIC_LIGHTING_ENABLED) + if (new_dynamic_lighting == dynamic_lighting) + return FALSE + + dynamic_lighting = new_dynamic_lighting + + if (IS_DYNAMIC_LIGHTING(src)) + for (var/turf/T in (area_contents())) + if (IS_DYNAMIC_LIGHTING(T)) + T.lighting_build_overlay() + + else + for (var/turf/T in (area_contents())) + if (T.lighting_overlay) + T.lighting_clear_overlay() + + return TRUE diff --git a/code/modules/lighting/lighting_atom.dm b/code/modules/lighting/lighting_atom.dm new file mode 100644 index 0000000000..aeef051734 --- /dev/null +++ b/code/modules/lighting/lighting_atom.dm @@ -0,0 +1,105 @@ +#define MINIMUM_USEFUL_LIGHT_RANGE 1.4 + +/atom + var/light_power = 1 // Intensity of the light. + var/light_range = 0 // Range in tiles of the light. + var/light_color // Hexadecimal RGB string representing the colour of the light. + + var/tmp/datum/light_source/light // Our light source. Don't fuck with this directly unless you have a good reason! + var/tmp/list/light_sources // Any light sources that are "inside" of us, for example, if src here was a mob that's carrying a flashlight, that flashlight's light source would be part of this list. + +// The proc you should always use to set the light of this atom. +// Nonesensical value for l_color default, so we can detect if it gets set to null. +#define NONSENSICAL_VALUE -99999 +/atom/proc/set_light(var/l_range, var/l_power, var/l_color = NONSENSICAL_VALUE) + if(l_range > 0 && l_range < MINIMUM_USEFUL_LIGHT_RANGE) + l_range = MINIMUM_USEFUL_LIGHT_RANGE //Brings the range up to 1.4, which is just barely brighter than the soft lighting that surrounds players. + + if (l_power != null) + light_power = l_power + + if (l_range != null) + light_range = l_range + + if (l_color != NONSENSICAL_VALUE) + light_color = l_color + + update_light() + +#undef NONSENSICAL_VALUE + +// Will update the light (duh). +// Creates or destroys it if needed, makes it update values, makes sure it's got the correct source turf... +/atom/proc/update_light() + set waitfor = FALSE + if (qdeleted(src)) + return + + if (!light_power || !light_range) // We won't emit light anyways, destroy the light source. + if(light) + light.destroy() + light = null + else + if (!istype(loc, /atom/movable)) // We choose what atom should be the top atom of the light here. + . = src + else + . = loc + + if (light) // Update the light or create it if it does not exist. + light.update(.) + else + light = new/datum/light_source(src, .) + +// Incase any lighting vars are on in the typepath we turn the light on in New(). +/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 guaranteed to be on afterwards anyways. + +// Destroy our light source so we GC correctly. +/atom/Destroy() + if (light) + light.destroy() + light = null + . = ..() + +// If we have opacity, make sure to tell (potentially) affected light sources. +/atom/movable/Destroy() + var/turf/T = loc + if (opacity && istype(T)) + T.reconsider_lights() + + . = ..() + +// Should always be used to change the opacity of an atom. +// It notifies (potentially) affected light sources so they can update (if needed). +/atom/proc/set_opacity(var/new_opacity) + if (new_opacity == opacity) + return + + opacity = new_opacity + var/turf/T = loc + if (!isturf(T)) + return + + if (new_opacity == TRUE) + T.has_opaque_atom = TRUE + T.reconsider_lights() + else + var/old_has_opaque_atom = T.has_opaque_atom + T.recalc_atom_opacity() + if (old_has_opaque_atom != T.has_opaque_atom) + T.reconsider_lights() + + +// This code makes the light be queued for update when it is moved. +// Entered() should handle it, however Exited() can do it if it is being moved to nullspace (as there would be no Entered() call in that situation). +/atom/movable/Moved(atom/OldLoc, Dir) //Implemented here because forceMove() doesn't call Move() + . = ..() + for (var/datum/light_source/L in src.light_sources) // Cycle through the light sources on this atom and tell them to update. + L.source_atom.update_light() diff --git a/code/modules/lighting/lighting_corner.dm b/code/modules/lighting/lighting_corner.dm new file mode 100644 index 0000000000..b96b696613 --- /dev/null +++ b/code/modules/lighting/lighting_corner.dm @@ -0,0 +1,137 @@ +/var/list/datum/lighting_corner/all_lighting_corners = list() +/var/datum/lighting_corner/dummy/dummy_lighting_corner = new +// Because we can control each corner of every lighting overlay. +// 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/x = 0 + var/y = 0 + var/z = 0 + + var/lum_r = 0 + var/lum_g = 0 + var/lum_b = 0 + + var/needs_update = FALSE + + var/cache_r = 0 + var/cache_g = 0 + var/cache_b = 0 + var/cache_mx = 0 + + var/update_gen = 0 + +/datum/lighting_corner/New(var/turf/new_turf, var/diagonal) + . = ..() + + all_lighting_corners += src + + masters[new_turf] = turn(diagonal, 180) + z = new_turf.z + + 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. + + x = new_turf.x + (horizontal == EAST ? 0.5 : -0.5) + y = new_turf.y + (vertical == NORTH ? 0.5 : -0.5) + + // 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 + + // 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 + + // 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 + + // And finally the vertical one. + T = get_step(new_turf, vertical) + if (T) + 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 + + update_active() + +/datum/lighting_corner/proc/update_active() + active = FALSE + for (var/turf/T in masters) + if (T.lighting_overlay) + active = TRUE + +// 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) + lum_r += delta_r + lum_g += delta_g + lum_b += delta_b + +#ifndef LIGHTING_INSTANT_UPDATES + if (!needs_update) + needs_update = TRUE + lighting_update_corners += src + +/datum/lighting_corner/proc/update_overlays() +#endif + + // Cache these values a head of time so 4 individual lighting overlays don't all calculate them individually. + var/mx = max(lum_r, lum_g, lum_b) // Scale it so 1 is the strongest lum, if it is above 1. + . = 1 // factor + if (mx > 1) + . = 1 / mx + + else if (mx < LIGHTING_SOFT_THRESHOLD) + . = 0 // 0 means soft lighting. + + cache_r = lum_r * . || LIGHTING_SOFT_THRESHOLD + cache_g = lum_g * . || LIGHTING_SOFT_THRESHOLD + cache_b = lum_b * . || LIGHTING_SOFT_THRESHOLD + cache_mx = mx + + for (var/TT in masters) + var/turf/T = TT + if (T.lighting_overlay) + #ifdef LIGHTING_INSTANT_UPDATES + T.lighting_overlay.update_overlay() + #else + if (!T.lighting_overlay.needs_update) + T.lighting_overlay.needs_update = TRUE + lighting_update_overlays += T.lighting_overlay + #endif + + +/datum/lighting_corner/dummy/New() + return + +/datum/lighting_corner/Destroy(var/force) + if(force) + CRASH("Nope you're not deleting me!") + + return QDEL_HINT_LETMELIVE diff --git a/code/modules/lighting/lighting_overlay.dm b/code/modules/lighting/lighting_overlay.dm new file mode 100644 index 0000000000..6dbc61047f --- /dev/null +++ b/code/modules/lighting/lighting_overlay.dm @@ -0,0 +1,112 @@ +/var/list/all_lighting_overlays = list() // Global list of lighting overlays. + +/atom/movable/lighting_overlay + name = "" + + anchored = TRUE + + icon = LIGHTING_ICON + color = LIGHTING_BASE_MATRIX + mouse_opacity = 0 + layer = LIGHTING_LAYER + invisibility = INVISIBILITY_LIGHTING + + blend_mode = BLEND_MULTIPLY + + var/needs_update = FALSE + +/atom/movable/lighting_overlay/New(var/atom/loc, var/no_update = FALSE) + . = ..() + verbs.Cut() + global.all_lighting_overlays += src + + var/turf/T = loc // If this runtimes atleast we'll know what's creating overlays in things that aren't turfs. + T.lighting_overlay = src + T.luminosity = 0 + + for(var/turf/open/space/S in RANGE_TURFS(1,src)) //RANGE_TURFS is in code\__HELPERS\game.dm + S.update_starlight() + + if (no_update) + return + + update_overlay() + +/atom/movable/lighting_overlay/Destroy(var/force) + global.all_lighting_overlays -= src + global.lighting_update_overlays -= src + global.lighting_update_overlays_old -= src + + var/turf/T = loc + if (istype(T)) + T.lighting_overlay = null + T.luminosity = 1 + + if (force) + ..() + return QDEL_HINT_PUTINPOOL + + else + return QDEL_HINT_LETMELIVE + +/atom/movable/lighting_overlay/proc/update_overlay() + var/turf/T = loc + if (!istype(T)) // Erm... + if (loc) + warning("A lighting overlay realised its loc was NOT a turf (actual loc: [loc], [loc.type]) in update_overlay() and got pooled!") + + else + warning("A lighting overlay realised it was in nullspace in update_overlay() and got pooled!") + + qdel(src, TRUE) + return + + // To the future coder who sees this and thinks + // "Why didn't he just use a loop?" + // Well my man, it's because the loop performed like shit. + // And there's no way to improve it because + // without a loop you can make the list all at once which is the fastest you're gonna get. + // 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/datum/lighting_corner/cr = T.corners[3] || dummy_lighting_corner + var/datum/lighting_corner/cg = T.corners[2] || dummy_lighting_corner + var/datum/lighting_corner/cb = T.corners[4] || dummy_lighting_corner + var/datum/lighting_corner/ca = T.corners[1] || dummy_lighting_corner + + var/max = max(cr.cache_mx, cg.cache_mx, cb.cache_mx, ca.cache_mx) + + color = list( + cr.cache_r, cr.cache_g, cr.cache_b, 0, + cg.cache_r, cg.cache_g, cg.cache_b, 0, + cb.cache_r, cb.cache_g, cb.cache_b, 0, + ca.cache_r, ca.cache_g, ca.cache_b, 0, + 0, 0, 0, 1 + ) + luminosity = max > LIGHTING_SOFT_THRESHOLD + +// Variety of overrides so the overlays don't get affected by weird things. + +/atom/movable/lighting_overlay/ex_act(severity) + return 0 + +/atom/movable/lighting_overlay/singularity_act() + return + +/atom/movable/lighting_overlay/singularity_pull() + return + +/atom/movable/lighting_overlay/blob_act() + return + +// Override here to prevent things accidentally moving around overlays. +/atom/movable/lighting_overlay/forceMove(atom/destination, var/no_tp=FALSE, var/harderforce = FALSE) + if(harderforce) + . = ..() + +/atom/movable/lighting_overlay/ResetVars() + color = LIGHTING_BASE_MATRIX + + ..("color") diff --git a/code/modules/lighting/lighting_setup.dm b/code/modules/lighting/lighting_setup.dm new file mode 100644 index 0000000000..1c35c27ac4 --- /dev/null +++ b/code/modules/lighting/lighting_setup.dm @@ -0,0 +1,17 @@ +/proc/create_all_lighting_overlays() + for (var/zlevel = 1 to world.maxz) + create_lighting_overlays_zlevel(zlevel) + + +/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 (!IS_DYNAMIC_LIGHTING(T)) + continue + + var/area/A = T.loc + if (!IS_DYNAMIC_LIGHTING(A)) + continue + + PoolOrNew(/atom/movable/lighting_overlay, list(T, TRUE)) diff --git a/code/modules/lighting/lighting_source.dm b/code/modules/lighting/lighting_source.dm new file mode 100644 index 0000000000..17746d6305 --- /dev/null +++ b/code/modules/lighting/lighting_source.dm @@ -0,0 +1,305 @@ +// 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. + + 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() + + // Variables for keeping track of the colour. + var/lum_r + var/lum_g + var/lum_b + + // The lumcount values used to apply the light. + var/tmp/applied_lum_r + 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 + + var/applied = FALSE // Whether we have applied our light yet or not. + + 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 + +/datum/light_source/New(var/atom/owner, var/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. + top_atom = top + if (top_atom != source_atom) + if (!top.light_sources) + top.light_sources = list() + + top_atom.light_sources += src + + source_turf = top_atom + 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() + + update() + + return ..() + +// Kill ourselves. +/datum/light_source/proc/destroy() + destroyed = TRUE + force_update() + if (source_atom) + if (source_atom.light == src) + source_atom.light = null + source_atom.light_sources -= src + + if (top_atom) + top_atom.light_sources -= src + +// Fuck supporting force. +/datum/light_source/Destroy(var/force) + destroy() + return QDEL_HINT_IWILLGC + + +#ifdef LIGHTING_INSTANT_UPDATES +/datum/light_source/proc/effect_update() + if (check() || destroyed || force_update) + remove_lum() + if (!destroyed) + apply_lum() + + else if (vis_update) // We smartly update only tiles that became (in) visible to use. + smart_vis_update() + + vis_update = FALSE + force_update = FALSE + needs_update = FALSE +#else + +// 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; \ + } +#endif + +// 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) + // 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 + + top_atom = new_top_atom + + if (top_atom != source_atom) + if(!top_atom.light_sources) + top_atom.light_sources = list() + + top_atom.light_sources += src // Add ourselves to the light sources of our new top atom. + + effect_update(null) + +// Will force an update without checking if it's actually needed. +/datum/light_source/proc/force_update() + force_update = 1 + + effect_update(null) + +// 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 (istype(top_atom, /turf)) + 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 + +// Macro that applies light to a new corner. +// It is a macro in the interest of speed, yet not having to copy paste it. +// If you're wondering what's with the backslashes, the backslashes cause BYOND to not automatically end the line. +// 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 \ + ); + +// 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 \ + ); + +// This is the define used to calculate falloff. +#define LUM_FALLOFF(C, T) (1 - CLAMP01(sqrt((C.x - T.x) ** 2 + (C.y - T.y) ** 2 + LIGHTING_HEIGHT) / max(1, light_range))) + +/datum/light_source/proc/apply_lum() + var/static/update_gen = 1 + applied = 1 + + // 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() + + for (var/datum/lighting_corner/C in T.get_corners()) + if (C.update_gen == update_gen) + continue + + C.update_gen = update_gen + C.affecting += src + + if (!C.active) + continue + + APPLY_CORNER(C) + + if (!T.affecting_lights) + T.affecting_lights = list() + + T.affecting_lights += src + affecting_turfs += T + + update_gen++ + +/datum/light_source/proc/remove_lum() + applied = FALSE + + 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 + + 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 + + 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 + + for (var/datum/lighting_corner/C in corners - effect_str) // New corners + C.affecting += src + if (!C.active) + continue + + 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 LUM_FALLOFF +#undef REMOVE_CORNER +#undef APPLY_CORNER diff --git a/code/modules/lighting/lighting_system.dm b/code/modules/lighting/lighting_system.dm deleted file mode 100644 index d65331be03..0000000000 --- a/code/modules/lighting/lighting_system.dm +++ /dev/null @@ -1,428 +0,0 @@ -/* - This is /tg/'s 'newer' lighting system. It's basically a combination of Forum_Account's and ShadowDarke's - respective lighting libraries heavily modified by Carnwennan for /tg/station with further edits by - MrPerson. Credits, where due, to them. - - Originally, like all other lighting libraries on BYOND, we used areas to render different hard-coded light levels. - The idea was that this was cheaper than using objects. Well as it turns out, the cost of the system is primarily from the - massive loops the system has to run, not from the areas or objects actually doing any work. Thus the newer system uses objects - so we can have more lighting states and smooth transitions between them. - - This is a queueing system. Everytime we call a change to opacity or luminosity throwgh SetOpacity() or SetLuminosity(), - we are simply updating variables and scheduling certain lights/turfs for an update. Actual updates are handled - periodically by the SSlighting subsystem. Specifically, it runs check() on every light datum that ran changed(). - Then it runs redraw_lighting() on every turf that ran update_lumcount(). - - Unlike our older system, there are hardcoded maximum luminosities (different for certain atoms). - This is to cap the cost of creating lighting effects. - (without this, an atom with luminosity of 20 would have to update 41^2 turfs!) :s - - Each light remembers the effect it casts on each turf. It reduces cost of removing lighting effects by a lot! - - Known Issues/TODO: - Shuttles still do not have support for dynamic lighting (I hope to fix this at some point) -probably trivial now - No directional lighting support. (prototype looked ugly) - Allow lights to be weaker than 'cap' radius - Colored lights -*/ - -#define LIGHTING_CIRCULAR 1 //Comment this out to use old square lighting effects. -//#define LIGHTING_LAYER 15 //Drawing layer for lighting, moved to layers.dm -#define LIGHTING_CAP 10 //The lumcount level at which alpha is 0 and we're fully lit. -#define LIGHTING_CAP_FRAC (255/LIGHTING_CAP) //A precal'd variable we'll use in turf/redraw_lighting() -#define LIGHTING_ICON 'icons/effects/alphacolors.dmi' -#define LIGHTING_ICON_STATE "white" -#define LIGHTING_TIME 2 //Time to do any lighting change. Actual number pulled out of my ass -#define LIGHTING_DARKEST_VISIBLE_ALPHA 250 //Anything darker than this is so dark, we'll just consider the whole tile unlit -#define LIGHTING_LUM_FOR_FULL_BRIGHT 6 //Anything who's lum is lower then this starts off less bright. -#define LIGHTING_MIN_RADIUS 4 //Lowest radius a light source can effect. - -/datum/light_source - var/atom/owner - var/radius = 0 - var/luminosity = 0 - var/cap = 0 - var/changed = 0 - var/list/effect = list() - var/__x = 0 //x coordinate at last update - var/__y = 0 //y coordinate at last update - -/datum/light_source/New(atom/A) - if(!istype(A)) - CRASH("The first argument to the light object's constructor must be the atom that is the light source. Expected atom, received '[A]' instead.") - ..() - owner = A - UpdateLuminosity(A.luminosity) - -/datum/light_source/Destroy() - if(owner && owner.light == src) - remove_effect() - owner.light = null - owner.luminosity = 0 - owner = null - if(changed) - SSlighting.changed_lights -= src - return ..() - -/datum/light_source/proc/UpdateLuminosity(new_luminosity, new_cap) - if(new_luminosity < 0) - new_luminosity = 0 - - if(luminosity == new_luminosity && (new_cap == null || cap == new_cap)) - return - - radius = max(LIGHTING_MIN_RADIUS, new_luminosity) - luminosity = new_luminosity - if (new_cap != null) - cap = new_cap - - changed() - - -//Check a light to see if its effect needs reprocessing. If it does, remove any old effect and create a new one -/datum/light_source/proc/check() - if(!owner) - remove_effect() - return 0 - - if(changed) - changed = 0 - remove_effect() - return add_effect() - - return 1 - -//Tell the lighting subsystem to check() next fire -/datum/light_source/proc/changed() - if(owner) - __x = owner.x - __y = owner.y - if(!changed) - changed = 1 - SSlighting.changed_lights |= src - -//Remove current effect -/datum/light_source/proc/remove_effect(). - for(var/turf/T in effect) - T.update_lumcount(-effect[T]) - - if(T.affecting_lights && T.affecting_lights.len) - T.affecting_lights -= src - - effect.Cut() - -//Apply a new effect. -/datum/light_source/proc/add_effect() - // only do this if the light is turned on and is on the map - if(!owner || !owner.loc) - return 0 - var/range = owner.get_light_range(radius) - if(range <= 0 || luminosity <= 0) - owner.luminosity = 0 - return 0 - - effect = list() - var/turf/To = get_turf(owner) - - - for(var/atom/movable/AM in To) - if(AM == owner) - continue - if(AM.opacity) - range = 1 - break - - owner.luminosity = range - var/center_strength = 0 - if (cap <= 0) - center_strength = LIGHTING_CAP/LIGHTING_LUM_FOR_FULL_BRIGHT*(luminosity) - else - center_strength = cap - - for(var/turf/T in view(range+1, To)) - -#ifdef LIGHTING_CIRCULAR - var/distance = cheap_hypotenuse(T.x, T.y, __x, __y) -#else - var/distance = max(abs(T,x - __x), abs(T.y - __y)) -#endif - - var/delta_lumcount = Clamp(center_strength * (range - distance) / range, 0, LIGHTING_CAP) - - if(delta_lumcount > 0) - effect[T] = delta_lumcount - T.update_lumcount(delta_lumcount) - - if(!T.affecting_lights) - T.affecting_lights = list() - T.affecting_lights |= src - - return 1 - -/atom - var/datum/light_source/light - - -//Turfs with opacity when they are constructed will trigger nearby lights to update -//Turfs and atoms with luminosity when they are constructed will create a light_source automatically -/turf/New() - ..() - if(luminosity) - light = new(src) - -//Movable atoms with opacity when they are constructed will trigger nearby lights to update -//Movable atoms with luminosity when they are constructed will create a light_source automatically -/atom/movable/New() - ..() - if(opacity && isturf(loc)) - loc.UpdateAffectingLights() - if(luminosity) - light = new(src) - -//Objects with opacity will trigger nearby lights to update at next SSlighting fire -/atom/movable/Destroy() - qdel(light) - if(opacity && isturf(loc)) - loc.UpdateAffectingLights() - return ..() - -//Objects with opacity will trigger nearby lights of the old location to update at next SSlighting fire -/atom/movable/Moved(atom/OldLoc, Dir) - if(opacity) - if (isturf(OldLoc)) - OldLoc.UpdateAffectingLights() - if (isturf(loc)) - loc.UpdateAffectingLights() - else - if(light) - light.changed() - return ..() - -//Sets our luminosity. -//If we have no light it will create one. -//If we are setting luminosity to 0 the light will be cleaned up by the controller and garbage collected once all its -//queues are complete. -//if we have a light already it is merely updated, rather than making a new one. -//The second arg allows you to scale the light cap for calculating falloff. - -/atom/proc/SetLuminosity(new_luminosity, new_cap) - if (!light) - if (new_luminosity <= 0) - return - light = new(src) - - light.UpdateLuminosity(new_luminosity, new_cap) - -/atom/proc/AddLuminosity(delta_luminosity) - if(light) - SetLuminosity(light.luminosity + delta_luminosity) - else - SetLuminosity(delta_luminosity) - -/area/SetLuminosity(new_luminosity) //we don't want dynamic lighting for areas - luminosity = !!new_luminosity - - -//change our opacity (defaults to toggle), and then update all lights that affect us. -/atom/proc/SetOpacity(new_opacity) - if(new_opacity == null) - new_opacity = !opacity //default = toggle opacity - else if(opacity == new_opacity) - return 0 //opacity hasn't changed! don't bother doing anything - opacity = new_opacity //update opacity, the below procs now call light updates. - UpdateAffectingLights() - return 1 - -/atom/movable/light - icon = LIGHTING_ICON - icon_state = LIGHTING_ICON_STATE - layer = LIGHTING_LAYER - mouse_opacity = 0 - blend_mode = BLEND_OVERLAY - invisibility = INVISIBILITY_LIGHTING - color = "#000" - luminosity = 0 - infra_luminosity = 1 - anchored = 1 - -/atom/movable/light/Destroy(force) - if(force) - . = ..() - else - return QDEL_HINT_LETMELIVE - -/atom/movable/light/Move() - return 0 - -/turf - var/lighting_lumcount = 0 - var/lighting_changed = 0 - var/atom/movable/light/lighting_object //Will be null for space turfs and anything in a static lighting area - var/list/affecting_lights //not initialised until used (even empty lists reserve a fair bit of memory) - -/turf/ChangeTurf(path) - if(!path || (!use_preloader && path == type)) //Sucks this is here but it would cause problems otherwise. - return ..() - - for(var/obj/effect/decal/cleanable/decal in src.contents) - qdel(decal) - - if(light) - qdel(light) - - var/old_lumcount = lighting_lumcount - initial(lighting_lumcount) - var/oldbaseturf = baseturf - - var/list/our_lights //reset affecting_lights if needed - if(opacity != initial(path:opacity) && old_lumcount) - UpdateAffectingLights() - - if(affecting_lights) - our_lights = affecting_lights.Copy() - - . = ..() //At this point the turf has changed - - affecting_lights = our_lights - - lighting_changed = 1 //Don't add ourself to SSlighting.changed_turfs - update_lumcount(old_lumcount) - baseturf = oldbaseturf - lighting_object = locate() in src - init_lighting() - - for(var/turf/open/space/S in RANGE_TURFS(1,src)) //RANGE_TURFS is in code\__HELPERS\game.dm - S.update_starlight() - -/turf/proc/update_lumcount(amount) - lighting_lumcount += amount - if(!lighting_changed) - SSlighting.changed_turfs += src - lighting_changed = 1 - -/turf/open/space/update_lumcount(amount) //Keep track in case the turf becomes a floor at some point, but don't process. - lighting_lumcount += amount - -/turf/proc/init_lighting() - var/area/A = loc - if(!IS_DYNAMIC_LIGHTING(A)) - if(lighting_changed) - lighting_changed = 0 - if(lighting_object) - lighting_object.alpha = 0 - lighting_object = null - else - if(!lighting_object) - lighting_object = new (src) - redraw_lighting(1) - for(var/turf/open/space/T in RANGE_TURFS(1,src)) - T.update_starlight() - - -/turf/open/space/init_lighting() - if(lighting_changed) - lighting_changed = 0 - if(lighting_object) - lighting_object.alpha = 0 - lighting_object = null - -/turf/proc/redraw_lighting(instantly = 0) - if(lighting_object) - var/newalpha - if(lighting_lumcount <= 0) - newalpha = 255 - else - if(lighting_lumcount < LIGHTING_CAP) - var/num = Clamp(lighting_lumcount * LIGHTING_CAP_FRAC, 0, 255) - newalpha = 255-num - else //if(lighting_lumcount >= LIGHTING_CAP) - newalpha = 0 - if(newalpha >= LIGHTING_DARKEST_VISIBLE_ALPHA) - newalpha = 255 - if(lighting_object.alpha != newalpha) - if(instantly) - lighting_object.alpha = newalpha - else - animate(lighting_object, alpha = newalpha, time = LIGHTING_TIME) - if(newalpha >= LIGHTING_DARKEST_VISIBLE_ALPHA) - luminosity = 0 - lighting_object.luminosity = 0 - else - luminosity = 1 - lighting_object.luminosity = 1 - - lighting_changed = 0 - -/turf/proc/get_lumcount() - . = LIGHTING_CAP - var/area/A = src.loc - if(IS_DYNAMIC_LIGHTING(A)) - . = src.lighting_lumcount - -/area - var/lighting_use_dynamic = DYNAMIC_LIGHTING_ENABLED //Turn this flag off to make the area fullbright - -/area/New() - . = ..() - if(lighting_use_dynamic != DYNAMIC_LIGHTING_ENABLED) - luminosity = 1 - -/area/proc/SetDynamicLighting() - if (lighting_use_dynamic == DYNAMIC_LIGHTING_DISABLED) - lighting_use_dynamic = DYNAMIC_LIGHTING_ENABLED - luminosity = 0 - for(var/turf/T in src.contents) - T.init_lighting() - T.update_lumcount(0) - -#undef LIGHTING_CIRCULAR -#undef LIGHTING_ICON -#undef LIGHTING_ICON_STATE -#undef LIGHTING_TIME -#undef LIGHTING_CAP -#undef LIGHTING_CAP_FRAC -#undef LIGHTING_DARKEST_VISIBLE_ALPHA -#undef LIGHTING_LUM_FOR_FULL_BRIGHT -#undef LIGHTING_MIN_RADIUS - - -//set the changed status of all lights which could have possibly lit this atom. -//We don't need to worry about lights which lit us but moved away, since they will have change status set already -//This proc can cause lots of lights to be updated. :( -/atom/proc/UpdateAffectingLights() - -/atom/movable/UpdateAffectingLights() - if(isturf(loc)) - loc.UpdateAffectingLights() - -/turf/UpdateAffectingLights() - if(affecting_lights) - for(var/datum/light_source/thing in affecting_lights) - if (!thing.changed) - thing.changed() //force it to update at next process() - - -#define LIGHTING_MAX_LUMINOSITY_STATIC 8 //Maximum luminosity to reduce lag. -#define LIGHTING_MAX_LUMINOSITY_MOBILE 7 //Moving objects have a lower max luminosity since these update more often. (lag reduction) -#define LIGHTING_MAX_LUMINOSITY_MOB 6 -#define LIGHTING_MAX_LUMINOSITY_TURF 8 //turfs are static too, why was this 1?! - -//caps luminosity effects max-range based on what type the light's owner is. -/atom/proc/get_light_range(radius) - return min(radius, LIGHTING_MAX_LUMINOSITY_STATIC) - -/atom/movable/get_light_range(radius) - return min(radius, LIGHTING_MAX_LUMINOSITY_MOBILE) - -/mob/get_light_range(radius) - return min(radius, LIGHTING_MAX_LUMINOSITY_MOB) - -/obj/machinery/light/get_light_range(radius) - return min(radius, LIGHTING_MAX_LUMINOSITY_STATIC) - -/turf/get_light_range(radius) - return min(radius, LIGHTING_MAX_LUMINOSITY_TURF) - -#undef LIGHTING_MAX_LUMINOSITY_STATIC -#undef LIGHTING_MAX_LUMINOSITY_MOBILE -#undef LIGHTING_MAX_LUMINOSITY_MOB -#undef LIGHTING_MAX_LUMINOSITY_TURF diff --git a/code/modules/lighting/lighting_turf.dm b/code/modules/lighting/lighting_turf.dm new file mode 100644 index 0000000000..bae6f502ae --- /dev/null +++ b/code/modules/lighting/lighting_turf.dm @@ -0,0 +1,153 @@ +/turf + var/dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + luminosity = 1 + + 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. + +/turf/New() + . = ..() + + if (opacity) + has_opaque_atom = TRUE + +// 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() + +/turf/proc/lighting_clear_overlay() + if (lighting_overlay) + qdel(lighting_overlay, TRUE) + lighting_overlay = null + + for (var/datum/lighting_corner/C in corners) + C.update_active() + + for(var/turf/open/space/S in RANGE_TURFS(1,src)) //RANGE_TURFS is in code\__HELPERS\game.dm + S.update_starlight() + +// Builds a lighting overlay for us, but only if our area is dynamic. +/turf/proc/lighting_build_overlay() + if (lighting_overlay) + return + + var/area/A = loc + if (IS_DYNAMIC_LIGHTING(A)) + if (!lighting_corners_initialised) + generate_missing_corners() + + PoolOrNew(/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 + +// Used to get a scaled lumcount. +/turf/proc/get_lumcount(var/minlum = 0, var/maxlum = 1) + if (!lighting_overlay) + return 0.5 + + var/totallums = 0 + for (var/datum/lighting_corner/L in corners) + totallums += L.lum_r + L.lum_b + L.lum_g + + totallums /= 12 // 4 corners, each with 3 channels, get the average. + + totallums = (totallums - minlum) / (maxlum - minlum) + + 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 + +// If an opaque movable atom moves around we need to potentially update visibility. +/turf/Entered(var/atom/movable/Obj, var/atom/OldLoc) + . = ..() + + 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) + . = ..() + + if (Obj && Obj.opacity) + recalc_atom_opacity() // Make sure to do this before reconsider_lights(), incase we're on instant updates. + reconsider_lights() + +/turf/change_area(var/area/old_area, var/area/new_area) + if (IS_DYNAMIC_LIGHTING(new_area) != IS_DYNAMIC_LIGHTING(old_area)) + if (IS_DYNAMIC_LIGHTING(new_area)) + lighting_build_overlay() + + else + lighting_clear_overlay() + +/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. + + return corners + +/turf/proc/generate_missing_corners() + 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]) + +/turf/ChangeTurf(path) + if(!path || (!use_preloader && path == type)) //Sucks this is here but it would cause problems otherwise. + return ..() + + if (!lighting_corners_initialised) + 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]) + + + 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 + + for(var/obj/effect/decal/cleanable/decal in src.contents) + qdel(decal) + + . = ..() //At this point the turf has changed + + lighting_corners_initialised = TRUE + recalc_atom_opacity() + 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(IS_DYNAMIC_LIGHTING(src)) + lighting_build_overlay() + else + lighting_clear_overlay() diff --git a/code/modules/lighting/~lighting_undefs.dm b/code/modules/lighting/~lighting_undefs.dm new file mode 100644 index 0000000000..b75094f4b7 --- /dev/null +++ b/code/modules/lighting/~lighting_undefs.dm @@ -0,0 +1,12 @@ +#ifdef LIGHTING_INSTANT_UPDATES +#undef LIGHTING_INTERVAL +#undef LIGHTING_INSTANT_UPDATES +#endif + +#undef LIGHTING_FALLOFF +#undef LIGHTING_LAMBERTIAN +#undef LIGHTING_HEIGHT + +#undef LIGHTING_ICON + +#undef LIGHTING_BASE_MATRIX \ No newline at end of file diff --git a/code/modules/mining/equipment.dm b/code/modules/mining/equipment.dm index 609940bc36..717f6bb87a 100644 --- a/code/modules/mining/equipment.dm +++ b/code/modules/mining/equipment.dm @@ -511,6 +511,9 @@ var/atom/mark = null var/marked_image = null +/obj/item/weapon/twohanded/required/mining_hammer/New() + set_light(luminosity) + /obj/item/projectile/destabilizer name = "destabilizing force" icon_state = "pulse1" @@ -581,11 +584,3 @@ charged = 1 icon_state = "mining_hammer1" playsound(src.loc, 'sound/weapons/kenetic_reload.ogg', 60, 1) - -/obj/item/weapon/twohanded/required/mining_hammer/pickup(mob/user) - ..() - user.AddLuminosity(luminosity) - -/obj/item/weapon/twohanded/required/mining_hammer/dropped(mob/user) - ..() - user.AddLuminosity(-luminosity) \ No newline at end of file diff --git a/code/modules/mining/laborcamp/laborshuttle.dm b/code/modules/mining/laborcamp/laborshuttle.dm index fac4dc3745..cf68eeff07 100644 --- a/code/modules/mining/laborcamp/laborshuttle.dm +++ b/code/modules/mining/laborcamp/laborshuttle.dm @@ -5,6 +5,7 @@ shuttleId = "laborcamp" possible_destinations = "laborcamp_home;laborcamp_away" req_access = list(access_brig) + light_color = LIGHT_COLOR_CYAN /obj/machinery/computer/shuttle/labor/one_way @@ -24,4 +25,4 @@ if(S && S.name == "laborcamp_away") usr << "Shuttle is already at the outpost!" return 0 - ..() \ No newline at end of file + ..() diff --git a/code/modules/mining/mine_items.dm b/code/modules/mining/mine_items.dm index f242c00724..84ab917813 100644 --- a/code/modules/mining/mine_items.dm +++ b/code/modules/mining/mine_items.dm @@ -57,6 +57,7 @@ shuttleId = "mining" possible_destinations = "mining_home;mining_away" no_destination_swap = 1 + light_color = LIGHT_COLOR_CYAN /*********************Pickaxe & Drills**************************/ @@ -638,4 +639,4 @@ if(cell) user << text("[src] has [cellcharge]/[cellmaxcharge] charge remaining.") else - user << text("[src] has no power supply installed.") \ No newline at end of file + user << text("[src] has no power supply installed.") diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index e9e2f54702..0d8d2d2a4a 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -109,7 +109,7 @@ on_fire = 1 src.visible_message("[src] catches fire!", \ "You're set on fire!") - src.AddLuminosity(3) + src.set_light(light_range + 3) throw_alert("fire", /obj/screen/alert/fire) update_fire() return TRUE @@ -119,7 +119,7 @@ if(on_fire) on_fire = 0 fire_stacks = 0 - src.AddLuminosity(-3) + src.set_light(light_range - 3) clear_alert("fire") update_fire() diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index b12a04ef51..233a7c35f9 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -738,7 +738,7 @@ var/list/ai_list = list() src << "Camera lights deactivated." for (var/obj/machinery/camera/C in lit_cameras) - C.SetLuminosity(0) + C.set_light(0) lit_cameras = list() return diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index c70a539e40..2fe0366cbb 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -1148,7 +1148,7 @@ update_headlamp() /mob/living/silicon/robot/proc/update_headlamp(var/turn_off = 0, var/cooldown = 100) - SetLuminosity(0) + set_light(0) if(lamp_intensity && (turn_off || stat || low_power_mode)) src << "Your headlamp has been deactivated." @@ -1157,7 +1157,7 @@ spawn(cooldown) //10 seconds by default, if the source of the deactivation does not keep stat that long. lamp_recharging = 0 else - AddLuminosity(lamp_intensity) + set_light(lamp_intensity) if(lamp_button) lamp_button.icon_state = "lamp[lamp_intensity]" diff --git a/code/modules/mob/living/simple_animal/bot/bot.dm b/code/modules/mob/living/simple_animal/bot/bot.dm index 0e851a4f15..e679cad45f 100644 --- a/code/modules/mob/living/simple_animal/bot/bot.dm +++ b/code/modules/mob/living/simple_animal/bot/bot.dm @@ -101,14 +101,14 @@ if(stat) return 0 on = 1 - SetLuminosity(initial(luminosity)) + set_light(initial(luminosity)) update_icon() diag_hud_set_botstat() return 1 /mob/living/simple_animal/bot/proc/turn_off() on = 0 - SetLuminosity(0) + set_light(0) bot_reset() //Resets an AI's call, should it exist. update_icon() @@ -863,7 +863,7 @@ Pass a positive integer as an argument to override a bot's default speed. else user << "[card] is inactive." else - user << "The personality slot is locked." + user << "The personality slot is locked." else user << "[src] is not compatible with [card]" diff --git a/code/modules/mob/living/simple_animal/friendly/dog.dm b/code/modules/mob/living/simple_animal/friendly/dog.dm index 401dc4c4a6..757fcd220d 100644 --- a/code/modules/mob/living/simple_animal/friendly/dog.dm +++ b/code/modules/mob/living/simple_animal/friendly/dog.dm @@ -255,7 +255,7 @@ emote_hear = list("barks!", "woofs!", "yaps.","pants.") emote_see = list("shakes its head.", "chases its tail.","shivers.") desc = initial(desc) - SetLuminosity(0) + set_light(0) if(inventory_head && inventory_head.dog_fashion) var/datum/dog_fashion/DF = new inventory_head.dog_fashion(src) diff --git a/code/modules/mob/living/simple_animal/friendly/drone/extra_drone_types.dm b/code/modules/mob/living/simple_animal/friendly/drone/extra_drone_types.dm index 8a5478dedc..811a2ad5fe 100644 --- a/code/modules/mob/living/simple_animal/friendly/drone/extra_drone_types.dm +++ b/code/modules/mob/living/simple_animal/friendly/drone/extra_drone_types.dm @@ -119,7 +119,7 @@ /mob/living/simple_animal/drone/cogscarab/New() . = ..() - SetLuminosity(2,1) + set_light(2,1) qdel(access_card) //we don't have free access access_card = null verbs -= /mob/living/simple_animal/drone/verb/check_laws diff --git a/code/modules/mob/living/simple_animal/friendly/drone/verbs.dm b/code/modules/mob/living/simple_animal/friendly/drone/verbs.dm index c231ec56e4..1390b589a5 100644 --- a/code/modules/mob/living/simple_animal/friendly/drone/verbs.dm +++ b/code/modules/mob/living/simple_animal/friendly/drone/verbs.dm @@ -16,9 +16,9 @@ set category = "Drone" set name = "Toggle drone light" if(light_on) - AddLuminosity(-8) + set_light(0) else - AddLuminosity(8) + set_light(8) light_on = !light_on @@ -51,4 +51,3 @@ staticChoice = selectedStatic updateSeeStaticMobs() - diff --git a/code/modules/mob/living/simple_animal/guardian/guardian.dm b/code/modules/mob/living/simple_animal/guardian/guardian.dm index a1d6748a28..01c621bda0 100644 --- a/code/modules/mob/living/simple_animal/guardian/guardian.dm +++ b/code/modules/mob/living/simple_animal/guardian/guardian.dm @@ -248,10 +248,10 @@ var/global/list/parasites = list() //all currently existing/living guardians /mob/living/simple_animal/hostile/guardian/proc/ToggleLight() if(!luminosity) src << "You activate your light." - SetLuminosity(3) + set_light(3) else src << "You deactivate your light." - SetLuminosity(0) + set_light(0) /mob/living/simple_animal/hostile/guardian/verb/ShowType() set name = "Check Guardian Type" diff --git a/code/modules/mob/living/simple_animal/hostile/statue.dm b/code/modules/mob/living/simple_animal/hostile/statue.dm index 739a332d65..b196579524 100644 --- a/code/modules/mob/living/simple_animal/hostile/statue.dm +++ b/code/modules/mob/living/simple_animal/hostile/statue.dm @@ -110,8 +110,8 @@ return null // Check for darkness var/turf/T = get_turf(loc) - if(T && destination && T.lighting_object) - if(T.lighting_lumcount<1 && destination.lighting_lumcount<1) // No one can see us in the darkness, right? + if(T && destination) + if((T.get_lumcount())<1 && (destination.get_lumcount())<1) // No one can see us in the darkness, right? return null if(T == destination) destination = null diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index ad0bcfc9ac..0683fced77 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -102,12 +102,7 @@ var/next_mob_id = 0 msg = blind_message else continue - else if(T.lighting_object) - if(T.lighting_object.invisibility <= M.see_invisible && !T.lighting_object.luminosity) - if(blind_message) //if the light object is dark and not invisible to us, we see blind_message/nothing - msg = blind_message - else - continue + M.show_message(msg,1,blind_message,2) /mob/proc/get_top_level_mob() @@ -140,12 +135,7 @@ proc/get_top_level_mob(var/mob/S) msg = blind_message else continue - else if(T.lighting_object) - if(T.lighting_object.invisibility <= M.see_invisible && !T.lighting_object.luminosity) //the light object is dark and not invisible to us - if(blind_message) - msg = blind_message - else - continue + M.show_message(msg,1,blind_message,2) // Show a message to all mobs in earshot of this one diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index fbf343381d..87c8364218 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -222,7 +222,7 @@ update_icon() if(on) - if(!light || light.luminosity != brightness) + if(!light || light.light_range != brightness) switchcount++ if(rigged) if(status == LIGHT_OK && trigger) @@ -232,13 +232,13 @@ status = LIGHT_BURNED icon_state = "[base_state]-burned" on = 0 - SetLuminosity(0) + set_light(0) else use_power = 2 - SetLuminosity(brightness) + set_light(brightness) else use_power = 1 - SetLuminosity(0) + set_light(0) active_power_usage = (brightness * 10) if(on != on_gs) diff --git a/code/modules/power/monitor.dm b/code/modules/power/monitor.dm index 1e12c0100b..0b935f8ac5 100644 --- a/code/modules/power/monitor.dm +++ b/code/modules/power/monitor.dm @@ -7,6 +7,7 @@ idle_power_usage = 20 active_power_usage = 100 circuit = /obj/item/weapon/circuitboard/computer/powermonitor + light_color = LIGHT_COLOR_ORANGE var/obj/structure/cable/attached diff --git a/code/modules/power/power.dm b/code/modules/power/power.dm index 3d2a726adc..cc968ac2b0 100644 --- a/code/modules/power/power.dm +++ b/code/modules/power/power.dm @@ -86,9 +86,18 @@ // can override if needed if(powered(power_channel)) stat &= ~NOPOWER + + if(!use_auto_lights) + return + set_light(light_range_on, light_power_on) + else stat |= NOPOWER + + if(!use_auto_lights) + return + set_light(0) return // connect the machine to a powernet if a node cable is present on the turf diff --git a/code/modules/power/solar.dm b/code/modules/power/solar.dm index 9a88564a0e..4d37bedcee 100644 --- a/code/modules/power/solar.dm +++ b/code/modules/power/solar.dm @@ -299,9 +299,13 @@ var/lastgen = 0 var/track = 0 // 0= off 1=timed 2=auto (tracker) var/trackrate = 600 // 300-900 seconds - var/nexttime = 0 // time for a panel to rotate of 1° in manual tracking + var/nexttime = 0 // time for a panel to rotate of 1� in manual tracking var/obj/machinery/power/tracker/connected_tracker = null var/list/connected_panels = list() + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 3 + light_color = LIGHT_COLOR_ORANGE /obj/machinery/power/solar_control/New() @@ -503,9 +507,9 @@ connected_tracker.unset_control() if(track==1 && trackrate) //manual tracking and set a rotation speed - if(nexttime <= world.time) //every time we need to increase/decrease the angle by 1°... + if(nexttime <= world.time) //every time we need to increase/decrease the angle by 1�... targetdir = (targetdir + trackrate/abs(trackrate) + 360) % 360 //... do it - nexttime += 36000/abs(trackrate) //reset the counter for the next 1° + nexttime += 36000/abs(trackrate) //reset the counter for the next 1� //rotates the panel to the passed angle /obj/machinery/power/solar_control/proc/set_panels(currentdir) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index a9f383c0ca..6cbaea8fb9 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -283,7 +283,7 @@ obj/item/weapon/gun/proc/newshot() return user << "You click [S] into place on [src]." if(S.on) - SetLuminosity(0) + set_light(0) F = S I.loc = src update_icon() @@ -332,21 +332,12 @@ obj/item/weapon/gun/proc/newshot() /obj/item/weapon/gun/proc/update_gunlight(mob/user = null) if(F) if(F.on) - if(loc == user) - user.AddLuminosity(F.brightness_on) - else if(isturf(loc)) - SetLuminosity(F.brightness_on) + set_light(F.brightness_on) else - if(loc == user) - user.AddLuminosity(-F.brightness_on) - else if(isturf(loc)) - SetLuminosity(0) + set_light(0) update_icon() else - if(loc == user) - user.AddLuminosity(-5) - else if(isturf(loc)) - SetLuminosity(0) + set_light(0) for(var/X in actions) var/datum/action/A = X A.UpdateButtonIcon() @@ -354,19 +345,11 @@ obj/item/weapon/gun/proc/newshot() /obj/item/weapon/gun/pickup(mob/user) ..() - if(F) - if(F.on) - user.AddLuminosity(F.brightness_on) - SetLuminosity(0) if(azoom) azoom.Grant(user) /obj/item/weapon/gun/dropped(mob/user) ..() - if(F) - if(F.on) - user.AddLuminosity(-F.brightness_on) - SetLuminosity(F.brightness_on) zoom(user,FALSE) if(azoom) azoom.Remove(user) diff --git a/code/modules/projectiles/projectile/energy.dm b/code/modules/projectiles/projectile/energy.dm index 5250df4a4f..e02513a9b1 100644 --- a/code/modules/projectiles/projectile/energy.dm +++ b/code/modules/projectiles/projectile/energy.dm @@ -72,7 +72,7 @@ /obj/effect/nettingportal/New() ..() - SetLuminosity(3) + set_light(3) var/obj/item/device/radio/beacon/teletarget = null for(var/obj/machinery/computer/teleporter/com in machines) if(com.target) diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm index 54d2aa60b0..8fd2019966 100644 --- a/code/modules/reagents/chemistry/machinery/chem_master.dm +++ b/code/modules/reagents/chemistry/machinery/chem_master.dm @@ -14,6 +14,10 @@ var/screen = "home" var/analyzeVars[0] var/useramount = 30 // Last used amount + use_auto_lights = 1 + light_power_on = 1 + light_range_on = 2 + light_color = LIGHT_COLOR_BLUE /obj/machinery/chem_master/New() create_reagents(100) diff --git a/code/modules/research/xenobiology/xenobio_camera.dm b/code/modules/research/xenobiology/xenobio_camera.dm index 3a8d86d979..2bfbd3b404 100644 --- a/code/modules/research/xenobiology/xenobio_camera.dm +++ b/code/modules/research/xenobiology/xenobio_camera.dm @@ -28,6 +28,7 @@ icon_screen = "slime_comp" icon_keyboard = "rd_key" + light_color = LIGHT_COLOR_PINK /obj/machinery/computer/camera_advanced/xenobio/CreateEye() eyeobj = new /mob/camera/aiEye/remote/xenobio() diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index 82e7b5009d..6ef0893120 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -474,14 +474,14 @@ T1.shuttleRotate(rotation) //lighting stuff - T1.redraw_lighting() + T1.reconsider_lights() SSair.remove_from_active(T1) T1.CalculateAdjacentTurfs() SSair.add_to_active(T1,1) T0.ChangeTurf(turf_type) - T0.redraw_lighting() + T0.reconsider_lights() SSair.remove_from_active(T0) T0.CalculateAdjacentTurfs() SSair.add_to_active(T0,1) diff --git a/code/modules/stock_market/computer.dm b/code/modules/stock_market/computer.dm index ced8a43f17..45125b084c 100644 --- a/code/modules/stock_market/computer.dm +++ b/code/modules/stock_market/computer.dm @@ -7,6 +7,8 @@ var/logged_in = "Cargo Department" var/vmode = 1 clockwork = TRUE //it'd look weird + light_color = LIGHT_COLOR_GREEN + light_range_on = 2 /obj/machinery/computer/stockexchange/New() ..() diff --git a/config/game_options.txt b/config/game_options.txt index efe59f12d2..292ada29d2 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -322,7 +322,7 @@ ASSISTANT_CAP -1 ## Starlight for exterior walls and breaches. Uncomment for starlight! ## This is disabled by default to make testing quicker, should be enabled on production servers or testing servers messing with lighting -#STARLIGHT +STARLIGHT ## Uncomment to bring back old grey suit assistants instead of the now default rainbow colored assistants. #GREY_ASSISTANTS diff --git a/icons/effects/lighting_overlay.png b/icons/effects/lighting_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..7598a6bbc7b4bc105d25aa3345e5f08cfdc77ee2 GIT binary patch literal 1542 zcmV+h2Ko7kP)QTWDy8~uMgn+EngqN_vb&K|Ic@S z{>T6L?qAOL=lH-Eg74rCzZ3ifcp7*bd^(uMPJ^?9*}!UGt#D0X70?BC1--A)0)gg*#>l6@WU>D<9|cujz_!?l7rwm{EtRoFA=3N5e|T49*0doTd^H~1sK zZ@l0;7x?E_fX@p&JDe+=Wv&&jiY_>p!dBP}%`M>j8rcE>5fBKG@rf@Od+fna{3{Xb znGJrnwQD%rS{<$q*Rqy2c**KpK$fow7}gCA@^%d&;{)F?o(O+n{=|G<@E=D{o6oCG zTeG9t=3LP%bCtCetuk9u%NtIrX&R9MnzsbC!65>{F9G8x;d4vqY3mv5$L7=4bo6X% zwqJEEb6x^1Yfpf`a6*m9gaXL10tyLZ=v`ogVLtN~H=nkicHPj~)?C&sYj$hj0@o7N zqMAD<)qo7kU^&$8o=PZ$LLzv4;tP!#7{Ai0y~Sf$Xeuhhc{A@-_H+%u(7ha=->f90@w#xR{5*TSzw!kO8u&}V` zm8I#@^3v@6u+3I2ts6cjS&JA891UC&868|;4JX4^Wy5!xg#!bPaZO;o{$`5nmBndk zSz2CNX3c($y%sShF%~cuG8)-6866ErqvK(7c!P&`_alvg@hiZU#g%!(wOkiiT2`&r z8+cD(z2G=r63OV~*ww?H+7hfbYxRBaG5QVu z3*FWBVb`#Iq_v@~k;Map0|N&d18aQZ3v)k^nOqTj3$QIMQEh28)%#(q-tgBwUl(*& zA8j8!?yhyXc({3_IZ`~*II?hH;6RNJe52TRQe2s8YcH+d;3jJI{%to={R@8^yN`|! z`;sUhZXF&vQ`!>6BZ~)$e+1Cc9d@{5%GABSSCiN89M!=M{uh3>eb{}tb@~Fkc%*oy za9laF-UT2wihc=5_Pw#78oZX*yt+63-t)fV?z5|ou0Gv5TsmDmBA#1<2ZR%a1Ns$! zBQ{8fH=MiPo65byp?a@y!}93(uIBEuOClh$qAcg!7t!;1G_OUjaFg{pw!X z%j&(p|AOTs>cg%*3F$B|3F(aV$SpuVvM2D!9|4d7al>QKfFhKAZ>jgLmSMZHyFaWR z;W(^5^9w(+>m%Z6>S6H_;*9tJ@jd~31bF0+ z07wALWfDX{m{{0w?Sq#K8(iQqfi1*y!`%IhH sdG{@A0OKun{C9M|HZ}18H2c;Ct!Lq;d0{{R307*qoM6N<$f;eO1{Qv*} literal 0 HcmV?d00001 diff --git a/tgstation.dme b/tgstation.dme index 0178f59e15..9f0a602fe0 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -22,6 +22,7 @@ #include "code\__DATASTRUCTURES\linked_lists.dm" #include "code\__DATASTRUCTURES\priority_queue.dm" #include "code\__DATASTRUCTURES\stacks.dm" +#include "code\__DEFINES\_MC.dm" #include "code\__DEFINES\admin.dm" #include "code\__DEFINES\atmospherics.dm" #include "code\__DEFINES\bots.dm" @@ -34,9 +35,9 @@ #include "code\__DEFINES\hud.dm" #include "code\__DEFINES\is_helpers.dm" #include "code\__DEFINES\layers.dm" +#include "code\__DEFINES\lighting.dm" #include "code\__DEFINES\machines.dm" #include "code\__DEFINES\math.dm" -#include "code\__DEFINES\MC.dm" #include "code\__DEFINES\misc.dm" #include "code\__DEFINES\pipe_construction.dm" #include "code\__DEFINES\preferences.dm" @@ -1257,7 +1258,15 @@ #include "code\modules\library\lib_machines.dm" #include "code\modules\library\lib_readme.dm" #include "code\modules\library\random_books.dm" -#include "code\modules\lighting\lighting_system.dm" +#include "code\modules\lighting\__lighting_docs.dm" +#include "code\modules\lighting\lighting_area.dm" +#include "code\modules\lighting\lighting_atom.dm" +#include "code\modules\lighting\lighting_corner.dm" +#include "code\modules\lighting\lighting_overlay.dm" +#include "code\modules\lighting\lighting_setup.dm" +#include "code\modules\lighting\lighting_source.dm" +#include "code\modules\lighting\lighting_turf.dm" +#include "code\modules\lighting\~lighting_undefs.dm" #include "code\modules\mining\abandoned_crates.dm" #include "code\modules\mining\equipment.dm" #include "code\modules\mining\fulton.dm"