Skip to main content

Class: SelectableChildrenTrait

traits.SelectableChildrenTrait

Used on container - its children can now be selected by players.

Holds indexes of selected children and in which order were these chosen.

TODO: This trait is clearly dependant on ParentTrait. There should be a way of checking/ensuring this dependency is met

Constructors

constructor

new SelectableChildrenTrait()

Properties

selectedChildren

selectedChildren: ArraySchema<SelectedChildData>

Methods

_selectableEnsureIndex

_selectableEnsureIndex(this, index): void

Parameters

NameType
thisParentTrait & SelectableChildrenTrait
indexnumber

Returns

void


countSelectedChildren

countSelectedChildren(): number

Number of selected child elements

Returns

number


countUnselectedChildren

countUnselectedChildren(this): number

Number of not selected child elements

Parameters

NameType
thisParentTrait & SelectableChildrenTrait

Returns

number


deselectChildAt

deselectChildAt(this, childIndex): void

Deselect child

Parameters

NameType
thisParentTrait & SelectableChildrenTrait
childIndexnumber

Returns

void


getSelectedChildren

getSelectedChildren<T>(this): T[]

Type parameters

NameType
Textends ChildTrait<T>

Parameters

NameType
thisParentTrait & SelectableChildrenTrait

Returns

T[]


getSelectionIndex

getSelectionIndex(childIndex): number

In which order was nth child selected. Returns undefined on index of UNselected child.

Parameters

NameTypeDescription
childIndexnumberindex of child

Returns

number


getUnselectedChildren

getUnselectedChildren<T>(this): T[]

Type parameters

NameType
Textends ChildTrait<T>

Parameters

NameType
thisParentTrait & SelectableChildrenTrait

Returns

T[]


isChildSelected

isChildSelected(childIndex): boolean

Parameters

NameType
childIndexnumber

Returns

boolean


selectChildAt

selectChildAt(this, childIndex): void

Select child

Parameters

NameType
thisParentTrait & SelectableChildrenTrait
childIndexnumber

Returns

void