API Docs for:
Show:

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 optional

    An 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.
    • [mapHeight=game.map.height] Bool optional
      • Height of this.map.
    • [skipSort=false] Bool optional
      • If true initial sort is skipped.

Methods

getCurrent

(
  • [autoset=true]
)
Object

Gets the currently selected target object.

Parameters:

  • [autoset=true] Bool optional
    • If no target is set to current autoset the first.

Returns:

Object:

getTargetByValue

(
  • value
)
Object

Finds a target object by its value.

Parameters:

  • value Object

Returns:

Object:

getTypeSortPriority

(
  • obj
)
Number

Gets the sort priority of an object based on its type using 'this.typeSortPriority'.

Parameters:

  • obj Object

Returns:

Number:

next

() Object

Sets the object after the currently selected object to be the selected object.

Returns:

Object:

The new currently selected object.

prev

() Object

Sets the object before the currently selected object to be the selected object.

Returns:

Object:

The new currently selected object.

setCurrent

(
  • target
)
Bool

Sets the currently selected target object.

Parameters:

  • target Object

Returns:

Bool:

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:

Number:

Properties

current

Object

Currently Selected Object.

game

Game

Game instance this obj is attached to.

map

MultiObjectManager

Map of target positions.

targets

Array

Array of target objects.

typeSortPriority

Array

Array of types in order of their sort priority.