![]() |
xyginext
0.2.0
Second generation of xygine game creation framework
|
Encapsulates a single scene. The scene class contains everything needed to create a scene graph by encapsulating the ECS and providing factory functions for entities. Multple scenes can exist at one time, for instance one to draw the game world, and another to draw the HUD. Everything is rendered through renderable systems which, in turn, require an ECS - therefore every state which wishes to draw something requires at least a scene, right down to menus. All systems should be added before attempting to create any entities else existing entities will not be processed by new systems. More...
#include <Scene.hpp>
Public Member Functions | |
Scene (MessageBus &messageBus, std::size_t initialPoolSize=256) | |
Constructor. More... | |
Scene (const Scene &)=delete | |
Scene (Scene &&)=delete | |
Scene & | operator= (const Scene &)=delete |
Scene & | operator= (Scene &&)=delete |
void | update (float dt) |
Executes one simulation step. More... | |
Entity | createEntity () |
Creates a new entity in the Scene, and returns a handle to it. | |
void | destroyEntity (Entity) |
Destroys the given entity and removes it from the scene. | |
Entity | getEntity (Entity::ID) const |
template<typename T , typename... Args> | |
T & | addSystem (Args &&... args) |
Creates a new system of the given type. All systems need to be fully created before adding entities, else entities will not be correctly processed by desired systems. More... | |
template<typename T > | |
T & | getSystem () |
Returns a reference to the Scene's system of this type, if it exists. | |
template<typename T > | |
void | setSystemActive (bool active) |
Sets the given system type active or inactive in the scene. Inactive systems are moved from the processing list and are ignored until set active again. If the system type give doesn't exist then this function does nothing. | |
template<typename T , typename... Args> | |
T & | addDirector (Args &&... args) |
Adds a Director to the Scene. Directors are used to control in game entities and events through observed messages and events. Returns a reference to the newly added director. More... | |
template<typename T > | |
T & | getDirector () |
Returns a reference to the the requested Director, if it exists. | |
template<typename T , typename... Args> | |
T & | addPostProcess (Args &&... args) |
Adds a post process effect to the scene. Any post processes added to the scene are performed on the entire output. To add post processes to a portion of the scene then a second scene should be created to draw overlays such as the UI. | |
void | setPostEnabled (bool) |
Enables or disables any added post processes added to the scene. | |
Entity | getDefaultCamera () const |
Returns a copy of the entity containing the default camera. | |
Entity | setActiveCamera (Entity) |
Sets the active camera used when rendering. This camera will be used to render the entire visible scene. A single scene may also be rendered multiple times with different cameras, for example when rendering split screen. More... | |
Entity | getActiveCamera () const |
Returns the entity containing the active camera component. | |
Entity | setActiveListener (Entity) |
Sets the active listener when processing audio. Usually this will be on the same entity as the active camera, although effects such as remote monitoring can be used by setting a different listener. More... | |
Entity | getActiveListener () const |
Returns the entity containing the active AudioListener component. | |
void | forwardEvent (const sf::Event &) |
Forwards any events to Directors in the Scene. | |
void | forwardMessage (const Message &) |
Forwards messages to the systems in the scene. | |
std::size_t | getEntityCount () const |
Returns the active entity count. Debugging util. | |
void | showSystemInfo (bool show=true) |
Draws a window with some information on the current active systems. Debug util - show ECS system info, not hardware system. | |
template<typename T , typename... Args> | |
T & | addSystem (Args &&... args) |
template<typename T > | |
T & | getSystem () |
template<typename T > | |
void | setSystemActive (bool active) |
template<typename T , typename... Args> | |
T & | addDirector (Args &&... args) |
template<typename T > | |
T & | getDirector () |
template<typename T , typename... Args> | |
T & | addPostProcess (Args &&... args) |
template<typename T > | |
bool | directorExists () const |
![]() | |
GuiClient (const GuiClient &)=default | |
GuiClient (GuiClient &&)=default | |
GuiClient & | operator= (const GuiClient &)=default |
GuiClient & | operator= (GuiClient &&)=default |
void | registerStatusControls (const std::function< void()> &) |
Registers one or more gui controls with the default status window. The given function should include the ui/ImGui functions as they would appear between the Begin() and End() commands without Begin() and End() themselves. These controls will then appear in the default status window all the time the object which inherits this interface exists. DEPRECATED. | |
void | registerConsoleTab (const std::string &name, const std::function< void()> &) |
Registers one or more gui controls with the console window. The given function should include the ui/ImGui functions as they would appear between the Begin() and End() commands without Begin() and End() themselves. These controls will then appear in a new tab in the console window all the time the object which inherits this interface exists. More... | |
void | registerWindow (const std::function< void()> &) |
Registers a custom window with the ImGui renderer. The given function should include the Begin() and End() calls to create a fully stand-alone window with ImGui. The window will exist all the time the object which inherits this interface exists. | |
Encapsulates a single scene. The scene class contains everything needed to create a scene graph by encapsulating the ECS and providing factory functions for entities. Multple scenes can exist at one time, for instance one to draw the game world, and another to draw the HUD. Everything is rendered through renderable systems which, in turn, require an ECS - therefore every state which wishes to draw something requires at least a scene, right down to menus. All systems should be added before attempting to create any entities else existing entities will not be processed by new systems.
|
explicit |
Constructor.
messageBus | Reference to the active message bus |
initialPoolSize | Components are pooled in memory, and this is the initial number of components for which memory is allocated. Memory pools will resize at runtime if necessary, but an initial size can be set here. The default is 256 components. As the maximum number of entity IDs is 1024 before they are recycled, values greater than this have no effect other than allocating unusable memory. |
T& xy::Scene::addDirector | ( | Args &&... | args | ) |
T& xy::Scene::addSystem | ( | Args &&... | args | ) |
Creates a new system of the given type. All systems need to be fully created before adding entities, else entities will not be correctly processed by desired systems.
Sets the active camera used when rendering. This camera will be used to render the entire visible scene. A single scene may also be rendered multiple times with different cameras, for example when rendering split screen.
Sets the active listener when processing audio. Usually this will be on the same entity as the active camera, although effects such as remote monitoring can be used by setting a different listener.
void xy::Scene::update | ( | float | dt | ) |
Executes one simulation step.
dt | The time elapsed since the last simulation step |