Constructor
new MenuVectorField(selectables, initialPos)
Parameters:
Name | Type | Description |
---|---|---|
selectables |
Array:.<Selectable:> | |
initialPos |
number |
- Source:
Members
(private) currPos :number
The current selectable we're at.
Type:
- number
- Source:
currPos
Getter and setter for module:menulib~MenuVectorField#currPos
- Source:
(private) selectables :Array:.<Selectable:>
List of selectables associated with this MenuVectorField.
Type:
- Source:
Methods
getFromDir(direction) → {number}
Given our current selector (module:menulib~MenuVectorField#currPos), pick another close-by selector in the given direction.
Parameters:
Name | Type | Description |
---|---|---|
direction |
MenuVector | A unit vector. |
- Source:
Returns:
Index from module:menulib~MenuVectorField#selectables
- Type
- number
raycastEstimate(from, direction, threshold) → {number}
Like a raycast, except this also accounts for rays that are CLOSE enough for the MenuVector field to qualify as "good enough".
So that means that this raycast returns some kind of Selectable, provided that Selectable is either:
Hit by the ray (the ray at some point is within its rectangle).
This will return the selectable that has the closest distance to where the raycast "hits", provided the distance is within the "threshold".
We prioritize elements that are closer to the current element, since this is meant to be used for navigation.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
from |
MenuVector | ||
direction |
MenuVector | ||
threshold |
number | 100 | The maximum distance a given Selectable from `from` can have to be selected. |
- Source:
Returns:
Index of closest selectable from raycast.
- Type
- number