mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
Opacity refactor (#52881)
Moves all opacity var manipulation to a proc which sends a signal.
light_blocker element for movable opaque atoms made, which tracks its movement and updates the affected turfs for proper lighting updates.
has_opaque_atom boolean replaced by the opacity_sources lazylist to keep track of the sources, and a directional_opacity which serves a similar function but also allows for future expansion with on-border opaque objects (not yet implemented).
Some opacity-related sight procs optimized as a result of this.
Some variables moved to the object's definition.
A define or two added into the mix for clarity.
Some code cleaning, like turning booleans into their defines.
One file renamed for clarity.
Changelog
cl
balance: Mechs no longer block sight. It's a non-trivial cost for the lighting system with little to no gain.
/cl
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Attached to movable atoms with opacity. Listens to them move and updates their old and new turf loc's opacity accordingly.
|
||||
*/
|
||||
/datum/element/light_blocking
|
||||
element_flags = ELEMENT_DETACH
|
||||
|
||||
|
||||
/datum/element/light_blocking/Attach(datum/target)
|
||||
. = ..()
|
||||
if(!ismovable(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/on_target_move)
|
||||
var/atom/movable/movable_target = target
|
||||
if(isturf(movable_target.loc))
|
||||
var/turf/turf_loc = movable_target.loc
|
||||
turf_loc.add_opacity_source(target)
|
||||
|
||||
|
||||
/datum/element/light_blocking/Detach(atom/movable/target)
|
||||
. = ..()
|
||||
UnregisterSignal(target, list(COMSIG_MOVABLE_MOVED))
|
||||
var/atom/movable/movable_target = target
|
||||
if(isturf(movable_target.loc))
|
||||
var/turf/turf_loc = movable_target.loc
|
||||
turf_loc.remove_opacity_source(target)
|
||||
|
||||
|
||||
///Updates old and new turf loc opacities.
|
||||
/datum/element/light_blocking/proc/on_target_move(atom/movable/source, atom/OldLoc, Dir, Forced = FALSE)
|
||||
if(isturf(OldLoc))
|
||||
var/turf/old_turf = OldLoc
|
||||
old_turf.remove_opacity_source(source)
|
||||
if(isturf(source.loc))
|
||||
var/turf/new_turf = source.loc
|
||||
new_turf.add_opacity_source(source)
|
||||
Reference in New Issue
Block a user