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
Name | Type |
---|---|
this | ParentTrait & SelectableChildrenTrait |
index | number |
Returns
void
countSelectedChildren
▸ countSelectedChildren(): number
Number of selected child elements
Returns
number
countUnselectedChildren
▸ countUnselectedChildren(this
): number
Number of not selected child elements
Parameters
Name | Type |
---|---|
this | ParentTrait & SelectableChildrenTrait |
Returns
number
deselectChildAt
▸ deselectChildAt(this
, childIndex
): void
Deselect child
Parameters
Name | Type |
---|---|
this | ParentTrait & SelectableChildrenTrait |
childIndex | number |
Returns
void
getSelectedChildren
▸ getSelectedChildren<T
>(this
): T
[]
Type parameters
Name | Type |
---|---|
T | extends ChildTrait <T > |
Parameters
Name | Type |
---|---|
this | ParentTrait & SelectableChildrenTrait |
Returns
T
[]
getSelectionIndex
▸ getSelectionIndex(childIndex
): number
In which order was nth child selected. Returns undefined
on index of UNselected child.
Parameters
Name | Type | Description |
---|---|---|
childIndex | number | index of child |
Returns
number
getUnselectedChildren
▸ getUnselectedChildren<T
>(this
): T
[]
Type parameters
Name | Type |
---|---|
T | extends ChildTrait <T > |
Parameters
Name | Type |
---|---|
this | ParentTrait & SelectableChildrenTrait |
Returns
T
[]
isChildSelected
▸ isChildSelected(childIndex
): boolean
Parameters
Name | Type |
---|---|
childIndex | number |
Returns
boolean
selectChildAt
▸ selectChildAt(this
, childIndex
): void
Select child
Parameters
Name | Type |
---|---|
this | ParentTrait & SelectableChildrenTrait |
childIndex | number |
Returns
void