From 547c0d361b5d7a27a956073829547f625e6ef4ac Mon Sep 17 00:00:00 2001 From: Ubpa Date: Tue, 17 Nov 2020 23:26:10 +0800 Subject: [PATCH] Add some template API for `SystemTraits` and `SystemMngr` --- CMakeLists.txt | 2 +- README.md | 7 +++-- doc/changelog.md | 7 +++-- include/UECS/CmptType.h | 2 +- include/UECS/EntityMngr.h | 4 ++- include/UECS/SystemMngr.h | 35 ++++++++++++++++++++++--- include/UECS/SystemTraits.h | 41 ++++++++++++++++++++++-------- include/UECS/World.h | 9 ++----- include/UECS/detail/EntityMngr.inl | 2 +- include/UECS/detail/SystemMngr.inl | 21 +++++++++++++++ src/core/SystemTraits.cpp | 24 +++++++++++++---- src/test/00_basic/main.cpp | 3 +-- src/test/01_tag/main.cpp | 3 +-- src/test/02_order/main.cpp | 3 +-- src/test/03_query_entity/main.cpp | 3 +-- src/test/04_filter/main.cpp | 3 +-- src/test/06_none_parallel/main.cpp | 3 +-- src/test/07_overload/main.cpp | 4 +-- src/test/08_job/main.cpp | 3 +-- src/test/10_instantiate/main.cpp | 3 +-- src/test/11_runtime_cmpt/main.cpp | 3 +-- src/test/12_framegraph/main.cpp | 3 +-- src/test/13_performance/main.cpp | 3 +-- src/test/14_serialize/main.cpp | 3 +-- src/test/15_chunk_job/main.cpp | 4 +-- src/test/16_singleton/main.cpp | 3 +-- src/test/17_serial/main.cpp | 3 +-- src/test/18_copy/main.cpp | 3 +-- src/test/19_direct_run/main.cpp | 3 +-- src/test/21_random/main.cpp | 3 +-- 30 files changed, 137 insertions(+), 76 deletions(-) create mode 100644 include/UECS/detail/SystemMngr.inl diff --git a/CMakeLists.txt b/CMakeLists.txt index de84aa3..4bad430 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ Ubpa_InitUCMake() Ubpa_InitProject() -Ubpa_AddDep(UContainer 0.0.8) +Ubpa_AddDep(UContainer 0.0.9) Ubpa_AddDep(UTemplate 0.4.9) Ubpa_AddDep(UGraphviz 0.1.6) diff --git a/README.md b/README.md index 562cc10..deaab7e 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,9 @@ struct MoverSystem { int main() { World w; - auto move = w.systemMngr.systemTraits.Register(); - w.entityMngr.Create(); - w.systemMngr.Activate(move); - w.Update(); + w.systemMngr.RegisterAndActivate(); + w.entityMngr.Create(); + w.Update(); } ``` diff --git a/doc/changelog.md b/doc/changelog.md index 024d875..1edb07f 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -1,6 +1,8 @@ # Change Log -- 0.14.4: EntityMngr add single `CmptType` API +- 0.14.4 + - EntityMngr add single `CmptType` API + - Add some template API for `SystemTraits` and `SystemMngr` - 0.14.3 - `CmptsView`, `SingletonsView` use `Span` - API with `const CmptType* types, size_t num` use `Span types` as instead @@ -14,4 +16,5 @@ - `CmptAccessType`'s default `AccessMode` change from `LATEST` to `WRITE` - `World` command buffer layer's type change from `size_t` to `int` - 0.14.1: `CmptAccessMode` remove singleton -- 0.14.0: System Lifecycle \ No newline at end of file +- 0.14.0: System Lifecycle + diff --git a/include/UECS/CmptType.h b/include/UECS/CmptType.h index b5b9100..2190f97 100644 --- a/include/UECS/CmptType.h +++ b/include/UECS/CmptType.h @@ -58,7 +58,7 @@ namespace Ubpa::UECS { constexpr CmptType GetCmptType() const noexcept { return type; } constexpr AccessMode GetAccessMode() const noexcept { return mode; } - constexpr operator CmptType()const noexcept { return type; } + constexpr operator CmptType() const noexcept { return type; } static constexpr CmptAccessType Invalid() noexcept { return CmptAccessType{ static_cast(-1), AccessMode{} }; } constexpr bool Valid() const noexcept { return type.Valid(); } diff --git a/include/UECS/EntityMngr.h b/include/UECS/EntityMngr.h index 36fd78f..e13b9b1 100644 --- a/include/UECS/EntityMngr.h +++ b/include/UECS/EntityMngr.h @@ -71,7 +71,7 @@ namespace Ubpa::UECS { std::vector Components(Entity) const; - bool Exist(Entity) const; + bool Exist(Entity) const noexcept; void Destroy(Entity); @@ -96,6 +96,8 @@ namespace Ubpa::UECS { void Accept(IListener* listener) const; + EntityMngr& operator=(EntityMngr&&) noexcept = delete; + EntityMngr& operator=(const EntityMngr&) = delete; private: friend class World; friend class Archetype; diff --git a/include/UECS/SystemMngr.h b/include/UECS/SystemMngr.h index 044e3a4..dfc119e 100644 --- a/include/UECS/SystemMngr.h +++ b/include/UECS/SystemMngr.h @@ -11,11 +11,14 @@ namespace Ubpa::UECS { public: SystemTraits systemTraits; - SystemMngr(World* w) : w{w}{} + SystemMngr(World* w) : w{w} {} SystemMngr(const SystemMngr& mngr, World* w); SystemMngr(SystemMngr&& mngr, World* w) noexcept; ~SystemMngr(); + const auto& GetAliveSystemIDs() const noexcept { return aliveSystemIDs; } + const auto& GetActiveSystemsIDs() const noexcept { return activeSystemIDs; } + // not alive -> create void Create(size_t systemID); @@ -33,8 +36,32 @@ namespace Ubpa::UECS { bool IsAlive(size_t systemID) const; bool IsActive(size_t systemID) const; - const auto& GetAliveSystemIDs() const noexcept { return aliveSystemIDs; } - const auto& GetActiveSystemsIDs() const noexcept { return activeSystemIDs; } + // [ Template ] Functions + /////////////////////////// + + template + void Create() { (Create(systemTraits.GetID()), ...); } + + template + void Activate() { (Activate(systemTraits.GetID()), ...); } + + template + void Deactivate() { (Deactivate(systemTraits.GetID()), ...); } + + template + void Destroy() { (Destroy(systemTraits.GetID()), ...); } + + template + bool IsAlive() const { return IsAlive(systemTraits.GetID()); } + + template + bool IsActive() const { return IsActive(systemTraits.GetID()); } + + template + std::array RegisterAndCreate(); + + template + std::array RegisterAndActivate(); SystemMngr(const SystemMngr&) = delete; SystemMngr(SystemMngr&&) noexcept = delete; @@ -51,3 +78,5 @@ namespace Ubpa::UECS { std::unordered_set activeSystemIDs; }; } + +#include "detail/SystemMngr.inl" diff --git a/include/UECS/SystemTraits.h b/include/UECS/SystemTraits.h index a7c9746..4459ae6 100644 --- a/include/UECS/SystemTraits.h +++ b/include/UECS/SystemTraits.h @@ -37,32 +37,51 @@ namespace Ubpa::UECS { SystemTraits() = default; SystemTraits(const SystemTraits&); SystemTraits(SystemTraits&&) noexcept = default; + SystemTraits& operator=(SystemTraits&); + SystemTraits& operator=(SystemTraits&&) noexcept = default; + // register system's name and get an ID + // if it is already registered, return it's ID directly size_t Register(std::string name); - void RegisterOnCreate(size_t ID, std::function); - void RegisterOnActivate(size_t ID, std::function); - void RegisterOnUpdate(size_t ID, std::function); + + // ID must exist + void RegisterOnCreate (size_t ID, std::function); + void RegisterOnActivate (size_t ID, std::function); + void RegisterOnUpdate (size_t ID, std::function); void RegisterOnDeactivate(size_t ID, std::function); - void RegisterOnDestroy(size_t ID, std::function); + void RegisterOnDestroy (size_t ID, std::function); - bool IsRegistered(size_t ID) const noexcept; - size_t GetID(std::string_view name) const; std::string_view Nameof(size_t ID) const noexcept; + size_t GetID(std::string_view name) const; + bool IsRegistered(size_t ID) const noexcept; const auto& GetNameIDMap() const noexcept { return name2id; } + // [ Template ] functions + /////////////////////////// + + template + static std::string_view StaticNameof() noexcept; + + // for each in + // 1. Register(StaticNameof()) + // 2. RegisterOn{Create|Activate|Update|Deactivate|Destroy} if has them template std::array Register(); + template - static std::string_view StaticNameof() noexcept; + size_t GetID() const { return GetID(StaticNameof()); } + + template + bool IsRegistered() const { return GetID(); } private: friend class SystemMngr; - void Create(size_t ID, World*) const; - void Activate(size_t ID, World*) const; - void Update(size_t ID, Schedule&) const; + void Create (size_t ID, World*) const; + void Activate (size_t ID, World*) const; + void Update (size_t ID, Schedule&) const; void Deactivate(size_t ID, World*) const; - void Destroy(size_t ID, World*) const; + void Destroy (size_t ID, World*) const; std::vector names; std::unordered_map name2id; diff --git a/include/UECS/World.h b/include/UECS/World.h index f44f968..ecb85d8 100644 --- a/include/UECS/World.h +++ b/include/UECS/World.h @@ -16,7 +16,7 @@ namespace Ubpa::UECS { class World { public: World() : systemMngr{ this }{} - // not copy schedule, so you can't use DumpUpdateJobGraph() and GenUpdateFrameGraph() before Update() + // not copy/move schedule, so you can't use DumpUpdateJobGraph() and GenUpdateFrameGraph() before Update() World(const World&); World(World&&) noexcept; ~World(); @@ -109,6 +109,7 @@ namespace Ubpa::UECS { bool isParallel = true, SingletonLocator = {} ) const; + private: bool inRunningJobGraph{ false }; @@ -125,12 +126,6 @@ namespace Ubpa::UECS { void RunCommands(); void Run(SystemFunc*); - - // ================================================== - //World(const World& world) = delete; - //World(World&& world) = delete; - //World& operator==(World&& world) = delete; - //World& operator=(const World& world) = delete; }; } diff --git a/include/UECS/detail/EntityMngr.inl b/include/UECS/detail/EntityMngr.inl index 728492e..1a0944f 100644 --- a/include/UECS/detail/EntityMngr.inl +++ b/include/UECS/detail/EntityMngr.inl @@ -140,7 +140,7 @@ namespace Ubpa::UECS { return { type, info.archetype->At(type, info.idxInArchetype) }; } - inline bool EntityMngr::Exist(Entity e) const { + inline bool EntityMngr::Exist(Entity e) const noexcept { return e.Idx() < entityTable.size() && e.Version() == entityTable[e.Idx()].version; } diff --git a/include/UECS/detail/SystemMngr.inl b/include/UECS/detail/SystemMngr.inl new file mode 100644 index 0000000..62816ac --- /dev/null +++ b/include/UECS/detail/SystemMngr.inl @@ -0,0 +1,21 @@ +#pragma once + +namespace Ubpa::UECS { + template + std::array SystemMngr::RegisterAndCreate() { + std::array systemIDs = systemTraits.Register(); + std::apply([this](auto... IDs) { + (Create(IDs), ...); + }, systemIDs); + return systemIDs; + } + + template + std::array SystemMngr::RegisterAndActivate() { + std::array systemIDs = systemTraits.Register(); + std::apply([this](auto... IDs) { + (Activate(IDs), ...); + }, systemIDs); + return systemIDs; + } +} diff --git a/src/core/SystemTraits.cpp b/src/core/SystemTraits.cpp index 97404e8..0f892cd 100644 --- a/src/core/SystemTraits.cpp +++ b/src/core/SystemTraits.cpp @@ -18,6 +18,20 @@ SystemTraits::SystemTraits(const SystemTraits& traits) } } +SystemTraits& SystemTraits::operator=(SystemTraits& rhs) { + names = rhs.names; + createMap = rhs.createMap; + activateMap = rhs.activateMap; + updateMap = rhs.updateMap; + deactivateMap = rhs.deactivateMap; + destroyMap = rhs.destroyMap; + for (size_t i = 0; i < names.size(); i++) { + const auto& name = names[i]; + name2id.emplace(std::string_view{ name }, i); + } + return *this; +} + size_t SystemTraits::Register(std::string name) { assert(!name.empty()); @@ -43,27 +57,27 @@ size_t SystemTraits::GetID(std::string_view name) const { void SystemTraits::RegisterOnCreate(size_t ID, std::function func) { assert(IsRegistered(ID)); - createMap.emplace(ID, std::move(func)); + createMap[ID] = std::move(func); } void SystemTraits::RegisterOnActivate(size_t ID, std::function func) { assert(IsRegistered(ID)); - activateMap.emplace(ID, std::move(func)); + activateMap[ID] = std::move(func); } void SystemTraits::RegisterOnUpdate(size_t ID, std::function func) { assert(IsRegistered(ID)); - updateMap.emplace(ID, std::move(func)); + updateMap[ID] = std::move(func); } void SystemTraits::RegisterOnDeactivate(size_t ID, std::function func) { assert(IsRegistered(ID)); - deactivateMap.emplace(ID, std::move(func)); + deactivateMap[ID] = std::move(func); } void SystemTraits::RegisterOnDestroy(size_t ID, std::function func) { assert(IsRegistered(ID)); - destroyMap.emplace(ID, std::move(func)); + destroyMap[ID] = std::move(func); } std::string_view SystemTraits::Nameof(size_t ID) const noexcept { diff --git a/src/test/00_basic/main.cpp b/src/test/00_basic/main.cpp index 0612c60..3a35512 100644 --- a/src/test/00_basic/main.cpp +++ b/src/test/00_basic/main.cpp @@ -18,8 +18,7 @@ struct MoverSystem { int main() { World w; - auto [move] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); w.entityMngr.Create(); - w.systemMngr.Activate(move); w.Update(); } diff --git a/src/test/01_tag/main.cpp b/src/test/01_tag/main.cpp index e1a015c..568b088 100644 --- a/src/test/01_tag/main.cpp +++ b/src/test/01_tag/main.cpp @@ -21,11 +21,10 @@ struct DataSystem { int main() { World w; - auto [dataSystem] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); w.entityMngr.Create(); - w.systemMngr.Activate(dataSystem); w.Update(); cout << w.DumpUpdateJobGraph() << endl; diff --git a/src/test/02_order/main.cpp b/src/test/02_order/main.cpp index 17325d7..9c4f2e9 100644 --- a/src/test/02_order/main.cpp +++ b/src/test/02_order/main.cpp @@ -23,7 +23,7 @@ struct DataSystem { int main() { World w; - auto [dataSystem] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); w.entityMngr.cmptTraits.Register< Data1, @@ -32,7 +32,6 @@ int main() { w.entityMngr.Create(); - w.systemMngr.Activate(dataSystem); w.Update(); cout << w.DumpUpdateJobGraph() << endl; diff --git a/src/test/03_query_entity/main.cpp b/src/test/03_query_entity/main.cpp index 91bf9da..df9735c 100644 --- a/src/test/03_query_entity/main.cpp +++ b/src/test/03_query_entity/main.cpp @@ -42,11 +42,10 @@ struct MySystem { int main() { World w; - auto [mySystem] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); w.entityMngr.Create(); - w.systemMngr.Activate(mySystem); w.Update(); w.Update(); w.Update(); diff --git a/src/test/04_filter/main.cpp b/src/test/04_filter/main.cpp index 11aeca4..8caffc3 100644 --- a/src/test/04_filter/main.cpp +++ b/src/test/04_filter/main.cpp @@ -32,7 +32,7 @@ struct MySystem { int main() { World w; - auto [mySystem] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); auto [e0, b0 ] = w.entityMngr.Create< B >(); // x auto [e1, a1 ] = w.entityMngr.Create(); // x @@ -44,7 +44,6 @@ int main() { w.entityMngr.Emplace(e2, 2.f); w.entityMngr.Emplace(e3, 3.f); - w.systemMngr.Activate(mySystem); w.Update(); cout << w.DumpUpdateJobGraph() << endl; diff --git a/src/test/06_none_parallel/main.cpp b/src/test/06_none_parallel/main.cpp index 3005f82..88a058a 100644 --- a/src/test/06_none_parallel/main.cpp +++ b/src/test/06_none_parallel/main.cpp @@ -21,13 +21,12 @@ struct MySystem { int main() { World w; - auto [mySystem] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); w.entityMngr.Create<>(); w.entityMngr.Create(); w.entityMngr.Create(); w.entityMngr.Create(); - w.systemMngr.Activate(mySystem); w.Update(); cout << w.DumpUpdateJobGraph() << endl; diff --git a/src/test/07_overload/main.cpp b/src/test/07_overload/main.cpp index 5ee717a..fe3deea 100644 --- a/src/test/07_overload/main.cpp +++ b/src/test/07_overload/main.cpp @@ -24,9 +24,7 @@ struct AVP_System { int main() { World w; - auto systemIndices = w.systemMngr.systemTraits.Register(); - for (auto idx : systemIndices) - w.systemMngr.Activate(idx); + w.systemMngr.RegisterAndActivate(); w.entityMngr.Create(); w.entityMngr.Create(); diff --git a/src/test/08_job/main.cpp b/src/test/08_job/main.cpp index 152458a..e95cfe4 100644 --- a/src/test/08_job/main.cpp +++ b/src/test/08_job/main.cpp @@ -39,14 +39,13 @@ struct MySystem { int main() { World w; - auto [mySystem] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); for (size_t i = 1; i <= 100; i++) { auto [e] = w.entityMngr.Create(); w.entityMngr.Emplace(e, i); } - w.systemMngr.Activate(mySystem); w.Update(); cout << w.DumpUpdateJobGraph() << endl; diff --git a/src/test/10_instantiate/main.cpp b/src/test/10_instantiate/main.cpp index 20fe1e4..b55ac7e 100644 --- a/src/test/10_instantiate/main.cpp +++ b/src/test/10_instantiate/main.cpp @@ -17,12 +17,11 @@ struct MySystem { int main() { World w; - auto [mySystem] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); auto [e] = w.entityMngr.Create<>(); w.entityMngr.Emplace(e, 1.f); w.entityMngr.Instantiate(e); - w.systemMngr.Activate(mySystem); w.Update(); cout << w.DumpUpdateJobGraph() << endl; diff --git a/src/test/11_runtime_cmpt/main.cpp b/src/test/11_runtime_cmpt/main.cpp index 24bc1c8..db1bfc1 100644 --- a/src/test/11_runtime_cmpt/main.cpp +++ b/src/test/11_runtime_cmpt/main.cpp @@ -49,7 +49,7 @@ int main() { // } World w; - auto [rtdSystem] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); w.entityMngr.cmptTraits .RegisterSize(type, 8) .RegisterDefaultConstructor(type, [](void*) { cout << "construct" << endl; }) @@ -57,7 +57,6 @@ int main() { auto [e] = w.entityMngr.Create(); w.entityMngr.Attach(e, { &type, 1 }); - w.systemMngr.Activate(rtdSystem); w.Update(); cout << w.DumpUpdateJobGraph() << endl; diff --git a/src/test/12_framegraph/main.cpp b/src/test/12_framegraph/main.cpp index 8909607..4e01690 100644 --- a/src/test/12_framegraph/main.cpp +++ b/src/test/12_framegraph/main.cpp @@ -31,7 +31,7 @@ struct MySystem { int main() { World w; - auto [mySystem] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); w.entityMngr.cmptTraits .RegisterName(CmptType::Of, "A") @@ -44,7 +44,6 @@ int main() { ; w.entityMngr.Create(); - w.systemMngr.Activate(mySystem); w.Update(); cout << w.DumpUpdateJobGraph() << endl; diff --git a/src/test/13_performance/main.cpp b/src/test/13_performance/main.cpp index e46af84..8c26d13 100644 --- a/src/test/13_performance/main.cpp +++ b/src/test/13_performance/main.cpp @@ -23,8 +23,7 @@ int main() { size_t numEntities = 65536; size_t numUpdate = 144 * 10; World w; - auto [testSystem] = w.systemMngr.systemTraits.Register(); - w.systemMngr.Activate(testSystem); + w.systemMngr.RegisterAndActivate(); auto t0 = std::chrono::steady_clock::now(); for (size_t i = 0; i < numEntities; i++) diff --git a/src/test/14_serialize/main.cpp b/src/test/14_serialize/main.cpp index 40203eb..33cf2d7 100644 --- a/src/test/14_serialize/main.cpp +++ b/src/test/14_serialize/main.cpp @@ -129,8 +129,7 @@ struct MoverSystem { int main() { World w; w.entityMngr.cmptTraits.Register(); - auto [moverSystem] = w.systemMngr.systemTraits.Register(); - w.systemMngr.Activate(moverSystem); + w.systemMngr.RegisterAndActivate(); w.entityMngr.Create(); w.entityMngr.Create(); w.entityMngr.Create(); diff --git a/src/test/15_chunk_job/main.cpp b/src/test/15_chunk_job/main.cpp index c867389..b496d71 100644 --- a/src/test/15_chunk_job/main.cpp +++ b/src/test/15_chunk_job/main.cpp @@ -50,9 +50,7 @@ struct SAB_System { int main() { World w; - auto [sabSystem] = w.systemMngr.systemTraits.Register(); - - w.systemMngr.Activate(sabSystem); + w.systemMngr.RegisterAndActivate(); w.entityMngr.cmptTraits.Register(); diff --git a/src/test/16_singleton/main.cpp b/src/test/16_singleton/main.cpp index 6c662d6..b013927 100644 --- a/src/test/16_singleton/main.cpp +++ b/src/test/16_singleton/main.cpp @@ -27,8 +27,7 @@ struct MoverSystem { int main() { World w; - auto [moverSystem] = w.systemMngr.systemTraits.Register(); - w.systemMngr.Activate(moverSystem); + w.systemMngr.RegisterAndActivate(); w.entityMngr.Create(); w.entityMngr.Create(); w.entityMngr.cmptTraits.Register diff --git a/src/test/17_serial/main.cpp b/src/test/17_serial/main.cpp index abd6b11..37973db 100644 --- a/src/test/17_serial/main.cpp +++ b/src/test/17_serial/main.cpp @@ -26,8 +26,7 @@ struct PrintASystem { int main() { World w; - auto [printSystem] = w.systemMngr.systemTraits.Register(); - w.systemMngr.Activate(printSystem); + w.systemMngr.RegisterAndActivate(); w.entityMngr.Create(); w.entityMngr.Create(); w.entityMngr.Create(); diff --git a/src/test/18_copy/main.cpp b/src/test/18_copy/main.cpp index 0033efa..aecf86e 100644 --- a/src/test/18_copy/main.cpp +++ b/src/test/18_copy/main.cpp @@ -27,8 +27,7 @@ struct MoverSystem { int main() { World w; - auto [moverSystem] = w.systemMngr.systemTraits.Register(); - w.systemMngr.Activate(moverSystem); + w.systemMngr.RegisterAndActivate(); w.entityMngr.Create(); World cpW = w; diff --git a/src/test/19_direct_run/main.cpp b/src/test/19_direct_run/main.cpp index 9da7a13..2b06ca7 100644 --- a/src/test/19_direct_run/main.cpp +++ b/src/test/19_direct_run/main.cpp @@ -44,9 +44,8 @@ void print1(const World& w) { int main() { World w; - auto [move] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); w.entityMngr.Create(); - w.systemMngr.Activate(move); w.Update(); print0(w); print1(w); diff --git a/src/test/21_random/main.cpp b/src/test/21_random/main.cpp index 52d3307..b0e360e 100644 --- a/src/test/21_random/main.cpp +++ b/src/test/21_random/main.cpp @@ -64,7 +64,7 @@ struct TranslationSystem { int main() { World w; w.entityMngr.cmptTraits.Register(); - auto [sys] = w.systemMngr.systemTraits.Register(); + w.systemMngr.RegisterAndActivate(); auto [e1, c, t1, l2w1] = w.entityMngr.Create(); auto [e2, p2, t2, l2p2, l2w2] = w.entityMngr.Create(); auto [e3, p3, t3, l2p3, l2w3] = w.entityMngr.Create(); @@ -77,7 +77,6 @@ int main() { t2->value = 2.f; t3->value = 3.f; - w.systemMngr.Activate(sys); w.Update(); std::cout << w.GenUpdateFrameGraph().Dump() << std::endl;