Skip to content

Commit

Permalink
Port tgstation/tgstation#79939 and other minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Drulikar committed Dec 29, 2023
1 parent 33af189 commit 73bd9e8
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions code/datums/components/overlay_lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@
get_new_turfs()


///Adds the luminosity and source for the afected movable atoms to keep track of their visibility.
///Adds the luminosity and source for the affected movable atoms to keep track of their visibility.
/datum/component/overlay_lighting/proc/add_dynamic_lumi()
LAZYSET(current_holder.affected_movable_lights, src, lumcount_range + 1)
current_holder.underlays += visible_mask
current_holder.update_dynamic_luminosity()
if(directional)
current_holder.underlays += cone

///Removes the luminosity and source for the afected movable atoms to keep track of their visibility.
///Removes the luminosity and source for the affected movable atoms to keep track of their visibility.
/datum/component/overlay_lighting/proc/remove_dynamic_lumi()
LAZYREMOVE(current_holder.affected_movable_lights, src)
current_holder.underlays -= visible_mask
Expand Down Expand Up @@ -262,6 +262,9 @@
///Used to determine the new valid current_holder from the parent's loc.
/datum/component/overlay_lighting/proc/check_holder()
var/atom/movable/movable_parent = GET_PARENT
if(QDELETED(movable_parent))
set_holder(null)
return
if(isturf(movable_parent.loc))
set_holder(movable_parent)
return
Expand All @@ -270,13 +273,21 @@
set_holder(null)
return
if(isturf(inside.loc))
set_holder(inside)
// storage items block light, also don't be moving into a qdeleted item
if(QDELETED(inside) || istype(inside, /obj/item/storage))
set_holder(null)
else
set_holder(inside)
return
set_holder(null)


///Called when the current_holder is qdeleted, to remove the light effect.
/datum/component/overlay_lighting/proc/on_holder_qdel(atom/movable/source, force)
SIGNAL_HANDLER
if(QDELETED(current_holder))
set_holder(null)
return
UnregisterSignal(current_holder, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED))
if(directional)
UnregisterSignal(current_holder, COMSIG_ATOM_DIR_CHANGE)
Expand All @@ -285,6 +296,7 @@

///Called when current_holder changes loc.
/datum/component/overlay_lighting/proc/on_holder_moved(atom/movable/source, OldLoc, Dir, Forced)
SIGNAL_HANDLER
if(!(overlay_lighting_flags & LIGHTING_ON))
return
make_luminosity_update()
Expand Down Expand Up @@ -443,8 +455,7 @@
. = lum_power
lum_power = new_lum_power
var/difference = . - lum_power
for(var/t in affected_turfs)
var/turf/lit_turf = t
for(var/turf/lit_turf as anything in affected_turfs)
lit_turf.dynamic_lumcount -= difference

///Here we append the behavior associated to changing lum_power.
Expand Down

0 comments on commit 73bd9e8

Please sign in to comment.