ComponentMapper Class
High performance component retrieval from entities. Use this wherever you need to retrieve components from entities often and fast.
Methods
get
(
ArtemiJS.Component
-
entity
Fast but unsafe retrieval of a component for this entity. No bounding checks, so this could return null, however in most scenarios you already know the entity possesses this component.
Parameters:
-
entity
ArtemiJS.Entity
Returns:
ArtemiJS.Component:
|null
getFor
(
ArtemiJS.ComponentMapper
static
-
type
-
the
Returns a component mapper for this type of components.
Parameters:
-
type
Objectthe type of components this mapper uses
-
the
ArtemiJS.Worldworld that this component mapper should use
Returns:
ArtemiJS.ComponentMapper:
getSafe
(
ArtemiJS.Component
-
entity
Fast and safe retrieval of a component for this entity. If the entity does not have this component then null is returned.
Parameters:
-
entity
ArtemiJS.Entity
Returns:
ArtemiJS.Component:
|null
has
(
-
entity
Checks if the entity has this type of component.
Parameters:
-
entity
ArtemiJS.Entity
Returns:
boolean true if the entity has this component type, false if it doesn't.