-
Notifications
You must be signed in to change notification settings - Fork 22
Entity Interface
Adam Martin edited this page May 16, 2015
·
4 revisions
The entity interface provides a thin wrapper over the central component storage. Entities can be instantiated and stored for quick access to interface methods without having to supply an entity id each time.
-
Entity::Get<TYPE>()
- returns aweak_ptr
for the specified component type. In order to use the componentlock()
must be called on it. Theweak_ptr
may be stored to be used successively but checking validity afterlock()
is a safe practice -
Entity::GetList<TYPE1, TYPE2, TYPEN>()
- returns a tuple ofweak_ptr
s for the specified component types. To get a specific component from the return callstd::get<N>()
where N is the number of the type in theEntity::GetList()
template list. After calling get usage is the same asEntity::Get()
-
Entity::Has<TYPE>()
- checks if the entity has the specified component type. -
Entity::Update<TYPE>(value)
- updates the specified component type by callingComponentUpdateSystem<TYPE>::SubmitUpdate()
. This is effectively a thin pass through. Value can either be a value type orshared_ptr
type with the former being copied into a shared_ptr internally. -
Entity::Remove<TYPE>()
- Removes a component of the specified type by callingComponentUpdateSystem<TYPE>::SubmitRemoval()
. This is effectively a thin pass through.