Skip to content

Commit

Permalink
fix(core): remove systemSetAfterSystem and systemSetBeforeSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoMendonc-a authored and RiscadoA committed Sep 8, 2023
1 parent ad2f133 commit 6aaf2a0
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions core/include/cubos/core/ecs/dispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,10 @@ namespace cubos::core::ecs
/// @param tag Tag to run after.
void systemSetAfterTag(const std::string& tag);

/// @brief Sets the current system to run after a given system.
/// @tparam F System type.
/// @param func System to run after.
template <typename F>
void systemSetAfterSystem(F func);

/// @brief Sets the current system to run before the tag.
/// @param tag Tag to run before.
void systemSetBeforeTag(const std::string& tag);

/// @brief Sets the current system to run before the system.
/// @tparam F System type.
/// @param func System to run before.
template <typename F>
void systemSetBeforeSystem(F func);

/// @brief Adds a condition to the current system.
/// @tparam F Condition type.
/// @param func Condition.
Expand Down Expand Up @@ -223,58 +211,6 @@ namespace cubos::core::ecs
mCurrSystem = mPendingSystems.back();
}

template <typename F>
void Dispatcher::systemSetAfterSystem(F func)
{
auto it = std::find_if(mPendingSystems.begin(), mPendingSystems.end(), [&func](const System* system) {
auto* wrapper = dynamic_cast<SystemWrapper<F>*>(system->system.get());
if (!wrapper)
{
return false;
}
return wrapper->mSystem == func;
});
if (it == mPendingSystems.end())
{
CUBOS_ERROR("Tried to set system after a non-existing system!");
return;
}
ENSURE_CURR_SYSTEM();
ENSURE_SYSTEM_SETTINGS(mCurrSystem);
System* system = *it;
ENSURE_SYSTEM_SETTINGS(system);
// Set curr to run after this system
mCurrSystem->settings->after.system.push_back(system);
// And this system to run before curr
system->settings->before.system.push_back(mCurrSystem);
}

template <typename F>
void Dispatcher::systemSetBeforeSystem(F func)
{
auto it = std::find_if(mPendingSystems.begin(), mPendingSystems.end(), [&func](const System* system) {
auto* wrapper = dynamic_cast<SystemWrapper<F>*>(system->system.get());
if (!wrapper)
{
return false;
}
return wrapper->mSystem == func;
});
if (it == mPendingSystems.end())
{
CUBOS_ERROR("Tried to set system before a non-existing system!");
return;
}
ENSURE_CURR_SYSTEM();
ENSURE_SYSTEM_SETTINGS(mCurrSystem);
System* system = *it;
ENSURE_SYSTEM_SETTINGS(system);
// Set curr to run before this system
mCurrSystem->settings->before.system.push_back(system);
// And this system to run after curr
system->settings->after.system.push_back(mCurrSystem);
}

template <typename F>
void Dispatcher::systemAddCondition(F func)
{
Expand Down

0 comments on commit 6aaf2a0

Please sign in to comment.