Skip to content
Adam Martin edited this page May 16, 2015 · 4 revisions

Overview

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.

Interface

  • Entity::Get<TYPE>() - returns a weak_ptr for the specified component type. In order to use the component lock() must be called on it. The weak_ptr may be stored to be used successively but checking validity after lock() is a safe practice
  • Entity::GetList<TYPE1, TYPE2, TYPEN>() - returns a tuple of weak_ptrs for the specified component types. To get a specific component from the return call std::get<N>() where N is the number of the type in the Entity::GetList() template list. After calling get usage is the same as Entity::Get()
  • Entity::Has<TYPE>() - checks if the entity has the specified component type.
  • Entity::Update<TYPE>(value) - updates the specified component type by calling ComponentUpdateSystem<TYPE>::SubmitUpdate(). This is effectively a thin pass through. Value can either be a value type or shared_ptr type with the former being copied into a shared_ptr internally.
  • Entity::Remove<TYPE>() - Removes a component of the specified type by calling ComponentUpdateSystem<TYPE>::SubmitRemoval(). This is effectively a thin pass through.