Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
|
Holds references to all the systems belonging to this manager's ECSWorld. More...
#include <ecs_world.hpp>
Public Member Functions | |
SystemManager (std::weak_ptr< ECSWorld > world) | |
Construct a new System Manager object. | |
Private Member Functions | |
SystemManager | instantiate (std::weak_ptr< ECSWorld > world) const |
Creates a new system manager containing fresh copies of the same systems this manager uses, and associates it with the new world. | |
template<typename TSystem> | |
void | registerSystem (const Signature &signature, const Signature &listenedForComponents) |
During static initialization, adds the new System type and its component signatures to its tables. | |
void | unregisterAll () |
Removes all references to managed systems, in preparation for destruction. | |
template<typename TSystem> | |
std::shared_ptr< TSystem > | getSystem () |
Gets an instance of a system belonging to this ECS World. | |
template<typename TSystem> | |
void | enableEntity (EntityID entityID) |
Enables the visibility of an entity to a particular system. | |
void | enableEntity (EntityID entityID, Signature entitySignature, Signature systemMask=Signature{}.set()) |
Enables an entity for all eligible systems, per its component signature and the system mask. | |
template<typename TSystem> | |
void | disableEntity (EntityID entityID) |
Disables an entity for a particular system. | |
void | disableEntity (EntityID entityID, Signature entitySignature) |
Disables all systems which match this entity's signature. | |
template<typename TSystem> | |
SystemType | getSystemType () const |
Get the SystemType for a system. | |
template<typename TSystem> | |
bool | isEnabled (EntityID entityID) |
Tests whether an entity is enabled for a particular system. | |
template<typename TSystem> | |
bool | isRegistered (EntityID entityID) |
Tests whether an entity is eligible for participation in a particular system. | |
void | handleEntitySignatureChanged (EntityID entityID, Signature signature) |
A callback for when components are added or removed from a particular entity, causing a corresponding change in its component signature, and addition or removal from various systems. | |
void | handleEntityDestroyed (EntityID entityID) |
A callback for the destruction of an entity, passed on to systems interested in it. | |
void | handleEntityUpdated (EntityID entityID, Signature signature, ComponentType updatedComponent) |
Handles an update to an entity by running a callback on all interested systems. | |
template<typename TSystem> | |
void | handleEntityUpdatedBySystem (EntityID entityID, Signature signature, ComponentType updatedComponent) |
Handles an update to an entity by running a callback on all interested systems (except the one that triggered the update) | |
void | handleInitialize () |
Runs the initialization callback of all systems that implement it. | |
void | handleSimulationActivated () |
Runs the activation callback of all systems that implement it. | |
void | handleSimulationPreStep (uint32_t simStepMillis) |
Runs the sim prestep callback of all systems that implement it. | |
void | handleSimulationStep (uint32_t simStepMillis) |
Runs the sim step callback for all systems that implement it. | |
void | handleSimulationPostStep (uint32_t simStepMillis) |
Runs the post simulation step callback for all systems that implement it. | |
void | handlePostTransformUpdate (uint32_t timeStepMillis) |
Runs the update callback that occurs after new transforms have been computed. | |
void | handleVariableStep (float simulationProgress, uint32_t variableStepMillis) |
Runs the System callback that occurs once every frame, after any simulation steps computed that frame. | |
void | handlePreRenderStep (float simulationProgress) |
Runs the System callback that occurs once before the scene in this ECSWorld is rendered. | |
void | handlePostRenderStep (float simulationProgress) |
Runs the System callback after the scene in this ECSWorld has been rendered. | |
void | handleSimulationDeactivated () |
Runs the System callback for deactivation, for any systems that have implemented it. | |
Private Attributes | |
std::unordered_map< std::string, Signature > | mNameToSignature {} |
Mapping from the system type name for a system to its component signature. | |
std::unordered_map< std::string, Signature > | mNameToListenedForComponents {} |
Mapping from the system type name for a system to its component listening signature. | |
std::unordered_map< std::string, SystemType > | mNameToSystemType {} |
Maps system type names to their corresponding SystemType values. | |
std::unordered_map< std::string, std::shared_ptr< BaseSystem > > | mNameToSystem {} |
Maps system type names to references to the actual in-memory Systems they represent. | |
std::weak_ptr< ECSWorld > | mWorld |
The world this System manager belongs to. | |
Friends | |
class | ECSWorld |
class | BaseSystem |
Holds references to all the systems belonging to this manager's ECSWorld.
The system manager is responsible for keeping track of and passing messages to the various systems in this world. It also maintains tables to track entity membership and activation for all the systems it manages.
|
inlineexplicit |
Construct a new System Manager object.
world | The world the system manager belongs to. |
|
private |
Disables an entity for a particular system.
TSystem | The system for which this entity will be disabled. |
entityID | The entity being disabled. |
Disables all systems which match this entity's signature.
entityID | The entity being disabled. |
entitySignature | The component signature of this entity. |
|
private |
Enables the visibility of an entity to a particular system.
TSystem | The system for which the entity is being enabled. |
entityID | The entity being enabled. |
|
private |
Enables an entity for all eligible systems, per its component signature and the system mask.
The position of each bit on the entitySignature corresponds to the type of a system. 1 indicates that this system ought to be enabled for this entity if possible, while 0 indicates no change.
entityID | The entity being enabled for multiple system. |
entitySignature | The component signature for this entity, which must match that of the system. |
systemMask | The systems for which this enabling should be performed. |
|
private |
Gets an instance of a system belonging to this ECS World.
TSystem | The type of system whose instance is being retrieved. |
|
private |
Get the SystemType for a system.
The SystemType of a System corresponds to a position on the bitset of various System Masks, and its meaning varies according to context.
TSystem | The System for which the SystemType id is being retrieved. |
|
private |
A callback for the destruction of an entity, passed on to systems interested in it.
entityID | The entity being destroyed. |
A callback for when components are added or removed from a particular entity, causing a corresponding change in its component signature, and addition or removal from various systems.
entityID | The entity whose component signature has changed. |
signature | The entity's new component signature. |
|
private |
Handles an update to an entity by running a callback on all interested systems.
entityID | The entity whose component was updated. |
signature | The component signature of the entity. |
updatedComponent | The ComponentType of the updated component. |
|
private |
Handles an update to an entity by running a callback on all interested systems (except the one that triggered the update)
TSystem | The system which caused the component update. |
entityID | The entity whose component was updated. |
signature | The component signature of the entity. |
updatedComponent | The ComponentType of the updated component. |
|
private |
Runs the initialization callback of all systems that implement it.
|
private |
|
private |
Runs the update callback that occurs after new transforms have been computed.
timeStepMillis | Simulation time since the end of the last transform update. |
|
private |
Runs the System callback that occurs once before the scene in this ECSWorld is rendered.
simulationProgress | Progress since the last simulation step towards the next simulation step, a number between 0.0 and 1.0. |
|
private |
Runs the activation callback of all systems that implement it.
|
private |
Runs the post simulation step callback for all systems that implement it.
simStepMillis | Time by which the simulation will advance this frame, in milliseconds. |
|
private |
Runs the sim prestep callback of all systems that implement it.
simStepMillis | Time by which the simulation will advance this update, in milliseconds. |
|
private |
Runs the sim step callback for all systems that implement it.
simStepMillis | Time by which the simulation will advance this frame, in milliseconds. |
|
private |
Runs the System callback that occurs once every frame, after any simulation steps computed that frame.
simulationProgress | Progress since the last simulation step towards the next simulation step, a number between 0.0 and 1.0. |
variableStepMillis | Time (in milliseconds) since the last variable step |
|
private |
Creates a new system manager containing fresh copies of the same systems this manager uses, and associates it with the new world.
world | The world to which the instantiated manager will be related. |
|
private |
Tests whether an entity is enabled for a particular system.
TSystem | The system being queried. |
entityID | The entity whose activation is being tested. |
true | Indicates the entity is active; |
false | Indicates the entity is inactive; |
|
private |
Tests whether an entity is eligible for participation in a particular system.
TSystem | The system being queried. |
entityID | The entity whose compatibility is being tested. |
true | Indicates the entity is eligible; |
false | Indicates the entity is ineligible; |
|
private |
During static initialization, adds the new System type and its component signatures to its tables.
This allows the System to receive callbacks from this manager. It also allows the manager to determine if and when a particular system should receive component-related updates.
TSystem | The system being registered against the system manager. |
signature | The component signature of the system, indicating which components an entity is required to have to be eligible for a particular system. |
listenedForComponents | The components this System would like to listen for updates for, when they occur on an entity enabled for it. |
|
private |
Mapping from the system type name for a system to its component listening signature.
When an entity enabled for a system has one of its components updated, and that component is marked in the systems listening signature, the corresponding system will be notified.
|
private |
Mapping from the system type name for a system to its component signature.
Only entities with Signatures that match a System's signature may be influenced by it.
|
private |
Maps system type names to their corresponding SystemType values.
Each position on an entity's SystemMask (as provided in enableEntity()) corresponds to a value of SystemType, and indicates whether the entity is to be enabled or left alone for that System.