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

The SimSystem is a system responsible for providing scriptability via SimObjects and SimObjectAspects. More...

#include <sim_system.hpp>

Inheritance diagram for ToyMaker::SimSystem:
ToyMaker::System< SimSystem, std::tuple<>, std::tuple< SimCore > >

Public Member Functions

 SimSystem (std::weak_ptr< ECSWorld > world)
 
bool aspectRegistered (const std::string &aspectName) const
 Tests whether an aspect with a certain name is a valid SimObjectAspect type known by this application's SimSystem.
 

Static Public Member Functions

static std::string getSystemTypeName ()
 Gets the system type string associated with this system.
 

Protected Member Functions

virtual std::shared_ptr< BaseSysteminstantiate (std::weak_ptr< ECSWorld > world) override
 

Private Member Functions

template<typename TSimObjectAspect>
void registerAspect ()
 Registers a new aspect (a derived class of SimObjectAspect) as an aspect known by the SimSystem.
 
std::shared_ptr< BaseSimObjectAspectconstructAspect (const nlohmann::json &jsonAspectProperties)
 Constructs a SimObjectAspect based on its description in JSON.
 
void onSimulationStep (uint32_t simulationStepMillis) override
 The method responsible for forwarding engine simulation step events to SimObjects and their SimObjectAspects.
 
void onVariableStep (float simulationProgress, uint32_t variableStepMillis) override
 The method responsible for forwarding engine variable step events to SimObjects and their SimObjectAspects.
 

Private Attributes

std::unordered_map< std::string, std::shared_ptr< BaseSimObjectAspect >(*)(const nlohmann::json &jsonAspectProperties)> mAspectConstructors {}
 A database for all constructors of SimObjectAspects, provided by the implementation of the aspects themselves.
 

Friends

class BaseSimObjectAspect
 
class SimObject
 

Detailed Description

The SimSystem is a system responsible for providing scriptability via SimObjects and SimObjectAspects.

A developer creates a subclass of SimObjectAspect, which can then be attached to a SimObject in the game either through the scene file or programmatically during the application's running.

The SimSystem then forwards scene object related lifecycle events and engine-loop events to active and interested SimObjectAspect subclasses.

Member Function Documentation

◆ aspectRegistered()

bool SimSystem::aspectRegistered ( const std::string & aspectName) const

Tests whether an aspect with a certain name is a valid SimObjectAspect type known by this application's SimSystem.

Parameters
aspectNameThe name of the aspect.
Return values
trueThis aspect has been registered with the SimSystem;
falseThis aspect has not yet been registered with the SimSystem;

◆ constructAspect()

std::shared_ptr< BaseSimObjectAspect > SimSystem::constructAspect ( const nlohmann::json & jsonAspectProperties)
private

Constructs a SimObjectAspect based on its description in JSON.

Parameters
jsonAspectPropertiesThe aspect's JSON description, including its type and initial value.
Returns
std::shared_ptr<BaseSimObjectAspect> [A base class pointer to] The newly constructed SimObjectAspect.

◆ getSystemTypeName()

static std::string ToyMaker::SimSystem::getSystemTypeName ( )
inlinestatic

Gets the system type string associated with this system.

Returns
std::string The system type string associated with this system.

◆ onSimulationStep()

void SimSystem::onSimulationStep ( uint32_t simulationStepMillis)
overrideprivate

The method responsible for forwarding engine simulation step events to SimObjects and their SimObjectAspects.

Parameters
simulationStepMillisThe time by which the simulation should be advanced, in milliseconds.

◆ onVariableStep()

void SimSystem::onVariableStep ( float simulationProgress,
uint32_t variableStepMillis )
overrideprivate

The method responsible for forwarding engine variable step events to SimObjects and their SimObjectAspects.

Parameters
simulationProgressThe progress towards the next simulation step after the end of the next simulation step as a number between 0 and 1.
variableStepMillisThe time since the computation of the last variable step.

◆ registerAspect()

template<typename TSimObjectAspect>
void ToyMaker::SimSystem::registerAspect ( )
private

Registers a new aspect (a derived class of SimObjectAspect) as an aspect known by the SimSystem.

Template Parameters
TSimObjectAspectThe type of the new aspect.

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