ValidTargets Class
Manages a list of valid targets and which is currently selected.
Constructor
ValidTargets
-
game
-
[targets=[]]
-
settings
Parameters:
-
game
Game- Game instance this obj is attached to.
-
[targets=[]]
Array optionalAn Array of valid target objects to select from (intended to be in the format
validTargetsFinder.getValidTargets()
returns). -
settings
Object-
[typeSortPriority=this.typeSortPriority]
Array optional- Array of types in order of their sort priority.
-
[mapWidth=game.map.width]
Bool optional- Width of
this.map
.
- Width of
-
[mapHeight=game.map.height]
Bool optional- Height of
this.map
.
- Height of
-
[skipSort=false]
Bool optional- If true initial sort is skipped.
-
Item Index
Properties
Methods
getCurrent
-
[autoset=true]
Gets the currently selected target object.
Parameters:
-
[autoset=true]
Bool optional- If no target is set to current autoset the first.
Returns:
getTargetByValue
-
value
Finds a target object by its value.
Parameters:
-
value
Object
Returns:
getTypeSortPriority
-
obj
Gets the sort priority of an object based on its type using 'this.typeSortPriority'.
Parameters:
-
obj
Object
Returns:
next
()
Object
Sets the object after the currently selected object to be the selected object.
Returns:
The new currently selected object.
prev
()
Object
Sets the object before the currently selected object to be the selected object.
Returns:
The new currently selected object.
setCurrent
-
target
Sets the currently selected target object.
Parameters:
-
target
Object
Returns:
If target was found in this.targets
. (only set if found).
setTargets
-
targets
Sets the targets, replacing currently set ones.
Parameters:
-
targets
Array
sort
()
Number
Sorts this.targets
by this.typeSortPriority
then by range.
Returns:
Properties
current
Object
Currently Selected Object.
targets
Array
Array of target objects.
typeSortPriority
Array
Array of types in order of their sort priority.