#include #include using namespace Ubpa::UECS; using namespace Ubpa; using namespace std; struct S { float value; }; struct A { float value; }; struct B { float value; }; constexpr float dt = 0.003f; struct SAB_System { static void OnUpdate(Schedule& schedule) { ArchetypeFilter filter; filter.all = { AccessTypeID_of> }; filter.any = { AccessTypeID_of>, AccessTypeID_of> }; schedule.RegisterChunkJob([](ChunkView chunk) { auto arrayS = chunk->GetCmptArray(); auto arrayA = chunk->GetCmptArray(); auto arrayB = chunk->GetCmptArray(); bool containsA = !arrayA.empty(); bool containsB = !arrayB.empty(); bool containsAB = containsA && containsB; if (containsAB) { cout << "[AB]" << endl; for (std::size_t i = 0; i < chunk->EntityNum(); i++) { arrayS[i].value += arrayA[i].value * arrayB[i].value; } } else if (containsA) { cout << "[A]" << endl; for (std::size_t i = 0; i < chunk->EntityNum(); i++) { arrayS[i].value += arrayA[i].value; } } else { // containsB cout << "[B]" << endl; for (std::size_t i = 0; i < chunk->EntityNum(); i++) { arrayS[i].value += arrayB[i].value; } } }, "SAB_System", filter); } }; int main() { World w; w.entityMngr.cmptTraits.Register(); w.systemMngr.RegisterAndActivate(); w.entityMngr.Create(Ubpa::TypeIDs_of); w.entityMngr.Create(Ubpa::TypeIDs_of); w.entityMngr.Create(Ubpa::TypeIDs_of); w.entityMngr.Create(Ubpa::TypeIDs_of); w.Update(); cout << w.GenUpdateFrameGraph().Dump() << endl; return 0; }