From e629c36febf8aeec0746c2560eb129ffaf76a103 Mon Sep 17 00:00:00 2001 From: TiviPlus <57223640+TiviPlus@users.noreply.github.com> Date: Thu, 26 Aug 2021 00:07:38 +0200 Subject: [PATCH] Refactor area and turf lighting (#60954) --- code/__DEFINES/flags.dm | 2 + code/__DEFINES/layers.dm | 5 ++ code/__DEFINES/lighting.dm | 11 --- code/__HELPERS/areas.dm | 1 - code/_globalvars/bitfields.dm | 1 + code/controllers/subsystem/lighting.dm | 8 +- code/datums/mapgen/JungleGenerator.dm | 4 +- code/game/area/areas.dm | 17 ++--- code/game/area/areas/away_content.dm | 14 +--- code/game/area/areas/centcom.dm | 24 ++++-- code/game/area/areas/holodeck.dm | 4 +- code/game/area/areas/ruins/_ruins.dm | 2 +- code/game/area/areas/shuttles.dm | 8 +- code/game/area/space_station_13_areas.dm | 15 ++-- code/game/turfs/change_turf.dm | 15 ++-- code/game/turfs/open/space/space.dm | 5 +- code/game/turfs/turf.dm | 8 +- .../awaymissions/mission_code/Cabin.dm | 12 +-- .../awaymissions/mission_code/caves.dm | 2 +- .../awaymissions/mission_code/murderdome.dm | 4 - .../awaymissions/mission_code/research.dm | 2 +- .../awaymissions/mission_code/snowdin.dm | 18 +++-- code/modules/events/aurora_caelus.dm | 6 +- code/modules/lighting/lighting_area.dm | 73 +++++++++++++------ code/modules/lighting/lighting_setup.dm | 6 +- code/modules/lighting/lighting_turf.dm | 11 ++- code/modules/lighting/static_lighting_area.dm | 17 +++++ code/modules/mafia/map_pieces.dm | 4 +- code/modules/mining/equipment/survival_pod.dm | 2 +- .../modules/mob/living/silicon/ai/multicam.dm | 4 +- .../power/lighting/light_wallframes.dm | 2 +- .../ruins/spaceruin_code/hilbertshotel.dm | 4 +- tgstation.dme | 1 + 33 files changed, 183 insertions(+), 129 deletions(-) create mode 100644 code/modules/lighting/static_lighting_area.dm diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm index b54b291843e..ac49c0e3a7f 100644 --- a/code/__DEFINES/flags.dm +++ b/code/__DEFINES/flags.dm @@ -120,6 +120,8 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 #define NO_ALERTS (1<<12) /// If blood cultists can draw runes or build structures on this AREA. #define CULT_PERMITTED (1<<13) +///Whther this area is iluminated by starlight +#define AREA_USES_STARLIGHT (1<<14) /* These defines are used specifically with the atom/pass_flags bitmask diff --git a/code/__DEFINES/layers.dm b/code/__DEFINES/layers.dm index ae9ec7e3489..77b3ac86ddc 100644 --- a/code/__DEFINES/layers.dm +++ b/code/__DEFINES/layers.dm @@ -125,6 +125,11 @@ #define ABOVE_LIGHTING_PLANE 120 #define ABOVE_LIGHTING_RENDER_TARGET "ABOVE_LIGHTING_PLANE" +#define LIGHTING_PRIMARY_LAYER 15 //The layer for the main lights of the station +#define LIGHTING_PRIMARY_DIMMER_LAYER 15.1 //The layer that dims the main lights of the station +#define LIGHTING_SECONDARY_LAYER 16 //The colourful, usually small lights that go on top + + ///visibility + hiding of things outside of light source range #define BYOND_LIGHTING_PLANE 130 #define BYOND_LIGHTING_RENDER_TARGET "BYOND_LIGHTING_PLANE" diff --git a/code/__DEFINES/lighting.dm b/code/__DEFINES/lighting.dm index 9336ac5f789..10b40ea10ca 100644 --- a/code/__DEFINES/lighting.dm +++ b/code/__DEFINES/lighting.dm @@ -53,17 +53,6 @@ #define LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE 128 #define LIGHTING_PLANE_ALPHA_INVISIBLE 0 -//lighting area defines -/// dynamic lighting disabled (area stays at full brightness) -#define DYNAMIC_LIGHTING_DISABLED 0 -/// dynamic lighting enabled -#define DYNAMIC_LIGHTING_ENABLED 1 -/// dynamic lighting enabled even if the area doesn't require power -#define DYNAMIC_LIGHTING_FORCED 2 -/// dynamic lighting enabled only if starlight is. -#define DYNAMIC_LIGHTING_IFSTARLIGHT 3 -#define IS_DYNAMIC_LIGHTING(A) A.dynamic_lighting - //code assumes higher numbers override lower numbers. #define LIGHTING_NO_UPDATE 0 diff --git a/code/__HELPERS/areas.dm b/code/__HELPERS/areas.dm index b8707e95304..5bdbbd60186 100644 --- a/code/__HELPERS/areas.dm +++ b/code/__HELPERS/areas.dm @@ -82,7 +82,6 @@ GLOBAL_LIST_INIT(typecache_powerfailure_safe_areas, typecacheof(/area/engineerin return newA = new area_choice newA.setup(str) - newA.set_dynamic_lighting() newA.has_gravity = oldA.has_gravity else newA = area_choice diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index d5a8163be13..2f64a5e05b9 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -63,6 +63,7 @@ DEFINE_BITFIELD(area_flags, list( "VALID_TERRITORY" = VALID_TERRITORY, "XENOBIOLOGY_COMPATIBLE" = XENOBIOLOGY_COMPATIBLE, "NO_ALERTS" = NO_ALERTS, + "AREA_USES_STARLIGHT" = AREA_USES_STARLIGHT, )) DEFINE_BITFIELD(turf_flags, list( diff --git a/code/controllers/subsystem/lighting.dm b/code/controllers/subsystem/lighting.dm index f38bea2b1ad..29999a8ff46 100644 --- a/code/controllers/subsystem/lighting.dm +++ b/code/controllers/subsystem/lighting.dm @@ -14,12 +14,6 @@ SUBSYSTEM_DEF(lighting) /datum/controller/subsystem/lighting/Initialize(timeofday) if(!initialized) - if (CONFIG_GET(flag/starlight)) - for(var/I in GLOB.sortedAreas) - var/area/A = I - if (A.dynamic_lighting == DYNAMIC_LIGHTING_IFSTARLIGHT) - A.luminosity = 0 - create_all_lighting_objects() initialized = TRUE @@ -57,7 +51,7 @@ SUBSYSTEM_DEF(lighting) C.needs_update = FALSE //update_objects() can call qdel if the corner is storing no data C.update_objects() - + if(init_tick_checks) CHECK_TICK else if (MC_TICK_CHECK) diff --git a/code/datums/mapgen/JungleGenerator.dm b/code/datums/mapgen/JungleGenerator.dm index f2536c7d1b5..0a3b3f01399 100644 --- a/code/datums/mapgen/JungleGenerator.dm +++ b/code/datums/mapgen/JungleGenerator.dm @@ -87,5 +87,7 @@ /area/mine/planetgeneration name = "planet generation area" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE + base_lighting_alpha = 255 + base_lighting_color = COLOR_WHITE map_generator = /datum/map_generator/jungle_generator diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 5b6a5895c4d..f9e10d33bfc 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -150,6 +150,10 @@ GLOBAL_LIST_EMPTY(teleportlocs) icon_state = "" if(!ambientsounds) ambientsounds = GLOB.ambience_assoc[ambience_index] + + if(area_flags & AREA_USES_STARLIGHT) + static_lighting = CONFIG_GET(flag/starlight) + if(requires_power) luminosity = 0 else @@ -157,20 +161,13 @@ GLOBAL_LIST_EMPTY(teleportlocs) power_equip = TRUE power_environ = TRUE - if(dynamic_lighting == DYNAMIC_LIGHTING_FORCED) - dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + if(static_lighting) luminosity = 0 - else if(dynamic_lighting != DYNAMIC_LIGHTING_IFSTARLIGHT) - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED - if(dynamic_lighting == DYNAMIC_LIGHTING_IFSTARLIGHT) - dynamic_lighting = CONFIG_GET(flag/starlight) ? DYNAMIC_LIGHTING_ENABLED : DYNAMIC_LIGHTING_DISABLED - . = ..() - if(!IS_DYNAMIC_LIGHTING(src)) + if(!static_lighting) blend_mode = BLEND_MULTIPLY - add_overlay(/obj/effect/fullbright) reg_in_areas_in_z() @@ -179,6 +176,8 @@ GLOBAL_LIST_EMPTY(teleportlocs) network_root_id = STATION_NETWORK_ROOT // default to station root because this might be created with a blueprint SSnetworks.assign_area_network_id(src) + update_base_lighting() + return INITIALIZE_HINT_LATELOAD /** diff --git a/code/game/area/areas/away_content.dm b/code/game/area/areas/away_content.dm index 15a6c386da2..b2fa702e363 100644 --- a/code/game/area/areas/away_content.dm +++ b/code/game/area/areas/away_content.dm @@ -14,21 +14,15 @@ Unused icons for new areas are "awaycontent1" ~ "awaycontent30" /area/awaymission/beach name = "Beach" icon_state = "away" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE requires_power = FALSE has_gravity = STANDARD_GRAVITY ambientsounds = list('sound/ambience/shore.ogg', 'sound/ambience/seag1.ogg','sound/ambience/seag2.ogg','sound/ambience/seag2.ogg','sound/ambience/ambiodd.ogg','sound/ambience/ambinice.ogg') /area/awaymission/errorroom name = "Super Secret Room" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE + base_lighting_alpha = 255 + base_lighting_color = COLOR_WHITE has_gravity = STANDARD_GRAVITY -/area/awaymission/vr - name = "Virtual Reality" - icon_state = "awaycontent1" - requires_power = FALSE - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED - var/pacifist = TRUE // if when you enter this zone, you become a pacifist or not - var/death = FALSE // if when you enter this zone, you die - network_root_id = "VR" diff --git a/code/game/area/areas/centcom.dm b/code/game/area/areas/centcom.dm index 52b5b5f330f..b3f06dd1576 100644 --- a/code/game/area/areas/centcom.dm +++ b/code/game/area/areas/centcom.dm @@ -8,7 +8,9 @@ /area/centcom name = "CentCom" icon_state = "centcom" - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = FALSE + base_lighting_color = COLOR_WHITE + base_lighting_alpha = 255 requires_power = FALSE has_gravity = STANDARD_GRAVITY area_flags = UNIQUE_AREA | NOTELEPORT @@ -39,7 +41,6 @@ /area/centcom/supplypod name = "Supplypod Facility" icon_state = "supplypod" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED /area/centcom/supplypod/pod_storage name = "Supplypod Storage" @@ -82,7 +83,9 @@ /area/tdome name = "Thunderdome" icon_state = "yellow" - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = FALSE + base_lighting_alpha = 255 + base_lighting_color = COLOR_WHITE requires_power = FALSE has_gravity = STANDARD_GRAVITY flags_1 = NONE @@ -90,12 +93,10 @@ /area/tdome/arena name = "Thunderdome Arena" icon_state = "thunder" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED /area/tdome/arena_source name = "Thunderdome Arena Template" icon_state = "thunder" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED /area/tdome/tdome1 name = "Thunderdome (Team 1)" @@ -120,7 +121,9 @@ /area/wizard_station name = "Wizard's Den" icon_state = "yellow" - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = FALSE + base_lighting_color = COLOR_WHITE + base_lighting_alpha = 255 requires_power = FALSE has_gravity = STANDARD_GRAVITY area_flags = UNIQUE_AREA | NOTELEPORT @@ -133,6 +136,8 @@ icon_state = "yellow" requires_power = FALSE area_flags = UNIQUE_AREA | NOTELEPORT + base_lighting_color = COLOR_WHITE + base_lighting_alpha = 255 has_gravity = STANDARD_GRAVITY flags_1 = NONE network_root_id = "ALIENS" @@ -151,7 +156,9 @@ /area/syndicate_mothership/control name = "Syndicate Control Room" icon_state = "syndie-control" - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = FALSE + base_lighting_alpha = 255 + base_lighting_color = COLOR_WHITE network_root_id = SYNDICATE_NETWORK_ROOT /area/syndicate_mothership/elite_squad @@ -164,6 +171,9 @@ name = "Capture the Flag" icon_state = "yellow" requires_power = FALSE + static_lighting = FALSE + base_lighting_color = COLOR_WHITE + base_lighting_alpha = 255 has_gravity = STANDARD_GRAVITY flags_1 = NONE diff --git a/code/game/area/areas/holodeck.dm b/code/game/area/areas/holodeck.dm index 4b6934799c0..a0a99e81dca 100644 --- a/code/game/area/areas/holodeck.dm +++ b/code/game/area/areas/holodeck.dm @@ -1,7 +1,9 @@ /area/holodeck name = "Holodeck" icon_state = "Holodeck" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE + base_lighting_color = COLOR_WHITE + base_lighting_alpha = 255 flags_1 = NONE sound_environment = SOUND_ENVIRONMENT_PADDED_CELL diff --git a/code/game/area/areas/ruins/_ruins.dm b/code/game/area/areas/ruins/_ruins.dm index 42241bfb118..d4d0c8d9db1 100644 --- a/code/game/area/areas/ruins/_ruins.dm +++ b/code/game/area/areas/ruins/_ruins.dm @@ -5,7 +5,7 @@ icon_state = "away" has_gravity = STANDARD_GRAVITY area_flags = HIDDEN_AREA | BLOBS_ALLOWED | UNIQUE_AREA | NO_ALERTS - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = TRUE ambience_index = AMBIENCE_RUINS flags_1 = CAN_BE_DIRTY_1 sound_environment = SOUND_ENVIRONMENT_STONEROOM diff --git a/code/game/area/areas/shuttles.dm b/code/game/area/areas/shuttles.dm index d6dd38e64ac..0bd12d47b19 100644 --- a/code/game/area/areas/shuttles.dm +++ b/code/game/area/areas/shuttles.dm @@ -5,7 +5,7 @@ /area/shuttle name = "Shuttle" requires_power = FALSE - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = TRUE has_gravity = STANDARD_GRAVITY always_unpowered = FALSE // Loading the same shuttle map at a different time will produce distinct area instances. @@ -63,7 +63,7 @@ /area/shuttle/hunter name = "Hunter Shuttle" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE ////////////////////////////White Ship//////////////////////////// @@ -97,7 +97,7 @@ /area/shuttle/transit name = "Hyperspace" desc = "Weeeeee" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE /area/shuttle/arrival @@ -167,7 +167,7 @@ name = "Medieval Reality Simulation Dome" icon_state = "shuttlectf" area_flags = NOTELEPORT - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE /area/shuttle/escape/arena name = "The Arena" diff --git a/code/game/area/space_station_13_areas.dm b/code/game/area/space_station_13_areas.dm index 62cc1d3c18f..510ace48d22 100644 --- a/code/game/area/space_station_13_areas.dm +++ b/code/game/area/space_station_13_areas.dm @@ -25,7 +25,9 @@ NOTE: there are two lists of areas in the end of this file: centcom and station icon_state = "space" requires_power = TRUE always_unpowered = TRUE - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE + base_lighting_color = COLOR_WHITE + base_lighting_alpha = 255 power_light = FALSE power_equip = FALSE power_environ = FALSE @@ -37,13 +39,13 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/space/nearstation icon_state = "space_near" - dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT + area_flags = UNIQUE_AREA | NO_ALERTS | AREA_USES_STARLIGHT /area/start name = "start area" icon_state = "start" requires_power = FALSE - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE has_gravity = STANDARD_GRAVITY @@ -68,7 +70,9 @@ NOTE: there are two lists of areas in the end of this file: centcom and station max_ambience_cooldown = 220 SECONDS /area/asteroid/nearstation - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = FALSE + base_lighting_alpha = 255 + base_lighting_color = COLOR_WHITE ambience_index = AMBIENCE_RUINS always_unpowered = FALSE requires_power = TRUE @@ -923,8 +927,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/solars requires_power = FALSE - dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT - area_flags = UNIQUE_AREA + area_flags = UNIQUE_AREA | AREA_USES_STARLIGHT flags_1 = NONE ambience_index = AMBIENCE_ENGI airlock_wires = /datum/wires/airlock/engineering diff --git a/code/game/turfs/change_turf.dm b/code/game/turfs/change_turf.dm index d46f01428a1..b877da36a84 100644 --- a/code/game/turfs/change_turf.dm +++ b/code/game/turfs/change_turf.dm @@ -77,7 +77,7 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( if(flags & CHANGETURF_SKIP) return new path(src) - var/old_dynamic_lighting = dynamic_lighting + var/old_always_lit = always_lit var/old_lighting_object = lighting_object var/old_lighting_corner_NE = lighting_corner_NE var/old_lighting_corner_SE = lighting_corner_SE @@ -132,18 +132,19 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( dynamic_lumcount = old_dynamic_lumcount + if(always_lit != old_always_lit) + if(always_lit) + add_overlay(GLOB.fullbright_overlay) + else + cut_overlay(GLOB.fullbright_overlay) + if(SSlighting.initialized) lighting_object = old_lighting_object directional_opacity = old_directional_opacity recalculate_directional_opacity() - if (dynamic_lighting != old_dynamic_lighting) - if (IS_DYNAMIC_LIGHTING(src)) - lighting_build_overlay() - else - lighting_clear_overlay() - else if(lighting_object && !lighting_object.needs_update) + if(lighting_object && !lighting_object.needs_update) lighting_object.update() for(var/turf/open/space/space_tile in RANGE_TURFS(1, src)) diff --git a/code/game/turfs/open/space/space.dm b/code/game/turfs/open/space/space.dm index 2c0b6de19d4..ae34b8ffabc 100644 --- a/code/game/turfs/open/space/space.dm +++ b/code/game/turfs/open/space/space.dm @@ -16,7 +16,7 @@ plane = PLANE_SPACE layer = SPACE_LAYER light_power = 0.25 - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + always_lit = TRUE bullet_bounce_sound = null vis_flags = VIS_INHERIT_ID //when this be added to vis_contents of something it be associated with something on clicking, important for visualisation of turf in openspace and interraction with openspace that show you turf. @@ -49,9 +49,6 @@ smoothing_flags |= SMOOTH_OBJ SET_BITFLAG_LIST(canSmoothWith) - var/area/A = loc - if(!IS_DYNAMIC_LIGHTING(src) && IS_DYNAMIC_LIGHTING(A)) - add_overlay(/obj/effect/fullbright) if(requires_activation) SSair.add_to_active(src, TRUE) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 01d33e4f330..ae9dc9b78b2 100755 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -42,7 +42,8 @@ GLOBAL_LIST_EMPTY(station_turfs) ///Lumcount added by sources other than lighting datum objects, such as the overlay lighting component. var/dynamic_lumcount = 0 - var/dynamic_lighting = TRUE + ///Bool, whether this turf will always be illuminated no matter what area it is in + var/always_lit = FALSE var/tmp/lighting_corners_initialised = FALSE @@ -108,9 +109,8 @@ GLOBAL_LIST_EMPTY(station_turfs) for(var/atom/movable/content as anything in src) Entered(content, null) - var/area/A = loc - if(!IS_DYNAMIC_LIGHTING(src) && IS_DYNAMIC_LIGHTING(A)) - add_overlay(/obj/effect/fullbright) + if(always_lit) + add_overlay(GLOB.fullbright_overlay) if(requires_activation) CALCULATE_ADJACENT_TURFS(src, KILL_EXCITED) diff --git a/code/modules/awaymissions/mission_code/Cabin.dm b/code/modules/awaymissions/mission_code/Cabin.dm index 7feec49d6d6..c79b6e454f2 100644 --- a/code/modules/awaymissions/mission_code/Cabin.dm +++ b/code/modules/awaymissions/mission_code/Cabin.dm @@ -4,12 +4,12 @@ name = "Cabin" icon_state = "away2" requires_power = TRUE - dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + static_lighting = TRUE /area/awaymission/cabin/snowforest name = "Snow Forest" icon_state = "away" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE /area/awaymission/cabin/snowforest/sovietsurface name = "Snow Forest" @@ -20,7 +20,7 @@ name = "Lumbermill" icon_state = "away3" requires_power = FALSE - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE /area/awaymission/cabin/caves/sovietcave name = "Soviet Bunker" @@ -29,7 +29,9 @@ /area/awaymission/cabin/caves name = "North Snowdin Caves" icon_state = "awaycontent15" - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = FALSE + base_lighting_alpha = 255 + base_lighting_color = COLOR_WHITE /area/awaymission/cabin/caves/mountain name = "North Snowdin Mountains" @@ -41,7 +43,7 @@ icon = 'icons/obj/fireplace.dmi' icon_state = "firepit-active" density = FALSE - var/active = 1 + var/active = TRUE /obj/structure/firepit/Initialize() . = ..() diff --git a/code/modules/awaymissions/mission_code/caves.dm b/code/modules/awaymissions/mission_code/caves.dm index 478f80ca682..28a38cf5c97 100644 --- a/code/modules/awaymissions/mission_code/caves.dm +++ b/code/modules/awaymissions/mission_code/caves.dm @@ -19,7 +19,7 @@ /area/awaymission/caves/research name = "Research Outpost" icon_state = "awaycontent5" - dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + static_lighting = TRUE /area/awaymission/caves/northblock //engineering, bridge (not really north but it doesnt really need its own APC) diff --git a/code/modules/awaymissions/mission_code/murderdome.dm b/code/modules/awaymissions/mission_code/murderdome.dm index 695692ed331..01eb33179e1 100644 --- a/code/modules/awaymissions/mission_code/murderdome.dm +++ b/code/modules/awaymissions/mission_code/murderdome.dm @@ -1,7 +1,3 @@ -/area/awaymission/vr/murderdome - name = "Murderdome" - icon_state = "awaycontent8" - pacifist = FALSE /obj/structure/window/reinforced/fulltile/indestructable name = "robust window" diff --git a/code/modules/awaymissions/mission_code/research.dm b/code/modules/awaymissions/mission_code/research.dm index 666ee7909e1..a075818ca80 100644 --- a/code/modules/awaymissions/mission_code/research.dm +++ b/code/modules/awaymissions/mission_code/research.dm @@ -3,7 +3,7 @@ /area/awaymission/research name = "Research Outpost" icon_state = "away" - dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + static_lighting = TRUE /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 b66a2c96351..7dc7d9d6fad 100644 --- a/code/modules/awaymissions/mission_code/snowdin.dm +++ b/code/modules/awaymissions/mission_code/snowdin.dm @@ -4,7 +4,7 @@ name = "Snowdin" icon_state = "awaycontent1" requires_power = FALSE - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE /area/awaymission/snowdin/outside name = "Snowdin Tundra Plains" @@ -14,7 +14,7 @@ name = "Snowdin Outpost" icon_state = "awaycontent2" requires_power = TRUE - dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + static_lighting = TRUE /area/awaymission/snowdin/post/medbay name = "Snowdin Outpost - Medbay" @@ -96,12 +96,16 @@ /area/awaymission/snowdin/igloo name = "Snowdin Igloos" icon_state = "awaycontent14" - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = FALSE + base_lighting_alpha = 255 + base_lighting_color = COLOR_WHITE /area/awaymission/snowdin/cave name = "Snowdin Caves" icon_state = "awaycontent15" - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = FALSE + base_lighting_color = COLOR_WHITE + base_lighting_alpha = 255 /area/awaymission/snowdin/cave/cavern name = "Snowdin Depths" @@ -115,18 +119,18 @@ /area/awaymission/snowdin/base name = "Snowdin Main Base" icon_state = "awaycontent16" - dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + static_lighting = TRUE requires_power = TRUE /area/awaymission/snowdin/dungeon1 name = "Snowdin Depths" icon_state = "awaycontent17" - dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + static_lighting = TRUE /area/awaymission/snowdin/sekret name = "Snowdin Operations" icon_state = "awaycontent18" - dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + static_lighting = TRUE requires_power = TRUE /area/shuttle/snowdin/elevator1 diff --git a/code/modules/events/aurora_caelus.dm b/code/modules/events/aurora_caelus.dm index a27cda10dff..d065d4c8cbe 100644 --- a/code/modules/events/aurora_caelus.dm +++ b/code/modules/events/aurora_caelus.dm @@ -29,7 +29,7 @@ /datum/round_event/aurora_caelus/start() for(var/area in GLOB.sortedAreas) var/area/A = area - if(initial(A.dynamic_lighting) == DYNAMIC_LIGHTING_IFSTARLIGHT) + if(A.area_flags & AREA_USES_STARLIGHT) for(var/turf/open/space/S in A) S.set_light(S.light_range * 3, S.light_power * 0.5) @@ -39,14 +39,14 @@ var/aurora_color = aurora_colors[aurora_progress] for(var/area in GLOB.sortedAreas) var/area/A = area - if(initial(A.dynamic_lighting) == DYNAMIC_LIGHTING_IFSTARLIGHT) + if(A.area_flags & AREA_USES_STARLIGHT) for(var/turf/open/space/S in A) S.set_light(l_color = aurora_color) /datum/round_event/aurora_caelus/end() for(var/area in GLOB.sortedAreas) var/area/A = area - if(initial(A.dynamic_lighting) == DYNAMIC_LIGHTING_IFSTARLIGHT) + if(A.area_flags & AREA_USES_STARLIGHT) for(var/turf/open/space/S in A) fade_to_black(S) priority_announce("The aurora caelus event is now ending. Starlight conditions will slowly return to normal. When this has concluded, please return to your workplace and continue work as normal. Have a pleasant shift, [station_name()], and thank you for watching with us.", diff --git a/code/modules/lighting/lighting_area.dm b/code/modules/lighting/lighting_area.dm index 497a7e857ed..caf7ed244fd 100644 --- a/code/modules/lighting/lighting_area.dm +++ b/code/modules/lighting/lighting_area.dm @@ -1,32 +1,59 @@ /area - luminosity = TRUE - var/dynamic_lighting = DYNAMIC_LIGHTING_ENABLED + luminosity = 1 + ///The mutable appearance we underlay to show light + var/mutable_appearance/lighting_effect = null + ///Whether this area has a currently active base lighting, bool + var/area_has_base_lighting = FALSE + ///alpha 0-255 of lighting_effect and thus baselighting intensity + var/base_lighting_alpha = 0 + ///The colour of the light acting on this area + var/base_lighting_color = null -/area/proc/set_dynamic_lighting(new_dynamic_lighting = DYNAMIC_LIGHTING_ENABLED) - if (new_dynamic_lighting == dynamic_lighting) +/area/proc/set_base_lighting(new_base_lighting_color = -1, new_alpha = -1) + if(base_lighting_alpha == new_alpha && base_lighting_color == new_base_lighting_color) return FALSE - - dynamic_lighting = new_dynamic_lighting - - if (IS_DYNAMIC_LIGHTING(src)) - cut_overlay(/obj/effect/fullbright) - blend_mode = BLEND_DEFAULT - for (var/turf/T in src) - if (IS_DYNAMIC_LIGHTING(T)) - T.lighting_build_overlay() - - else - add_overlay(/obj/effect/fullbright) - blend_mode = BLEND_MULTIPLY - for (var/turf/T in src) - if (T.lighting_object) - T.lighting_clear_overlay() - + if(new_alpha != -1) + base_lighting_alpha = new_alpha + if(new_base_lighting_color != -1) + base_lighting_color = new_base_lighting_color + update_base_lighting() return TRUE /area/vv_edit_var(var_name, var_value) switch(var_name) - if(NAMEOF(src, dynamic_lighting)) - set_dynamic_lighting(var_value) + if("base_lighting_color") + set_base_lighting(new_base_lighting_color = var_value) + return TRUE + if("base_lighting_alpha") + set_base_lighting(new_alpha = var_value) return TRUE return ..() + +/area/proc/update_base_lighting() + if(!area_has_base_lighting && (!base_lighting_alpha || !base_lighting_color)) + return + + if(!area_has_base_lighting) + add_base_lighting() + return + remove_base_lighting() + if(base_lighting_alpha && base_lighting_color) + add_base_lighting() + +/area/proc/remove_base_lighting() + for(var/turf/T in src) + T.cut_overlay(lighting_effect) + QDEL_NULL(lighting_effect) + area_has_base_lighting = FALSE + +/area/proc/add_base_lighting() + lighting_effect = mutable_appearance('icons/effects/alphacolors.dmi', "white") + lighting_effect.plane = LIGHTING_PLANE + lighting_effect.layer = LIGHTING_PRIMARY_LAYER + lighting_effect.blend_mode = BLEND_ADD + lighting_effect.alpha = base_lighting_alpha + lighting_effect.color = base_lighting_color + for(var/turf/T in src) + T.add_overlay(lighting_effect) + T.luminosity = 1 + area_has_base_lighting = TRUE diff --git a/code/modules/lighting/lighting_setup.dm b/code/modules/lighting/lighting_setup.dm index bc44e863978..78fde88899e 100644 --- a/code/modules/lighting/lighting_setup.dm +++ b/code/modules/lighting/lighting_setup.dm @@ -1,14 +1,12 @@ /proc/create_all_lighting_objects() for(var/area/A in world) - if(!IS_DYNAMIC_LIGHTING(A)) + if(!A.static_lighting) continue for(var/turf/T in A) - - if(!IS_DYNAMIC_LIGHTING(T)) + if(T.always_lit) continue - new/datum/lighting_object(T) CHECK_TICK CHECK_TICK diff --git a/code/modules/lighting/lighting_turf.dm b/code/modules/lighting/lighting_turf.dm index ebe4b1b6bb3..a4bddc0c433 100644 --- a/code/modules/lighting/lighting_turf.dm +++ b/code/modules/lighting/lighting_turf.dm @@ -15,7 +15,7 @@ qdel(lighting_object, force=TRUE) //Shitty fix for lighting objects persisting after death var/area/our_area = loc - if (!IS_DYNAMIC_LIGHTING(our_area) && !light_sources) + if (!our_area.static_lighting && !light_sources) return new/datum/lighting_object(src) @@ -97,11 +97,16 @@ /turf/proc/change_area(area/old_area, area/new_area) if(SSlighting.initialized) - if (new_area.dynamic_lighting != old_area.dynamic_lighting) - if (new_area.dynamic_lighting) + if (new_area.static_lighting != old_area.static_lighting) + if (new_area.static_lighting) lighting_build_overlay() else lighting_clear_overlay() + //Inherit overlay of new area + if(old_area.lighting_effect) + cut_overlay(old_area.lighting_effect) + if(new_area.lighting_effect) + add_overlay(new_area.lighting_effect) /turf/proc/generate_missing_corners() if (!lighting_corner_NE) diff --git a/code/modules/lighting/static_lighting_area.dm b/code/modules/lighting/static_lighting_area.dm new file mode 100644 index 00000000000..150ee669e54 --- /dev/null +++ b/code/modules/lighting/static_lighting_area.dm @@ -0,0 +1,17 @@ + +GLOBAL_DATUM_INIT(fullbright_overlay, /mutable_appearance, create_fullbright_overlay()) + +/proc/create_fullbright_overlay() + var/mutable_appearance/lighting_effect = mutable_appearance('icons/effects/alphacolors.dmi', "white") + lighting_effect.plane = LIGHTING_PLANE + lighting_effect.layer = LIGHTING_PRIMARY_LAYER + lighting_effect.blend_mode = BLEND_ADD + return lighting_effect + +/area + ///Whether this area allows static lighting and thus loads the lighting objects + var/static_lighting = TRUE + +//Non static lighting areas. +//Any lighting area that wont support static lights. +//These areas will NOT have corners generated. diff --git a/code/modules/mafia/map_pieces.dm b/code/modules/mafia/map_pieces.dm index c367acc2a84..a2342847b09 100644 --- a/code/modules/mafia/map_pieces.dm +++ b/code/modules/mafia/map_pieces.dm @@ -29,7 +29,9 @@ /area/mafia name = "Mafia Minigame" icon_state = "mafia" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE + base_lighting_color = COLOR_WHITE + base_lighting_alpha = 255 requires_power = FALSE has_gravity = STANDARD_GRAVITY flags_1 = NONE diff --git a/code/modules/mining/equipment/survival_pod.dm b/code/modules/mining/equipment/survival_pod.dm index 93ad499d6c4..467adc11c0a 100644 --- a/code/modules/mining/equipment/survival_pod.dm +++ b/code/modules/mining/equipment/survival_pod.dm @@ -2,7 +2,7 @@ /area/survivalpod name = "\improper Emergency Shelter" icon_state = "away" - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = TRUE requires_power = FALSE has_gravity = STANDARD_GRAVITY area_flags = BLOBS_ALLOWED | UNIQUE_AREA | CULT_PERMITTED diff --git a/code/modules/mob/living/silicon/ai/multicam.dm b/code/modules/mob/living/silicon/ai/multicam.dm index 2d9234fae6a..5e35bd80d19 100644 --- a/code/modules/mob/living/silicon/ai/multicam.dm +++ b/code/modules/mob/living/silicon/ai/multicam.dm @@ -91,7 +91,9 @@ /area/ai_multicam_room name = "ai_multicam_room" icon_state = "ai_camera_room" - dynamic_lighting = DYNAMIC_LIGHTING_DISABLED + static_lighting = FALSE + base_lighting_color = COLOR_WHITE + base_lighting_alpha = 255 area_flags = NOTELEPORT | HIDDEN_AREA | UNIQUE_AREA ambientsounds = null flags_1 = NONE diff --git a/code/modules/power/lighting/light_wallframes.dm b/code/modules/power/lighting/light_wallframes.dm index 90a38cc989c..653de771652 100644 --- a/code/modules/power/lighting/light_wallframes.dm +++ b/code/modules/power/lighting/light_wallframes.dm @@ -16,7 +16,7 @@ if(!..()) return var/area/local_area = get_area(user) - if(!IS_DYNAMIC_LIGHTING(local_area)) + if(!local_area.static_lighting) to_chat(user, span_warning("You cannot place [src] in this area!")) return return TRUE diff --git a/code/modules/ruins/spaceruin_code/hilbertshotel.dm b/code/modules/ruins/spaceruin_code/hilbertshotel.dm index e75359d7536..c8a7e681541 100644 --- a/code/modules/ruins/spaceruin_code/hilbertshotel.dm +++ b/code/modules/ruins/spaceruin_code/hilbertshotel.dm @@ -351,7 +351,9 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999)) requires_power = FALSE has_gravity = TRUE area_flags = NOTELEPORT | HIDDEN_AREA - dynamic_lighting = DYNAMIC_LIGHTING_FORCED + static_lighting = FALSE + base_lighting_alpha = 255 + base_lighting_color = COLOR_WHITE ambientsounds = list('sound/ambience/servicebell.ogg') var/roomnumber = 0 var/obj/item/hilbertshotel/parentSphere diff --git a/tgstation.dme b/tgstation.dme index 7a2d4257f43..9d3a52fcfaa 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2581,6 +2581,7 @@ #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\static_lighting_area.dm" #include "code\modules\mafia\_defines.dm" #include "code\modules\mafia\controller.dm" #include "code\modules\mafia\map_pieces.dm"