# Class: World
Maintains all of the entities and performs queries.
const world = new flock.World()
# Constructors
# constructor
+ new World(): World
Returns: World
# Methods
# _addEntityComponent
▸ _addEntityComponent<T>(entity
: Entity, component
: Component‹T›, componentValue
: ComponentValue‹T›): void
Type parameters:
▪ T
Parameters:
Name | Type |
---|---|
entity | Entity |
component | Component‹T› |
componentValue | ComponentValue‹T› |
Returns: void
# _getEntityComponent
▸ _getEntityComponent<T>(entity
: Entity, component
: Component‹T›): ComponentValue‹T› | undefined
Type parameters:
▪ T
Parameters:
Name | Type |
---|---|
entity | Entity |
component | Component‹T› |
Returns: ComponentValue‹T› | undefined
# _removeEntityComponent
▸ _removeEntityComponent<T>(entity
: Entity, component
: Component‹T›): ComponentValue‹T› | undefined
Type parameters:
▪ T
Parameters:
Name | Type |
---|---|
entity | Entity |
component | Component‹T› |
Returns: ComponentValue‹T› | undefined
# createEntity
▸ createEntity(): Entity
Creates a new Entity.
const entity = world.createEntity();
Returns: Entity
# maintain
▸ maintain(): void
Removes Entities from the World that have been marked for removal.
Unmarks Entities as added
.
world.maintain();
Returns: void
# query
▸ query(componentQueries
: ComponentQuery‹any›[]): Entity[]
Given a set of Without, Current, Removed, and Added, will return a list of Entities that match the query.
Typically this is not used directly, but implictly when System.run is called.
Parameters:
Name | Type |
---|---|
componentQueries | ComponentQuery‹any›[] |
Returns: Entity[]
# registerComponent
▸ registerComponent<T>(component
: Component‹T›): void
Registers a Component with the World.
const age = new flock.Component(() => 30);
world.registerComponent(age);
Type parameters:
▪ T
Parameters:
Name | Type |
---|---|
component | Component‹T› |
Returns: void
# unregisterComponent
▸ unregisterComponent<T>(component
: Component‹T›): void
Unregisters a Component with the World.
const age = new flock.Component(() => 30);
world.registerComponent(age);
world.unregisterComponent(age);
Type parameters:
▪ T
Parameters:
Name | Type |
---|---|
component | Component‹T› |
Returns: void