Basic Proximity Monitor
Attaching this component to an atom means that the atom will be able to detect mobs or objects moving within a specified radius of it.
The component creates several /obj/effect/abstract/proximity_checker objects, which follow the parent
AKA hasprox_receiver
around, always making sure it's at the center.
When something crosses one of these proximiy checkers, the hasprox_receiver
will have the HasProximity()
proc called on it, with the crossing mob/obj as the argument.
Vars | |
always_active | Should the parent always detect proximity and update the field on movement, even if it's not on a turf? |
---|---|
field_checker_type | The type of checker object that should be used for the main field. |
hasprox_receiver | The primary atom the component is attached to and that will be receiving HasProximity() calls. Same as the parent . |
nested_receiver_locs | A list which contains references to movable atoms which the hasprox_receiver has moved into.
Used to handle complex situations where the receiver is nested several layers deep into an object.
For example: inside of a box, that's inside of a bag, which is worn on a human. In this situation there are 3 locations we need to listen to for movement. |
proximity_checkers | A list of currently created /obj/effect/abstract/proximity_checker in use with this component. |
radius | The radius of the field, in tiles. |
Procs | |
clear_nested_locs | Removes and unregisters signals from all objects currently in the nested_receiver_locs list. |
create_prox_checkers | Called in Initialize(). Generates a set of proximity checker objects around the parent. |
create_single_prox_checker | Creates a single proximity checker object, at the given location and of the given type. Adds it to the proximity checkers list. |
map_nested_locs | Registers signals to any nested locations the hasprox_receiver is in, excluding turfs, so they can be monitored for movement. |
move_prox_checkers | Relays basic directional movement from the hasprox_receiver or host , to all objects in the proximity_checkers list. |
on_disposal_enter | Called when the receiver or an atom in the nested_receiver_locs list moves into a disposals holder object. |
on_disposal_exit | Called when the receiver or an atom in the nested_receiver_locs list moves out of a disposals holder object. |
on_nested_loc_move | Called when an atom in nested_receiver_locs list moves, if one exists. |
on_receiver_move | Called when the hasprox_receiver moves. |
recenter_prox_checkers | Re-centers all of the proximity_checker s around the parent's current location. |
set_radius | Specifies a new radius for the field. Creates or deletes proximity_checkers accordingly. |
toggle_checkers | Update all of the component's proximity checker's to either become active or not active. |
Var Details
always_active
Should the parent always detect proximity and update the field on movement, even if it's not on a turf?
field_checker_type
The type of checker object that should be used for the main field.
hasprox_receiver
The primary atom the component is attached to and that will be receiving HasProximity()
calls. Same as the parent
.
nested_receiver_locs
A list which contains references to movable atoms which the hasprox_receiver
has moved into.
Used to handle complex situations where the receiver is nested several layers deep into an object.
For example: inside of a box, that's inside of a bag, which is worn on a human. In this situation there are 3 locations we need to listen to for movement.
proximity_checkers
A list of currently created /obj/effect/abstract/proximity_checker in use with this component.
radius
The radius of the field, in tiles.
Proc Details
clear_nested_locs
Removes and unregisters signals from all objects currently in the nested_receiver_locs
list.
create_prox_checkers
Called in Initialize(). Generates a set of proximity checker objects around the parent.
create_single_prox_checker
Creates a single proximity checker object, at the given location and of the given type. Adds it to the proximity checkers list.
Arguments:
- turf/T - the turf the checker should be created on
- checker_type - the type of /obj/item/abstract/proximity_checker to create
map_nested_locs
Registers signals to any nested locations the hasprox_receiver
is in, excluding turfs, so they can be monitored for movement.
move_prox_checkers
Relays basic directional movement from the hasprox_receiver
or host
, to all objects in the proximity_checkers
list.
Arguments:
- move_dir - the direction the checkers should move in
on_disposal_enter
Called when the receiver or an atom in the nested_receiver_locs
list moves into a disposals holder object.
This proc receives arguments, but they aren't needed.
on_disposal_exit
Called when the receiver or an atom in the nested_receiver_locs
list moves out of a disposals holder object.
This proc receives arguments, but they aren't needed.
on_nested_loc_move
Called when an atom in nested_receiver_locs
list moves, if one exists.
Arguments:
- atom/moved_atom - one of the atoms in
nested_receiver_locs
- atom/old_loc - the location
moved_atom
just moved from - dir - the direction
moved_atom
just moved in
on_receiver_move
Called when the hasprox_receiver
moves.
Arguments:
- datum/source - this will be the
hasprox_receiver
- atom/old_loc - the location the receiver just moved from
- dir - the direction the receiver just moved in
recenter_prox_checkers
Re-centers all of the proximity_checker
s around the parent's current location.
set_radius
Specifies a new radius for the field. Creates or deletes proximity_checkers accordingly.
This proc can have a high cost due to the new
s and qdel
s of the proximity checkers, depending on the number of calls you need to make to it.
Arguments:
new_radius - the new value that proximity_radius
should be set to.
toggle_checkers
Update all of the component's proximity checker's to either become active or not active.
Arguments:
- new_active - the value to be assigned to the proximity checker's
active
variable