Skip to content

Commit

Permalink
the lighting redux
Browse files Browse the repository at this point in the history
  • Loading branch information
dwasint committed Apr 10, 2024
1 parent f0f7a2b commit 3e5e307
Show file tree
Hide file tree
Showing 71 changed files with 272 additions and 246 deletions.
6 changes: 3 additions & 3 deletions code/__DEFINES/lighting.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
///Object doesn't use any of the light systems. Should be changed to add a light source to the object.
#define NO_LIGHT_SUPPORT 0
///Light made with the lighting datums, applying a matrix.
#define STATIC_LIGHT 1
#define COMPLEX_LIGHT 1
///Light made by masking the lighting darkness plane.
#define MOVABLE_LIGHT 2
#define OVERLAY_LIGHT 2
///Light made by masking the lighting darkness plane, and is directional.
#define MOVABLE_LIGHT_DIRECTIONAL 3
#define OVERLAY_LIGHT_DIRECTIONAL 3
///Light made by masking the lighting darkness plane, and is a directionally focused beam.
#define MOVABLE_LIGHT_BEAM 4
/// Nonesensical value for light color, used for null checks.
Expand Down
2 changes: 1 addition & 1 deletion code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
// Displays static object lighting updates
// Also enables some debug vars on sslighting that can be used to modify
// How extensively we prune lighting corners to update
#define VISUALIZE_LIGHT_UPDATES
// #define VISUALIZE_LIGHT_UPDATES

#define VISUALIZE_ACTIVE_TURFS //Highlights atmos active turfs in green
#define TRACK_MAX_SHARE //Allows max share tracking, for use in the atmos debugging ui
Expand Down
6 changes: 3 additions & 3 deletions code/datums/components/overlay_lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
return COMPONENT_INCOMPATIBLE

var/atom/movable/movable_parent = parent
if(movable_parent.light_system != MOVABLE_LIGHT && movable_parent.light_system != MOVABLE_LIGHT_DIRECTIONAL && movable_parent.light_system != MOVABLE_LIGHT_BEAM)
stack_trace("[type] added to [parent], with [movable_parent.light_system] value for the light_system var. Use [MOVABLE_LIGHT], [MOVABLE_LIGHT_DIRECTIONAL] or [MOVABLE_LIGHT_BEAM] instead.")
if(movable_parent.light_system != OVERLAY_LIGHT && movable_parent.light_system != OVERLAY_LIGHT_DIRECTIONAL && movable_parent.light_system != MOVABLE_LIGHT_BEAM)
stack_trace("[type] added to [parent], with [movable_parent.light_system] value for the light_system var. Use [OVERLAY_LIGHT], [OVERLAY_LIGHT_DIRECTIONAL] or [MOVABLE_LIGHT_BEAM] instead.")
return COMPONENT_INCOMPATIBLE

. = ..()
Expand Down Expand Up @@ -371,7 +371,7 @@
if(directional)
if(beam)
cast_range = max(round(new_range * 0.5), 1)
else
else
cast_range = clamp(round(new_range * 0.5), 1, 3)
if(overlay_lighting_flags & LIGHTING_ON)
make_luminosity_update()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/elements/light_eaten.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/// Because the lighting system does not like movable lights getting set_light() called.
switch(atom_target.light_system)
if(STATIC_LIGHT)
if(COMPLEX_LIGHT)
target.set_light(0, 0, null, FALSE)
else
target.set_light_power(0)
Expand Down
12 changes: 6 additions & 6 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
var/list/alternate_appearances

///Light systems, both shouldn't be active at the same time.
var/light_system = STATIC_LIGHT
var/light_system = COMPLEX_LIGHT
///Range of the maximum brightness of light in tiles. Zero means no light.
var/light_inner_range = 0
///Range where light begins to taper into darkness in tiles.
Expand Down Expand Up @@ -262,7 +262,7 @@
if(color)
add_atom_colour(color, FIXED_COLOUR_PRIORITY)

if (light_system == STATIC_LIGHT && light_power && (light_inner_range || light_outer_range))
if (light_system == COMPLEX_LIGHT && light_power && (light_inner_range || light_outer_range))
update_light()

SETUP_SMOOTHING()
Expand Down Expand Up @@ -1267,23 +1267,23 @@
/atom/vv_edit_var(var_name, var_value)
switch(var_name)
if(NAMEOF(src, light_inner_range))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_inner_range = var_value)
. = TRUE
if(NAMEOF(src, light_outer_range))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_outer_range = var_value)
else
set_light_range(var_value)
. = TRUE
if(NAMEOF(src, light_power))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_power = var_value)
else
set_light_power(var_value)
. = TRUE
if(NAMEOF(src, light_color))
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
set_light(l_color = var_value)
else
set_light_color(var_value)
Expand Down
4 changes: 2 additions & 2 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@
if(opacity)
AddElement(/datum/element/light_blocking)
switch(light_system)
if(MOVABLE_LIGHT)
if(OVERLAY_LIGHT)
AddComponent(/datum/component/overlay_lighting)
if(MOVABLE_LIGHT_DIRECTIONAL)
if(OVERLAY_LIGHT_DIRECTIONAL)
AddComponent(/datum/component/overlay_lighting, is_directional = TRUE)
if(MOVABLE_LIGHT_BEAM)
AddComponent(/datum/component/overlay_lighting, is_directional = TRUE, is_beam = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/effect_system/effects_sparks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
name = "sparks"
icon_state = "sparks"
anchored = TRUE
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = 2
light_power = 0.5
light_color = LIGHT_COLOR_FIRE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
name = "lighting"
desc = "Tell a coder if you're seeing this."
icon_state = "nothing"
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = MINIMUM_USEFUL_LIGHT_RANGE
light_color = COLOR_WHITE
blocks_emissive = EMISSIVE_BLOCK_NONE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/portals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
anchored = TRUE
density = TRUE // dense for receiving bumbs
layer = HIGH_OBJ_LAYER
light_system = STATIC_LIGHT
light_system = COMPLEX_LIGHT
light_outer_range = 3
light_power = 1
light_on = TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/cigs_lighters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
resistance_flags = FIRE_PROOF
grind_results = list(/datum/reagent/iron = 1, /datum/reagent/fuel = 5, /datum/reagent/fuel/oil = 5)
custom_price = PAYCHECK_CREW * 1.1
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = 2
light_power = 0.6
light_color = LIGHT_COLOR_FIRE
Expand Down
20 changes: 10 additions & 10 deletions code/game/objects/items/devices/flashlight.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
slot_flags = ITEM_SLOT_BELT
custom_materials = list(/datum/material/iron= SMALL_MATERIAL_AMOUNT * 0.5, /datum/material/glass= SMALL_MATERIAL_AMOUNT * 0.2)
actions_types = list(/datum/action/item_action/toggle_light)
light_system = MOVABLE_LIGHT_DIRECTIONAL
light_system = OVERLAY_LIGHT_DIRECTIONAL
light_outer_range = 4
light_power = 1
light_on = FALSE
Expand Down Expand Up @@ -61,7 +61,7 @@
if(!isnull(inhand_icon_state))
inhand_icon_state = initial(inhand_icon_state)
set_light_on(on)
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
update_light()

/obj/item/flashlight/proc/toggle_light()
Expand Down Expand Up @@ -325,7 +325,7 @@
righthand_file = 'icons/mob/inhands/items_righthand.dmi'
force = 10
light_outer_range = 3.5
light_system = STATIC_LIGHT
light_system = COMPLEX_LIGHT
light_color = LIGHT_COLOR_FAINT_BLUE
w_class = WEIGHT_CLASS_BULKY
flags_1 = CONDUCT_1
Expand Down Expand Up @@ -358,7 +358,7 @@
actions_types = list()
heat = 1000
light_color = LIGHT_COLOR_FLARE
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
grind_results = list(/datum/reagent/sulfur = 15)
sound_on = 'sound/items/match_strike.ogg'
toggle_context = FALSE
Expand Down Expand Up @@ -623,7 +623,7 @@
righthand_file = 'icons/mob/inhands/equipment/mining_righthand.dmi'
desc = "A mining lantern."
light_outer_range = 6 // luminosity when on
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT

/obj/item/flashlight/lantern/heirloom_moth
name = "old lantern"
Expand Down Expand Up @@ -654,7 +654,7 @@
slot_flags = ITEM_SLOT_BELT
custom_materials = null
light_outer_range = 7 //luminosity when on
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT

/obj/item/flashlight/emp
var/emp_max_charges = 4
Expand Down Expand Up @@ -718,7 +718,7 @@
custom_price = PAYCHECK_LOWER
w_class = WEIGHT_CLASS_SMALL
light_outer_range = 4
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
color = LIGHT_COLOR_GREEN
icon_state = "glowstick"
base_icon_state = "glowstick"
Expand Down Expand Up @@ -825,7 +825,7 @@
name = "disco light"
desc = "Groovy..."
icon_state = null
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = 4
light_power = 10
alpha = 0
Expand Down Expand Up @@ -853,7 +853,7 @@
desc = "A strange device manufactured with mysterious elements that somehow emits darkness. Or maybe it just sucks in light? Nobody knows for sure."
icon_state = "flashdark"
inhand_icon_state = "flashdark"
light_system = STATIC_LIGHT //The overlay light component is not yet ready to produce darkness.
light_system = COMPLEX_LIGHT //The overlay light component is not yet ready to produce darkness.
light_outer_range = 0
///Variable to preserve old lighting behavior in flashlights, to handle darkness.
var/dark_light_outer_range = 2.5
Expand All @@ -871,7 +871,7 @@
/obj/item/flashlight/eyelight
name = "eyelight"
desc = "This shouldn't exist outside of someone's head, how are you seeing this?"
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = 15
light_power = 1
flags_1 = CONDUCT_1
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/dualsaber.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
w_class = WEIGHT_CLASS_SMALL
hitsound = SFX_SWING_HIT
armour_penetration = 35
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = 6 //TWICE AS BRIGHT AS A REGULAR ESWORD
light_color = LIGHT_COLOR_ELECTRIC_GREEN
light_on = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/flamethrower.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
custom_materials = list(/datum/material/iron= HALF_SHEET_MATERIAL_AMOUNT * 0.5)
resistance_flags = FIRE_PROOF
trigger_guard = TRIGGER_GUARD_NORMAL
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_on = FALSE
var/status = FALSE
var/lit = FALSE //on or off
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/melee/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
attack_verb_continuous = list("hits", "taps", "pokes")
attack_verb_simple = list("hit", "tap", "poke")
resistance_flags = FIRE_PROOF
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = 3
light_power = 1
light_on = FALSE
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/plushes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@
var/has_creepy_icons = FALSE //for updating icons

// only used for the base moth plush light
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = 4
light_power = 1

Expand Down Expand Up @@ -767,7 +767,7 @@
update_brightness()

set_light_on(on)
if(light_system == STATIC_LIGHT)
if(light_system == COMPLEX_LIGHT)
update_light()

return TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/tools/weldingtool.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
usesound = list('sound/items/welder.ogg', 'sound/items/welder2.ogg')
drop_sound = 'sound/items/handling/weldingtool_drop.ogg'
pickup_sound = 'sound/items/handling/weldingtool_pickup.ogg'
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = 2
light_power = 0.75
light_color = LIGHT_COLOR_FIRE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/heretic/items/keyring.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
desc = "A crack in space, impossibly deep and painful to the eyes. Definitely not safe."
icon = 'icons/effects/eldritch.dmi'
icon_state = "realitycrack"
light_system = STATIC_LIGHT
light_system = COMPLEX_LIGHT
light_power = 1
light_on = TRUE
light_color = COLOR_GREEN
Expand Down
2 changes: 1 addition & 1 deletion code/modules/assembly/flash.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
throwforce = 0
w_class = WEIGHT_CLASS_TINY
custom_materials = list(/datum/material/iron = SMALL_MATERIAL_AMOUNT*3, /datum/material/glass = SMALL_MATERIAL_AMOUNT*3)
light_system = MOVABLE_LIGHT //Used as a flash here.
light_system = OVERLAY_LIGHT //Used as a flash here.
light_outer_range = FLASH_LIGHT_RANGE
light_color = COLOR_WHITE
light_power = FLASH_LIGHT_POWER
Expand Down
2 changes: 1 addition & 1 deletion code/modules/atmospherics/environmental/LINDA_fire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
layer = GASFIRE_LAYER
plane = ABOVE_GAME_PLANE
blend_mode = BLEND_ADD
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = LIGHT_RANGE_FIRE
light_power = 1
light_color = LIGHT_COLOR_FIRE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/head/cakehat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
flags_inv = HIDEEARS|HIDEHAIR
armor_type = /datum/armor/none
light_outer_range = 2 //luminosity when on
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
flags_cover = HEADCOVERSEYES
heat = 999

Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/head/hardhat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
clothing_flags = SNUG_FIT | PLASMAMAN_HELMET_EXEMPT
resistance_flags = FIRE_PROOF

light_system = MOVABLE_LIGHT_DIRECTIONAL
light_system = OVERLAY_LIGHT_DIRECTIONAL
light_outer_range = 4
light_power = 0.8
light_on = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/shoes/kindlekicks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
icon_state = "kindleKicks"
inhand_icon_state = null
actions_types = list(/datum/action/item_action/kindle_kicks)
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = 2
light_power = 3
light_on = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/spacesuits/plasmamen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
tint = 2
armor_type = /datum/armor/space_plasmaman
resistance_flags = FIRE_PROOF
light_system = MOVABLE_LIGHT_DIRECTIONAL
light_system = OVERLAY_LIGHT_DIRECTIONAL
light_outer_range = 4
light_on = FALSE
var/helmet_on = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/grown/ambrosia.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
name = "ambrosia gaia branch"
desc = "Eating this <i>makes</i> you immortal."
icon_state = "ambrosia_gaia"
light_system = MOVABLE_LIGHT
light_system = OVERLAY_LIGHT
light_outer_range = 3
seed = /obj/item/seeds/ambrosia/gaia
wine_power = 70
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/plant_genes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
return

var/obj/item/seeds/our_seed = our_plant.get_plant_seed()
our_plant.light_system = MOVABLE_LIGHT
our_plant.light_system = OVERLAY_LIGHT
our_plant.AddComponent(/datum/component/overlay_lighting, glow_range(our_seed), glow_power(our_seed), glow_color)

/*
Expand Down
2 changes: 1 addition & 1 deletion code/modules/lighting/lighting_atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/atom/proc/update_light()
SHOULD_NOT_SLEEP(TRUE)

if(light_system != STATIC_LIGHT)
if(light_system != COMPLEX_LIGHT)
CRASH("update_light() for [src] with following light_system value: [light_system]")

if (!light_power || !light_outer_range || !light_on) // We won't emit light anyways, destroy the light source.
Expand Down
Loading

0 comments on commit 3e5e307

Please sign in to comment.