MCPcopy Create free account
hub / github.com/Illation/ETEngine / UnregisterSystemInternal

Method UnregisterSystemInternal

Engine/source/EtFramework/ECS/EcsController.cpp:692–735  ·  view source on GitHub ↗

----------------------------------------- EcsController::UnregisterSystemInternal

Source from the content-addressed store, hash-verified

690// EcsController::UnregisterSystemInternal
691//
692void EcsController::UnregisterSystemInternal(T_SystemType const sysType)
693{
694 // find the registered system
695 auto foundSys = std::find_if(m_Systems.cbegin(), m_Systems.cend(), [sysType](RegisteredSystem const* const sys)
696 {
697 return (sys->system->GetTypeId() == sysType);
698 });
699 ET_ASSERT(foundSys != m_Systems.cend());
700
701 RegisteredSystem* const registered = *foundSys;
702
703 // remove from system list - swap and remove
704 uint8 const idx = static_cast<uint8>(foundSys - m_Systems.cbegin());
705 if (idx != m_Systems.size() - 1)
706 {
707 m_Systems[idx] = m_Systems[m_Systems.size() - 1];
708 }
709
710 m_Systems.pop_back();
711
712 // since there are other systems left, remove this system from their dependencies
713 for (RegisteredSystem* const other : m_Systems)
714 {
715 auto const foundDep = std::find(other->dependencies.cbegin(), other->dependencies.cend(), registered);
716
717 if (foundDep != other->dependencies.cend())
718 {
719 // swap and remove
720 size_t const depIdx = foundDep - other->dependencies.cbegin();
721 if (depIdx != other->dependencies.size() - 1)
722 {
723 other->dependencies[depIdx] = other->dependencies[other->dependencies.size() - 1];
724 }
725
726 other->dependencies.pop_back();
727 }
728 }
729
730 // delete the system
731 delete registered->system;
732 delete registered;
733
734 RecalculateSystemSchedule();
735}
736
737//------------------------------------------
738// EcsController::RecalculateSystemSchedule

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected