immerse
A visual element that makes movables entering the attached turfs look immersed into that turf.
Abandon all hope, ye who read forth, for this immerse works on mind-numbing workarounds,
Vars | |
attached_turfs_and_movables | An association list of turfs that have this element attached and their affected contents. |
---|---|
generated_immerse_icons | A list of icons generated from a target and a mask, later used as appearances for the overlays. |
generated_visual_overlays | A list of instances of /atom/movable/immerse_overlay then used as visual overlays for the immersed movables. |
immersed_movables | An association list of movables as key and overlays as assoc. |
movables_to_ignore | A list of movables that shouldn't be affected by the element, either because it'd look bad or barely perceptible. |
Procs | |
Detach | Hello, you may be wondering why we're blending icons and not simply overlaying one mutable appearance with the blend multiply on another. Well, the latter option doesn't work as neatly when added to an atom with the KEEP_TOGETHER appearance flag, with the mask icon also showing on said atom, while we don't want it to. |
add_immerse_overlay | The main proc, which adds a visual overlay to the movable that has entered the turf to make it look immersed. It's kind of iffy but basically, we want the overlay to cover as much area as needed to avoid the movable's icon from spilling horizontally or below. Also, while these visual overlays are mainly cached movables, for certain movables, such as living mobs, we want them to have their own unique vis overlay with additional signals registered. This allows the vis overlay to look more or less unchanged while its owner is spinning or resting without otherwise affecting other movables with identical overlays. |
clear_overlay_refs | We need to make sure to remove hard refs from the element when deleted. |
generate_vis_overlay | Let's give an unique immerse visual only to those movables that would benefit from this the most, for the sake of a smidge of lightweightness. Initializes and caches a new visual overlay given parameters such as width, height and whether it should appear fully underwater. |
on_atom_exited | Called when a movable exits the turf. If its new location is not in the list of turfs with this element, Remove the movable from the element. |
on_init_or_entered | If the movable is within the right layers and planes, not in the list of movable types to ignore, or already affected by the element for that matter, Signals will be registered and, unless the movable (or whatever it's buckled to) is flying, it'll appear as if immersed in that water. |
on_move_flag_disabled | Readds the overlay to the mob and bucklees if no longer flying. |
on_move_flag_enabled | Removes the overlay from mob and bucklees is flying. |
on_spin_animation | Here, we temporarily switch from the offset of the mutable appearance to one for movable used as visual overlay. Why? While visual overlays can be animated, their fixed point stays at the center of the icon of the atom they're attached to and not theirs, which can make manipulating the transform var a pain, but because we cannot do that with normal overlay or filters (reliably), we have to bend a knee and try to compensate it. Oh, yeah, didn't I mention turning a visual overlay affects its pixel x/y/w/z too? Yeah, it sucks. Spin the overlay in the opposite direction so it doesn't look like it's spinning at all. |
on_throw | Works just like on_move_flag_enabled, except it only has to check that movable isn't flying |
on_throw_landed | Works just like on_move_flag_disabled, except it only has to check that movable isn't flying |
on_update_transform | A band-aid to keep the (unique) visual overlay from scaling and rotating along with its owner. I'm sorry. |
remove_from_element | Remove any signal, overlay, trait given to the movable and reference to it within the element. |
remove_immerse_overlay | vis contents spin around the center of the icon of their vis locs but since we want the appearance to stay where it should be, we have to counteract this one. This proc removes the vis_overlay, the keep together trait and some signals from the movable. |
start_immersion | Makes the element start affecting the turf and its contents. Called on Attach() or when TRAIT_IMMERSE_STOPPED is removed. |
stop_immersion | Stops the element from affecting on the turf and its contents. Called on Detach() or when TRAIT_IMMERSE_STOPPED is added. |
try_immerse | Called by init_or_entered() and on_set_buckled(). This applies the overlay if neither the movable or whatever is buckled to (exclusive to living mobs) are flying as well as movetype signals when the movable isn't buckled. |
try_unimmerse | Called by on_set_buckled() and remove_from_element(). This removes the filter and signals from the movable unless it doesn't have them. |
Var Details
attached_turfs_and_movables
An association list of turfs that have this element attached and their affected contents.
generated_immerse_icons
A list of icons generated from a target and a mask, later used as appearances for the overlays.
generated_visual_overlays
A list of instances of /atom/movable/immerse_overlay then used as visual overlays for the immersed movables.
immersed_movables
An association list of movables as key and overlays as assoc.
movables_to_ignore
A list of movables that shouldn't be affected by the element, either because it'd look bad or barely perceptible.
Proc Details
Detach
Hello, you may be wondering why we're blending icons and not simply overlaying one mutable appearance with the blend multiply on another. Well, the latter option doesn't work as neatly when added to an atom with the KEEP_TOGETHER appearance flag, with the mask icon also showing on said atom, while we don't want it to.
Also using KEEP_APART isn't an option, because unless it's drawn as one with its visual loation, the whole plane the atom belongs to will count as part of the mask of the final visual overlay since that's how the BLEND_INSET_OVERLAY blend mode works here. In layman terms, with KEEP_APART on, if a flying monkey gets nears an immersed human, the visual overlay will appear on the flying monkey even if it shouldn't.
add_immerse_overlay
The main proc, which adds a visual overlay to the movable that has entered the turf to make it look immersed. It's kind of iffy but basically, we want the overlay to cover as much area as needed to avoid the movable's icon from spilling horizontally or below. Also, while these visual overlays are mainly cached movables, for certain movables, such as living mobs, we want them to have their own unique vis overlay with additional signals registered. This allows the vis overlay to look more or less unchanged while its owner is spinning or resting without otherwise affecting other movables with identical overlays.
clear_overlay_refs
We need to make sure to remove hard refs from the element when deleted.
generate_vis_overlay
Let's give an unique immerse visual only to those movables that would benefit from this the most, for the sake of a smidge of lightweightness. Initializes and caches a new visual overlay given parameters such as width, height and whether it should appear fully underwater.
on_atom_exited
Called when a movable exits the turf. If its new location is not in the list of turfs with this element, Remove the movable from the element.
on_init_or_entered
If the movable is within the right layers and planes, not in the list of movable types to ignore, or already affected by the element for that matter, Signals will be registered and, unless the movable (or whatever it's buckled to) is flying, it'll appear as if immersed in that water.
on_move_flag_disabled
Readds the overlay to the mob and bucklees if no longer flying.
on_move_flag_enabled
Removes the overlay from mob and bucklees is flying.
on_spin_animation
Here, we temporarily switch from the offset of the mutable appearance to one for movable used as visual overlay. Why? While visual overlays can be animated, their fixed point stays at the center of the icon of the atom they're attached to and not theirs, which can make manipulating the transform var a pain, but because we cannot do that with normal overlay or filters (reliably), we have to bend a knee and try to compensate it. Oh, yeah, didn't I mention turning a visual overlay affects its pixel x/y/w/z too? Yeah, it sucks. Spin the overlay in the opposite direction so it doesn't look like it's spinning at all.
on_throw
Works just like on_move_flag_enabled, except it only has to check that movable isn't flying
on_throw_landed
Works just like on_move_flag_disabled, except it only has to check that movable isn't flying
on_update_transform
A band-aid to keep the (unique) visual overlay from scaling and rotating along with its owner. I'm sorry.
remove_from_element
Remove any signal, overlay, trait given to the movable and reference to it within the element.
remove_immerse_overlay
vis contents spin around the center of the icon of their vis locs but since we want the appearance to stay where it should be, we have to counteract this one. This proc removes the vis_overlay, the keep together trait and some signals from the movable.
start_immersion
Makes the element start affecting the turf and its contents. Called on Attach() or when TRAIT_IMMERSE_STOPPED is removed.
stop_immersion
Stops the element from affecting on the turf and its contents. Called on Detach() or when TRAIT_IMMERSE_STOPPED is added.
try_immerse
Called by init_or_entered() and on_set_buckled(). This applies the overlay if neither the movable or whatever is buckled to (exclusive to living mobs) are flying as well as movetype signals when the movable isn't buckled.
try_unimmerse
Called by on_set_buckled() and remove_from_element(). This removes the filter and signals from the movable unless it doesn't have them.