One screen of the application: it owns the entities shown and the components that hold their state.
More...
|
| void | placeEntitiesInFrontOfView (const utility::graphic::ViewF &view) |
| | Line up the scene's entities in front of a view.
|
| template<typename NextScene> |
| void | goToScene (void) |
| | Ask to leave this scene for another one.
|
| | Scene (std::shared_ptr< utility::RessourceProvider > ressourceProvider, LocalStorage &localStorage, SessionStorage &sessionStorage) |
| | Create an empty scene with its registries and its builders.
|
|
virtual | ~Scene (void) |
| | Destroy the scene with its entities and components.
|
| ecs::ComponentRegistry & | getComponentRegistry (void) |
| | Get the registry holding the components of every entity of this scene.
|
| ecs::EntityRegistry & | getEntityRegistry (void) |
| | Get the scene as the registry that owns its entities.
|
| bool | wantsToSwitch (void) const noexcept |
| | Tell whether goToScene() was called and the switch has not happened yet.
|
| std::type_index | getNextSceneType (void) const noexcept |
| | Get the scene type asked for by goToScene().
|
| void | clearNextScene (void) noexcept |
| | Forget the pending switch request, if any.
|
| virtual void | onEnter (void) |
| | Called each time the scene becomes the active one: at start-up for the default scene, then after each switch to it.
|
| virtual void | onExit (void) |
| | Called each time the scene stops being the active one, before onEnter() of the next scene.
|
|
| EntityRegistry (void)=default |
| | Create a registry.
|
| virtual | ~EntityRegistry (void)=default |
| | Virtual destructor.
|
| void | addEntity (std::shared_ptr< Entity > entity) |
| | Make this registry own an entity, so that it stays alive and systems visit it.
|
| bool | removeEntity (Entity::Identifier identifier) |
| | Remove an entity, with its children and all their components.
|
| void | clearEntities (void) |
| | Remove every entity owned by this registry, with everything they own and all their components.
|
| const std::vector< std::shared_ptr< Entity > > & | getEntities (void) const |
| | Get the entities this registry owns directly.
|
| std::vector< std::shared_ptr< Entity > > | getEntitiesBreadthFirst (void) |
| | List every entity of this registry and of the registries nested in it, level by level.
|
| std::vector< std::shared_ptr< Entity > > | getEntitiesBreadthFirst (void) const |
| | List every entity of this registry and of the registries nested in it, level by level (const overload).
|
| template<InheritFromEntity EntityType> |
| std::shared_ptr< EntityType > | getEntity (Entity::Identifier identifier) |
| | Find an entity owned directly by this registry, by identifier.
|
| template<InheritFromEntity EntityType> |
| std::shared_ptr< const EntityType > | getEntity (Entity::Identifier identifier) const |
| | Find an entity owned directly by this registry, by identifier (const overload).
|
| std::vector< Entity::Identifier > | getEntityWithSignature (Entity::Signature systemSignature) const |
| | List the entities that have every component type of a signature, from the root down.
|
| std::vector< Entity::Identifier > | getEntityWithSignature (Entity::Signature systemSignature, const EntityTreeTraveler &traveler) const |
| | List the entities that have every component type of a signature, in the order chosen by a traveler.
|
One screen of the application: it owns the entities shown and the components that hold their state.
A program derives one class per screen and overrides onEnter() to build its widgets. Application creates one instance of each scene type at start-up and keeps it until the program ends; exactly one scene is active at a time, and only that one is processed by the systems each frame.
A scene is three things:
{
public:
{
nullptr, "Settings",
guillaume::entities::Button::Color::Filled,
guillaume::entities::Button::Shape::Round,
guillaume::entities::Button::Size::Medium, false);
}
{
}
};
guillaume::Application<HomeScene, SettingsScene> app(
resources, std::move(engine));
One screen of the application: it owns the entities shown and the components that hold their state.
virtual void onExit(void)
Called each time the scene stops being the active one, before onEnter() of the next scene.
ecs::EntityBuilderManager & getBuilderManager(void)
Get the builders of this scene, one per widget of the library.
void goToScene(void)
Ask to leave this scene for another one.
Scene(std::shared_ptr< utility::RessourceProvider > ressourceProvider, LocalStorage &localStorage, SessionStorage &sessionStorage)
Create an empty scene with its registries and its builders.
virtual void onEnter(void)
Called each time the scene becomes the active one: at start-up for the default scene,...
BuilderType & getBuilder(void)
Get the builder of a given type.
void clearEntities(void)
Remove every entity owned by this registry, with everything they own and all their components.
Things to watch out for:
- onEnter() runs every time the scene becomes active, and the scene keeps its entities while it is inactive. A scene that can be entered twice either removes its entities in onExit(), as above, or builds them only once.
- Right after onEnter(), the entities the scene owns directly that have a Transform and a Bound are placed side by side in front of the engine's view (placeEntitiesInFrontOfView()).
- goToScene() only records a request; the switch happens at the end of the frame.
- A builder registers what it creates in the scene. addRootEntity() only gives an entity a name to find it again with getRootEntity(); it does not register it. A name cannot be taken back or reused, so a scene that names entities in onEnter() must build them only once.
- See also
- Application
-
SceneManager
-
ecs::EntityBuilderManager
Definition at line 113 of file scene.hpp.
| void guillaume::Scene::placeEntitiesInFrontOfView |
( |
const utility::graphic::ViewF & | view | ) |
|
Line up the scene's entities in front of a view.
Concerns the entities the scene owns directly that have both a components::Transform and a components::Bound. They are put in a row, in registration order, 300 units in front of the view, centered on its axis, 50 units apart, each one facing the same way as the view. The Transform position is the top-left corner of the entity. The other entities are not touched.
SceneManager calls it once after each onEnter(), with the engine's current view. The entities are not moved again when the view changes.
- Parameters
-
| view | The view to place the entities in front of. |