beam 
Beam Datum and Effect
-
IF YOU ARE LAZY AND DO NOT WANT TO READ, GO TO THE BOTTOM OF THE FILE AND USE THAT PROC!
-
This is the beam datum! It's a really neat effect for the game in drawing a line from one atom to another.
-
It has two parts:
-
The datum itself which manages redrawing the beam to constantly keep it pointing from the origin to the target.
-
The effect which is what the beams are made out of. They're placed in a line from the origin to target, rotated towards the target and snipped off at the end.
-
These effects are kept in a list and constantly created and destroyed (hence the proc names draw and reset, reset destroying all effects and draw creating more.)
-
You can add more special effects to the beam itself by changing what the drawn beam effects do. For example you can make a vine that pricks people by making the beam_type
-
include a crossed proc that damages the crosser. Examples in venus_human_trap.dm
Vars | |
| anim_duration | Duration of the last animation, in deciseconds (matches the time= passed to animate()). |
|---|---|
| anim_from_origin_x | Last animation's "from" (where segments were seeded at draw time) — origin endpoint. |
| anim_from_target_x | Last animation's "from" — target endpoint. |
| anim_start_time | world.time at which the last animation began. Combined with anim_duration to estimate segments' current visual position mid-animation. |
| animate | If FALSE, redraws snap per update instead of using animate() interpolation. |
| beam_color | The color of the beam we're drawing. |
| beam_layer | the layer of our beam |
| beam_type | the objects placed in the elements list |
| elements | list of beam objects. These have their visuals set by the visuals var which is created on starting |
| emissive | If we use an emissive appearance |
| icon | icon used by the beam. |
| icon_state | icon state of the main segments of the beam |
| last_draw_valid | Whether we have a cached last-drawn geometry from a previous Draw(). |
| last_origin_x | Last drawn origin tile/pixel coordinates (used as the "from" frame for animated redraws). |
| last_target_x | Last drawn target tile/pixel coordinates. |
| max_distance | The beam will qdel if it's longer than this many tiles. |
| origin | where the beam goes from |
| override_origin_pixel_x | If set will be used instead of origin's pixel_x in offset calculations |
| override_origin_pixel_y | If set will be used instead of origin's pixel_y in offset calculations |
| override_target_pixel_x | If set will be used instead of targets's pixel_x in offset calculations |
| override_target_pixel_y | If set will be used instead of targets's pixel_y in offset calculations |
| pending_animate_time | Animate time queued for the pending redraw. We take the largest (slowest glide) of any movers that triggered the redraw. |
| target | where the beam goes to |
| visuals | This is used as the visual_contents of beams, so you can apply one effect to this and the whole beam will look like that. never gets deleted on redrawing. |
Procs | |
| Draw | Creates the beam effects and places them in a line from the origin to the target. Sets their rotation to make the beams face the target, too. |
| Start | Proc called by the atom Beam() proc. Sets up signals, and draws the beam for the first time. |
| get_last_geometry | Returns the last drawn endpoints for reuse by inherit_glide(), or null if undrawn. |
| inherit_glide | Seeds the next Draw() from saved geometry so rebuilt beams glide instead of snapping. |
| redrawing | Triggered by signals set up when the beam is set up. If it's still sane to create a beam, it removes the old beam, creates a new one. Otherwise it kills the beam. |
| set_subsegment_appearance | sets the sprite of the segment, using the more performant viscontents by default |
Var Details
anim_duration 
Duration of the last animation, in deciseconds (matches the time= passed to animate()).
anim_from_origin_x 
Last animation's "from" (where segments were seeded at draw time) — origin endpoint.
anim_from_target_x 
Last animation's "from" — target endpoint.
anim_start_time 
world.time at which the last animation began. Combined with anim_duration to estimate segments' current visual position mid-animation.
animate 
If FALSE, redraws snap per update instead of using animate() interpolation.
beam_color 
The color of the beam we're drawing.
beam_layer 
the layer of our beam
beam_type 
the objects placed in the elements list
elements 
list of beam objects. These have their visuals set by the visuals var which is created on starting
emissive 
If we use an emissive appearance
icon 
icon used by the beam.
icon_state 
icon state of the main segments of the beam
last_draw_valid 
Whether we have a cached last-drawn geometry from a previous Draw().
last_origin_x 
Last drawn origin tile/pixel coordinates (used as the "from" frame for animated redraws).
last_target_x 
Last drawn target tile/pixel coordinates.
max_distance 
The beam will qdel if it's longer than this many tiles.
origin 
where the beam goes from
override_origin_pixel_x 
If set will be used instead of origin's pixel_x in offset calculations
override_origin_pixel_y 
If set will be used instead of origin's pixel_y in offset calculations
override_target_pixel_x 
If set will be used instead of targets's pixel_x in offset calculations
override_target_pixel_y 
If set will be used instead of targets's pixel_y in offset calculations
pending_animate_time 
Animate time queued for the pending redraw. We take the largest (slowest glide) of any movers that triggered the redraw.
target 
where the beam goes to
visuals 
This is used as the visual_contents of beams, so you can apply one effect to this and the whole beam will look like that. never gets deleted on redrawing.
Proc Details
Draw
Creates the beam effects and places them in a line from the origin to the target. Sets their rotation to make the beams face the target, too.
Start
Proc called by the atom Beam() proc. Sets up signals, and draws the beam for the first time.
get_last_geometry
Returns the last drawn endpoints for reuse by inherit_glide(), or null if undrawn.
inherit_glide
Seeds the next Draw() from saved geometry so rebuilt beams glide instead of snapping.
redrawing
Triggered by signals set up when the beam is set up. If it's still sane to create a beam, it removes the old beam, creates a new one. Otherwise it kills the beam.
Arguments: mover: either the origin of the beam or the target of the beam that moved. oldloc: from where mover moved. direction: in what direction mover moved from.
set_subsegment_appearance
sets the sprite of the segment, using the more performant viscontents by default