--------------------------------------- EcsController::RegisterSystemInternal
| 644 | // EcsController::RegisterSystemInternal |
| 645 | // |
| 646 | void EcsController::RegisterSystemInternal(SystemBase* const sys) |
| 647 | { |
| 648 | // create registered system |
| 649 | RegisteredSystem* const registered = new RegisteredSystem(sys); |
| 650 | |
| 651 | // add to dependencies |
| 652 | for (RegisteredSystem* const other : m_Systems) |
| 653 | { |
| 654 | if (std::find(sys->GetDependencies().cbegin(), sys->GetDependencies().cend(), other->system->GetTypeId()) != sys->GetDependencies().cend()) |
| 655 | { |
| 656 | registered->dependencies.emplace_back(other); |
| 657 | } |
| 658 | |
| 659 | if (std::find(sys->GetDependents().cbegin(), sys->GetDependents().cend(), other->system->GetTypeId()) != sys->GetDependents().cend()) |
| 660 | { |
| 661 | other->dependencies.emplace_back(registered); |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | // add existing archetypes |
| 666 | for (uint8 layer = 0u; layer < static_cast<uint8>(m_HierachyLevels.size()); ++layer) |
| 667 | { |
| 668 | for (std::pair<T_Hash const, Archetype*>& arch : m_HierachyLevels[layer].archetypes) |
| 669 | { |
| 670 | // go layer wise to ensure correct hierachy dependency resolution |
| 671 | if (arch.second->GetSignature().Contains(registered->signature)) |
| 672 | { |
| 673 | while (registered->matchingArchetypes.size() <= static_cast<size_t>(layer)) // ensure we have enough layers |
| 674 | { |
| 675 | registered->matchingArchetypes.push_back(RegisteredSystem::ArchetypeLayer()); |
| 676 | } |
| 677 | |
| 678 | registered->matchingArchetypes[layer].archetypes.push_back(arch.second); |
| 679 | } |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | // add to system list |
| 684 | m_Systems.emplace_back(registered); |
| 685 | |
| 686 | RecalculateSystemSchedule(); |
| 687 | } |
| 688 | |
| 689 | //----------------------------------------- |
| 690 | // EcsController::UnregisterSystemInternal |
nothing calls this directly
no test coverage detected