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
sim_system.hpp
Go to the documentation of this file.
1
11
17
18#ifndef FOOLSENGINE_SIMSYSTEM_H
19#define FOOLSENGINE_SIMSYSTEM_H
20
21#include <memory>
22#include <set>
23#include <cassert>
24#include <functional>
25#include <typeinfo>
26#include <type_traits>
27
28#include <nlohmann/json.hpp>
29
31#include "core/ecs_world.hpp"
32
34#include "registrator.hpp"
36#include "scene_system.hpp"
37#include "signals.hpp"
38
39namespace ToyMaker{
40
42 class SimObject;
43 class SimSystem;
44
54 struct SimCore {
60 inline static std::string getComponentTypeName() { return "SimCore"; }
61
67 };
68
69 // never used, so make empty definitions for these
71 inline void from_json(const nlohmann::json& json, SimCore& simCore) {
72 (void)json; // prevent unused parameter warnings
73 (void)simCore; // prevent unused parameter warnings
74 }
75
76 // never used, so make empty definitions for these
78 inline void to_json(nlohmann::json& json, const SimCore& simCore) {
79 (void)json; // prevent unused parameter warnings
80 (void)simCore; // prevent unused parameter warnings
81 }
82
92 class SimSystem: public System<SimSystem, std::tuple<>, std::tuple<SimCore>> {
93 public:
94 explicit SimSystem(std::weak_ptr<ECSWorld> world):
95 System<SimSystem, std::tuple<>, std::tuple<SimCore>>{world}
96 {}
97
103 static std::string getSystemTypeName() { return "SimSystem"; }
104
112 bool aspectRegistered(const std::string& aspectName) const;
113
114 protected:
115 virtual std::shared_ptr<BaseSystem> instantiate(std::weak_ptr<ECSWorld> world) override;
116
117 private:
118
124 template <typename TSimObjectAspect>
125 void registerAspect();
126
133 std::shared_ptr<BaseSimObjectAspect> constructAspect(const nlohmann::json& jsonAspectProperties);
134
140 void onSimulationStep(uint32_t simulationStepMillis) override;
141
148 void onVariableStep(float simulationProgress, uint32_t variableStepMillis) override;
149
154 std::unordered_map<std::string, std::shared_ptr<BaseSimObjectAspect> (*)(const nlohmann::json& jsonAspectProperties)> mAspectConstructors {};
155
156 friend class BaseSimObjectAspect;
157 friend class SimObject;
158 };
159
219 class SimObject: public BaseSceneNode<SimObject>, public Resource<SimObject> {
220 public:
225 ~SimObject() override;
226
227
233 inline static std::string getResourceTypeName() { return "SimObject"; }
234
245 template <typename ...TComponents>
246 static std::shared_ptr<SimObject> create(const Placement& placement, const std::string& name, TComponents...components);
247
254 static std::shared_ptr<SimObject> create(const nlohmann::json& jsonSimObject);
255
262 static std::shared_ptr<SimObject> copy(const std::shared_ptr<const SimObject> simObject);
263
269 void addAspect(const nlohmann::json& jsonAspectProperties);
270
276 void addAspect(const BaseSimObjectAspect& simObjectAspect);
277
285 template <typename TSimObjectAspect>
286 bool hasAspect() const;
287
295 bool hasAspect(const std::string& aspectType) const;
296
304 template <typename TInterface>
305 bool hasAspectWithInterface() const;
306
312 void addOrReplaceAspect(const BaseSimObjectAspect& simObjectAspect);
313
319 void addOrReplaceAspect(const nlohmann::json& jsonAspectProperties);
320
327 template <typename TSimObjectAspect>
328 TSimObjectAspect& getAspect();
329
336 BaseSimObjectAspect& getAspect(const std::string& aspectType);
337
344 template <typename TInterface>
345 std::vector<std::reference_wrapper<TInterface>> getAspectsWithInterface();
346
352 template <typename TSimObjectAspect>
353 void removeAspect();
354
360 void removeAspect(const std::string& aspectType);
361
362 protected:
363
364 template <typename ...TComponents>
365 SimObject(const Placement& placement, const std::string& name, TComponents...components);
366 SimObject(const nlohmann::json& jsonSimObject);
367 SimObject(const SimObject& other);
368
369 // /**
370 // * @brief Copy assignment operator.
371 // *
372 // * @todo Figure out whether this operator will actually ever be useful.
373 // *
374 // */
375 // SimObject& operator=(const SimObject& other);
376
377 private:
383 void simulationUpdate(uint32_t simStepMillis);
384
391 void variableUpdate(uint32_t variableStepMillis);
392
399 void onActivated() override;
400
407 void onDeactivated() override;
408
414 void copyAspects(const SimObject& other);
415
421 std::shared_ptr<SceneNodeCore> clone() const override;
422
427 std::unordered_map<std::string, std::shared_ptr<BaseSimObjectAspect>> mSimObjectAspects {};
428
429 friend class SimSystem;
430 friend class BaseSimObjectAspect;
431 friend class BaseSceneNode<SimObject>;
432 };
433
444 private:
453 inline bool call(const ActionData& actionData, const ActionDefinition& actionDefinition) {
454 return mHandler(actionData, actionDefinition);
455 }
456
464 FixedActionBinding(const std::string& context, const std::string& name, std::function<bool(const ActionData&, const ActionDefinition&)> handler):
465 mContext { context },
466 mName { name },
467 mHandler { handler }
468 {}
469
474 std::string mContext;
475
480 std::string mName;
481
488 std::function<bool(const ActionData&, const ActionDefinition&)> mHandler;
489 friend class BaseSimObjectAspect;
490 };
491
499 class BaseSimObjectAspect : public std::enable_shared_from_this<BaseSimObjectAspect>, public SignalTracker, public IActionHandler {
500 public:
505 virtual ~BaseSimObjectAspect()=default;
506
514 virtual void simulationUpdate(uint32_t simStepMillis) { (void)simStepMillis; /*prevent unused parameter warnings*/}
515
523 virtual void variableUpdate(uint32_t variableStepMillis) {(void)variableStepMillis; /*prevent unused parameter warnings*/}
524
539 bool handleAction(const ActionData& actionData, const ActionDefinition& actionDefinition) override final;
540
547
548 protected:
549 BaseSimObjectAspect()=default;
550
551 BaseSimObjectAspect(const BaseSimObjectAspect& other)=delete;
553
563 template <typename TSimObjectAspectDerived>
564 static inline void registerAspect() {
565 // ensure registration of SimSystem before trying to register
566 // this aspect
567 auto& simSystemRegistrator {
568 Registrator<System<SimSystem, std::tuple<>, std::tuple<SimCore>>>::getRegistrator()
569 };
570 simSystemRegistrator.emptyFunc(); // (I think) prevent registrator from being optimized out.
571
572 // Let SimSystem know that this type of aspect exists
573 ECSWorld::getSystemPrototype<SimSystem>()->registerAspect<TSimObjectAspectDerived>();
574 }
575
582
589 template <typename TComponent>
590 void addComponent(const TComponent& component);
591
599 template <typename TComponent>
600 bool hasComponent();
601
608 template <typename TComponent>
609 void updateComponent(const TComponent& component);
610
618 template <typename TComponent>
619 TComponent getComponent(const float simulationProgress=1.f) const;
620
626 template <typename TComponent>
627 void removeComponent();
628
635 void addAspect(const nlohmann::json& jsonAspectProperties);
636
642 void addAspect(const BaseSimObjectAspect& aspect);
643
651 template <typename TSimObjectAspect>
652 bool hasAspect() const;
653
662 bool hasAspect(const std::string& aspectType) const;
663
670 template <typename TSimObjectAspect>
671 TSimObjectAspect& getAspect();
672
679 BaseSimObjectAspect& getAspect(const std::string& aspectType);
680
686 template <typename TSimObjectAspect>
687 void removeAspect();
688
695 void addOrReplaceAspect(const BaseSimObjectAspect& aspect);
696
702 void addOrReplaceAspect(const nlohmann::json& jsonAspectProperties);
703
740 std::weak_ptr<FixedActionBinding> declareFixedActionBinding(const std::string& context, const std::string& action, std::function<bool(const ActionData&, const ActionDefinition&)>);
741
747 EntityID getEntityID() const;
748
754 std::weak_ptr<ECSWorld> getWorld() const;
755
761 virtual std::string getAspectTypeName() const = 0;
762
763 private:
769
775
776 void onAttached_();
777 void onDetached_();
778 void onActivated_();
779 void onDeactivated_();
780
785 virtual void onAttached(){}
786
791 virtual void onDetached(){}
792
797 virtual void onActivated() {}
798
803 virtual void onDeactivated() {}
804
811 inline bool isAttached() { return mState&AspectState::ATTACHED; }
812
819 inline bool isActive() { return mState&AspectState::ACTIVE; }
820
826 void attach(SimObject* owner);
827
832 void detach();
833
839 virtual std::shared_ptr<BaseSimObjectAspect> clone() const = 0;
840
846 std::map<
847 std::pair<std::string, std::string>,
848 std::shared_ptr<FixedActionBinding>,
849 std::less<std::pair<std::string, std::string>>
851
856 SimObject* mSimObject { nullptr };
857
862 enum AspectState : uint8_t {
863 ATTACHED=1, //< Whether this aspect is attached to a SimObject.
864 ACTIVE=2, //< Whether the attached SimObject is active.
865 };
866
873 uint8_t mState { 0x0 };
874
875 friend class SimObject;
876 };
877
955 template <typename TSimObjectAspectDerived>
956 class SimObjectAspect: public BaseSimObjectAspect {
957 protected:
958 SimObjectAspect(int explicitlyInitializeMe){
959 (void)explicitlyInitializeMe; // prevent unused parameter warnings
960 s_registrator.emptyFunc();
961 }
962 private:
968 inline std::string getAspectTypeName() const override {
969 return TSimObjectAspectDerived::getSimObjectAspectTypeName();
970 }
971
979
985 friend class Registrator<SimObjectAspect<TSimObjectAspectDerived>>;
986 friend class SimObject;
987 };
988
989 template<typename TSimObjectAspectDerived>
992 };
993
994 template <typename TSimObjectAspect>
996 assert((std::is_base_of<BaseSimObjectAspect, TSimObjectAspect>::value) && "Type being registered must be a subclass of BaseSimObjectAspect");
997 mAspectConstructors.insert_or_assign(
998 TSimObjectAspect::getSimObjectAspectTypeName(),
999 &(TSimObjectAspect::create)
1000 );
1001 }
1002
1003 template <typename ...TComponents>
1004 std::shared_ptr<SimObject> SimObject::create(const Placement& placement, const std::string& name, TComponents...components) {
1005 return BaseSceneNode<SimObject>::create<SimObject, TComponents...>(placement, name, components...);
1006 }
1007
1008 template <typename ...TComponents>
1009 SimObject::SimObject(const Placement& placement, const std::string& name, TComponents ... components) :
1010 BaseSceneNode<SimObject> { placement, name, SimCore{this}, components... },
1012 {}
1013
1014 template <typename TComponent>
1015 void BaseSimObjectAspect::addComponent(const TComponent& component) {
1016 mSimObject->addComponent<TComponent>(component);
1017 }
1018 template <typename TComponent>
1020 return mSimObject->hasComponent<TComponent>();
1021 }
1022 template <typename TComponent>
1023 void BaseSimObjectAspect::updateComponent(const TComponent& component) {
1024 mSimObject->updateComponent<TComponent>(component);
1025 }
1026 template <typename TComponent>
1027 TComponent BaseSimObjectAspect::getComponent(const float simulationProgress) const {
1028 return mSimObject->getComponent<TComponent>(simulationProgress);
1029 }
1030 template <typename TComponent>
1032 return mSimObject->removeComponent<TComponent>();
1033 }
1034
1035 template <typename TSimObjectAspect>
1037 return mSimObjectAspects.find(TSimObjectAspect::getSimObjectAspectTypeName()) != mSimObjectAspects.end();
1038 }
1039
1040 template <typename TInterface>
1042 for(auto aspect: mSimObjectAspects) {
1043 if(auto interfaceReference = std::dynamic_pointer_cast<TInterface>(aspect.second)){
1044 return true;
1045 }
1046 }
1047 return false;
1048 }
1049
1050 template <typename TSimObjectAspect>
1051 TSimObjectAspect& SimObject::getAspect() {
1052 return *(static_cast<TSimObjectAspect*>(mSimObjectAspects.at(TSimObjectAspect::getSimObjectAspectTypeName()).get()));
1053 }
1054
1055 template <typename TInterface>
1056 std::vector<std::reference_wrapper<TInterface>> SimObject::getAspectsWithInterface() {
1057 std::vector<std::reference_wrapper<TInterface>> interfaceImplementations {};
1058 for(auto aspect: mSimObjectAspects) {
1059 if(auto interfaceReference = std::dynamic_pointer_cast<TInterface>(aspect.second)) {
1060 interfaceImplementations.push_back(*interfaceReference);
1061 }
1062 }
1063 return interfaceImplementations;
1064 }
1065
1066 template <typename TSimObjectAspect>
1068 mSimObjectAspects.erase(TSimObjectAspect::getSimObjectAspectTypeName());
1069 }
1070
1071 template <typename TSimObjectAspect>
1073 mSimObject->removeAspect<TSimObjectAspect>();
1074 }
1075
1076 template <typename TSimObjectAspect>
1078 return mSimObject->getAspect<TSimObjectAspect>();
1079 }
1080
1081 template <typename TSimObjectAspect>
1083 return mSimObject->hasAspect<TSimObjectAspect>();
1084 }
1085
1086 template <>
1088 static BaseSimObjectAspect& get(std::shared_ptr<SceneNodeCore> rootNode, const std::string& where) {
1089 std::string::const_iterator div {std::find(where.begin(), where.end(), '@')};
1090 assert(div != where.end() && "Must contain @ to be a valid path to a scene node's aspect");
1091
1092 // extract the node path from full path
1093 const std::string nodePath { where.substr(0, div - where.begin()) };
1094 const std::string aspectName { where.substr(1 + (div - where.begin())) };
1095 assert(rootNode->getWorld().lock()->getSystem<SimSystem>()->aspectRegistered(aspectName) && "No aspect of this type has been registered with the Sim System");
1096
1097 std::shared_ptr<SimObject> node { rootNode->getByPath<std::shared_ptr<SimObject>>(nodePath) };
1098 return node->getAspect(aspectName);
1099 }
1100
1101 static constexpr bool s_valid { true };
1102 };
1103
1104 template <typename TAspect>
1105 struct SceneNodeCore::getByPath_Helper<TAspect&, std::enable_if_t<std::is_base_of<BaseSimObjectAspect, TAspect>::value>> {
1106 static TAspect& get(std::shared_ptr<SceneNodeCore> rootNode, const std::string& where) {
1107 return static_cast<TAspect&>(SceneNodeCore::getByPath_Helper<BaseSimObjectAspect&>::get(rootNode, where));
1108 }
1109 static constexpr bool s_valid { true };
1110 };
1111
1113 template<>
1114 inline SimCore Interpolator<SimCore>::operator() (const SimCore&, const SimCore& next, float) const {
1115 // Never return the previous state, as that is (supposed to be)
1116 // an invalidated reference to this node
1117 return next;
1118 }
1119
1120 template <>
1122 assert(false && "Cannot remove a sim object's sim core component.");
1123 }
1124}
1125
1126#endif
A CRTP template for all the scene node types present in the project.
Definition scene_system.hpp:699
BaseSceneNode(const Key &key, const Placement &placement, const std::string &name, TComponents...components)
Definition scene_system.hpp:762
static std::shared_ptr< TSceneNode > create(const Key &, const Placement &placement, const std::string &name, TComponents...components)
A (private) method for the creation of a new scene node for a particular type.
Definition scene_system.hpp:1771
The base class for all aspects, providing an interface to its attached SimObject, and consequently,...
Definition sim_system.hpp:499
void addComponent(const TComponent &component)
Adds a component of some type to the underlying entity.
Definition sim_system.hpp:1015
virtual ~BaseSimObjectAspect()=default
Destroys this object.
void removeComponent()
Removes a component of some type belonging to the underlying SimObject.
Definition sim_system.hpp:1031
ViewportNode & getLocalViewport()
Returns the closest ancestor viewport to this node, if one exists (which it should,...
Definition sim_system.cpp:210
virtual void onActivated()
Callback for when the aspect is activated (after it is attached to an active SimObject,...
Definition sim_system.hpp:797
void activateFixedActionBindings()
Called when an aspect has just been activated to bind its handler method to its associated action.
Definition sim_system.cpp:234
virtual void onDetached()
Callback for when an aspect is about to be removed from an object (after it has been deactivated).
Definition sim_system.hpp:791
TSimObjectAspect & getAspect()
Gets an aspect of a particular type belonging to the underlying SimObject.
Definition sim_system.hpp:1077
uint8_t mState
Value representing the readiness of this aspect.
Definition sim_system.hpp:873
bool hasAspect() const
Tests whether an aspect of a particular type is attached to the underlying SimObject.
Definition sim_system.hpp:1082
virtual std::string getAspectTypeName() const =0
Overridable function for fetching the aspect type string of an aspect.
bool isAttached()
Tests whether this aspect is attached to a SimObject.
Definition sim_system.hpp:811
void addOrReplaceAspect(const BaseSimObjectAspect &aspect)
Adds or replaces an aspect on the underlying SimObject with a new aspect constructed as a copy of ano...
Definition sim_system.cpp:195
std::map< std::pair< std::string, std::string >, std::shared_ptr< FixedActionBinding >, std::less< std::pair< std::string, std::string > > > mFixedActionBindings
The set of action bindings owned by this aspect.
Definition sim_system.hpp:850
std::weak_ptr< FixedActionBinding > declareFixedActionBinding(const std::string &context, const std::string &action, std::function< bool(const ActionData &, const ActionDefinition &)>)
Binds some method (or any function) present on this object to an action generated by the InputManager...
Definition sim_system.cpp:219
static void registerAspect()
Registers an implementation of an aspect with the SimSystem.
Definition sim_system.hpp:564
bool isActive()
Tests whether the SimObject this aspect is attached to is active on the SceneSystem and the SimSystem...
Definition sim_system.hpp:819
virtual void simulationUpdate(uint32_t simStepMillis)
Overriding this allows an aspect to respond to simulation updates.
Definition sim_system.hpp:514
TComponent getComponent(const float simulationProgress=1.f) const
Gets the value of a component belonging to this object.
Definition sim_system.hpp:1027
void deactivateFixedActionBindings()
Called when an aspect's SimObject has been deactivated, retiring all currently active action bindings...
Definition sim_system.cpp:251
std::weak_ptr< ECSWorld > getWorld() const
Gets a weak reference to the ECSWorld to which our SimObject's entity belongs.
Definition sim_system.cpp:262
void detach()
Causes this aspect to be disconnected from its current SimObject.
Definition sim_system.cpp:177
EntityID getEntityID() const
Gets the ID of the ECSWorld Entity belonging to our SimObject.
Definition sim_system.cpp:120
SimObject & getSimObject()
Returns the sim object that this aspect is attached to.
Definition sim_system.cpp:214
void addAspect(const nlohmann::json &jsonAspectProperties)
Adds a new aspect to the underlying SimObject constructed based on its properties in JSON.
Definition sim_system.cpp:191
virtual void onDeactivated()
Callback for when the aspect is deactivated (just prior to being detached, or when its SimObject has ...
Definition sim_system.hpp:803
virtual void onAttached()
Callback for when an aspect has just been attached to an object (but which hasn't yet been activated)...
Definition sim_system.hpp:785
SimObject * mSimObject
The SimObject underlying this aspect.
Definition sim_system.hpp:856
AspectState
Enum for mask values representing the readiness of an aspect.
Definition sim_system.hpp:862
virtual void variableUpdate(uint32_t variableStepMillis)
Overriding this allows an aspect to respond to variable updates.
Definition sim_system.hpp:523
void attach(SimObject *owner)
Causes this aspect to be detached from its previous owner and to be attached to a new one.
Definition sim_system.cpp:167
virtual std::shared_ptr< BaseSimObjectAspect > clone() const =0
A method which must be overridden to specify how a new aspect should be constructed as a copy of this...
void updateComponent(const TComponent &component)
Updates the value of a component belonging to this object to a new one.
Definition sim_system.hpp:1023
void removeAspect()
Removes an aspect from the underlying SimObject.
Definition sim_system.hpp:1072
bool handleAction(const ActionData &actionData, const ActionDefinition &actionDefinition) override final
Pipes an action received from the InputManager via our SimObject to all that action's handler methods...
Definition sim_system.cpp:245
bool hasComponent()
Tests whether a component of some specific type is present on the object.
Definition sim_system.hpp:1019
static std::shared_ptr< TSystem > getSystemPrototype()
Get the system object of a specific type belonging to the prototype ECSWorld.
Definition ecs_world.hpp:2777
FixedActionBinding(const std::string &context, const std::string &name, std::function< bool(const ActionData &, const ActionDefinition &)> handler)
Constructs a new binding object with the given action name and context, and a reference to the functi...
Definition sim_system.hpp:464
std::string mContext
The name of the context owning the action.
Definition sim_system.hpp:474
std::string mName
The name of the action itself.
Definition sim_system.hpp:480
std::function< bool(const ActionData &, const ActionDefinition &)> mHandler
A reference to the handler interested in receiving the action.
Definition sim_system.hpp:488
bool call(const ActionData &actionData, const ActionDefinition &actionDefinition)
Calls the handler this binding holds a reference to with some newly received action data generated by...
Definition sim_system.hpp:453
Class interface for systems that wish to be notified when action events occur in an action context.
Definition input_system.hpp:301
Helper class for registering a class at program startup.
Definition registrator.hpp:64
The base class for any type whose creation and storage should be managed by the ResourceDatabase.
Definition resource_database.hpp:372
Resource(int explicitlyInitializeMe)
Definition resource_database.hpp:389
void removeComponent()
Removes a component present on this node.
Definition scene_system.hpp:1911
SignalTracker()
Constructs a new SignalTracker object.
std::string getAspectTypeName() const override
Returns the aspect type string associated with TSimObjectAspectDerived.
Definition sim_system.hpp:968
static Registrator< SimObjectAspect< TSimObjectAspectDerived > > & s_registrator
The static helper class instance, responsible for making sure registerSelf() is called during the sta...
Definition sim_system.hpp:984
static void registerSelf()
Registers the new aspect class and its constructor with the SimSystem.
Definition sim_system.hpp:976
A wrapper on entity that allows objects in the Scene to be scriptable.
Definition sim_system.hpp:219
static std::shared_ptr< SimObject > copy(const std::shared_ptr< const SimObject > simObject)
Creates a new SimObject as a copy of another.
Definition sim_system.cpp:19
void copyAspects(const SimObject &other)
Copies all aspects present on another SimObject onto this one.
Definition sim_system.cpp:112
~SimObject() override
Detaches all SimObjectAspects from this SimObject before allowing destruction to proceed.
Definition sim_system.cpp:5
void variableUpdate(uint32_t variableStepMillis)
Calls aspect variable update hooks for attached aspects.
Definition sim_system.cpp:106
void removeAspect()
Removes an aspect of a certain type from this SimObject.
Definition sim_system.hpp:1067
void onDeactivated() override
Notifies all attached aspects that this scene node has stopped being an active part of the scene.
Definition sim_system.cpp:53
std::shared_ptr< SceneNodeCore > clone() const override
Copies this scene object returning one containing all the same components and aspects as it.
Definition sim_system.cpp:23
void onActivated() override
Notifies all attached aspects that this scene node has become an active part of the scene.
Definition sim_system.cpp:48
bool hasAspect() const
Tests whether an aspect of a particular type is attached to this node.
Definition sim_system.hpp:1036
static std::shared_ptr< SimObject > create(const Placement &placement, const std::string &name, TComponents...components)
Creates a new SimObject scene node initialized with some placement and component values.
Definition sim_system.hpp:1004
bool hasAspectWithInterface() const
Tests whether any aspects implementing some base class are present on this node.
Definition sim_system.hpp:1041
void simulationUpdate(uint32_t simStepMillis)
Copy assignment operator.
Definition sim_system.cpp:100
static std::string getResourceTypeName()
Gets the resource type string for the SimObject class.
Definition sim_system.hpp:233
void addAspect(const nlohmann::json &jsonAspectProperties)
Constructs and attaches a new SimObjectAspect to this node based on the aspect's description in JSON.
Definition sim_system.cpp:138
TSimObjectAspect & getAspect()
Gets a reference to a specific aspect present on this node.
Definition sim_system.hpp:1051
std::unordered_map< std::string, std::shared_ptr< BaseSimObjectAspect > > mSimObjectAspects
Aspect name and pointer pairs for all aspects attached to this SimObject.
Definition sim_system.hpp:427
std::vector< std::reference_wrapper< TInterface > > getAspectsWithInterface()
Gets a list of aspects which subclass some base class.
Definition sim_system.hpp:1056
void addOrReplaceAspect(const BaseSimObjectAspect &simObjectAspect)
Adds or replaces an aspect for this node.
Definition sim_system.cpp:130
The SimSystem is a system responsible for providing scriptability via SimObjects and SimObjectAspects...
Definition sim_system.hpp:92
std::shared_ptr< BaseSimObjectAspect > constructAspect(const nlohmann::json &jsonAspectProperties)
Constructs a SimObjectAspect based on its description in JSON.
Definition sim_system.cpp:84
void registerAspect()
Registers a new aspect (a derived class of SimObjectAspect) as an aspect known by the SimSystem.
Definition sim_system.hpp:995
bool aspectRegistered(const std::string &aspectName) const
Tests whether an aspect with a certain name is a valid SimObjectAspect type known by this application...
Definition sim_system.cpp:74
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 th...
Definition sim_system.hpp:154
void onSimulationStep(uint32_t simulationStepMillis) override
The method responsible for forwarding engine simulation step events to SimObjects and their SimObject...
Definition sim_system.cpp:88
static std::string getSystemTypeName()
Gets the system type string associated with this system.
Definition sim_system.hpp:103
void onVariableStep(float simulationProgress, uint32_t variableStepMillis) override
The method responsible for forwarding engine variable step events to SimObjects and their SimObjectAs...
Definition sim_system.cpp:93
A system template that disables systems with this form of declaration.
Definition ecs_world.hpp:1062
A type of node capable of and responsible for interacting sensibly with the engine's RenderSystem and...
Definition scene_system.hpp:844
ToyMaker Engine's implementation of an ECS system.
T operator()(const T &previousState, const T &nextState, float simulationProgress=1.f) const
Returns an interpolated value for a component between two given states.
Definition ecs_world.hpp:2346
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
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition camera_system.hpp:20
Contains the definition for the Registrator<T> utility class, used anywhere that automatic registrati...
Headers relating to resources and their management for a given project.
System classes relating to the SceneSystem, which in some ways lies at the heart of the engine.
Classes relating to this engine's implementation of signals. Contains template classes used to define...
The file containing classes related to the spatial query system, which uses simplified geometrical da...
The definition of a single action, including whether it represents state or change,...
Definition input_data.hpp:511
A component representing the position, rotation, and scale of an entity.
Definition scene_components.hpp:30
A helper intended to get scene nodes and related objects attached to the scene tree.
Definition scene_system.hpp:548
The component associated with the SimSystem.
Definition sim_system.hpp:54
SimObject * mSimObject
Unmanaged pointer to the SimObject this is a component of.
Definition sim_system.hpp:66
static std::string getComponentTypeName()
Gets the component type string for this class.
Definition sim_system.hpp:60
A union that may contain any one of SimpleActionData, OneAxisActionData, TwoAxisActionData,...
Definition input_data.hpp:721