ig.

Hierarchy

new Hierarchy()

Hierarchy structure using ancestor/descendant instead of child/parent.
- child/parent is avoided due to Impact's class using parent to reference prototype functions.

Author:
  • Collin Hover - collinhover.com
Source:

<static> SORT

Sorting methods for hierarchy descendants.

Source:

ancestor :Object

Ancestor hierarchy.

Default Value:
  • null
Source:

descendants :Array

List of descendants.

Source:

descendantsMap :Object

Map of descendants.

Source:

id :String

Unique instance id.

Source:

name :String

Unique instance name.
- usually names are used to map instances for faster searching.

Source:

sortBy :function

Method to sort descendants by.
- set during init

Default Value:
  • null
Source:

activate() → {Boolean}

Activate all descendants with blocking check and cleans up descendants that are blocked.

Source:
Returns:
{ Boolean } whether at least one ability was successfully activated.

addDescendant(adding)

Adds a descendant.

Parameters:
Name Type Description
adding * descendant object.
Source:

addDescendants(adding)

Adds one or more descendants.

Parameters:
Name Type Description
adding ig.Hierarchy | Array object or array of objects.
Source:

cleanup()

Cleanup all descendants.

Source:

clearDescendants()

Removes all descendants.

Source:

clone(c) → {ig.Hierarchy}

Clones this hierarchy object.

Parameters:
Name Type Argument Description
c ig.Hierarchy <optional>
hierarchy object to clone into.
Source:
Returns:
{ ig.Hierarchy } copy of this.

deactivate()

Deactivate all descendants.

Source:

forAll(callback)

Executes a function in the context of self and each descendant.

Parameters:
Name Type Description
callback function function.
Source:

forAllDescendants(callback)

Executes a function in the context of ONLY descendants.

Parameters:
Name Type Description
callback function function.
Source:

forAllDescendantsWithCallback(callbackName)

Executes a function in the context of each descendant that has a function with a matching name.

Parameters:
Name Type Description
callbackName String callback function name.
Source:

forAllWithCallback(callbackName)

Executes a function in the context of this and each descendant that has a function with a matching name.

Parameters:
Name Type Description
callbackName String callback function name.
Source:

forImmediate(callback)

Executes a function in the context of each immediate descendant.

Parameters:
Name Type Description
callback function callback function.
Source:

forImmediateWithCallback(callbackName)

Executes a function in the context of each immediate descendant that has a function with a matching name.

Parameters:
Name Type Description
callbackName String callback function name.
Source:

getDescendantByName(name, recursive) → {*}

Searches for a descendant by name and, optionally, searches recursively.

Parameters:
Name Type Argument Description
name String name of descendant.
recursive Boolean <optional>
search recursively.
Source:
Returns:
{ * } descendant if found.

getDescendants(array) → {Array}

Gets all descendants from here to last descendant.

Parameters:
Name Type Argument Description
array String <optional>
list of descendants already found.
Source:
Returns:
{ Array } array of all descendants.

getDescendantsByType(type, recursive) → {Array}

Searches for descendants by type and, optionally, searches recursively.

Parameters:
Name Type Argument Description
type Number type of descendant.
recursive Boolean <optional>
search recursively.
Source:
Returns:
{ Array } descendants if found.

getRoot() → {ig.Hierarchy}

Gets root ancestor.

Source:
Returns:
{ ig.Hierarchy } root if found.

getUsing()

Check if any descendants are in use and should not be disturbed.

Source:

init(settings)

Initializes hierarchy.

Parameters:
Name Type Argument Description
settings Object <optional>
settings object.
Source:

isAncestor(target) → {Boolean}

Gets if a target is an ancestor.

Parameters:
Name Type Description
target ig.Hierarchy hierarchy object.
Source:
Returns:
{ Boolean } true if ancestors, false if not.

mapDescendant(descendant)

Maps a descendant by name for faster lookups.

Parameters:
Name Type Description
descendant * descendant object.
Source:

pause()

Pauses all descendants.

Source:

removeDescendant(removing)

Removes a descendant.

Parameters:
Name Type Description
removing * descendant object.
Source:

removeDescendants(removing)

Removes one or more descendants.

Parameters:
Name Type Description
removing * | Array descendant object or array of objects.
Source:

setAncestor(ancestor)

Sets the ancestor of this.

Parameters:
Name Type Description
ancestor ig.Hierarchy hierarchy object.
Source:

setEntity()

Set entity of all descendants.

Source:

setEntityOptions()

Set entity options of all descendants.

Source:

setEntityTarget()

Set entity target of all descendants.

Source:

setEntityTargetFirst()

Set entity target of all descendants from a list of targets.

Source:

setFallback(fallback)

Sets the fallback hierarchy of this for when a lookup by name is done and nothing found.

Parameters:
Name Type Argument Description
fallback ig.Hierarchy <optional>
hierarchy object.
Source:

setName(name)

Sets the name of this and remaps this within ancestor for quick by-name lookups.

Parameters:
Name Type Description
name String name of this.
Source:

sortDescendants()

Sort descendants.

Source:

unmapDescendant(descendant)

Unmaps a descendant by name.

Parameters:
Name Type Description
descendant * descendant object.
Source:

unpause()

Unpauses all descendants.

Source:

update()

Update all descendants.

Source: