overlay_lighting
Movable atom overlay-based lighting component.
-
Component works by applying a visual object to the parent target.
-
The component tracks the parent's loc to determine the current_holder.
-
The current_holder is either the parent or its loc, whichever is on a turf. If none, then the current_holder is null and the light is not visible.
-
Lighting works at its base by applying a dark overlay and "cutting" said darkness with light, adding (possibly colored) transparency.
-
This component uses the visible_mask visual object to apply said light mask on the darkness.
-
The main limitation of this system is that it uses a limited number of pre-baked geometrical shapes, but for most uses it does the job.
-
Another limitation is for big lights: you only see the light if you see the object emiting it.
-
For small objects this is good (you can't see them behind a wall), but for big ones this quickly becomes prety clumsy.
Vars | |
affected_turfs | Lazy list to track the turfs being affected by our light, to determine their visibility. |
---|---|
beam | Whether we're a beam light |
cast_range | Cast range for the directional cast (how far away the atom is moved) |
cone | A cone overlay for directional light, its alpha and color are dependent on the light |
current_direction | Current tracked direction for the directional cast behaviour |
current_holder | Movable atom currently holding the light. Parent might be a flashlight, for example, but that might be held by a mob or something else. |
directional | Whether we're a directional light |
directional_offset_x | Tracks current directional x offset so we don't update unnecessarily |
directional_offset_y | Tracks current directional y offset so we don't update unnecessarily |
light_overlays | Cache of the possible light overlays, according to size. |
lum_power | How much this light affects the dynamic_lumcount of turfs. |
lumcount_range | Ceiling of range, integer without decimal entries. |
overlay_lighting_flags | For light sources that can be turned on and off. |
parent_attached_to | Movable atom the parent is attached to. For example, a flashlight into a helmet or gun. We'll need to track the thing the parent is attached to as if it were the parent itself. |
range | How far the light reaches, float. |
set_alpha | Transparency value. |
visible_mask | Overlay effect to cut into the darkness and provide light. |
Procs | |
add_dynamic_lumi | Adds the luminosity and source for the affected movable atoms to keep track of their visibility. |
cast_directional_light | Here we append the behavior associated to changing lum_power. |
check_holder | Used to determine the new valid current_holder from the parent's loc. |
clean_old_turfs | Clears the affected_turfs lazylist, removing from its contents the effects of being near the light. |
get_new_turfs | Populates the affected_turfs lazylist, adding to its contents the effects of being near the light. |
make_luminosity_update | Clears the old affected turfs and populates the new ones. |
on_holder_dir_change | Called when current_holder changes loc. |
on_holder_moved | Called when current_holder changes loc. |
on_holder_qdel | Called when the current_holder is qdeleted, to remove the light effect. |
on_light_eater | Handles putting the source for overlay lights into the light eater queue since we aren't tracked by /atom/var/light_sources |
on_light_flags_change | Triggered right after the parent light flags change. |
on_parent_attached_to_moved | Called when parent_attached_to changes loc. |
on_parent_attached_to_qdel | Called when the current_holder is qdeleted, to remove the light effect. |
on_parent_dir_change | Called when parent changes loc. |
on_parent_moved | Called when parent changes loc. |
on_toggle | Toggles the light on and off. |
remove_dynamic_lumi | Removes the luminosity and source for the affected movable atoms to keep track of their visibility. |
set_color | Changes the light's color, pretty straightforward. |
set_direction | Sets a new direction for the directional cast, then updates luminosity |
set_holder | Called to change the value of current_holder. |
set_lum_power | Here we append the behavior associated to changing lum_power. |
set_parent_attached_to | Called to change the value of parent_attached_to. |
set_power | Changes the intensity/brightness of the light by altering the visual object's alpha. |
set_range | Changes the range which the light reaches. 0 means no light, 6 is the maximum value. |
turn_off | Toggles the light off. |
turn_on | Toggles the light on. |
Var Details
affected_turfs
Lazy list to track the turfs being affected by our light, to determine their visibility.
beam
Whether we're a beam light
cast_range
Cast range for the directional cast (how far away the atom is moved)
cone
A cone overlay for directional light, its alpha and color are dependent on the light
current_direction
Current tracked direction for the directional cast behaviour
current_holder
Movable atom currently holding the light. Parent might be a flashlight, for example, but that might be held by a mob or something else.
directional
Whether we're a directional light
directional_offset_x
Tracks current directional x offset so we don't update unnecessarily
directional_offset_y
Tracks current directional y offset so we don't update unnecessarily
light_overlays
Cache of the possible light overlays, according to size.
lum_power
How much this light affects the dynamic_lumcount of turfs.
lumcount_range
Ceiling of range, integer without decimal entries.
overlay_lighting_flags
For light sources that can be turned on and off.
parent_attached_to
Movable atom the parent is attached to. For example, a flashlight into a helmet or gun. We'll need to track the thing the parent is attached to as if it were the parent itself.
range
How far the light reaches, float.
set_alpha
Transparency value.
visible_mask
Overlay effect to cut into the darkness and provide light.
Proc Details
add_dynamic_lumi
Adds the luminosity and source for the affected movable atoms to keep track of their visibility.
cast_directional_light
Here we append the behavior associated to changing lum_power.
check_holder
Used to determine the new valid current_holder from the parent's loc.
clean_old_turfs
Clears the affected_turfs lazylist, removing from its contents the effects of being near the light.
get_new_turfs
Populates the affected_turfs lazylist, adding to its contents the effects of being near the light.
make_luminosity_update
Clears the old affected turfs and populates the new ones.
on_holder_dir_change
Called when current_holder changes loc.
on_holder_moved
Called when current_holder changes loc.
on_holder_qdel
Called when the current_holder is qdeleted, to remove the light effect.
on_light_eater
Handles putting the source for overlay lights into the light eater queue since we aren't tracked by /atom/var/light_sources
on_light_flags_change
Triggered right after the parent light flags change.
on_parent_attached_to_moved
Called when parent_attached_to changes loc.
on_parent_attached_to_qdel
Called when the current_holder is qdeleted, to remove the light effect.
on_parent_dir_change
Called when parent changes loc.
on_parent_moved
Called when parent changes loc.
on_toggle
Toggles the light on and off.
remove_dynamic_lumi
Removes the luminosity and source for the affected movable atoms to keep track of their visibility.
set_color
Changes the light's color, pretty straightforward.
set_direction
Sets a new direction for the directional cast, then updates luminosity
set_holder
Called to change the value of current_holder.
set_lum_power
Here we append the behavior associated to changing lum_power.
set_parent_attached_to
Called to change the value of parent_attached_to.
set_power
Changes the intensity/brightness of the light by altering the visual object's alpha.
set_range
Changes the range which the light reaches. 0 means no light, 6 is the maximum value.
turn_off
Toggles the light off.
turn_on
Toggles the light on.