Skip to content

Commit

Permalink
formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomanita committed Feb 11, 2024
1 parent a343262 commit 3f611f3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 40 deletions.
3 changes: 2 additions & 1 deletion core/include/cubos/core/ecs/cubos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ namespace cubos::core::ecs
}

template <typename F>
TagBuilder& TagBuilder::repeatWhile(F func){
TagBuilder& TagBuilder::repeatWhile(F func)
{
mDispatcher.tagRepeatWhile(System<bool>::make(mWorld, std::move(func), {}));
return *this;
}
Expand Down
28 changes: 12 additions & 16 deletions core/include/cubos/core/ecs/system/dispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ namespace cubos::core::ecs
{
public:
virtual ~Step() = default;
virtual void call(CommandBuffer& cmds,
std::vector<ecs::System<bool>>& mConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRunConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRetConditions) = 0;
virtual void call(CommandBuffer& cmds, std::vector<ecs::System<bool>>& mConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRunConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRetConditions) = 0;
};

class SystemStep : public Step
Expand All @@ -167,10 +166,9 @@ namespace cubos::core::ecs
: system(system)
{
}
void call(CommandBuffer& cmds,
std::vector<ecs::System<bool>>& mConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRunConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRetConditions);
void call(CommandBuffer& cmds, std::vector<ecs::System<bool>>& mConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRunConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRetConditions);

System* getSystem()
{
Expand All @@ -189,10 +187,9 @@ namespace cubos::core::ecs
, parent_step(parent_step)
{
}
void call(CommandBuffer& cmds,
std::vector<ecs::System<bool>>& mConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRunConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRetConditions);
void call(CommandBuffer& cmds, std::vector<ecs::System<bool>>& mConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRunConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRetConditions);

void addSystemStep(System* system)
{
Expand All @@ -216,7 +213,6 @@ namespace cubos::core::ecs
}
}


std::shared_ptr<GroupStep> FindGroup(const std::string& tag)
{
if (tag == grouptag)
Expand Down Expand Up @@ -260,10 +256,11 @@ namespace cubos::core::ecs
}
}

const std::string& getGroupTag(){
const std::string& getGroupTag()
{
return grouptag;
}
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> conditions;
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> conditions;

private:
const std::string grouptag;
Expand Down Expand Up @@ -335,7 +332,6 @@ namespace cubos::core::ecs
mCurrGroup->conditions |= bit;
}


inline void Dispatcher::addSystem(ecs::System<void> system)
{
// Wrap the system and put it in the pending queue
Expand Down
40 changes: 19 additions & 21 deletions core/src/ecs/system/dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ void Dispatcher::tagSetBeforeTag(const std::string& tag)
}

void Dispatcher::groupAddGroup()
{
//CUBOS_WARN("{}", mCurrGroup->getGroupTag());
{
// CUBOS_WARN("{}", mCurrGroup->getGroupTag());
mCurrGroup = mCurrGroup->addGroupStep(mCurrTag, mCurrGroup);
//CUBOS_WARN("{}", mCurrGroup->getGroupTag());
// CUBOS_WARN("{}", mCurrGroup->getGroupTag());
}

void Dispatcher::systemAddTag(const std::string& tag)
Expand All @@ -87,8 +87,9 @@ void Dispatcher::systemAddTag(const std::string& tag)
mCurrGroup = group;
}

if (tag == "last"){
//mMainStep->printStructure();
if (tag == "last")
{
// mMainStep->printStructure();
}
}

Expand Down Expand Up @@ -250,7 +251,7 @@ bool Dispatcher::dfsVisit(DFSNode& node, std::vector<DFSNode>& nodes)
if (node.s != nullptr)
{
// mSystems.push_back(node.s);
//CUBOS_WARN("{}", node.s->grouptag);
// CUBOS_WARN("{}", node.s->grouptag);
mMainStep->QueueSystem(node.s->grouptag, node.s);
}
return false;
Expand All @@ -259,10 +260,9 @@ bool Dispatcher::dfsVisit(DFSNode& node, std::vector<DFSNode>& nodes)
return false;
}

void Dispatcher::SystemStep::call(CommandBuffer& cmds,
std::vector<ecs::System<bool>>& mConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRunConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRetConditions)
void Dispatcher::SystemStep::call(CommandBuffer& cmds, std::vector<ecs::System<bool>>& mConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRunConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRetConditions)
{
bool canRun = true;
if (system->settings != nullptr)
Expand Down Expand Up @@ -304,10 +304,9 @@ void Dispatcher::SystemStep::call(CommandBuffer& cmds,
cmds.commit();
}

void Dispatcher::GroupStep::call(CommandBuffer& cmds,
std::vector<ecs::System<bool>>& mConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRunConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRetConditions)
void Dispatcher::GroupStep::call(CommandBuffer& cmds, std::vector<ecs::System<bool>>& mConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRunConditions,
std::bitset<CUBOS_CORE_DISPATCHER_MAX_CONDITIONS> mRetConditions)
{
bool canRun = true;
while (canRun)
Expand All @@ -327,14 +326,15 @@ void Dispatcher::GroupStep::call(CommandBuffer& cmds,
{
mRetConditions.set(i);
}
else{
else
{
mRetConditions.reset(i);
}
// Check if the condition returned true
if (!mRetConditions.test(i))
{
canRun = false;
break;
canRun = false;
break;
}
}

Expand All @@ -347,12 +347,12 @@ void Dispatcher::GroupStep::call(CommandBuffer& cmds,
{
if (auto groupStepPtr = std::dynamic_pointer_cast<GroupStep>(step))
{
//CUBOS_WARN("{}", groupStepPtr->grouptag);
// CUBOS_WARN("{}", groupStepPtr->grouptag);
groupStepPtr->call(cmds, mConditions, mRunConditions, mRetConditions);
}
else if (auto SystemStepPtr = std::dynamic_pointer_cast<SystemStep>(step))
{
//CUBOS_WARN("{}", SystemStepPtr->getSystem()->grouptag);
// CUBOS_WARN("{}", SystemStepPtr->getSystem()->grouptag);
SystemStepPtr->call(cmds, mConditions, mRunConditions, mRetConditions);
}
}
Expand All @@ -361,9 +361,7 @@ void Dispatcher::GroupStep::call(CommandBuffer& cmds,
{
canRun = false;
}

}

}

void Dispatcher::callSystems(CommandBuffer& cmds)
Expand Down
5 changes: 3 additions & 2 deletions core/tests/ecs/dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ static bool pushToOrderAndSucceed(std::vector<int>& order)

static bool succeed2Times(int& counter)
{

counter++;
if (counter == 4){
if (counter == 4)
{
counter++;
return false;
}
Expand Down

0 comments on commit 3f611f3

Please sign in to comment.