Go to the documentation of this file.
29 std::vector<std::shared_ptr<IView>>
_views = {};
59 template<
typename ...Components>
62 static std::unordered_map<int, std::weak_ptr<
View<Components...>>> cache;
63 auto existing = cache.find(this->_id);
64 if (existing != cache.end() && !existing->second.expired())
65 return *existing->second.lock();
68 cache.emplace(this->_id,
view);
void emplace_back(Entity &entity) override
Definition: View.hpp:175
friend Entity
Definition: Scene.hpp:84
Scene & operator=(const Scene &)
A scene is assignable.
Definition: Scene.cpp:17
void applyChanges()
Delete entities marked as deleted and create scheduled entities.
Definition: Scene.cpp:65
std::list< Entity > _newEntities
The list of entities to add on the next call to applyChanges.
Definition: Scene.hpp:27
Definition: Component.cpp:7
Entity & addEntity(const std::string &name)
Add a new entity to the scene.
Definition: Scene.cpp:22
void _componentAdded(Entity &entity, const std::type_index &type)
Notify this scene that a component has been added to the given entity.
Definition: Scene.cpp:32
An entity of the WAL's ECS.
Definition: Entity.hpp:20
static int _nextID
Definition: Scene.hpp:20
int getID() const
Get the ID of this scene.
Definition: Scene.cpp:54
void _componentRemoved(const Entity &entity, const std::type_index &type)
Notify this scene that a component has been removed to the given entity.
Definition: Scene.cpp:45
std::list< Entity > & getEntities()
Get the list of entities.
Definition: Scene.cpp:12
Scene()=default
A default constructor.
std::list< Entity > _entities
The list of registered entities.
Definition: Scene.hpp:25
int _id
An ID representing this scene.
Definition: Scene.hpp:22
A view allowing one to easily access entities containing a set list of component. A view is always up...
Definition: View.hpp:133
Represent a single scene that contains entities.
Definition: Scene.hpp:17
void _entityRemoved(const Entity &entity)
Remove an entity from every views.
Definition: Scene.cpp:59
View< Components... > & view()
Definition: Scene.hpp:60
std::vector< std::shared_ptr< IView > > _views
The list of cached views to update.
Definition: Scene.hpp:29
~Scene()=default
A default destructor.
Entity & scheduleNewEntity(const std::string &name)
Add a new entity to the scene, this entity will be added on the next call to applyChanges.
Definition: Scene.cpp:27