Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::ECSWorld Class Reference

A class that represents a set of systems, entities, and components, that are all interrelated, but isolated from other similar sets. More...

#include <ecs_world.hpp>

Inheritance diagram for ToyMaker::ECSWorld:

Classes

struct  SystemRegistrationArgs
 Prevents the use of the unspecialized version of SystemRegistrationArgs. More...
 
struct  SystemRegistrationArgs< TSystemDerived, std::tuple< TListenedForComponents... >, std::tuple< TRequiredComponents... > >
 The partially specialized version of SystemRegistrationArgs, with its latter 2 template parameters being tuples of components. More...
 

Public Member Functions

std::shared_ptr< ECSWorldinstantiate () const
 Creates a new ECSWorld using the systems and component arrays present in this one as a template.
 
template<typename TSystem>
std::shared_ptr< TSystem > getSystem ()
 Get the system object of a specific type belonging to this ECSWorld.
 
template<typename TSystem>
SystemType getSystemType ()
 Get the SystemType id for a particular system.
 
template<typename TSystem>
bool isEnabled (EntityID entityID)
 Tests whether a particular entity is enabled for a particular system.
 
template<typename TSystem>
bool isRegistered (EntityID entityID)
 Tests whether an entity is eligible for membership with a system, per its component signature.
 
template<typename ... TComponents>
Entity createEntity (TComponents...components)
 Creates a new entity that will exist in this ECSWorld.
 
void initialize ()
 Runs the initialization step for this world and the systems that belong to it.
 
void activateSimulation ()
 Marks this world as an active one, calling the activation callbacks of systems that belong to it.
 
void deactivateSimulation ()
 Marks ths world as an inactive one, and suspends operation for its member systems.
 
void simulationPreStep (uint32_t simStepMillis)
 Runs callbacks associated with the start of a simulation update.
 
void simulationStep (uint32_t simStepMillis)
 Runs callbacks associated with the simulation step.
 
void simulationPostStep (uint32_t simStepMillis)
 Runs calbacks associated with the end of the simulation step.
 
void postTransformUpdate (uint32_t timeStepMillis)
 Runs callbacks associated with the end of transform updates.
 
void variableStep (float simulationProgress, uint32_t variableStepMillis)
 Runs callbacks associated with the variable step of the game loop.
 
void preRenderStep (float simulationProgress)
 Runs callbacks associated with the start of the rendering step.
 
void postRenderStep (float simulationProgress)
 Runs callbacks associated with the end of the rendering step.
 
void cleanup ()
 Loses references to member systems, component arrays, and entities, resulting in their destruction.
 
WorldID getID () const
 Gets the ID associated with this world.
 
template<typename TSystem, typename ... TListenedForComponents, typename ... TRequiredComponents>
void registerSystem (ECSWorld::SystemRegistrationArgs< TSystem, std::tuple< TListenedForComponents... >, std::tuple< TRequiredComponents... > >)
 

Static Public Member Functions

static std::weak_ptr< const ECSWorldgetPrototype ()
 Get the prototype ECSWorld.
 
template<typename ... TComponent>
static void registerComponentTypes ()
 Registers ComponentArrays for each type of component present in the component type list, if required.
 
template<typename TSystemDerived, typename ... TListenedForComponents, typename ... TRequiredComponents>
static void registerSystem (SystemRegistrationArgs< TSystemDerived, std::tuple< TListenedForComponents... >, std::tuple< TRequiredComponents... > >)
 Registers a System with the ECS System for this project.
 
template<typename TSystem>
static std::shared_ptr< TSystem > getSystemPrototype ()
 Get the system object of a specific type belonging to the prototype ECSWorld.
 
template<typename TSingletonSystem>
static std::shared_ptr< TSingletonSystem > getSingletonSystem ()
 Get a system that has been marked as a singleton System.
 
template<typename ... TComponents>
static Entity createEntityPrototype (TComponents...components)
 Create a prototype entity object.
 

Private Member Functions

 ECSWorld ()=default
 Construct a new ECSWorld object.
 
void copyComponents (EntityID to, EntityID from)
 Copies components from one entity to another within a single ECSWorld.
 
void copyComponents (EntityID to, EntityID from, ECSWorld &other)
 Copies components from one entity to another, where the source entity may be from another ECSWorld.
 
void relocateEntity (Entity &entity)
 Moves an entity from one ECSWorld to this one.
 
template<typename ... TComponents>
Entity privateCreateEntity (TComponents...components)
 Creates a new entity and assigns it the components specified as arguments.
 
void destroyEntity (EntityID entityID)
 Destroys an Entity with a specific ID.
 
template<typename TSystem>
void enableEntity (EntityID entityID)
 Enables an entity for a specific system.
 
void enableEntity (EntityID entityID, Signature systemMask=Signature{}.set())
 Enables an entity for multiple systems, restricted by its component signature and its system mask.
 
template<typename TSystem>
void disableEntity (EntityID entityID)
 Disables an entity on a particular system.
 
void disableEntity (EntityID entityID)
 Disables an entity for all systems.
 
template<typename TComponent>
void addComponent (EntityID entityID, const TComponent &component)
 Adds a new component to the entity.
 
void addComponent (EntityID entityID, const nlohmann::json &jsonComponent)
 Adds a new component to an entity based on its description in JSON.
 
template<typename TComponent>
TComponent getComponent (EntityID entityID, float simulationProgress=1.f) const
 Get a component associated with an entity.
 
template<typename TComponent, typename TSystem>
TComponent getComponent (EntityID entityID, float simulationProgress=1.f) const
 Get a component associated with an entity, specialized for Systems.
 
template<typename TComponent>
bool hasComponent (EntityID entityID) const
 Tests whether an entity has a component of a specific type.
 
bool hasComponent (EntityID entityID, const std::string &typeName) const
 Tests whether an entity has a component of a specific type.
 
template<typename TComponent>
void updateComponent (EntityID entityID, const TComponent &newValue)
 Updates a component belonging to an entity with a new value.
 
void updateComponent (EntityID entityID, const nlohmann::json &newValue)
 Updates a component belonging to an entity with a new value, based on its JSON description.
 
template<typename TComponent, typename TSystem>
void updateComponent (EntityID entityID, const TComponent &newValue)
 Updates a component belonging to an entity with a new value, noting the System causing the update.
 
template<typename TSystem>
void updateComponent (EntityID entityID, const nlohmann::json &newValue)
 Updates a component belonging to an entity with a new value, noting the system causing the update.
 
template<typename TComponent>
void removeComponent (EntityID entityID)
 Removes a component from an entity.
 
void removeComponent (EntityID entityID, const std::string &typeName)
 Removes a component from an entity based on its component type string.
 
void removeComponentsAll (EntityID entityID)
 Removes all components associated with an entity.
 

Static Private Member Functions

static std::shared_ptr< ECSWorldcreateWorld ()
 Creates an ECSWorld.
 
static std::weak_ptr< ECSWorldgetInstance ()
 Creates an instance of the prototype ECSWorld, and returns a reference to it.
 

Private Attributes

std::unique_ptr< ComponentManagermComponentManager {nullptr}
 A reference to this world's ComponentManager.
 
std::unique_ptr< SystemManagermSystemManager {nullptr}
 A reference to this world SystemManager.
 
std::vector< EntityIDmDeletedIDs {}
 A list of previously existing entity IDs that were since retired and are available to be used again.
 
EntityID mNextEntity {}
 A new EntityID that has never been created before in this world.
 
WorldID mID {0}
 The unique ID associated with this ECSWorld.
 

Static Private Attributes

static WorldID s_nextWorld { 0 }
 The ID the next ECSWorld to be instantiated will receive.
 

Friends

class Entity
 
class BaseSystem
 

Detailed Description

A class that represents a set of systems, entities, and components, that are all interrelated, but isolated from other similar sets.

A single such set is called an ECSWorld. Each ECSWorld is comprised of a list of entities, a system manager, and a component manager of its own. Entities, systems, and components belonging to one world are not visible to systems in other worlds, or to any other ECSWorld.

Note
Why would one want such a thing?
A game has game elements (e.g., player avatar, enemies, obstacles, etc.,), and UI elements (health bar, options button, inventory, etc.,)
Both game and UI elements have visual components (meshes, textures, lights), interactive elements (collision volumes), placement components (position, rotation, scale), and more.
One expects that when the player moves, the game scene moves, but the UI scene stays in place. One also expects the collision system of the UI to be independent of the game, and vice versa. Certain systems, such as the physics system, should apply to game elements and not to UI elements. The movement of a UI element should not influence game elements, and vice versa.
Self-contained, isolated ECS worlds are one convenient way to accomplish this separation. The results of one simulation may still be displayed in the other (eg., screenshots on save files, or in-game UIs, or graphics settings) while keeping most of their operation independent.
It is then up to the developer of the project to specify when and where one world should "influence," or be exposed to, the other.

Member Function Documentation

◆ addComponent() [1/2]

void ECSWorld::addComponent ( EntityID entityID,
const nlohmann::json & jsonComponent )
private

Adds a new component to an entity based on its description in JSON.

Parameters
entityIDThe entity to which the component is being added.
jsonComponentThe initial value of the component, described in JSON.
See also
ComponentManager::addComponent()

◆ addComponent() [2/2]

template<typename TComponent>
void ToyMaker::ECSWorld::addComponent ( EntityID entityID,
const TComponent & component )
private

Adds a new component to the entity.

Template Parameters
TComponentThe type of component being added.
Parameters
entityIDThe entity to which the component is being added.
componentThe initial value of the component.
See also
ComponentManager::addComponent()

◆ copyComponents() [1/2]

void ECSWorld::copyComponents ( EntityID to,
EntityID from )
private

Copies components from one entity to another within a single ECSWorld.

Parameters
toThe entity which will receive the copied components.
fromThe entity from whose components will be copied.

◆ copyComponents() [2/2]

void ECSWorld::copyComponents ( EntityID to,
EntityID from,
ECSWorld & other )
private

Copies components from one entity to another, where the source entity may be from another ECSWorld.

Parameters
toThe destination entity, belonging to this world.
fromThe source entity whose components will be copied.
otherThe world that owns the source entity.

◆ createEntity()

template<typename ... TComponents>
Entity ToyMaker::ECSWorld::createEntity ( TComponents... components)

Creates a new entity that will exist in this ECSWorld.

This mainly means that a new EntityID is created and stored from a list of previously retired IDs or a completely new EntityID. In the same step, and if desired, new components belonging to the entity can be initialized and stored as entries in their respective component arrays.

Template Parameters
TComponentsComponents to initialize and store right after the entity is created.
Parameters
componentsThe initial values of the components being stored.
Returns
Entity A handle to the entity, through which its system membership and its components can be accessed.

◆ createEntityPrototype()

template<typename ... TComponents>
Entity ToyMaker::ECSWorld::createEntityPrototype ( TComponents... components)
static

Create a prototype entity object.

This is an entity whose components and system membership are stored in the prototype ECSWorld, until it is moved to its actual ECSWorld.

Template Parameters
TComponentsComponents to initialize and store right after the entity is created.
Parameters
componentsThe initial values of the components being stored.
Returns
Entity A handle to the entity, through which its system membership and its components can be accessed.
See also
createEntity()

◆ createWorld()

std::shared_ptr< ECSWorld > ECSWorld::createWorld ( )
staticprivate

Creates an ECSWorld.

Returns
std::shared_ptr<ECSWorld> The new ECS World.

◆ destroyEntity()

void ECSWorld::destroyEntity ( EntityID entityID)
private

Destroys an Entity with a specific ID.

The ID is moved into a list of available IDs which can be reused by a new entity. All entries relating to the entity in owning Systems and ComponentArrays are removed.

Parameters
entityIDThe Entity being destroyed.

◆ disableEntity() [1/2]

template<typename TSystem>
void ToyMaker::ECSWorld::disableEntity ( EntityID entityID)
private

Disables an entity on a particular system.

Template Parameters
TSystemThe system for which the entity is being deactivated.
Parameters
entityIDThe entity being deactivated.
See also
SystemManager::disableEntity()

◆ disableEntity() [2/2]

void ECSWorld::disableEntity ( EntityID entityID)
private

Disables an entity for all systems.

Parameters
entityIDThe entity being deactivated.
See also
SystemManager::disableEntity()

◆ enableEntity() [1/2]

template<typename TSystem>
void ToyMaker::ECSWorld::enableEntity ( EntityID entityID)
private

Enables an entity for a specific system.

Template Parameters
TSystemThe system the entity will be influenced by post-activation.
Parameters
entityIDThe entity being enabled.
See also
SystemManager::enableEntity()

◆ enableEntity() [2/2]

void ECSWorld::enableEntity ( EntityID entityID,
Signature systemMask = Signature{}.set() )
private

Enables an entity for multiple systems, restricted by its component signature and its system mask.

Parameters
entityIDThe entity being activated.
systemMaskBitset representing which systems the entity is allowed to be activated for.
See also
SystemManager::enableEntity()

◆ getComponent() [1/2]

template<typename TComponent>
TComponent ToyMaker::ECSWorld::getComponent ( EntityID entityID,
float simulationProgress = 1.f ) const
private

Get a component associated with an entity.

Template Parameters
TComponentThe type of component being retrieved.
Parameters
entityIDThe entity whose component is being retrieved.
simulationProgressThe progress since the last simulation step towards the next simulation step, represented as a number between 0 and 1.
Returns
TComponent The value of the component, interpolated according to simulationProgress
See also
ComponentManager::getComponent()

◆ getComponent() [2/2]

template<typename TComponent, typename TSystem>
TComponent ToyMaker::ECSWorld::getComponent ( EntityID entityID,
float simulationProgress = 1.f ) const
private

Get a component associated with an entity, specialized for Systems.

Template Parameters
TComponentThe type of component being retrieved.
TSystemThe system requesting the component.
Parameters
entityIDThe entity whose component is being retrieved.
simulationProgressThe progress since the last simulation step towards the next simulation step, represented as a number between 0 and 1.
Returns
TComponent The value of the component, interpolated according to simulationProgress.
See also
ComponentManager::getComponent()

◆ getID()

WorldID ToyMaker::ECSWorld::getID ( ) const
inline

Gets the ID associated with this world.

Note
a prototype world has an ID of 0.
Returns
WorldID The ID of this world.

◆ getInstance()

std::weak_ptr< ECSWorld > ECSWorld::getInstance ( )
staticprivate

Creates an instance of the prototype ECSWorld, and returns a reference to it.

Returns
std::weak_ptr<ECSWorld> A reference to the prototype ECSWorld.

◆ getPrototype()

std::weak_ptr< const ECSWorld > ECSWorld::getPrototype ( )
static

Get the prototype ECSWorld.

The prototype ECSWorld is the first ECSWorld created in a project. All systems and components that register themselves to this module will be registered with this Prototype ECSWorld during the static initialization of the program.

The prototype is then used as a blueprint for instantiating more ECSWorlds, and populating them with the necessary component arrays and systems.

The prototype ECSWorld is also where a newly loaded scene node's components are stored, before it is made a member of the ECSWorld where it actually belongs.

Returns
std::weak_ptr<const ECSWorld> A constant reference to the prototype ECSWorld.

◆ getSingletonSystem()

template<typename TSingletonSystem>
std::shared_ptr< TSingletonSystem > ToyMaker::ECSWorld::getSingletonSystem ( )
static

Get a system that has been marked as a singleton System.

A singleton System is a system that has no real entities or components of its own, and does not technically belong to any ECSWorld. How it tracks active entities is up to the System's implementation.

Such a system can be assumed to preside over eligible entities across several world. The SceneSystem is one such system.

Template Parameters
TSingletonSystemThe type of the singleton System being retrieved.
Returns
std::shared_ptr<TSingletonSystem> A reference to the retrieved System.

◆ getSystem()

template<typename TSystem>
std::shared_ptr< TSystem > ToyMaker::ECSWorld::getSystem ( )

Get the system object of a specific type belonging to this ECSWorld.

Template Parameters
TSystemThe type of system being retrieved.
Returns
std::shared_ptr<TSystem> A reference to this ECSWorld's TSystem.

◆ getSystemPrototype()

template<typename TSystem>
std::shared_ptr< TSystem > ToyMaker::ECSWorld::getSystemPrototype ( )
static

Get the system object of a specific type belonging to the prototype ECSWorld.

Template Parameters
TSystemThe type of system being retrieved.
Returns
std::shared_ptr<TSystem> A reference to the prototype ECSWorld's TSystem.
See also
getPrototype()

◆ getSystemType()

template<typename TSystem>
SystemType ToyMaker::ECSWorld::getSystemType ( )

Get the SystemType id for a particular system.

The SystemType of a system corresponds to a position in the bitset of an entity's system mask, or other system related signatures. Its meaning varies depending on the usage of the bitset.

For the system mask, as seen in a call to SystemManager::enableEntity(), it indicates which systems the manager is expected to activate the entity for.

Template Parameters
TSystemThe system whose SystemType id is being retrieved.
Returns
SystemType The system type id retrieved.

◆ hasComponent() [1/2]

template<typename TComponent>
bool ToyMaker::ECSWorld::hasComponent ( EntityID entityID) const
private

Tests whether an entity has a component of a specific type.

Template Parameters
TComponentThe type of component being tested.
Parameters
entityIDThe entity being queried.
Return values
trueIndicates the entity has such a component;
falseIndicates the entity doesn't have such a component;
See also
ComponentManager::hasComponent()

◆ hasComponent() [2/2]

bool ECSWorld::hasComponent ( EntityID entityID,
const std::string & typeName ) const
private

Tests whether an entity has a component of a specific type.

Parameters
entityIDThe entity being queried.
typeNamethe component type string of the component being tested.
Return values
trueIndicates the entity has such a component;
falseIndicates the entity doesn't have such a component;
See also
ComponentManager::updateComponent()

◆ instantiate()

std::shared_ptr< ECSWorld > ECSWorld::instantiate ( ) const

Creates a new ECSWorld using the systems and component arrays present in this one as a template.

Returns
std::shared_ptr<ECSWorld> The new ECSWorld

◆ isEnabled()

template<typename TSystem>
bool ToyMaker::ECSWorld::isEnabled ( EntityID entityID)

Tests whether a particular entity is enabled for a particular system.

Template Parameters
TSystemThe system being queried.
Parameters
entityIDThe entity whose activation is being tested.
Return values
trueIndicates that the entity is enabled for a system;
falseIndicates that the entity is disabled for a system;

◆ isRegistered()

template<typename TSystem>
bool ToyMaker::ECSWorld::isRegistered ( EntityID entityID)

Tests whether an entity is eligible for membership with a system, per its component signature.

Template Parameters
TSystemThe system being queried.
Parameters
entityIDThe entity whose eligibility is being tested.
Return values
trueIndicates the entity is eligible;
falseIndicates the entity is ineligible.

◆ postRenderStep()

void ECSWorld::postRenderStep ( float simulationProgress)

Runs callbacks associated with the end of the rendering step.

Parameters
simulationProgressThe progress towards the next simulation step since the previous one, represented as a number between 0 and 1.
See also
SystemManager::handlePostRenderStep()

◆ postTransformUpdate()

void ECSWorld::postTransformUpdate ( uint32_t timeStepMillis)

Runs callbacks associated with the end of transform updates.

Parameters
timeStepMillisThe time, in milliseconds, since the end of the last transform update.
See also
SystemManager::handlePostTransformUpdate()

◆ preRenderStep()

void ECSWorld::preRenderStep ( float simulationProgress)

Runs callbacks associated with the start of the rendering step.

Parameters
simulationProgressThe progress towards the next simulation step since the previous one, represented as a number between 0 and 1.
See also
SystemManager::handlePreRenderStep()

◆ privateCreateEntity()

template<typename ... TComponents>
Entity ToyMaker::ECSWorld::privateCreateEntity ( TComponents... components)
private

Creates a new entity and assigns it the components specified as arguments.

Template Parameters
TComponentsThe types of components to initialize with the entity.
Parameters
componentsThe initial values of the components of the entity.
Returns
Entity A handle to the new entity.

◆ registerComponentTypes()

template<typename ... TComponents>
void ToyMaker::ECSWorld::registerComponentTypes ( )
static

Registers ComponentArrays for each type of component present in the component type list, if required.

Template Parameters
TComponentThe component type(s) being registered.

Usage:

// ...
// NOTE: Static method returning the name of this component.
static std::string getComponentTypeName() { return "CameraProperties"; }
// ...
};
// ...
// NOTE: methods for converting this component to and from JSON, so that the component can be used/defined in a scene file.
inline void from_json(const nlohmann::json& json, CameraProperties& cameraProperties) {
assert(json.at("type").get<std::string>() == CameraProperties::getComponentTypeName() && "Type mismatch, json must be of camera properties type");
json.at("projection_mode").get_to(cameraProperties.mProjectionType);
json.at("fov").get_to(cameraProperties.mFov);
json.at("aspect").get_to(cameraProperties.mAspect);
json.at("orthographic_dimensions")
.at("horizontal")
.get_to(cameraProperties.mOrthographicDimensions.x);
json.at("orthographic_dimensions")
.at("vertical")
.get_to(cameraProperties.mOrthographicDimensions.y);
json.at("near_far_planes").at("near").get_to(cameraProperties.mNearFarPlanes.x);
json.at("near_far_planes").at("far").get_to(cameraProperties.mNearFarPlanes.y);
}
inline void to_json(nlohmann::json& json, const CameraProperties& cameraProperties) {
json = {
{"projection_mode", cameraProperties.mProjectionType},
{"fov", cameraProperties.mFov},
{"aspect", cameraProperties.mAspect},
{"orthographic_dimensions", {
{"horizontal", cameraProperties.mOrthographicDimensions.x},
{"vertical", cameraProperties.mOrthographicDimensions.y},
}},
{"near_far_planes", {
{"near", cameraProperties.mNearFarPlanes.x},
{"far", cameraProperties.mNearFarPlanes.y},
}}
};
}
Struct that encapsulates properties which define the (geometric) aspects of a scene camera.
Definition camera_system.hpp:51
static std::string getComponentTypeName()
The component type string of the camera properties component.
Definition camera_system.hpp:112
See also
ComponentArray<TComponent>

◆ registerSystem()

template<typename TSystemDerived, typename ... TListenedForComponents, typename ... TRequiredComponents>
static void ToyMaker::ECSWorld::registerSystem ( SystemRegistrationArgs< TSystemDerived, std::tuple< TListenedForComponents... >, std::tuple< TRequiredComponents... > > )
static

Registers a System with the ECS System for this project.

This registration occurs at static initialization against the prototype ECSWorld. All other ECSWorlds for a project are derived from the prototype.

Such a system has access to the project's ECS callbacks, and will be notified when any update to one of the entities it manages occurs.

Usage:

// NOTE: TSystem inherits from System<TSystem, std::tuple<TListenedForComponent_1, TListenedForComponent_2, ...>, std::tuple<TOtherRequiredComponent_1, TOtherRequiredComponent_2, ...>>
class CameraSystem: public System<CameraSystem, std::tuple<Transform, CameraProperties>, std::tuple<>> {
public:
// NOTE: implements static std::string getSystemTypeName()
static std::string getSystemTypeName() { return "CameraSystem"; }
// ...
private:
// ...
// NOTE: (optional) may override base class virtual functions
void onEntityEnabled(EntityID entityID) override;
void onEntityDisabled(EntityID entityID) override;
void onEntityUpdated(EntityID entityID) override;
void onSimulationActivated() override;
void onPreRenderStep(float simulationProgress) override;
// ...
};
System responsible for managing all active cameras belonging to this world, tracking and updating ass...
Definition camera_system.hpp:129
A system template that disables systems with this form of declaration.
Definition ecs_world.hpp:1062
std::uint64_t EntityID
A single unsigned integer used as a name for an entity managed by an ECS system.
Definition ecs_world.hpp:68
Template Parameters
TSystemDerivedThe new System being registered.
TListenedForComponentsA tuple of component types, indicating which component updates the system wants callbacks for.
TRequiredComponentsA tuple of component types, indicating what components an entity needs to be eligible for management by this system.
See also
template <typename TSystemDerived, typename ...TListenedForComponents, typename ...TRequiredComponents> class System<TSystemDerived, std::tuple<TListenedForComponents...>, std::tuple<TRequiredComponents...>>

◆ relocateEntity()

void ECSWorld::relocateEntity ( Entity & entity)
private

Moves an entity from one ECSWorld to this one.

Parameters
entityThe handle for an entity, presumably from a different ECSWorld.

◆ removeComponent() [1/2]

template<typename TComponent>
void ToyMaker::ECSWorld::removeComponent ( EntityID entityID)
private

Removes a component from an entity.

Template Parameters
TComponentThe type of component being removed.
Parameters
entityIDThe entity being updated.
See also
ComponentManager::removeComponent()

◆ removeComponent() [2/2]

void ECSWorld::removeComponent ( EntityID entityID,
const std::string & typeName )
private

Removes a component from an entity based on its component type string.

Parameters
entityIDThe entity being updated.
typeNameThe component type string of the component being removed.

◆ removeComponentsAll()

void ECSWorld::removeComponentsAll ( EntityID entityID)
private

Removes all components associated with an entity.

Parameters
entityIDThe entity whose components are being removed.

◆ simulationPostStep()

void ECSWorld::simulationPostStep ( uint32_t simStepMillis)

Runs calbacks associated with the end of the simulation step.

Parameters
simStepMillisThe time in milliseconds that the simulation will be advanced by.
See also
SystemManager::handleSimulationPostStep()

◆ simulationPreStep()

void ECSWorld::simulationPreStep ( uint32_t simStepMillis)

Runs callbacks associated with the start of a simulation update.

Parameters
simStepMillisThe time in milliseconds that the simulation will be advanced by.
See also
SystemManager::handleSimulationPreStep()
ComponentManager::handlePreSimulationStep()

◆ simulationStep()

void ECSWorld::simulationStep ( uint32_t simStepMillis)

Runs callbacks associated with the simulation step.

Parameters
simStepMillisThe time in milliseconds that the simulation will be advanced by.
See also
SystemManager::handleSimulationStep()

◆ updateComponent() [1/4]

void ECSWorld::updateComponent ( EntityID entityID,
const nlohmann::json & newValue )
private

Updates a component belonging to an entity with a new value, based on its JSON description.

Parameters
entityIDThe entity being updated.
newValueThe type and new value of the component, described in JSON.
See also
ComponentManager::updateComponent()

◆ updateComponent() [2/4]

template<typename TSystem>
void ToyMaker::ECSWorld::updateComponent ( EntityID entityID,
const nlohmann::json & newValue )
private

Updates a component belonging to an entity with a new value, noting the system causing the update.

Template Parameters
TSystemThe system causing the update.
Parameters
entityIDThe entity being updated.
newValueThe new value for the component.
See also
ComponentManager::updateComponent()

◆ updateComponent() [3/4]

template<typename TComponent>
void ToyMaker::ECSWorld::updateComponent ( EntityID entityID,
const TComponent & newValue )
private

Updates a component belonging to an entity with a new value.

Template Parameters
TComponentThe type of component receiving an update.
Parameters
entityIDThe entity whose component is being updated.
newValueThe new value the component will have post update.
See also
ComponentManager::updateComponent()

◆ updateComponent() [4/4]

template<typename TComponent, typename TSystem>
void ToyMaker::ECSWorld::updateComponent ( EntityID entityID,
const TComponent & newValue )
private

Updates a component belonging to an entity with a new value, noting the System causing the update.

Template Parameters
TComponentThe component being updated.
TSystemThe system causing the update.
Parameters
entityIDThe entity being updated.
newValueThe new value for the component.
See also
ComponentManager::updateComponent()

◆ variableStep()

void ECSWorld::variableStep ( float simulationProgress,
uint32_t variableStepMillis )

Runs callbacks associated with the variable step of the game loop.

The variable step is run once each frame. It may be run multiple times between simulation steps, or once every handful of simulation steps, according to the capabilities of its platform, and be affected by any other ongoing operations taking place on that platform.

Parameters
simulationProgressProgress, from 0.0 to 1.0, since the end of the last simulation step and the beginning of the next one.
variableStepMillisThe time, in milliseconds, since the last frame.
See also
SystemManager::handleVariableStep()

Member Data Documentation

◆ mNextEntity

EntityID ToyMaker::ECSWorld::mNextEntity {}
private

A new EntityID that has never been created before in this world.

See also
mDeletedIDs

The documentation for this class was generated from the following files: